From 89f7a2b9b9e45b542ba0f9608b053308c45b3d60 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 29 Oct 2023 00:16:07 -0700 Subject: [PATCH] wip: start brute force closest_fev --- src/model_physics.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/model_physics.rs b/src/model_physics.rs index ec7364b..9646e00 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -52,6 +52,46 @@ pub trait MeshQuery{ impl MeshQuery for PhysicsMesh{ fn closest_fev(&self,point:Planar64Vec3)->FEV{ //put some genius code right here + + //TODO write genius code + //brute force + let mut best_distance_squared=Planar64::MAX; + let mut best_fev:FEV; + //check each vert + for (i,v) in self.verts.iter().enumerate(){ + let d=(v.0-point).dot(v.0-point); + if d::Vert(VertId(i)); + } + } + let face_dots=self.faces.iter().map(|f|f.normal.dot(point)); + //check each edge + for (i,v) in self.edge_topology.iter().enumerate(){ + let verts=self.edge_verts(EdgeId(i)); + if verts.iter().all(|&(vert_id,face_id)|{ + let (n,d)=self.face_nd(face_id); + n.dot(point)::Edge(EdgeId(i)); + } + } + //check each face todo!() } fn face_nd(&self,face_id:FaceId)->(Planar64Vec3,Planar64){