Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix properties #587

Merged
merged 5 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meshIO/src/meshIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void ExportMesh(const std::string& filename, const MeshGL& mesh,
? 1
: mesh.vertProperties[i * mesh.numProp +
options.mat.colorChannels[j]];
c = glm::saturate(c);
mesh_out->mColors[0][i] = aiColor4D(c.r, c.g, c.b, c.a);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/manifold/src/boolean_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void CreateProperties(Manifold::Impl &outR, const Vec<TriRef> &refPQ,
}
if (uvw[j] == 0) edge = j;
}
if (edge >= 0) {
if (edge >= 0) { // This misses some edges
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the root cause of the problem: when an edge is collapsed (before this step) you can end up with verts that refer (through refPQ) to a triangle that they are now outside of, since they were merged with their neighboring triangle but the references were not updated. This would be fine, except here I'm assuming I can tell when a vert is on a retained edge by checking its barycentric coordinates - but I miss these ones. So I end up assigning a key with only the meshID and vert, which isn't enough when the other side of the retained edge might have different properties.

// On an edge, both propVerts must match
const int p0 = triProp[Next3(edge)];
const int p1 = triProp[Prev3(edge)];
Expand Down Expand Up @@ -772,6 +772,7 @@ Manifold::Impl Boolean3::Result(OpType op) const {

Vec<TriRef> refPQ = UpdateReference(outR, inP_, inQ_, invertQ);

// This causes some verts to be outside of their refPQ triangle.
outR.SimplifyTopology();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried just reversing the order - create the properties first, and then simplify the topology. However, in this case it's very difficult to keep from duplicating prop verts (CoplanarProp test does a good job catching this). This might not seem like a huge deal, but they tend to continue to multiply, until your final output going to the renderer is basically triangle soup, even if the geometry is manifold.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for refPQ anymore since now everything happens in a logical order.


CreateProperties(outR, refPQ, inP_, inQ_);
Expand Down
Loading