From fca8c8d01d64e425b85b8df7903788b09318fbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 6 Jul 2021 11:04:51 +0200 Subject: [PATCH] Physics3D/Physics3DSystem: Don't update sleeping rigid bodies --- src/Nazara/Physics3D/Systems/Physics3DSystem.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp b/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp index f92bc1dee..f12504c29 100644 --- a/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp +++ b/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp @@ -23,9 +23,12 @@ namespace Nz m_physWorld.Step(elapsedTime); // Replicate rigid body position to their node components - auto velView = registry.view(); - for (auto [entity, nodeComponent, rigidBodyComponent] : velView.each()) + auto view = registry.view(); + for (auto [entity, nodeComponent, rigidBodyComponent] : view.each()) { + if (rigidBodyComponent.IsSleeping()) + continue; + nodeComponent.SetPosition(rigidBodyComponent.GetPosition(), CoordSys::Global); nodeComponent.SetRotation(rigidBodyComponent.GetRotation(), CoordSys::Global); }