| 265 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 266 | |
| 267 | void PhysXController::simulationBegin(float dt) |
| 268 | { |
| 269 | PROFILER_SCOPED_FUNCTION(); |
| 270 | |
| 271 | if (m_paused) |
| 272 | return; |
| 273 | |
| 274 | updateDragging(dt); |
| 275 | processExplosionQueue(); |
| 276 | |
| 277 | // slower physics if fps is too low |
| 278 | dt = PxClamp(dt, 0.0f, 0.0333f); |
| 279 | |
| 280 | { |
| 281 | PROFILER_SCOPED("PhysX simulate call"); |
| 282 | if (m_useFixedTimeStep) |
| 283 | { |
| 284 | m_timeAccumulator += dt; |
| 285 | m_substepCount = (uint32_t)std::floor(m_timeAccumulator / m_fixedTimeStep); |
| 286 | m_timeAccumulator -= m_fixedTimeStep * m_substepCount; |
| 287 | m_substepCount = m_maxSubstepCount > 0 ? physx::PxClamp<uint32_t>(m_substepCount, 0, m_maxSubstepCount) : m_substepCount; |
| 288 | if (m_substepCount > 0) |
| 289 | { |
| 290 | m_physicsScene->simulate(m_fixedTimeStep); |
| 291 | m_isSimulating = true; |
| 292 | } |
| 293 | } |
| 294 | else |
| 295 | { |
| 296 | m_substepCount = 1; |
| 297 | PX_ASSERT(!m_isSimulating); |
| 298 | m_physicsScene->simulate(dt); |
| 299 | m_isSimulating = true; |
| 300 | |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | void PhysXController::simualtionSyncEnd() |
| 306 | { |