C++ GDExtension: missing methods in MultiMeshInstance2D class

Godot 4.3 stable unofficial platpack + godot_cpp 4.3

Hi all,
I am testing gdextension and want to create a MultiMeshInstance2D from there. I am able to create the Mesh and the Multimesh for the instance. I succesfully got them in gdscript and built the instance for test purpouses. But I got a missing member of MultiMeshInstance2D class error when trying to create it into the extension.

#include <godot_cpp/classes/mesh.hpp>
#include <godot_cpp/classes/array_mesh.hpp>
#include <godot_cpp/classes/multi_mesh.hpp>
#include <godot_cpp/classes/multi_mesh_instance2d.hpp>

...

Ref<MultiMeshInstance2D> TiledRails::_create_multimesh_instance() {
    Ref<MultiMeshInstance2D> _multimesh_instance = memnew( MultiMeshInstance2D );
    _multimesh_instance->set_multimesh( _create_multimesh() );

    return _multimesh_instance;
}
In file included from godot-cpp/gen/include/godot_cpp/classes/node.hpp:41,
                 from godot-cpp/gen/include/godot_cpp/classes/canvas_item.hpp:38,
                 from godot-cpp/gen/include/godot_cpp/classes/node2d.hpp:36,
                 from src/tiled_rails.h:8,
                 from src/tiled_rails.cpp:13:
godot-cpp/include/godot_cpp/classes/ref.hpp: In instantiation of 'void godot::Ref<T>::unref() [with T = godot::MultiMeshInstance2D]':
godot-cpp/include/godot_cpp/classes/ref.hpp:217:3:   required from 'godot::Ref<T>::~Ref() [with T = godot::MultiMeshInstance2D]'
src/tiled_rails.cpp:432:78:   required from here
godot-cpp/include/godot_cpp/classes/ref.hpp:204:45: error: 'class godot::MultiMeshInstance2D' has no member named 'unreference'
  204 |                 if (reference && reference->unreference()) {

It returns same errors for ‘reference’ and ‘init_ref’ methods too.
It also returns some incomplete type errors around MultiMeshInstance2D.

In file included from godot-cpp/include/godot_cpp/core/class_db.hpp:38,
                 from src/tiled_rails.h:7:
godot-cpp/include/godot_cpp/core/method_bind.hpp: In instantiation of 'GDExtensionVariantType godot::MethodBindTR<R, P>::gen_argument_type(int) const [with R = godot::Ref<godot::MultiMeshInstance2D>; P = {}]':
godot-cpp/include/godot_cpp/core/method_bind.hpp:447:33:   required from here
godot-cpp/include/godot_cpp/core/method_bind.hpp:451:71: error: incomplete type 'godot::GetTypeInfo<godot::Ref<godot::MultiMeshInstance2D>, void>' used in nested name specifier
  451 |               return GDExtensionVariantType(GetTypeInfo<R>::VARIANT_TYPE);
      |                                                             ^~~~~~~~~~~~

godot-cpp/include/godot_cpp/core/method_bind.hpp: In instantiation of 'godot::PropertyInfo godot::MethodBindTR<R, P>::gen_argument_type_info(int) const [with R = godot::Ref<godot::MultiMeshInstance2D>; P = {}]':
godot-cpp/include/godot_cpp/core/method_bind.hpp:455:23:   required from here
godot-cpp/include/godot_cpp/core/method_bind.hpp:461:62: error: incomplete type 'godot::GetTypeInfo<godot::Ref<godot::MultiMeshInstance2D>, void>' used in nested name specifier
  461 |                         return GetTypeInfo<R>::get_class_info();
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
godot-cpp/include/godot_cpp/core/method_bind.hpp: In instantiation of 'GDExtensionClassMethodArgumentMetadata godot::MethodBindTR<R, P>::get_argument_metadata(int) const [with R = godot::Ref<godot::MultiMeshInstance2D>; P = {}]':
godot-cpp/include/godot_cpp/core/method_bind.hpp:469:49:   required from here
godot-cpp/include/godot_cpp/core/method_bind.hpp:473:48: error: incomplete type 'godot::GetTypeInfo<godot::Ref<godot::MultiMeshInstance2D>, void>' used in nested name specifier
  473 |                         return GetTypeInfo<R>::METADATA;
      |                                                ^~~~~~~~

What is happening here? It seems an internal error…
Thanks in advance

MultiMeshInstance2D is not ref counted but you are wrapping it in a Ref in your code. If you read the compiler message carefully it is telling you exactly this. Also check the docs (MultiMeshInstance2D — Godot Engine (stable) documentation in English) if it does not inherit from RefCounted you cannot make that class a Ref.

1 Like

omg, for some reason I though all complex objects were treated as references. I was obviously wrong. I will take care of this in the future.

Thank you very much and forgive my clumsiness.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.