Leapfrog integration applies half of the first acceleration update to velocity on the first frame after waking. After that, the updates proceed as usual with the full acceleration applied each frame. This corrects for impulses which otherwise have too much of the first frame's acceleration applied to them and lose mechincal energy as a result.
Leapfrog integration is implemented by setting PxsRigidBody::mAccelScale to 0.5 when a body is first woken up (or added to a scene with an initial velocity) in Sc::Scene::onBodyWakeUp. It then resets this scale back to 1.0 after integration for all active bodies in Sc::Scene::afterIntegration. PxsRigidBody::mAccelScale is already used when applying the acceleration from the built in gravity. I've also modified BodySim::updateForces to use this value when manually applying gravity (or any other acceleration.)
Leapfrog integration applies half of the first acceleration update to velocity on the first frame after waking. After that, the updates proceed as usual with the full acceleration applied each frame. This corrects for impulses which otherwise have too much of the first frame's acceleration applied to them and lose mechincal energy as a result.
This fixes issue #308
I have also included some tests here: https://github.com/LSBUGPG/PhysXJump/tree/test-without-leapfrog-integration https://github.com/LSBUGPG/PhysXJump/tree/test-leapfrog-integration
Leapfrog integration is implemented by setting
PxsRigidBody::mAccelScale
to 0.5 when a body is first woken up (or added to a scene with an initial velocity) inSc::Scene::onBodyWakeUp
. It then resets this scale back to 1.0 after integration for all active bodies inSc::Scene::afterIntegration
.PxsRigidBody::mAccelScale
is already used when applying the acceleration from the built in gravity. I've also modifiedBodySim::updateForces
to use this value when manually applying gravity (or any other acceleration.)