Physics2D/PhysWorld2D: Add invStepCount argument to pre/post steps callbacks
This commit is contained in:
@@ -311,14 +311,15 @@ namespace Nz
|
||||
{
|
||||
m_timestepAccumulator += timestep;
|
||||
|
||||
std::size_t stepCount = 0;
|
||||
while (m_timestepAccumulator >= m_stepSize && stepCount < m_maxStepCount)
|
||||
std::size_t stepCount = std::min(static_cast<std::size_t>(m_timestepAccumulator / m_stepSize), m_maxStepCount);
|
||||
float invStepCount = 1.f / stepCount;
|
||||
for (std::size_t i = 0; i < stepCount; ++i)
|
||||
{
|
||||
OnPhysWorld2DPreStep(this);
|
||||
OnPhysWorld2DPreStep(this, invStepCount);
|
||||
|
||||
cpSpaceStep(m_handle, m_stepSize);
|
||||
|
||||
OnPhysWorld2DPostStep(this);
|
||||
OnPhysWorld2DPostStep(this, invStepCount);
|
||||
if (!m_rigidPostSteps.empty())
|
||||
{
|
||||
for (const auto& pair : m_rigidPostSteps)
|
||||
@@ -331,7 +332,6 @@ namespace Nz
|
||||
}
|
||||
|
||||
m_timestepAccumulator -= m_stepSize;
|
||||
stepCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user