Repository navigation
Conversation
`Wheel::rotation` only followed the ground speed: an airborne wheel kept coasting (and slowed down even under throttle), a wheel slipping under power didn't spin faster than the ground, and a braked wheel kept rolling while the vehicle skidded. The wheel spin is now driven by the engine and brake impulses acting on the wheel's share of the chassis mass, the same response the engine has on the vehicle while it has traction, so no new tuning parameter is needed: - airborne: the engine impulse spins the wheel up, the brake impulse slows it down to a stop; - slipping under power: the part of the engine impulse the friction circle didn't transmit spins the wheel faster than the ground; - skidding under braking: the part of the brake impulse not countered by the ground friction slows the wheel down until it locks; - otherwise the wheel rolls with the ground, so gentle braking doesn't lock it. The free-spin damping no longer applies while the engine drives the wheel. Follow-up to dimforge#950. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #950: #980 merged the rolling-direction fix (#925) and the skid clamp (#946), but the two other behaviours from #950 are still missing.
0.99damping even slows it down while the throttle is held. It also doesn't spin faster than the ground when it loses grip under power (burnout).#950 handled these with cannon-es' approach: a new
free_spin_speedtuning parameter, and locking wheneverbrake > engine_force. That approach locked the wheel during any gentle braking. This PR derives both behaviours from the existing engine and brake impulses instead, with no new field or constant.Approach
Each wheel's spin is driven by the engine and brake impulses acting on its share of the chassis mass (
chassis.mass() / num_wheels). That is the same response the engine force has on the vehicle while the wheel has traction, so the spin stays continuous when the wheel leaves the ground, loses grip, or lands. The previous step's spin speed is recovered from the existingdelta_rotation.skid_info == 1)engine_force != 0forward_impulse) / mass, never slower than the groundbrake != 0forward_impulse) / mass toward zero, never faster than the groundengine_force != 0As in
update_friction, the brake only acts whenengine_force == 0, and it is treated as a per-step impulse. The0.99free-spin damping now applies only when the engine isn't driving the wheel. Otherwise it caps the airborne spin at ~99× the per-step spin-up, so a wheel that leaves the ground at speed spins down under throttle.Gentle braking (within the friction circle) keeps the wheel rolling with the ground. Only an actual skid locks it.
Tests
crates/rapier3d/tests/vehicle_wheel_free_spin.rs:airborne_wheels_spin_up_under_engine_force: spin keeps increasing under throttle, reverses with the engine force, and decays when the throttle is released.wheels_spin_faster_than_the_ground_on_burnoutairborne_brake_stops_the_wheel_spinhard_braking_locks_the_wheels_while_sliding: wheels stop rotating while the chassis still slides.gentle_braking_keeps_the_wheels_rollingThe existing
issue_925_wheel_rotationandissue_946_vehicle_braking_frictiontests still pass. I also tested the change through the TypeScript bindings (a locally builtrapier3d-compat) in a three.js driving game.