diff options
author | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2022-04-09 02:35:50 -0700 |
---|---|---|
committer | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2022-05-20 06:58:48 -0700 |
commit | d600e0bc00244c46ff385ec4f52995faa4825ef3 (patch) | |
tree | bf61a1352185b244776910be628d506a7cf2f779 /modules/gltf/gltf_document_extension.cpp | |
parent | 920ca6252888489ca72647ad8d5ef721d5e5e686 (diff) | |
download | redot-engine-d600e0bc00244c46ff385ec4f52995faa4825ef3.tar.gz |
Improve gltf extension GLTFDocument api.
Diffstat (limited to 'modules/gltf/gltf_document_extension.cpp')
-rw-r--r-- | modules/gltf/gltf_document_extension.cpp | 100 |
1 files changed, 60 insertions, 40 deletions
diff --git a/modules/gltf/gltf_document_extension.cpp b/modules/gltf/gltf_document_extension.cpp index 192a1d347c..d0bd7651e0 100644 --- a/modules/gltf/gltf_document_extension.cpp +++ b/modules/gltf/gltf_document_extension.cpp @@ -30,59 +30,79 @@ #include "gltf_document_extension.h" -#include "gltf_document.h" - void GLTFDocumentExtension::_bind_methods() { - // Import - ClassDB::bind_method(D_METHOD("get_import_setting_keys"), - &GLTFDocumentExtension::get_import_setting_keys); - ClassDB::bind_method(D_METHOD("import_preflight", "document"), - &GLTFDocumentExtension::import_preflight); - ClassDB::bind_method(D_METHOD("get_import_setting", "key"), - &GLTFDocumentExtension::get_import_setting); - ClassDB::bind_method(D_METHOD("set_import_setting", "key", "value"), - &GLTFDocumentExtension::set_import_setting); - ClassDB::bind_method(D_METHOD("import_post", "document", "node"), - &GLTFDocumentExtension::import_post); - // Export - ClassDB::bind_method(D_METHOD("get_export_setting_keys"), - &GLTFDocumentExtension::get_export_setting_keys); - ClassDB::bind_method(D_METHOD("get_export_setting", "key"), - &GLTFDocumentExtension::get_export_setting); - ClassDB::bind_method(D_METHOD("set_export_setting", "key", "value"), - &GLTFDocumentExtension::set_export_setting); - ClassDB::bind_method(D_METHOD("export_preflight", "document", "node"), - &GLTFDocumentExtension::export_preflight); - ClassDB::bind_method(D_METHOD("export_post", "document"), - &GLTFDocumentExtension::export_post); + GDVIRTUAL_BIND(_import_preflight, "state"); + GDVIRTUAL_BIND(_import_post_parse, "state"); + GDVIRTUAL_BIND(_import_node, "state", "gltf_node", "json", "node"); + GDVIRTUAL_BIND(_import_post, "state", "root"); + GDVIRTUAL_BIND(_export_preflight, "root"); + GDVIRTUAL_BIND(_export_node, "state", "gltf_node", "json", "node"); + GDVIRTUAL_BIND(_export_post, "state"); } -Array GLTFDocumentExtension::get_import_setting_keys() const { - return import_settings.keys(); +Error GLTFDocumentExtension::import_post(Ref<GLTFState> p_state, Node *p_root) { + ERR_FAIL_NULL_V(p_root, ERR_INVALID_PARAMETER); + ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_import_post, p_state, p_root, err)) { + return Error(err); + } + return OK; } -Variant GLTFDocumentExtension::get_import_setting(const StringName &p_key) const { - if (!import_settings.has(p_key)) { - return Variant(); +Error GLTFDocumentExtension::import_preflight(Ref<GLTFState> p_state) { + ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_import_preflight, p_state, err)) { + return Error(err); } - return import_settings[p_key]; + return OK; } -void GLTFDocumentExtension::set_import_setting(const StringName &p_key, Variant p_var) { - import_settings[p_key] = p_var; +Error GLTFDocumentExtension::import_post_parse(Ref<GLTFState> p_state) { + ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_import_post_parse, p_state, err)) { + return Error(err); + } + return OK; } -Array GLTFDocumentExtension::get_export_setting_keys() const { - return import_settings.keys(); +Error GLTFDocumentExtension::export_post(Ref<GLTFState> p_state) { + ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_export_post, p_state, err)) { + return Error(err); + } + return OK; +} +Error GLTFDocumentExtension::export_preflight(Node *p_root) { + ERR_FAIL_NULL_V(p_root, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_export_preflight, p_root, err)) { + return Error(err); + } + return OK; } -Variant GLTFDocumentExtension::get_export_setting(const StringName &p_key) const { - if (!import_settings.has(p_key)) { - return Variant(); +Error GLTFDocumentExtension::import_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_dict, Node *p_node) { + ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); + ERR_FAIL_NULL_V(p_gltf_node, ERR_INVALID_PARAMETER); + ERR_FAIL_NULL_V(p_node, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_import_node, p_state, p_gltf_node, r_dict, p_node, err)) { + return Error(err); } - return import_settings[p_key]; + return OK; } -void GLTFDocumentExtension::set_export_setting(const StringName &p_key, Variant p_var) { - import_settings[p_key] = p_var; +Error GLTFDocumentExtension::export_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_dict, Node *p_node) { + ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); + ERR_FAIL_NULL_V(p_gltf_node, ERR_INVALID_PARAMETER); + ERR_FAIL_NULL_V(p_node, ERR_INVALID_PARAMETER); + int err = OK; + if (GDVIRTUAL_CALL(_export_node, p_state, p_gltf_node, r_dict, p_node, err)) { + return Error(err); + } + return OK; } |