before and after not needed currently

This commit is contained in:
Quaternions 2024-02-21 05:24:12 -08:00
parent 0026b92a72
commit f027594ab4

View File

@ -488,6 +488,19 @@ enum MoveState{
Fly, Fly,
} }
impl MoveState{ impl MoveState{
//call this after state.move_state is changed
fn changed(&self,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
match self{
MoveState::Fly=>body.acceleration=Planar64Vec3::ZERO,
MoveState::Air=>{
//calculate base acceleration
let a=touching.base_acceleration(models,style,camera,input_state);
//set_acceleration clips according to contacts
set_acceleration(body,touching,models,hitbox_mesh,a);
},
_=>(),
}
}
//function to coerce &mut self into &self //function to coerce &mut self into &self
fn apply_to_body(&self,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){ fn apply_to_body(&self,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
match self{ match self{
@ -569,18 +582,6 @@ impl MoveState{
} }
} }
} }
fn move_state_edge(old_move_state:&MoveState,new_move_state:&MoveState,body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState){
match new_move_state{
MoveState::Fly=>body.acceleration=Planar64Vec3::ZERO,
MoveState::Air=>{
//calculate base acceleration
let a=touching.base_acceleration(models,style,camera,input_state);
//set_acceleration clips according to contacts
set_acceleration(body,touching,models,hitbox_mesh,a);
},
_=>(),
}
}
#[derive(Clone,Default)] #[derive(Clone,Default)]
pub struct PhysicsOutputState{ pub struct PhysicsOutputState{
@ -955,7 +956,7 @@ impl PhysicsState {
self.move_state.next_move_instruction(&self.style.strafe,self.time) self.move_state.next_move_instruction(&self.style.strafe,self.time)
} }
fn set_move_state(&mut self,data:&PhysicsData,move_state:MoveState){ fn set_move_state(&mut self,data:&PhysicsData,move_state:MoveState){
move_state_edge(&self.move_state,&move_state,&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state); move_state.changed(&mut self.body,&self.touching,&data.models,&data.hitbox_mesh,&self.style,&self.camera,&self.input_state);
self.move_state=move_state; self.move_state=move_state;
} }