Skip to content
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

Allow GridMap to combine child meshes into a single MeshItem #7970

Open
elvisish opened this issue Oct 3, 2023 · 6 comments
Open

Allow GridMap to combine child meshes into a single MeshItem #7970

elvisish opened this issue Oct 3, 2023 · 6 comments
Labels

Comments

@elvisish
Copy link

elvisish commented Oct 3, 2023

Describe the project you are working on

Walking simulator.

Describe the problem or limitation you are having in your project

It's inconvenient to have to use the CSG addon to combine multiple meshes into a single mesh in order for them to appear as one MeshItem in MeshLibrary. It's also confusing when importing a GLB that contains multiple meshes into a gridmap meshlibrary and only one of the meshes is used.

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

When building the meshlibrary, godot should combine child meshes into a single meshitem.

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

This:
image
Should be combined into a single meshitem when building the meshlibrary.

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

It would be a gridmap enhancement. The current workaround is installing Ed's CSG to MeshInstance (https://godotengine.org/asset-library/asset/1425), painstakingly adding each mesh into a CGSMesh, adding those as children of CSGCombiner and destructively combining the meshes into a single mesh.

If in Blender, merging the meshes before exporting to GLB.

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

Gridmap core.

@elvisish elvisish changed the title Allow gridmap to combine children meshes into single MeshItem Allow gridmap to combine child meshes into single MeshItem Oct 3, 2023
@fire
Copy link
Member

fire commented Oct 3, 2023

We missed the 4.2 feature phase but I’ll try to champion this for 4.3

@Calinou Calinou changed the title Allow gridmap to combine child meshes into single MeshItem Allow GridMap to combine child meshes into a single Mesh Oct 3, 2023
@Calinou Calinou changed the title Allow GridMap to combine child meshes into a single Mesh Allow GridMap to combine child meshes into a single MeshItem Oct 3, 2023
@Calinou
Copy link
Member

Calinou commented Oct 3, 2023

This is different from merging actual mesh data though (which has its own complexities when it comes to managing materials). Here, we want multiple overlapping meshes to draw onto the same tile.

@elvisish
Copy link
Author

elvisish commented Oct 3, 2023

This is different from merging actual mesh data though (which has its own complexities when it comes to managing materials). Here, we want multiple overlapping meshes to draw onto the same tile.

It's a shame Godot doesn't have a MultiMesh type node that allows multiple meshes to be non-destructively combined into a single mesh at runtime, and that could be interchangeably used in Gridmap.

@Calinou
Copy link
Member

Calinou commented Oct 3, 2023

It's a shame Godot doesn't have a MultiMesh type node that allows multiple meshes to be non-destructively combined into a single mesh at runtime, and that could be interchangeably used in Gridmap.

This is exactly what godotengine/godot#61568 does, but it's not as relevant for 4.x given draw calls are cheaper in Vulkan and automatic instancing is performed when possible. There are still some benefits to mesh merging in Vulkan, but the drawbacks (such as material handling and increased loading times) remain the exact same. This tends to tip the balance of mesh merging towards "not worth it" in most cases.

@bastianccm
Copy link

Hey, I've looked into this issue (encountered a similar situation where I didn't want to merge objects in Blender but have multiple parts on the same grid position).
As the mesh library is storing meshes and not nodes, this would probably require a major overhaul to implement. Merging meshes requires somehow to work with different materials etc., so only cases where a mesh was duplicated would really work.

@elvisish for this particular case, assuming the object is modelled in blender, it might be easier to just create one fence object and use an array modifier to duplicate it. As the modifier is applied upon importing blender in godot, you would end up with one mesh which can then be used by the gridmap.

@DoodleGarbage
Copy link

I can recognize that there's likely significant difficulty in implementing this, but I'll add that I do have use for this feature. It may not require merging the meshes, just letting the GridMap's mesh library stack meshes when created.
In my case in particular, I was using some of Kenney's modular building assets and had doors disappearing, as it was split into a second mesh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants