diff --git a/examples/PhysicsPlayground/main.cpp b/examples/PhysicsPlayground/main.cpp index 44207df14..1efbe3a8e 100644 --- a/examples/PhysicsPlayground/main.cpp +++ b/examples/PhysicsPlayground/main.cpp @@ -523,7 +523,6 @@ int main(int argc, char* argv[]) if (fpsClock.RestartIfOver(Nz::Time::Second())) { mainWindow.SetTitle("Physics playground - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetAliveEntityCount()) + " entities"); - physSystem.Dump(); fps = 0; } }); diff --git a/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.hpp b/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.hpp index 01f280cde..dc43c6813 100644 --- a/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.hpp +++ b/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.hpp @@ -32,10 +32,9 @@ namespace Nz JoltPhysics3DSystem(JoltPhysics3DSystem&&) = delete; ~JoltPhysics3DSystem(); - void Dump(); - inline JoltPhysWorld3D& GetPhysWorld(); inline const JoltPhysWorld3D& GetPhysWorld() const; + inline entt::handle GetRigidBodyEntity(UInt32 bodyIndex) const; bool RaycastQuery(const Vector3f& from, const Vector3f& to, const FunctionRef(const RaycastHit& hitInfo)>& callback); bool RaycastQueryFirst(const Vector3f& from, const Vector3f& to, const FunctionRef& callback); @@ -56,7 +55,7 @@ namespace Nz void OnBodyDestruct(entt::registry& registry, entt::entity entity); std::size_t m_stepCount; - std::vector m_physicsEntities; + std::vector m_bodyIndicesToEntity; entt::registry& m_registry; entt::observer m_characterConstructObserver; entt::observer m_rigidBodyConstructObserver; @@ -64,8 +63,6 @@ namespace Nz entt::scoped_connection m_characterConstructConnection; entt::scoped_connection m_bodyDestructConnection; JoltPhysWorld3D m_physWorld; - Time m_physicsTime; - Time m_updateTime; }; } diff --git a/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.inl b/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.inl index 6c235edd1..bb54ba07c 100644 --- a/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.inl +++ b/include/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.inl @@ -15,6 +15,11 @@ namespace Nz { return m_physWorld; } + + inline entt::handle JoltPhysics3DSystem::GetRigidBodyEntity(UInt32 bodyIndex) const + { + return entt::handle(m_registry, m_bodyIndicesToEntity[bodyIndex]); + } } #include diff --git a/src/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.cpp b/src/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.cpp index ee8e0141e..1e80a9e8b 100644 --- a/src/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.cpp +++ b/src/Nazara/JoltPhysics3D/Systems/JoltPhysics3DSystem.cpp @@ -18,8 +18,6 @@ namespace Nz m_bodyConstructConnection = registry.on_construct().connect<&JoltPhysics3DSystem::OnBodyConstruct>(this); m_characterConstructConnection = registry.on_construct().connect<&JoltPhysics3DSystem::OnCharacterConstruct>(this); m_bodyDestructConnection = registry.on_destroy().connect<&JoltPhysics3DSystem::OnBodyDestruct>(this); - - m_stepCount = 0; } JoltPhysics3DSystem::~JoltPhysics3DSystem() @@ -92,14 +90,8 @@ namespace Nz entityBody.TeleportTo(entityNode.GetPosition(), entityNode.GetRotation()); }); - - Time t1 = GetElapsedNanoseconds(); - // Update the physics world m_physWorld.Step(elapsedTime); - m_stepCount++; - - Time t2 = GetElapsedNanoseconds(); // Replicate characters to their NodeComponent { @@ -132,11 +124,6 @@ namespace Nz nodeComponent.SetTransform(position, rotation); } } - - Time t3 = GetElapsedNanoseconds(); - - m_physicsTime += (t2 - t1); - m_updateTime += (t3 - t2); } void JoltPhysics3DSystem::OnBodyConstruct(entt::registry& registry, entt::entity entity)