+1 vote

There is get_rid() for resources. But there is no get_rid() for nodes (except, strangely, the single node type CollisionObject2D, which does have it). How do I get RID for any kind of instanced node?

There are many google hits making me think that get_rid() was perhaps a valid node method in Godot 2.0. It isn't in 3.0.x.

My specific need is to get RID for a MultiMeshInstance to set AABB. Unless someone can tell me otherwise, the only way to set AABB for a node instance (not a mesh) is using VisualServer.instance_set_custom_aabb ( RID instance, AABB aabb ). But I need RID for the MultiMeshInstance to do so.

I did try VisualServer.mesh_set_custom_aabb() on the MultiMesh, but that gives me an error telling me that my MultiMesh is not a Mesh (which I knew already). Setting AABB for the original Mesh used in the MultiMesh does not determine AABB of the MultiMesh or the MultiMeshInstance.

asked Sep 3, 2018 in Engine by Charlie (91 points)
edited Sep 4, 2018 by Zylann

Arghhh... does anyone know how to make the Q&A forum not garble underscores?
The methods I was trying to reference above are as follows (substitute underscore for dash):
get-rid()
instance-set-custom-aabb()
mesh-set-custom-aabb()

The need for setting AABB on an instance is stated in the docs for MultiMesh: "Since instances may have any behavior, the AABB used for visibility must be provided by the user." Annoyingly, there are getaabb() methods everywhere but no setaabb() anywhere that I could use (not for MultiMesh or MultiMeshInstance or MultiMeshInstance inherited classes).
The method to do so using VisualServer is referenced here:
https://github.com/godotengine/godot/issues/9544
https://github.com/godotengine/godot/pull/12645

However, I'm still stuck since I don't know how to get the instance RID that I need to use in
VisualServer.instance-set-custom-aabb(RID, AABB).

1 Answer

+1 vote

Indeed, the function is missing from the nodes API. This function has to be exposed in GeometryInstance but so far only exists in the server API, so it's fine if you use that directly instead of nodes but that's quite impractical for more common use.

I posted an issue: https://github.com/godotengine/godot/issues/21758

answered Sep 4, 2018 by Zylann (27,004 points)

Thanks! I'm glad to know this is being tracked down.

Back to the 1st question, is there some back-door trick (via server or whatever) to get RID for my MultiMeshInstance? I tried RID(obj) but that seems to work only for resources. This led me to think that I am having a conceptual misunderstanding and that RIDs only exist for resources. But then your server method made me think that, yes, they exist for nodes too, even if I can't figure out how to get one. Is that correct?

Btw, I also tried using MultiMesh RID in your VisualServer.instance-set-custom-aabb(), but that gave me "!instance" errors.

RIDs really exist for some nodes that are actually high-level wrappers around VisualServer objects (that includes resources, but not only).

Using on MultiMesh won't give the expected result because it's not a GeometryInstance. Here is how I used it in my project: https://github.com/Zylann/godot_heightmap_native_plugin/blob/master/addons/zylann.hterrain/hterrain_chunk.gd#L110 (look at what _mesh_instance actually is)

But again it's not easy for common usage so it's just better to have that on nodes too rather than trying to get RIDs to bypass that lack (also I checked Godot 2.1.5, get_rid did not exist for nodes either).

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.