Open golddotasksquestions opened 5 years ago
I need to work on this, but this is usable for meshes, csg and gridmaps. https://github.com/godotengine/godot/pull/32218
Future work is animated characters and materials.
Does this have to be limited to CSG, or is this a tool used for all 3d meshes? It could be put in the "Mesh" dropdown. EDIT: Just read @fire s comment and I think he has the same point.
Note: by code, you can call get_meshes() on the root object to generate an ArrayMesh, which you can put in a separate MeshInstance later. Adding a button in the resource's dropdown would be pretty easy.
CSG not merge, this is limitation, but you can merge as single mesh get_meshes()
or exist addon CSGExport (generate obj file).
But probality more usefull use blender or another editor for this, Godot now make non optimal CSG (generate a lot of vertex), this good only if you have procedual mesh, if you have this - get_meshes()
, make mesh instance and del CSG. CSG needed if you morph mesh as boolean operation (hole in the any type wall) - i examle use for breaking glass
Note that for this to be done in a non-destructive way, it should create a new MeshInstance node as a sibling and hide the CSG nodes instead of removing the CSG nodes entirely after conversion. If you are certain that you won't need to edit the mesh anymore, then you can remove the CSG nodes after conveting them to a MeshInstance. (Hidden CSG nodes don't use much CPU time compared to visible CSG nodes, so you can leave them as-is in most cases.)
To make the BakedLightmap + CSG workflow quicker, we can enable UV2 and lightmap generation if a dedicated property is enabled on the selected CSG node. (The property in question needs to be added too, as use_in_baked_light
will most likely be hidden from CSG nodes soon to avoid confusion.)
As for the implementation itself, there should probably be two options offered in a node context menu when a CSG node is selected:
If needed, we can add a Shift modifier for destructive operation (indicated in a tooltip for each option). This would remove the original CSG node automatically after the operation is complete.
Note that for this to be done in a non-destructive way, it should create a new MeshInstance node as a sibling and hide the CSG nodes instead of removing the CSG nodes entirely after conversion.
This would pair nicely with the proposed editor-only nodes. You would mark the the CSG tree as editor-only, then build the MeshInstances either manually or automatically on run.
This would pair nicely with the proposed editor-only nodes. You would mark the the CSG tree as editor-only, then build the MeshInstances either manually or automatically on run.
If you don't intend to change CSG nodes during gameplay, there isn't much of a point to merge several CSG nodes into one, as the mesh is only built once on load. Merging meshes might improve load times a bit, but probably not by a significant margin in most scenes (especially when you factor in things like texture loading).
Merging several CSG nodes into one is useful if you intend to change CSG nodes during gameplay, or if you have a complex enough CSG tree that editing becomes very slow. However, in this case, it's usually a better idea to use less deep CSG trees with fewer nodes.
Working with CSG https://github.com/elalish/manifold/issues/91 so I have interest in improving this.
From what I understand, baking CSG will not be available @fire improve it. But, I don't know when It's going to be finished. For temporary solution, why can't they just allow get_meshes()
to work at runtime?
allow
get_meshes()
to work at runtime
As in, exposing it as a button in the editor?
Describe the project you are working on: Prototype for level design.
(Currently on hiatus. salvagable.)
Describe the problem or limitation you are having in your project: The scene tree becomes increasingly chaotic the more CSG meshes are in the scene. Besides being chaotic, performance get's worse the bigger the tree and the number of Booolean operations. There is even an explicit warning about it in the docs. Overview in the viewport becomes worse and worse with every CSG mesh. Even as few as 3 CSG boxes make it hard to tell the wireframe of the mesh apart from all the bounding boxes! Boolean operations are usually an intermediate step to get the part to a reusable unit. Not being able to merge CSG meshes together makes reuse ability hard and prototyping harder to manage.
This is just 3 boxes. Can't make a level with 3 boxes.
"Make the sure the objects children are not selectable" is helping with visibility, and is great for when you want CSGs to stay open and editable, but not with performance and I still would like to have to option to commit to this shape by merging it together, freeing up all overhead that a huge open CSG mesh tree would undoubtedly entail.
Describe how this feature / enhancement will help you overcome this problem or limitation: The true power and potential of CSG meshes unfolds when infinite reusability, recombination and remerging of CSG meshes is possible. For this to happen we need the ability to
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work: Viewport RMB click -> "merge CSG mesh and it's children", Scene panel RMB click -> "merge CSG mesh and it's children", Menu bar: RMB click -> "merge CSG mesh and it's children" ->
Describe implementation detail for your proposal (in code), if possible: I can't pronounce "C" with classes.
If this enhancement will not be used often, can it be worked around with a few lines of script?: It would be used often by Level designers, people who quickly want to block out prototypes, gamejams games that require just very basic geometry. It would also integrate brilliantly with the upcoming Gltf2 export https://github.com/godotengine/godot/issues/14752
Is there a reason why this should be core and not an add-on in the asset library?: It would be a imho necessary improvement to an existing feature to make is more usable for production work.