btRaycastVehicle.cpp: forward impulse way too strong when sideImpulse==0 #3220
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.
This pull request fixes a recently discovered bug in
btRaycastVehicle
. When a vehicle at rest starts moving, sometimes its forward impulse is much too large, causing it to immediately reach its steady-state speed.In my application (a particular vehicle configuration on a level surface) the impulse was 140x too large about 18% of the time. The bug was highly reproducible: it happened for some starting locations on the surface but not for others. I tracked it back to line 612 of btRaycastVehicle.cpp:
m_sideImpulse[wheel]
was either-0
(for bad starting locations) or roughly-2e-09
(for good ones).For such a tiny side impulse to reduce the forward impulse by 140x makes no sense, physically. I suspect the test in line 612 was originally a hand optimization from at time when the loop was scaling
m_sideImpulse[wheel]
only. Removing the test fixed the bug.