MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / updatePhysics

Method updatePhysics

testbed/src/TestbedApplication.cpp:409–433  ·  view source on GitHub ↗

Update the physics of the current scene

Source from the content-addressed store, hash-verified

407
408// Update the physics of the current scene
409void 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
435void TestbedApplication::update() {
436

Callers 1

Calls 5

getElapsedPhysicsTimeMethod · 0.80
isRunningMethod · 0.80
isPossibleToTakeStepMethod · 0.80
nextStepMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected