From 1e1fb145b3b3fd974149a8c2265065c58aabfaaa Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 21 Jan 2022 19:57:52 +0100 Subject: [PATCH] Improve CSGPolygon3D documentation - Describe why polygon triangulation usually fails in the error message. --- modules/csg/csg_shape.cpp | 2 +- modules/csg/doc_classes/CSGMesh.xml | 2 +- modules/csg/doc_classes/CSGPolygon.xml | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 1b305cd97f6..a2dfaf5074c 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1757,7 +1757,7 @@ CSGBrush *CSGPolygon::_build_brush() { } int shape_sides = shape_polygon.size(); Vector shape_faces = Geometry::triangulate_polygon(shape_polygon); - ERR_FAIL_COND_V_MSG(shape_faces.size() < 3, brush, "Failed to triangulate CSGPolygon"); + ERR_FAIL_COND_V_MSG(shape_faces.size() < 3, brush, "Failed to triangulate CSGPolygon. Make sure the polygon doesn't have any intersecting edges."); // Get polygon enclosing Rect2. Rect2 shape_rect(shape_polygon[0], Vector2()); diff --git a/modules/csg/doc_classes/CSGMesh.xml b/modules/csg/doc_classes/CSGMesh.xml index a175ad6fc94..693bf4b164f 100644 --- a/modules/csg/doc_classes/CSGMesh.xml +++ b/modules/csg/doc_classes/CSGMesh.xml @@ -4,7 +4,7 @@ A CSG Mesh shape that uses a mesh resource. - This CSG node allows you to use any mesh resource as a CSG shape, provided it is closed, does not self-intersect, does not contain internal faces and has no edges that connect to more then two faces. + This CSG node allows you to use any mesh resource as a CSG shape, provided it is closed, does not self-intersect, does not contain internal faces and has no edges that connect to more than two faces. See also [CSGPolygon] for drawing 2D extruded polygons to be used as CSG nodes. diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon.xml index cd349fbdf7f..05f55deabf9 100644 --- a/modules/csg/doc_classes/CSGPolygon.xml +++ b/modules/csg/doc_classes/CSGPolygon.xml @@ -4,7 +4,7 @@ Extrudes a 2D polygon shape to create a 3D mesh. - An array of 2D points is extruded to quickly and easily create a variety of 3D meshes. + An array of 2D points is extruded to quickly and easily create a variety of 3D meshes. See also [CSGMesh] for using 3D meshes as CSG nodes. @@ -48,7 +48,8 @@ When [member mode] is [constant MODE_PATH], this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling. - The point array that defines the 2D polygon that is extruded. + The point array that defines the 2D polygon that is extruded. This can be a convex or concave polygon with 3 or more points. The polygon must [i]not[/i] have any intersecting edges. Otherwise, triangulation will fail and no mesh will be generated. + [b]Note:[/b] If only 1 or 2 points are defined in [member polygon], no mesh will be generated. If [code]true[/code], applies smooth shading to the extrusions.