From fa0be33bf5148d623295ee9b4651b73039f9c6df Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 16 Nov 2023 18:39:46 -0800 Subject: [PATCH] initialize variable + guarantees --- src/model_physics.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/model_physics.rs b/src/model_physics.rs index a291e21..553e5b6 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -131,6 +131,7 @@ impl EdgePool{ } impl From<&crate::model::IndexedModel> for PhysicsMesh{ fn from(indexed_model:&crate::model::IndexedModel)->Self{ + assert!(indexed_model.unique_pos.len()!=0,"Mesh cannot have 0 vertices"); let verts=indexed_model.unique_pos.iter().map(|v|Vert(v.clone())).collect(); let mut vert_ref_guys=vec![VertRefGuy::default();indexed_model.unique_pos.len()]; let mut edge_pool=EdgePool::default(); @@ -247,8 +248,8 @@ impl TransformedMesh<'_>{ } } fn farthest_vert(&self,dir:Planar64Vec3)->VertId{ - let best_dot=Planar64::MIN; - let best_vert; + let mut best_dot=Planar64::MIN; + let mut best_vert=VertId(0); for (i,vert) in self.mesh.verts.iter().enumerate(){ let p=self.transform.transform_point3(vert.0); let d=dir.dot(p);