diff --git a/ChangeLog.md b/ChangeLog.md index d4f37c6a3..79553a105 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -37,6 +37,7 @@ Nazara Engine: - Fix MemoryStream::WriteBlock "Invalid buffer" assertion triggering when writing a zero-sized block - ⚠️ Rename RigidBody3D::[Get|Set]Velocity to [Get|Set]LinearVelocity - Fix RigidBody3D copy constructor not copying all physics states (angular/linear damping/velocity, mass center, position and rotation) +- Add RigidBody3D simulation control (via EnableSimulation and IsSimulationEnabled), which allows to disable physics and collisions at will. Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Physics3D/RigidBody3D.hpp b/include/Nazara/Physics3D/RigidBody3D.hpp index 06c617405..cb0128994 100644 --- a/include/Nazara/Physics3D/RigidBody3D.hpp +++ b/include/Nazara/Physics3D/RigidBody3D.hpp @@ -35,6 +35,7 @@ namespace Nz void AddTorque(const Vector3f& torque, CoordSys coordSys = CoordSys_Global); void EnableAutoSleep(bool autoSleep); + void EnableSimulation(bool simulation); Boxf GetAABB() const; Vector3f GetAngularDamping() const; @@ -53,6 +54,7 @@ namespace Nz bool IsAutoSleepEnabled() const; bool IsMoveable() const; + bool IsSimulationEnabled() const; bool IsSleeping() const; void SetAngularDamping(const Nz::Vector3f& angularDamping); diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index 978afa569..60db49240 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -133,6 +133,11 @@ namespace Nz NewtonBodySetAutoSleep(m_body, autoSleep); } + void RigidBody3D::EnableSimulation(bool simulation) + { + NewtonBodySetSimulationState(m_body, simulation); + } + Boxf RigidBody3D::GetAABB() const { Vector3f min, max; @@ -238,6 +243,11 @@ namespace Nz return m_mass > 0.f; } + bool RigidBody3D::IsSimulationEnabled() const + { + return NewtonBodyGetSimulationState(m_body) != 0; + } + bool RigidBody3D::IsSleeping() const { return NewtonBodyGetSleepState(m_body) != 0;