godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add CSGPolygon3D option to suppress end-caps #8411

Open Malcolmnixon opened 1 year ago

Malcolmnixon commented 1 year ago

Describe the project you are working on

I'm working on the TiltFive toolkit for Godot which requires a curved pointer due to the wand design.

Describe the problem or limitation you are having in your project

I'm attempting to construct the curved pointer using a CSGPolygon3D following a bezier Path3D. The "Path Continuous U = true" and "Path U Distance = 0" options result in the path mesh having a continuous texture U coordinate from 0.0 to 1.0 across the length of the path - perfect for a shader to then shade the "active" part of the pointer.

The problem is there is no way to suppress the creation of the end-caps; and the end-caps span the complete UV coordinates: image image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would be nice to add a "Suppress Endcaps" boolean property.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

It looks like 95% of the machinery already exists in CSGPolygon3D::_build_brush() to do this. It already suppresses the end-caps if the mode is "Spin" and the angle is 360 degrees; or if the mode is "Path" and the path is joined.

If this enhancement will not be used often, can it be worked around with a few lines of script?

There appears to be no way to suppress this, or easily delete it from the ArrayMesh after construction.

Is there a reason why this should be core and not an add-on in the asset library?

The CSGPolygon3D already does a very nice job of building swept polygons around paths, and the code is not small. Replicating it in a separate asset would mean significant duplication of code, and the corresponding maintenance issues later.

Calinou commented 12 months ago

We should really move away from CSG nodes for drawing 3D lines procedurally, as it has a huge performance impact compared to what a lightweight Line3D node could do (https://github.com/godotengine/godot-proposals/issues/7082, https://github.com/godotengine/godot-proposals/issues/6151).

CSG requires meshes to be manifold, and removing the end caps makes the mesh non-manifold if I'm not mistaken.