Update the physics of the current scene
| 407 | |
| 408 | // Update the physics of the current scene |
| 409 | void TestbedApplication::updatePhysics() { |
| 410 | |
| 411 | // Update the elapsed time |
| 412 | mCurrentScene->getEngineSettings().elapsedTime = mTimer.getElapsedPhysicsTime(); |
| 413 | |
| 414 | if (mTimer.isRunning()) { |
| 415 | |
| 416 | // Compute the time since the last update() call and update the timer |
| 417 | mTimer.update(); |
| 418 | |
| 419 | // While the time accumulator is not empty |
| 420 | while(mTimer.isPossibleToTakeStep(mCurrentScene->getEngineSettings().timeStep)) { |
| 421 | |
| 422 | double currentTime = glfwGetTime(); |
| 423 | |
| 424 | // Take a physics simulation step |
| 425 | mCurrentScene->updatePhysics(); |
| 426 | |
| 427 | mPhysicsStepTime = glfwGetTime() - currentTime; |
| 428 | |
| 429 | // Update the timer |
| 430 | mTimer.nextStep(mCurrentScene->getEngineSettings().timeStep); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | void TestbedApplication::update() { |
| 436 |
no test coverage detected