diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs index f061b7b..ecde420 100644 --- a/strafe-client/src/physics.rs +++ b/strafe-client/src/physics.rs @@ -200,17 +200,17 @@ fn ground_things(walk_settings:&gameplay_style::WalkSettings,contact:&ContactCol let normal=contact_normal(models,hitbox_mesh,contact); let gravity=touching.base_acceleration(models,style,camera,input_state); let control_dir=style.get_y_control_dir(camera,input_state.controls); - let mut target_velocity=walk_settings.get_walk_target_velocity(control_dir,normal); - touching.constrain_velocity(models,hitbox_mesh,&mut target_velocity); - (gravity,target_velocity) + let target_velocity=walk_settings.get_walk_target_velocity(control_dir,normal); + let target_velocity_clipped=touching.constrain_velocity(models,hitbox_mesh,target_velocity); + (gravity,target_velocity_clipped) } fn ladder_things(ladder_settings:&gameplay_style::LadderSettings,contact:&ContactCollision,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,style:&StyleModifiers,camera:&PhysicsCamera,input_state:&InputState)->(Planar64Vec3,Planar64Vec3){ let normal=contact_normal(models,hitbox_mesh,contact); let gravity=touching.base_acceleration(models,style,camera,input_state); let control_dir=style.get_y_control_dir(camera,input_state.controls); - let mut target_velocity=ladder_settings.get_ladder_target_velocity(control_dir,normal); - touching.constrain_velocity(models,hitbox_mesh,&mut target_velocity); - (gravity,target_velocity) + let target_velocity=ladder_settings.get_ladder_target_velocity(control_dir,normal); + let target_velocity_clipped=touching.constrain_velocity(models,hitbox_mesh,target_velocity); + (gravity,target_velocity_clipped) } #[derive(Default)] @@ -807,7 +807,7 @@ impl TouchingState{ //TODO: add water a } - fn constrain_velocity(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,velocity:&mut Planar64Vec3){ + fn constrain_velocity(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,velocity:Planar64Vec3)->Planar64Vec3{ let contacts=self.contacts.iter().map(|contact|{ let n=contact_normal(models,hitbox_mesh,contact); crate::push_solve::Contact{ @@ -816,9 +816,9 @@ impl TouchingState{ normal:n, } }).collect(); - *velocity=crate::push_solve::push_solve(&contacts,*velocity); + crate::push_solve::push_solve(&contacts,velocity) } - fn constrain_acceleration(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,acceleration:&mut Planar64Vec3){ + fn constrain_acceleration(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,acceleration:Planar64Vec3)->Planar64Vec3{ let contacts=self.contacts.iter().map(|contact|{ let n=contact_normal(models,hitbox_mesh,contact); crate::push_solve::Contact{ @@ -827,7 +827,7 @@ impl TouchingState{ normal:n, } }).collect(); - *acceleration=crate::push_solve::push_solve(&contacts,*acceleration); + crate::push_solve::push_solve(&contacts,acceleration) } fn predict_collision_end(&self,collector:&mut instruction::InstructionCollector,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,body:&Body,start_time:Time){ // let relative_body=crate::body::VirtualBody::relative(&Body::ZERO,body).body(time); @@ -1303,9 +1303,8 @@ fn set_velocity_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsM set_velocity(body,touching,models,hitbox_mesh,v); culled } -fn set_velocity(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,mut v:Planar64Vec3){ - touching.constrain_velocity(models,hitbox_mesh,&mut v); - body.velocity=v; +fn set_velocity(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,v:Planar64Vec3){ + body.velocity=touching.constrain_velocity(models,hitbox_mesh,v);; } fn set_acceleration_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,a:Planar64Vec3)->bool{ //This is not correct but is better than what I have @@ -1321,9 +1320,8 @@ fn set_acceleration_cull(body:&mut Body,touching:&mut TouchingState,models:&Phys set_acceleration(body,touching,models,hitbox_mesh,a); culled } -fn set_acceleration(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,mut a:Planar64Vec3){ - touching.constrain_acceleration(models,hitbox_mesh,&mut a); - body.acceleration=a; +fn set_acceleration(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,a:Planar64Vec3){ + body.acceleration=touching.constrain_acceleration(models,hitbox_mesh,a); } fn teleport(