From 0150bb977d7db4f801901cf28a7e67222b158e4b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 25 Sep 2024 10:18:38 -0700 Subject: [PATCH] optimize is_empty_volume --- src/model_physics.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/model_physics.rs b/src/model_physics.rs index 6c1cbbb..25ed516 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -964,12 +964,13 @@ fn is_empty_volume(normals:Vec>>)->bool{ for i in 0..len-1{ for j in i+1..len{ let n=normals[i].cross(normals[j]); - let mut d_comp:Option>=None; + let mut d_comp=None; for k in 0..len{ if k!=i&&k!=j{ - let d=n.dot(normals[k]); + let d=n.dot(normals[k]).is_negative(); if let Some(comp)=&d_comp{ - if comp.is_negative()^d.is_negative(){ + // This is testing if d_comp*d < 0 + if comp^d{ return true; } }else{