clarify and comment
This commit is contained in:
parent
0418b83eaf
commit
b6c40c3470
@ -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)?;
|
let mut intersection=solve3(face0,face1,face2).ok_or(PlanesToFacesError::InitIntersection)?;
|
||||||
|
|
||||||
// repeatedly update face0, face1 until all faces form part of the convex solid
|
// drain a hashset of references to the original list
|
||||||
let mut clone_every_loop:std::collections::HashSet<_>=face_list.iter().filter(|&new_face|
|
let mut remaining_face_refs:std::collections::HashSet<_>=face_list.iter().filter(|&new_face|
|
||||||
core::ptr::eq(face0,new_face)
|
core::ptr::eq(face0,new_face)
|
||||||
|core::ptr::eq(face1,new_face)
|
|core::ptr::eq(face1,new_face)
|
||||||
|core::ptr::eq(face2,new_face)
|
|core::ptr::eq(face2,new_face)
|
||||||
).collect();
|
).collect();
|
||||||
|
|
||||||
|
// repeatedly update face0, face1 until all faces form part of the convex solid
|
||||||
'find: loop{
|
'find: loop{
|
||||||
// test if any *other* faces occlude the intersection
|
// 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
|
// new face occludes intersection point
|
||||||
if new_face.dot*intersection.den<new_face.normal.dot(intersection.num){
|
if new_face.dot*intersection.den<new_face.normal.dot(intersection.num){
|
||||||
// replace one of the faces with the new face
|
// 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){
|
if let Some(new_intersection)=solve3(face0,new_face,face2){
|
||||||
// face1 does not occlude (or intersect) the new intersection
|
// face1 does not occlude (or intersect) the new intersection
|
||||||
if face1.dot*new_intersection.den>face1.normal.dot(new_intersection.num){
|
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;
|
face1=new_face;
|
||||||
intersection=new_intersection;
|
intersection=new_intersection;
|
||||||
continue 'find;
|
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){
|
if let Some(new_intersection)=solve3(face0,face1,new_face){
|
||||||
// face2 does not occlude (or intersect) the new intersection
|
// face2 does not occlude (or intersect) the new intersection
|
||||||
if face2.dot*new_intersection.den>face2.normal.dot(new_intersection.num){
|
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;
|
face2=new_face;
|
||||||
intersection=new_intersection;
|
intersection=new_intersection;
|
||||||
continue 'find;
|
continue 'find;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user