physics: [BUG 6] update move state on collision end with non-walk contact while walking

This commit is contained in:
Quaternions 2025-03-20 13:24:17 -07:00
parent 02615af1fd
commit db33f28ed9

@ -601,12 +601,16 @@ impl MoveState{
fn cull_velocity(&mut self,velocity:Planar64Vec3,body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
//TODO: be more precise about contacts
if set_velocity_cull(body,touching,models,hitbox_mesh,velocity){
//TODO do better
// TODO do better
// TODO: unduplicate this code
match self.get_walk_state(){
//did you stop touching the thing you were walking on?
Some(walk_state)=>if !touching.contacts.contains(&walk_state.contact){
// did you stop touching the thing you were walking on?
Some(walk_state)if !touching.contacts.contains(&walk_state.contact)=>{
self.set_move_state(MoveState::Air,body,touching,models,hitbox_mesh,style,camera,input_state);
},
// stopped touching something else while walking
Some(_)=>self.apply_enum_and_input_and_body(body,touching,models,hitbox_mesh,style,camera,input_state),
// not walking, but stopped touching something
None=>self.apply_enum_and_body(body,touching,models,hitbox_mesh,style,camera,input_state),
}
}
@ -1620,10 +1624,13 @@ fn collision_end_contact(
//TODO do better
//this is inner code from move_state.cull_velocity
match move_state.get_walk_state(){
//did you stop touching the thing you were walking on?
Some(walk_state)=>if walk_state.contact==contact{
// did you stop touching the thing you were walking on?
Some(walk_state)if walk_state.contact==contact=>{
move_state.set_move_state(MoveState::Air,body,touching,models,hitbox_mesh,style,camera,input_state);
},
// stopped touching something else while walking
Some(_)=>move_state.apply_enum_and_input_and_body(body,touching,models,hitbox_mesh,style,camera,input_state),
// not walking, but stopped touching something
None=>move_state.apply_enum_and_body(body,touching,models,hitbox_mesh,style,camera,input_state),
}
}