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

Subtracting two CSG box nodes from a box can generate a floating triangle #86567

Closed
31 opened this issue Dec 27, 2023 · 10 comments
Closed

Subtracting two CSG box nodes from a box can generate a floating triangle #86567

31 opened this issue Dec 27, 2023 · 10 comments
Milestone

Comments

@31
Copy link
Contributor

31 commented Dec 27, 2023

Tested versions

  • 4.2.1
  • 4.3-dev1

System information

Godot v4.3.dev1 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 Ti (NVIDIA; 31.0.15.4584) - Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 Threads)

Issue description

Subtracting two CSGBox nodes from one larger CSGBox gave me a floating triangle:

image

I normally hit this in more complicated level prototyping situations, but it's pretty easy (at least with my luck 😄) to reproduce with simple subtractions like this, too.

Wiggling one of the boxes a little can get a good mesh, but this only works after noticing the issue. When making level geometry prototypes, I often end up with missing/extra triangles that I didn't notice on the first pass. Wiggling a node that is already involved in the level (e.g. it has things placed on top of it) also causes more work to get everything placed right again.

Steps to reproduce

The MRP contains a camera pointed at the triangle and lighting to make it easier to see when running the scene. It should look like the screenshot.

Minimal reproduction project (MRP)

CSGSubtractRepro.zip

More at https://github.com/31/godot-csg-mesh-repro

@fire
Copy link
Member

fire commented Dec 28, 2023

There hasn't been much work in the CSG code and I've been busy, so poke me if you want to investigate. I can give you a tour of where the code is on discord.

https://github.com/godotengine/godot/blob/master/modules/csg/csg.cpp#L283-L463

@31
Copy link
Contributor Author

31 commented Dec 28, 2023

Thanks for the offer, but after reading this earlier issue I found:

I'm not sure working on this rather than trying to find an alternative would actually be the best for my project. I do also use coplanar faces quite frequently, and don't need good performance. Based on that issue, it seems that good performance is considered a core requirement of Godot's CSG for compatibility reasons and making Godot's fast CSG handle all cases might not be feasible.

Maybe I could figure out how to add a slow layer on top of Godot's CSG that e.g. detects that the mesh isn't manifold and "shakes" nearby nodes. 😄 However, if I'm using subtraction to e.g. make a tunnel (involving coplanar faces), random shaking could lead to the tunnel being totally blocked rather than open, so it is probably not so simple.

Even just detecting non-manifold CSG output would at least help with level design by letting me know the CSG nodes need some manual shaking before I put things on the floor. It would also make it easier to catch bad cases and report them.

For now, I've added a few more examples at https://github.com/31/godot-csg-mesh-repro: one uses coplanar faces, and one uses near-coplanar faces and ends up with a missing triangle.

@fire
Copy link
Member

fire commented Dec 28, 2023

I think a way to detect non-manifold as a ui element would help.

Even just detecting non-manifold CSG output would at least help with level design by letting me know the CSG nodes need some manual shaking before I put things on the floor. It would also make it easier to catch bad cases and report them.

@Mickeon
Copy link
Contributor

Mickeon commented Jan 6, 2024

I confirm this has been an issue even in 3.5. In a project we have, CSG subtraction was required during random generation, causing these to happen at complete random. I'm unsure on what the workaround is. "Shaking the CSG nodes" is not good enough in a random situation.

@fire

This comment was marked as outdated.

@fire

This comment was marked as outdated.

@fire
Copy link
Member

fire commented May 9, 2024

editor_screenshot_2024-05-08T204422

Testing some csg bug cases on a bugfix pr.

@Mickeon
Copy link
Contributor

Mickeon commented Jul 5, 2024

@fire What is the PR in question?

@fire
Copy link
Member

fire commented Jul 5, 2024

#91748

@fire
Copy link
Member

fire commented Nov 30, 2024

Fixed by: #94321

@fire fire closed this as completed Nov 30, 2024
@akien-mga akien-mga added this to the 4.4 milestone Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants