Skip to content

Commit

Permalink
Partial fix for #540
Browse files Browse the repository at this point in the history
Centroid falls exactly in the boundary of a face causing a bug, this fix changes the centroid function
  • Loading branch information
QuimMoya committed Oct 21, 2024
1 parent 8a0a595 commit 33741e1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cpp/geometry/operations/boolean-utils/clip-mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace fuzzybools

glm::dvec3 n = computeNormal(a, b, c);

glm::dvec3 triCenter = (a + b + c) * 1.0 / 3.0;
glm::dvec3 triCenter = (a + b * 2.0 + c * 3.0) * 1.0 / 6.0; // Using true centroid could cause issues (#540)

auto isInsideTarget = MeshLocation::INSIDE;

Expand Down Expand Up @@ -158,18 +158,18 @@ namespace fuzzybools
}

#ifdef CSG_DEBUG_OUTPUT
if (doit || true)
if (doit)
{
edgesPrinted.push_back({ glm::dvec2(a.z + a.x/2, a.y+ a.x/2), glm::dvec2(b.z+ b.x/2, b.y+ b.x/2)});
edgesPrinted.push_back({ glm::dvec2(a.z+ a.x/2, a.y+ a.x/2), glm::dvec2(c.z+ c.x/2, c.y+ c.x/2) });
edgesPrinted.push_back({ glm::dvec2(b.z+ b.x/2, b.y+ b.x/2), glm::dvec2(c.z+ c.x/2, c.y+ c.x/2) });
DumpSVGLines(edgesPrinted, L"final_tri.html");
// edgesPrinted.push_back({ glm::dvec2(a.z + a.x/2, a.y+ a.x/2), glm::dvec2(b.z+ b.x/2, b.y+ b.x/2)});
// edgesPrinted.push_back({ glm::dvec2(a.z+ a.x/2, a.y+ a.x/2), glm::dvec2(c.z+ c.x/2, c.y+ c.x/2) });
// edgesPrinted.push_back({ glm::dvec2(b.z+ b.x/2, b.y+ b.x/2), glm::dvec2(c.z+ c.x/2, c.y+ c.x/2) });
// DumpSVGLines(edgesPrinted, L"final_tri.html");
}
#endif
}

#ifdef CSG_DEBUG_OUTPUT
DumpSVGLines(edgesPrinted, L"final_tri.html");
// DumpSVGLines(edgesPrinted, L"final_tri.html");
#endif
}

Expand Down

0 comments on commit 33741e1

Please sign in to comment.