From ee9585a4c23b4f2650efcd93766a6874143c89b4 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 21 Jan 2025 07:20:58 -0800 Subject: [PATCH] accept slice in push_solve --- strafe-client/src/physics.rs | 4 ++-- strafe-client/src/push_solve.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs index 4621cc5..155c2ab 100644 --- a/strafe-client/src/physics.rs +++ b/strafe-client/src/physics.rs @@ -808,7 +808,7 @@ impl TouchingState{ a } fn constrain_velocity(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,velocity:Planar64Vec3)->Planar64Vec3{ - let contacts=self.contacts.iter().map(|contact|{ + let contacts:Vec<_>=self.contacts.iter().map(|contact|{ let n=contact_normal(models,hitbox_mesh,contact); crate::push_solve::Contact{ position:vec3::ZERO, @@ -819,7 +819,7 @@ impl TouchingState{ crate::push_solve::push_solve(&contacts,velocity) } fn constrain_acceleration(&self,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,acceleration:Planar64Vec3)->Planar64Vec3{ - let contacts=self.contacts.iter().map(|contact|{ + let contacts:Vec<_>=self.contacts.iter().map(|contact|{ let n=contact_normal(models,hitbox_mesh,contact); crate::push_solve::Contact{ position:vec3::ZERO, diff --git a/strafe-client/src/push_solve.rs b/strafe-client/src/push_solve.rs index 26d1770..a40eaa8 100644 --- a/strafe-client/src/push_solve.rs +++ b/strafe-client/src/push_solve.rs @@ -289,7 +289,7 @@ fn get_best_push_ray_and_conts<'a>( } } -fn get_first_touch<'a>(contacts:&'a Vec,ray:&Ray,conts:&Conts)->Option<(Ratio,Fixed<2,64>>,&'a Contact)>{ +fn get_first_touch<'a>(contacts:&'a [Contact],ray:&Ray,conts:&Conts)->Option<(Ratio,Fixed<2,64>>,&'a Contact)>{ contacts.iter() .filter(|&contact| !conts.iter().any(|&c|std::ptr::eq(c,contact)) @@ -299,7 +299,7 @@ fn get_first_touch<'a>(contacts:&'a Vec,ray:&Ray,conts:&Conts)->Option< .min_by_key(|&(t,_)|t) } -pub fn push_solve(contacts:&Vec,point:Planar64Vec3)->Planar64Vec3{ +pub fn push_solve(contacts:&[Contact],point:Planar64Vec3)->Planar64Vec3{ let (mut ray,mut conts)=get_best_push_ray_and_conts_0(point); loop{ let (next_t,next_cont)=match get_first_touch(contacts,&ray,&conts){