Cleaned up GLTFDocumentExtension aswell.

This commit is contained in:
Relintai 2022-08-08 00:39:35 +02:00
parent 2f9608aa65
commit 5e5ae40009
4 changed files with 89 additions and 67 deletions

View File

@ -9,6 +9,7 @@ env_gltf = env_modules.Clone()
env_gltf.add_source_files(env.modules_sources, "register_types.cpp")
env_gltf.add_source_files(env.modules_sources, "gltf_state.cpp")
env_gltf.add_source_files(env.modules_sources, "gltf_document_extension.cpp")
#env_gltf.add_source_files(env.modules_sources, "*.cpp")
env_gltf.add_source_files(env.modules_sources, "extensions/*.cpp")

View File

@ -30,79 +30,100 @@
#include "gltf_document_extension.h"
void GLTFDocumentExtension::_bind_methods() {
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");
}
#include "gltf_state.h"
#include "structures/gltf_node.h"
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;
ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER);
int err = call("_import_post", p_state, p_root);
return static_cast<Error>(err);
}
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 OK;
ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER);
int err = call("_import_preflight", p_state);
return static_cast<Error>(err);
}
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;
ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER);
int err = call("_import_post_parse", p_state);
return static_cast<Error>(err);
}
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;
ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER);
int err = call("_export_post", p_state);
return static_cast<Error>(err);
}
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;
int err = call("_export_preflight", p_root);
return static_cast<Error>(err);
}
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_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);
int err = OK;
if (GDVIRTUAL_CALL(_import_node, p_state, p_gltf_node, r_dict, p_node, err)) {
return Error(err);
}
return OK;
int err = call("_import_node", p_state, p_gltf_node, r_dict, p_node);
return static_cast<Error>(err);
}
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_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);
int err = OK;
if (GDVIRTUAL_CALL(_export_node, p_state, p_gltf_node, r_dict, p_node, err)) {
return Error(err);
}
return OK;
int err = call("_export_node", p_state, p_gltf_node, r_dict, p_node);
return static_cast<Error>(err);
}
GLTFDocumentExtension::GLTFDocumentExtension() {
}
GLTFDocumentExtension::~GLTFDocumentExtension() {
}
void GLTFDocumentExtension::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_import_preflight",
PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_import_post_parse",
PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_import_node",
PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState"),
PropertyInfo(Variant::OBJECT, "gltf_node", PROPERTY_HINT_RESOURCE_TYPE, "GLTFNode"),
PropertyInfo(Variant::DICTIONARY, "json"),
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_import_post",
PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState"),
PropertyInfo(Variant::OBJECT, "root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_export_preflight",
PropertyInfo(Variant::OBJECT, "root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_export_node",
PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState"),
PropertyInfo(Variant::OBJECT, "gltf_node", PROPERTY_HINT_RESOURCE_TYPE, "GLTFNode"),
PropertyInfo(Variant::DICTIONARY, "json"),
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"),
"_export_post",
PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "GLTFState")));
}

View File

@ -31,15 +31,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gltf_state.h"
#include "structures/gltf_node.h"
#include "core/reference.h"
#include "core/resource.h"
class GLTFNode;
class GLTFState;
class GLTFDocumentExtension : public Resource {
GDCLASS(GLTFDocumentExtension, Resource);
protected:
static void _bind_methods();
public:
virtual Error import_preflight(Ref<GLTFState> p_state);
virtual Error import_post_parse(Ref<GLTFState> p_state);
@ -48,13 +49,12 @@ public:
virtual Error export_preflight(Node *p_state);
virtual Error import_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_json, Node *p_node);
virtual Error export_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_json, Node *p_node);
GDVIRTUAL1R(int, _import_preflight, Ref<GLTFState>);
GDVIRTUAL1R(int, _import_post_parse, Ref<GLTFState>);
GDVIRTUAL4R(int, _import_node, Ref<GLTFState>, Ref<GLTFNode>, Dictionary, Node *);
GDVIRTUAL2R(int, _import_post, Ref<GLTFState>, Node *);
GDVIRTUAL1R(int, _export_preflight, Node *);
GDVIRTUAL4R(int, _export_node, Ref<GLTFState>, Ref<GLTFNode>, Dictionary, Node *);
GDVIRTUAL1R(int, _export_post, Ref<GLTFState>);
GLTFDocumentExtension();
~GLTFDocumentExtension();
protected:
static void _bind_methods();
};
#endif // GLTF_DOCUMENT_EXTENSION_H

View File

@ -45,6 +45,7 @@
#include "extensions/gltf_light.h"
#include "extensions/gltf_spec_gloss.h"
#include "gltf_document_extension.h"
#include "gltf_state.h"
void register_gltf_types() {
@ -62,18 +63,17 @@ void register_gltf_types() {
ClassDB::register_class<GLTFLight>();
//ClassDB::register_class<GLTFDocument>();
//ClassDB::register_class<GLTFDocumentExtension>();
ClassDB::register_class<GLTFDocumentExtension>();
//ClassDB::register_class<GLTFDocumentExtensionConvertImporterMesh>();
ClassDB::register_class<GLTFState>();
}
void unregister_gltf_types() {
void unregister_gltf_types() {
}
/*
#include "gltf_document.h"
#include "gltf_document_extension.h"
#include "gltf_document_extension_convert_importer_mesh.h"