Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.)