Reverted world extents computation

This commit is contained in:
Diren D Bharwani 2022-11-25 14:05:43 +08:00
parent 7f9f2bd194
commit 43a5cb4deb
3 changed files with 5 additions and 6 deletions

View File

@ -107,6 +107,7 @@ namespace SHADE
const SHVec3& RELATIVE_EXTENTS = box->GetRelativeExtents(); const SHVec3& RELATIVE_EXTENTS = box->GetRelativeExtents();
// Recompute world extents based on new scale and fixed relative extents // Recompute world extents based on new scale and fixed relative extents
const SHVec3 WORLD_EXTENTS = RELATIVE_EXTENTS * (scale * 0.5f); const SHVec3 WORLD_EXTENTS = RELATIVE_EXTENTS * (scale * 0.5f);
box->SetWorldExtents(WORLD_EXTENTS); box->SetWorldExtents(WORLD_EXTENTS);
@ -118,6 +119,7 @@ namespace SHADE
const float RELATIVE_RADIUS = sphere->GetRelativeRadius(); const float RELATIVE_RADIUS = sphere->GetRelativeRadius();
// Recompute world radius based on new scale and fixed radius // Recompute world radius based on new scale and fixed radius
const float MAX_SCALE = SHMath::Max({ scale.x, scale.y, scale.z }); const float MAX_SCALE = SHMath::Max({ scale.x, scale.y, scale.z });
const float WORLD_RADIUS = RELATIVE_RADIUS * MAX_SCALE * 0.5f; const float WORLD_RADIUS = RELATIVE_RADIUS * MAX_SCALE * 0.5f;
sphere->SetWorldRadius(WORLD_RADIUS); sphere->SetWorldRadius(WORLD_RADIUS);

View File

@ -206,7 +206,7 @@ namespace SHADE
} }
// Set the half extents relative to world scale // Set the half extents relative to world scale
const SHVec3 WORLD_EXTENTS = correctedHalfExtents * COLLIDER->GetScale(); const SHVec3 WORLD_EXTENTS = correctedHalfExtents * COLLIDER->GetScale() * 0.5f;
if (type != Type::BOX) if (type != Type::BOX)
{ {

View File

@ -309,12 +309,9 @@ namespace SHADE
{ {
colliderComponent->position = WORLD_POS; colliderComponent->position = WORLD_POS;
colliderComponent->orientation = WORLD_ROT; colliderComponent->orientation = WORLD_ROT;
colliderComponent->scale = WORLD_SCL;
if (colliderComponent->scale != WORLD_SCL) colliderComponent->RecomputeCollisionShapes();
{
colliderComponent->scale = WORLD_SCL;
colliderComponent->RecomputeCollisionShapes();
}
} }
} }