rename and swap faces

This commit is contained in:
Quaternions 2023-11-28 19:19:42 -08:00
parent 9af374ee14
commit 49d799eb60

View File

@ -579,17 +579,17 @@ impl MeshQuery<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert> for MinkowskiM
let &[e1f0,e1f1]=self.mesh1.edge_faces(e1).borrow(); let &[e1f0,e1f1]=self.mesh1.edge_faces(e1).borrow();
let e1f0_n=self.mesh0.face_nd(e1f0).0; let e1f0_n=self.mesh0.face_nd(e1f0).0;
let e1f1_n=self.mesh0.face_nd(e1f1).0; let e1f1_n=self.mesh0.face_nd(e1f1).0;
Cow::Owned([(e1f1,e1f1_n,e1f0_n,true),(e1f0,e1f0_n,e1f1_n,false)].map(|(edge_face_id1,edge_face1_n,edge_other_face1_n,face_parity)|{ Cow::Owned([(e1f1,e1f1_n,e1f0_n,true),(e1f0,e1f0_n,e1f1_n,false)].map(|(edge_face_id1,behind_n,sort_n,face_parity)|{
let mut best_edge=None; let mut best_edge=None;
let mut best_d=Planar64::MAX; let mut best_d=Planar64::MAX;
let edge_face1_nn=edge_face1_n.dot(edge_face1_n); let sort_nn=sort_n.dot(sort_n);
for &directed_edge_id0 in v0e.iter(){ for &directed_edge_id0 in v0e.iter(){
let edge0_n=self.mesh0.directed_edge_n(directed_edge_id0); let edge0_n=self.mesh0.directed_edge_n(directed_edge_id0);
//must be behind other face. //must be behind other face.
if edge_other_face1_n.dot(edge0_n)<Planar64::ZERO{ if behind_n.dot(edge0_n)<Planar64::ZERO{
let edge0_nn=edge0_n.dot(edge0_n); let edge0_nn=edge0_n.dot(edge0_n);
let d=edge_face1_n.dot(edge0_n); let d=sort_n.dot(edge0_n);
let dd=d*d/(edge_face1_nn*edge0_nn); let dd=d*d/(sort_nn*edge0_nn);
if dd<best_d{ if dd<best_d{
best_d=dd; best_d=dd;
best_edge=Some(directed_edge_id0); best_edge=Some(directed_edge_id0);
@ -608,16 +608,16 @@ impl MeshQuery<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert> for MinkowskiM
let &[e0f0,e0f1]=self.mesh0.edge_faces(e0).borrow(); let &[e0f0,e0f1]=self.mesh0.edge_faces(e0).borrow();
let e0f0_n=self.mesh0.face_nd(e0f0).0; let e0f0_n=self.mesh0.face_nd(e0f0).0;
let e0f1_n=self.mesh0.face_nd(e0f1).0; let e0f1_n=self.mesh0.face_nd(e0f1).0;
Cow::Owned([(e0f0,e0f0_n,e0f1_n,true),(e0f1,e0f1_n,e0f0_n,false)].map(|(edge_face_id0,edge_face0_n,edge_other_face0_n,face_parity)|{ Cow::Owned([(e0f0,e0f0_n,e0f1_n,true),(e0f1,e0f1_n,e0f0_n,false)].map(|(edge_face_id0,behind_n,sort_n,face_parity)|{
let mut best_edge=None; let mut best_edge=None;
let mut best_d=Planar64::MAX; let mut best_d=Planar64::MAX;
let edge_face0_nn=edge_face0_n.dot(edge_face0_n); let sort_nn=sort_n.dot(sort_n);
for &directed_edge_id1 in v1e.iter(){ for &directed_edge_id1 in v1e.iter(){
let edge1_n=self.mesh1.directed_edge_n(directed_edge_id1); let edge1_n=self.mesh1.directed_edge_n(directed_edge_id1);
if edge_other_face0_n.dot(edge1_n)<Planar64::ZERO{ if behind_n.dot(edge1_n)<Planar64::ZERO{
let edge1_nn=edge1_n.dot(edge1_n); let edge1_nn=edge1_n.dot(edge1_n);
let d=edge_face0_n.dot(edge1_n); let d=sort_n.dot(edge1_n);
let dd=d*d/(edge_face0_nn*edge1_nn); let dd=d*d/(sort_nn*edge1_nn);
if dd<best_d{ if dd<best_d{
best_d=dd; best_d=dd;
best_edge=Some(directed_edge_id1); best_edge=Some(directed_edge_id1);