From b28af3a91278c665da0458aaffee1d212309c76e Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 8 Aug 2022 00:50:00 +0200 Subject: [PATCH] Proper 3.x style bindings for GLTFDocumentExtension. --- modules/gltf/gltf_document_extension.cpp | 34 ++++++++++++++++++++++-- modules/gltf/gltf_document_extension.h | 22 ++++++++++----- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/modules/gltf/gltf_document_extension.cpp b/modules/gltf/gltf_document_extension.cpp index cb4e437ca..729bb13eb 100644 --- a/modules/gltf/gltf_document_extension.cpp +++ b/modules/gltf/gltf_document_extension.cpp @@ -68,7 +68,7 @@ Error GLTFDocumentExtension::export_preflight(Node *p_root) { return static_cast(err); } -Error GLTFDocumentExtension::import_node(Ref p_state, Ref p_gltf_node, Dictionary &r_dict, Node *p_node) { +Error GLTFDocumentExtension::import_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_dict, Node *p_node) { ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_gltf_node.is_null(), ERR_INVALID_PARAMETER); ERR_FAIL_NULL_V(p_node, ERR_INVALID_PARAMETER); @@ -77,7 +77,7 @@ Error GLTFDocumentExtension::import_node(Ref p_state, Ref p return static_cast(err); } -Error GLTFDocumentExtension::export_node(Ref p_state, Ref p_gltf_node, Dictionary &r_dict, Node *p_node) { +Error GLTFDocumentExtension::export_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_dict, Node *p_node) { ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_gltf_node.is_null(), ERR_INVALID_PARAMETER); ERR_FAIL_NULL_V(p_node, ERR_INVALID_PARAMETER); @@ -86,6 +86,28 @@ Error GLTFDocumentExtension::export_node(Ref p_state, Ref p return static_cast(err); } +int GLTFDocumentExtension::_import_preflight(Ref p_state) { + return OK; +} +int GLTFDocumentExtension::_import_post_parse(Ref p_state) { + return OK; +} +int GLTFDocumentExtension::_export_post(Ref p_state) { + return OK; +} +int GLTFDocumentExtension::_import_post(Ref p_state, Node *p_node) { + return OK; +} +int GLTFDocumentExtension::_export_preflight(Node *p_state) { + return OK; +} +int GLTFDocumentExtension::_import_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_json, Node *p_node) { + return OK; +} +int GLTFDocumentExtension::_export_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_json, Node *p_node) { + return OK; +} + GLTFDocumentExtension::GLTFDocumentExtension() { } GLTFDocumentExtension::~GLTFDocumentExtension() { @@ -126,4 +148,12 @@ void GLTFDocumentExtension::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"), "_export_post", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState"))); + + ClassDB::bind_method(D_METHOD("_import_preflight", "p_state"), &GLTFDocumentExtension::_import_preflight); + ClassDB::bind_method(D_METHOD("_import_post_parse", "p_state"), &GLTFDocumentExtension::_import_post_parse); + ClassDB::bind_method(D_METHOD("_export_post", "p_state"), &GLTFDocumentExtension::_export_post); + ClassDB::bind_method(D_METHOD("_import_post", "p_state", "p_node"), &GLTFDocumentExtension::_import_post); + ClassDB::bind_method(D_METHOD("_export_preflight", "p_state"), &GLTFDocumentExtension::_export_preflight); + ClassDB::bind_method(D_METHOD("_import_node", "p_state", "p_gltf_node", "r_json", "p_node"), &GLTFDocumentExtension::_import_node); + ClassDB::bind_method(D_METHOD("_export_node", "p_state", "p_gltf_node", "r_json", "p_node"), &GLTFDocumentExtension::_export_node); } diff --git a/modules/gltf/gltf_document_extension.h b/modules/gltf/gltf_document_extension.h index 49319a35f..edcde3b5f 100644 --- a/modules/gltf/gltf_document_extension.h +++ b/modules/gltf/gltf_document_extension.h @@ -42,13 +42,21 @@ class GLTFDocumentExtension : public Resource { GDCLASS(GLTFDocumentExtension, Resource); public: - virtual Error import_preflight(Ref p_state); - virtual Error import_post_parse(Ref p_state); - virtual Error export_post(Ref p_state); - virtual Error import_post(Ref p_state, Node *p_node); - virtual Error export_preflight(Node *p_state); - virtual Error import_node(Ref p_state, Ref p_gltf_node, Dictionary &r_json, Node *p_node); - virtual Error export_node(Ref p_state, Ref p_gltf_node, Dictionary &r_json, Node *p_node); + Error import_preflight(Ref p_state); + Error import_post_parse(Ref p_state); + Error export_post(Ref p_state); + Error import_post(Ref p_state, Node *p_node); + Error export_preflight(Node *p_state); + Error import_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_json, Node *p_node); + Error export_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_json, Node *p_node); + + virtual int _import_preflight(Ref p_state); + virtual int _import_post_parse(Ref p_state); + virtual int _export_post(Ref p_state); + virtual int _import_post(Ref p_state, Node *p_node); + virtual int _export_preflight(Node *p_state); + virtual int _import_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_json, Node *p_node); + virtual int _export_node(Ref p_state, Ref p_gltf_node, const Dictionary &r_json, Node *p_node); GLTFDocumentExtension(); ~GLTFDocumentExtension();