Physics2D/PhysWorld2D: Add iteration count control

This commit is contained in:
Jérôme Leclercq 2018-02-09 17:24:00 +01:00
parent 1feb4b2ba7
commit 17849226e4
3 changed files with 13 additions and 0 deletions

View File

@ -63,6 +63,7 @@ Nazara Engine:
- Add RigidBody2D simulation control (via EnableSimulation and IsSimulationEnabled), which allows to disable physics and collisions at will.
- ⚠️ LuaInstance no longer load all lua libraries on construction, this is done in the new LoadLibraries method which allows you to excludes some libraries
- Clock::Restart now returns the elapsed microseconds since construction or last Restart call
- Add PhysWorld2D::[Get|Set]IterationCount to control how many iterations chipmunk will perform per step.
Nazara Development Kit:
- Added ImageWidget (#139)

View File

@ -54,6 +54,7 @@ namespace Nz
float GetDamping() const;
Vector2f GetGravity() const;
cpSpace* GetHandle() const;
std::size_t GetIterationCount() const;
float GetStepSize() const;
bool NearestBodyQuery(const Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RigidBody2D** nearestBody = nullptr);
@ -69,6 +70,7 @@ namespace Nz
void SetDamping(float dampingValue);
void SetGravity(const Vector2f& gravity);
void SetIterationCount(std::size_t iterationCount);
void SetStepSize(float stepSize);
void Step(float timestep);

View File

@ -144,6 +144,11 @@ namespace Nz
return m_handle;
}
std::size_t PhysWorld2D::GetIterationCount() const
{
return cpSpaceGetIterations(m_handle);
}
float PhysWorld2D::GetStepSize() const
{
return m_stepSize;
@ -281,6 +286,11 @@ namespace Nz
cpSpaceSetGravity(m_handle, cpv(gravity.x, gravity.y));
}
void PhysWorld2D::SetIterationCount(std::size_t iterationCount)
{
cpSpaceSetIterations(m_handle, int(iterationCount));
}
void PhysWorld2D::SetStepSize(float stepSize)
{
m_stepSize = stepSize;