From c87ace7ae5d546cdb1b15acde7d05bffec2c0eb1 Mon Sep 17 00:00:00 2001 From: QuimMoya Date: Fri, 11 Oct 2024 08:44:14 +0200 Subject: [PATCH] Update clip-mesh.h --- .../operations/boolean-utils/clip-mesh.h | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/cpp/geometry/operations/boolean-utils/clip-mesh.h b/src/cpp/geometry/operations/boolean-utils/clip-mesh.h index a142246a..52a0c142 100644 --- a/src/cpp/geometry/operations/boolean-utils/clip-mesh.h +++ b/src/cpp/geometry/operations/boolean-utils/clip-mesh.h @@ -19,6 +19,8 @@ namespace fuzzybools std::vector> edgesPrinted; #endif + std::vector> boundingList; + for (uint32_t i = 0; i < mesh.numFaces; i++) { bool doit = false; @@ -43,6 +45,35 @@ namespace fuzzybools //continue; } + bool doNext = true; + + for(auto pair: boundingList) + { + if (aabb.intersects(pair.second)) + { + Face tri_temp = mesh.GetFace(pair.first); + + glm::dvec3 at = mesh.GetPoint(tri_temp.i0); + glm::dvec3 bt = mesh.GetPoint(tri_temp.i1); + glm::dvec3 ct = mesh.GetPoint(tri_temp.i2); + + if((equals(at,a, EPS_MINISCULE) && equals(bt,b, EPS_MINISCULE) && equals(ct,c, EPS_MINISCULE)) + || (equals(at,b, EPS_MINISCULE) && equals(bt,c, EPS_MINISCULE) && equals(ct,a, EPS_MINISCULE)) + || (equals(at,c, EPS_MINISCULE) && equals(bt,a, EPS_MINISCULE) && equals(ct,b, EPS_MINISCULE))) + { + doNext = false; + break; + } + } + } + + if(!doNext) + { + continue; + } + + boundingList.push_back(std::make_pair(i, aabb)); + glm::dvec3 n = computeNormal(a, b, c); glm::dvec3 triCenter = (a + b + c) * 1.0 / 3.0;