tweak ReachWalkTargetVelocity

This commit is contained in:
Quaternions 2025-01-21 06:05:47 -08:00
parent 4bbccd68ed
commit 5bce4a84cf

View File

@ -1774,19 +1774,19 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim
|MoveState::Fly |MoveState::Fly
=>println!("ReachWalkTargetVelocity fired for non-walking MoveState"), =>println!("ReachWalkTargetVelocity fired for non-walking MoveState"),
MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>{ MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>{
match &walk_state.target{
//you are not supposed to reach a walk target which is already reached!
TransientAcceleration::Reached=>unreachable!(),
TransientAcceleration::Reachable{acceleration:_,time:_}=>{
//velocity is already handled by advance_time //velocity is already handled by advance_time
//we know that the acceleration is precisely zero because the walk target is known to be reachable //we know that the acceleration is precisely zero because the walk target is known to be reachable
//which means that gravity can be fully cancelled //which means that gravity can be fully cancelled
//ignore moving platforms for now //ignore moving platforms for now
let target=core::mem::replace(&mut walk_state.target,TransientAcceleration::Reached);
set_acceleration(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,vec3::ZERO); set_acceleration(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,vec3::ZERO);
walk_state.target=TransientAcceleration::Reached; // check what the target was to see if it was invalid
}, match target{
//you are not supposed to reach a walk target which is already reached!
TransientAcceleration::Reached=>println!("Invalid walk target: Reached"),
TransientAcceleration::Reachable{..}=>(),
//you are not supposed to reach an unreachable walk target! //you are not supposed to reach an unreachable walk target!
TransientAcceleration::Unreachable{acceleration:_}=>unreachable!(), TransientAcceleration::Unreachable{..}=>println!("Invalid walk target: Unreachable"),
} }
} }
} }