Multimeshes How to Share Resource Meshes?

Godot Version

Latest compiled

Question

Is there any way to reference a mesh in another file? Like: "res://somepackedscene.tscn::palm_tree/coconut/mesh" ?

The problem is that the Multimesh is very keen to duplicate meshes and dump all that data into your scene files - the bloat is real!

Or any other techniques? I’d just like to share mesh data as much as possible.

(Edited to shorten question)

Would saving the MultiMesh resource to disk help?

image

The problem lies in the way that a Multimesh refers (points) to a Mesh resource.

I’m not 100% sure this is what you mean, but I ended up cobbling this together (in an autoload) from various nuggets of information for the purpose of creating multi meshes. See if it helps.

func extract_mesh(n:Node) -> Mesh :
	var result
	if n is MeshInstance3D:
		result = n.mesh
	else:
		for c in n.get_children():
			result = extract_mesh(c)
			if result:
				break
	return result

Instantiate a model, then pass it to this routine, you get back the first mesh it comes across in the hierarchy, which you can then put into the MultiMesh mesh value.

1 Like

Barrybaz, thanks for that thoughtful post. I am doing exactly that at the moment, but I save the meshes to .tres files instead so that the Multimeshes get a pointer to a resource file. I did this so that I can open my scenes and all the meshes are just there by default.

Your suggestion of a just-in-time in-ram kind of trick will bear some thought. I am making a tool, so the lifecycles of things gets weird.

Thanks over all!