From 62c4b3837d42e8831877dc53fdc11ba2d40a9bbc Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Tue, 22 Nov 2022 20:46:05 +0800 Subject: [PATCH] Fixed bug where transform dirty flags were not being properly cleared. This was preventing bodies from going to sleep and transforms always updating. --- .../src/Math/Transform/SHTransformSystem.cpp | 4 ++-- .../src/Physics/System/SHPhysicsSystemRoutines.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp index 94c133dd..38d44984 100644 --- a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp +++ b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp @@ -47,14 +47,14 @@ namespace SHADE { // Get the current scene graph to traverse and update const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph(); - UpdateEntity(SCENE_GRAPH.GetRoot(), !IsRunInEditorPause); + UpdateEntity(SCENE_GRAPH.GetRoot(), false); } void SHTransformSystem::TransformPostPhysicsUpdate::Execute(double) noexcept { // Get the current scene graph to traverse and update const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph(); - UpdateEntity(SCENE_GRAPH.GetRoot(), IsRunInEditorPause); + UpdateEntity(SCENE_GRAPH.GetRoot(), true); } void SHTransformSystem::Init() diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp index 45f236f3..24bd2f81 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp @@ -302,9 +302,12 @@ namespace SHADE { colliderComponent->position = WORLD_POS; colliderComponent->orientation = WORLD_ROT; - colliderComponent->scale = WORLD_SCL; - colliderComponent->RecomputeCollisionShapes(); + if (colliderComponent->scale != WORLD_SCL) + { + colliderComponent->scale = WORLD_SCL; + colliderComponent->RecomputeCollisionShapes(); + } } } @@ -325,7 +328,11 @@ namespace SHADE if (physicsObject.GetRigidBody()->isActive()) physicsObject.prevTransform = CURRENT_TF; - // Sync with rigid bodies. If an object doesn't have a rigidbody, no update is needed here as it is done in pre-update. + // Skip sleeping objects + if (physicsObject.GetRigidBody()->isSleeping()) + return; + + // Sync with rigid bodies if (rigidBodyComponent && SHSceneManager::CheckNodeAndComponentsActive(physicsObject.entityID)) { // Skip static bodies