Fixed transform updates to clear dirty flags appropriately #280

Merged
direnbharwani merged 4 commits from SP3-2-Physics into main 2022-11-25 15:10:32 +08:00
3 changed files with 5 additions and 6 deletions
Showing only changes of commit 43a5cb4deb - Show all commits

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,14 +309,11 @@ namespace SHADE
{ {
colliderComponent->position = WORLD_POS; colliderComponent->position = WORLD_POS;
colliderComponent->orientation = WORLD_ROT; colliderComponent->orientation = WORLD_ROT;
if (colliderComponent->scale != WORLD_SCL)
{
colliderComponent->scale = WORLD_SCL; colliderComponent->scale = WORLD_SCL;
colliderComponent->RecomputeCollisionShapes(); colliderComponent->RecomputeCollisionShapes();
} }
} }
}
void SHPhysicsSystem::PhysicsPostUpdate::postUpdateSyncTransforms void SHPhysicsSystem::PhysicsPostUpdate::postUpdateSyncTransforms
( (