diff --git a/src/model_physics.rs b/src/model_physics.rs index 38764da..6027ac9 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -271,6 +271,19 @@ pub struct TransformedMesh<'a>{ normal_determinant:Planar64, } impl TransformedMesh<'_>{ + pub fn new<'a>( + mesh:&'a PhysicsMesh, + transform:&'a crate::integer::Planar64Affine3, + normal_transform:&'a crate::integer::Planar64Mat3, + normal_determinant:Planar64 + )->TransformedMesh<'a>{ + TransformedMesh{ + mesh, + transform, + normal_transform, + normal_determinant, + } + } pub fn brute_in(&self,body:&crate::physics::Body,time_limit:crate::integer::Time)->Option<(FaceId,crate::integer::Time)>{ //check each face let mut best_time=time_limit; diff --git a/src/physics.rs b/src/physics.rs index 8c17777..1969b50 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -180,12 +180,12 @@ impl PhysicsModels{ //TODO: "statically" verify the maps don't refer to any nonexistant data, if they do delete the references. //then I can make these getter functions unchecked. fn mesh(&self,model_id:usize)->TransformedMesh{ - TransformedMesh{ - mesh:&self.meshes[self.models[model_id].mesh_id], - transform:&self.models[model_id].transform, - normal_transform:&self.models[model_id].normal_transform, - normal_determinant:self.models[model_id].normal_determinant, - } + TransformedMesh::new( + &self.meshes[self.models[model_id].mesh_id], + &self.models[model_id].transform, + &self.models[model_id].normal_transform, + self.models[model_id].normal_determinant, + ) } fn model(&self,model_id:usize)->&PhysicsModel{ &self.models[model_id]