Remove degenerate triangles when generating triangle mesh.
This commit is contained in:
parent
4465bc0270
commit
baf9dc0aae
|
@ -346,6 +346,11 @@ void Group::GenerateShellAndMesh() {
|
||||||
SMesh outm = {};
|
SMesh outm = {};
|
||||||
GenerateForBoolean<SMesh>(&prevm, &thism, &outm, srcg->meshCombine);
|
GenerateForBoolean<SMesh>(&prevm, &thism, &outm, srcg->meshCombine);
|
||||||
|
|
||||||
|
// Remove degenerate triangles; if we don't, they'll get split in SnapToMesh
|
||||||
|
// in every generated group, resulting in polynomial increase in triangle count,
|
||||||
|
// and corresponding slowdown.
|
||||||
|
outm.RemoveDegenerateTriangles();
|
||||||
|
|
||||||
// And make sure that the output mesh is vertex-to-vertex.
|
// And make sure that the output mesh is vertex-to-vertex.
|
||||||
SKdNode *root = SKdNode::From(&outm);
|
SKdNode *root = SKdNode::From(&outm);
|
||||||
root->SnapToMesh(&outm);
|
root->SnapToMesh(&outm);
|
||||||
|
|
10
src/mesh.cpp
10
src/mesh.cpp
|
@ -1114,3 +1114,13 @@ void SMesh::PrecomputeTransparency() {
|
||||||
return (opaquea != opaqueb && opaquea == true);
|
return (opaquea != opaqueb && opaquea == true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SMesh::RemoveDegenerateTriangles() {
|
||||||
|
for(auto &tr : l) {
|
||||||
|
bool isDegenerate = tr.a.OnLineSegment(tr.b, tr.c) ||
|
||||||
|
tr.b.OnLineSegment(tr.a, tr.c) ||
|
||||||
|
tr.c.OnLineSegment(tr.a, tr.b);
|
||||||
|
tr.tag = (int)isDegenerate;
|
||||||
|
}
|
||||||
|
l.RemoveTagged();
|
||||||
|
}
|
||||||
|
|
|
@ -278,6 +278,7 @@ public:
|
||||||
void MakeOutlinesInto(SOutlineList *sol, EdgeKind type);
|
void MakeOutlinesInto(SOutlineList *sol, EdgeKind type);
|
||||||
|
|
||||||
void PrecomputeTransparency();
|
void PrecomputeTransparency();
|
||||||
|
void RemoveDegenerateTriangles();
|
||||||
|
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
void RemapFaces(Group *g, int remap);
|
void RemapFaces(Group *g, int remap);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user