From b6c40c3470ae378dc8d87c76decfa2418ddb3184 Mon Sep 17 00:00:00 2001 From: Quaternions <krakow20@gmail.com> Date: Wed, 5 Feb 2025 11:32:06 -0800 Subject: [PATCH] clarify and comment --- lib/bsp_loader/src/brush.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/bsp_loader/src/brush.rs b/lib/bsp_loader/src/brush.rs index 469f7d2..de398b3 100644 --- a/lib/bsp_loader/src/brush.rs +++ b/lib/bsp_loader/src/brush.rs @@ -69,15 +69,17 @@ fn planes_to_faces(face_list:std::collections::HashSet<Face>)->Result<Faces,Plan let mut intersection=solve3(face0,face1,face2).ok_or(PlanesToFacesError::InitIntersection)?; - // repeatedly update face0, face1 until all faces form part of the convex solid - let mut clone_every_loop:std::collections::HashSet<_>=face_list.iter().filter(|&new_face| + // drain a hashset of references to the original list + let mut remaining_face_refs:std::collections::HashSet<_>=face_list.iter().filter(|&new_face| core::ptr::eq(face0,new_face) |core::ptr::eq(face1,new_face) |core::ptr::eq(face2,new_face) ).collect(); + + // repeatedly update face0, face1 until all faces form part of the convex solid 'find: loop{ // test if any *other* faces occlude the intersection - for &new_face in &clone_every_loop{ + for &new_face in &remaining_face_refs{ // new face occludes intersection point if new_face.dot*intersection.den<new_face.normal.dot(intersection.num){ // replace one of the faces with the new face @@ -85,7 +87,7 @@ fn planes_to_faces(face_list:std::collections::HashSet<Face>)->Result<Faces,Plan if let Some(new_intersection)=solve3(face0,new_face,face2){ // face1 does not occlude (or intersect) the new intersection if face1.dot*new_intersection.den>face1.normal.dot(new_intersection.num){ - clone_every_loop.remove(new_face); + remaining_face_refs.remove(new_face); face1=new_face; intersection=new_intersection; continue 'find; @@ -94,7 +96,7 @@ fn planes_to_faces(face_list:std::collections::HashSet<Face>)->Result<Faces,Plan if let Some(new_intersection)=solve3(face0,face1,new_face){ // face2 does not occlude (or intersect) the new intersection if face2.dot*new_intersection.den>face2.normal.dot(new_intersection.num){ - clone_every_loop.remove(new_face); + remaining_face_refs.remove(new_face); face2=new_face; intersection=new_intersection; continue 'find;