diff --git a/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp b/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp index 135e7e42..d7db2c64 100644 --- a/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp @@ -107,6 +107,7 @@ namespace SHADE const SHVec3& RELATIVE_EXTENTS = box->GetRelativeExtents(); // Recompute world extents based on new scale and fixed relative extents + const SHVec3 WORLD_EXTENTS = RELATIVE_EXTENTS * (scale * 0.5f); box->SetWorldExtents(WORLD_EXTENTS); @@ -118,6 +119,7 @@ namespace SHADE const float RELATIVE_RADIUS = sphere->GetRelativeRadius(); // Recompute world radius based on new scale and fixed radius + const float MAX_SCALE = SHMath::Max({ scale.x, scale.y, scale.z }); const float WORLD_RADIUS = RELATIVE_RADIUS * MAX_SCALE * 0.5f; sphere->SetWorldRadius(WORLD_RADIUS); diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp index 43906c22..f597077f 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp @@ -206,7 +206,7 @@ namespace SHADE } // 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) { diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp index 6168d673..89224628 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp @@ -309,12 +309,9 @@ namespace SHADE { colliderComponent->position = WORLD_POS; colliderComponent->orientation = WORLD_ROT; + colliderComponent->scale = WORLD_SCL; - if (colliderComponent->scale != WORLD_SCL) - { - colliderComponent->scale = WORLD_SCL; - colliderComponent->RecomputeCollisionShapes(); - } + colliderComponent->RecomputeCollisionShapes(); } }