Physics3D/RigidBody3D: Add simulation property

This commit is contained in:
Lynix 2017-12-10 13:35:58 +01:00
parent b8e447e4fe
commit 33b3b2feaf
3 changed files with 13 additions and 0 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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;