A level design tool that generates a mesh based on curves:
Describe the problem or limitation you are having in your project
When creating a mesh from a curve, I need to use Geometry2D.triangulate_delaunay() to create the triangles of my top/cap geometry, which requires me to create a temporary PackedVector2Array, which may be an uncessary walkaround. Also, I need to create a temporary SurfaceTool to deindex the result.
func update_top_surface(arrays:Array, for_collision=false):
# Here, I use curve.tessalate to extract points from the curve:
top_vertices = self.curve.tessellate(3,4)
arrays[Mesh.ARRAY_VERTEX] = top_vertices
# Here, I convert the results to a 2D curve to access the triangulate function
v2d_array = PackedVector2Array()
for v3d in top_vertices:
v2d_array.append(Vector2(v3d.x, v3d.z))
top_triangles = Geometry2D.triangulate_delaunay(v2d_array)
top_triangles.reverse() # flip normal to be facing up
delete_outside_faces() # in this function I use cross-product to filter out outside faces
arrays[Mesh.ARRAY_INDEX] = top_triangles
# Here, I create a temporary surface access the deindex() function
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.create_from_arrays(arrays)
st.deindex()
arrays[Mesh.ARRAY_VERTEX] = st.commit_to_arrays()[Mesh.ARRAY_VERTEX]
arrays[Mesh.ARRAY_INDEX] = []
Describe the feature / enhancement and how it helps to overcome the problem or limitation
It would make it more straighforward if:
the triangulate_delaunay() was accessible from Geometry3D
triangulate_delaunay() could directly return an array_vertex with a array_index, either in indexed or deindexed format.
alternatively, index/deindex could be available outside the SurfaceTool, or as static functions.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Reusing the Geometry2D code into the Geometry3D code.
Returning the vertices and the triangles.
Alternatively, making index/deindex static.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No.
Is there a reason why this should be core and not an add-on in the asset library?
Describe the project you are working on
A level design tool that generates a mesh based on curves:
Describe the problem or limitation you are having in your project
When creating a mesh from a curve, I need to use
Geometry2D.triangulate_delaunay()
to create the triangles of my top/cap geometry, which requires me to create a temporaryPackedVector2Array
, which may be an uncessary walkaround. Also, I need to create a temporarySurfaceTool
to deindex the result.Describe the feature / enhancement and how it helps to overcome the problem or limitation
It would make it more straighforward if:
triangulate_delaunay()
was accessible from Geometry3Dtriangulate_delaunay()
could directly return an array_vertex with a array_index, either in indexed or deindexed format.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Reusing the Geometry2D code into the Geometry3D code. Returning the vertices and the triangles. Alternatively, making index/deindex static.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No.
Is there a reason why this should be core and not an add-on in the asset library?
These are core functions.