-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Holes in CSG meshes with coplanar faces and engine freeze when moving them #58637
Comments
Coplanar faces and CSG don't mix well. I suggest moving around your CSG nodes slightly (0.001 units will do) to avoid having coplanar faces. This is something that could be handled automatically internally, but I don't know how much complexity it would add to be done properly. Accurate CSG algorithms (that handle coplanar faces correctly) are much slower, so I don't know if it's a viable tradeoff given many users are using those nodes at run-time. |
Thanks! Moving around the nodes seems like a bit of a hack, and kinda breaks the use-case I need CSG for.
Kinda off-topic, but do you happen to know of any such algorithms that I can drop into C or C++? |
I don't have any resources for this (as most CSG libraries or implementations are GPL-licensed, such as Blender's or CGAL). reduz had to write a custom CSG implementation for Godot to get something permissively licensed… |
Related to / duplicate of #41140. |
There is no point in using CSG or CSG operations if the operation results in a mesh with holes. Not only does it look broken, it also results in bad prototyping functionality because to resulting collision shape is broken too. I have had CSG blockout prototype levels were I failed to arrange the shapes in such a way there were no holes in the scene, despite knowing about he workaround fix of avoiding coplanar faces. In certain situations there is just always going to be coplanar faces. Also sometimes it is just not feasible to avoid them because non coplanar faces would create collision issues during gameplay. I would at the very least offer this slower CSG algorithm as an option in the Project Settings. If is reduces this issue drastically it will be definitely worth the time it takes to compute the new mesh. Recalculating CSG shapes in game during runtime is strongly discouraged anyway already (because of performance) and does not really make much sense in most cases unless the user is building an editor, not a game. And if the user is creating an editor, the slower CSG solver will be no or much less of an issue, just like it is almost no issue in the Godot editor right now. |
I have tested #74771 fixes this bug. |
eaa84bc fixes only the visual appearance.
|
… 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]>
… 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]> (cherry picked from commit eaa84bc)
Godot version
4.0.alpha3
System information
Windows 11
Issue description
I am generating a number of
CSGMesh3D
objects and putting them in aCSGCombiner3D
. All meshes are set to be a union. Sometimes, this generates random holes:And, potentially related, when moving the mesh with the hole on the Z axis, the engine freezes.
Steps to reproduce
csg_bug.tscn
in the editorMinimal reproduction project
CSGBug.zip
The text was updated successfully, but these errors were encountered: