-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Fixes to CSG robustness #74771
Fixes to CSG robustness #74771
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
1ca83d0
to
db156fc
Compare
aa46ddc
to
54cf963
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
67bb3af
to
04baa3c
Compare
Latest test cases CSGBug_2023-03-11.zip |
21d9106
to
6c3af47
Compare
04baa3c
to
4c3f7a8
Compare
e1930b2
to
826fa4b
Compare
I started testing this PR, as I have a project using CSG which suffers from glitches. This PR seems to fix a lot of the problems! It's a fairly pathological case, we stitched 40 Path3Ds together, generating CSGPolygon3D from each Path3D and using them to subtract from a big CSGBox3D. Here's how it looks like in 4.0.2-stable: And here's how it looks like with this PR (rebased on latest So... it's definitely better :D I'll soon make that project open source so it can be used by others for testing too. It's this game: https://akien.itch.io/godog The above screenshots is from a level we didn't use in the end due to those glitches. But even the playable build on itch has CSG glitches (weird hard lines going through the level where it's supposed to be subtracting geometry), and I confirmed that this PR fixes them. |
Does this also fix #73927? (Which may be a duplicate of the linked issue.) |
… 2 triangles. The previous implementation assumed that the intersection entered or exited a shape when it hit right on the common edge of 2 triangles. However, there is also a case where it just "skirts" the other shape on the outside. To fix this, we added code to check the intersection distance and if the normals of the faces are pointed in the same direction as the intersection or not (e.g. inner product > 0). This handles the case where the intersection line hits the common edge of 2 triangles and skirts the other shape on the outside. Extended code to cover a third case. Fixes godotengine#58637. Co-authored-by: OldBelge <[email protected]>
I pushed some changes to avoid breaking compatibility. It's still possible to reduce the It's not perfect, but hopefully that makes things more usable. |
Tested some more projects from previously reported issues / duplicates. This PR does fix the MRPs from those issues:
But doesn't fix the MRPs from those issues:
So it doesn't solve everything, we should probably reopen one of the issues closed as duplicate of #58637, if we're going to close that one. Or open a new one after this is merged, linking the old and new MRPs which still have issues. |
Thanks! |
Testing with the repro project here from #74343 it does not appear so. I have a branch on my fork that fixes this issue by keeping track of which edges have already been processed by the loop. Will post over on issue #73927 to continue the conversation there. |
Cherry-picked for 4.0.3. |
…iangles
Collaboration with OldBelge
Previously, the code assumed that if the intersection line hit the common edge of 2 triangles, it meant that the intersection entered or exited a shape. However, there is also a case where the intersection just "skirts" the other shape on the outside. To handle this case, we added a check for the direction of the normals of the faces. If the inner product of the normals and the intersection is greater than 0, then the intersection is inside the shape.
Fixes: #58637
Still happens: #41140