При привязке функций к ClassDB, если функция принимает массив указателей с плавающей запятой, она не может найти преобразование, и я не нашел никакой документации, кроме небольших примеров.
Я хочу для передачи списков из GDScript в функции в моем коде.
Информации по этой теме не нашел.
Я думал, что смогу передать список GDScript в качестве указателя и список с пустым списком внутри в качестве указателя на указатель, но в итоге он не скомпилировался.
Библиотека, которую я пытаюсь вызвать из GDScript, не была Он не создан для Godot, но я мог бы создать некоторые промежуточные функции, поскольку часть, которую я хочу вызвать с помощью Godot, действительно мала по сравнению со всем исполняемым кодом.
NN.h
#include
#include
class NN : public godot::Object
{
GDClass(NN, godot::Object)
private:
...
public:
...
static void _bind_methods();
}
register_types.cpp
NN::_bind_methods()
{
// Input is of type float*
ClassDB::bind_method(D_METHOD("execute", "input"), &NN::execute);
}
void register_gameplay_types(godot::ModuleInitializationLevel p_level) {
if (p_level != godot::ModuleInitializationLevel::MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
// REGISTER CLASSES
ClassDB::register_class();
}
void unregister_gameplay_types(godot::ModuleInitializationLevel p_level) {
// DO NOTHING
}
extern "C" {
GDExtensionBool GDE_EXPORT gameplay_library_init(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_object(p_interface, p_library, r_initialization);
init_object.register_initializer(register_gameplay_types);
init_object.register_terminator(unregister_gameplay_types);
init_object.set_minimum_library_initialization_level(godot::ModuleInitializationLevel::MODULE_INITIALIZATION_LEVEL_SCENE);
return init_object.init();
}
}
Ошибки:
Импорт godot_cpp/classes/object.hpp или node3d.hpp генерирует следующую ошибку даже без наследования
_deps/gdextension-src/include/godot_cpp/variant/variant.hpp(296): error: initial value of reference to non-const must be an lvalue
callp_static(type, method, argptrs.data(), argptrs.size(), sizeof...(args), result, error);
^
_deps/gdextension-src/include/godot_cpp/variant/variant.hpp(296): error: a reference of type "GDExtensionCallError &" (not const-qualified) cannot be initialized with a value of type "godot::Variant"
callp_static(type, method, argptrs.data(), argptrs.size(), sizeof...(args), result, error);
^
_deps/gdextension-src/include/godot_cpp/variant/variant.hpp(296): error: too many arguments in function call
callp_static(type, method, argptrs.data(), argptrs.size(), sizeof...(args), result, error);
error: explicit type is missing ("int" assumed)
GDClass(NN, godot::Object)
(I think its due it not importing correctly or because the previous error)
error: expected a ";"
private:
error: conversion from ‘const godot::Variant’ to ‘float*’ is ambiguous
Подробнее здесь: https://stackoverflow.com/questions/787 ... gdclass-gd
Передайте указатель на функцию + ошибка при импорте object.hpp и с помощью GDClass GDExtensions C++ ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение