From 101442ced9f266eca289cb3ad61dc7f8756ecbd0 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 18 Jul 2023 14:28:09 -0500 Subject: [PATCH] Expose filename in GLTFState --- modules/gltf/doc_classes/GLTFState.xml | 4 ++++ modules/gltf/gltf_state.cpp | 15 +++++++++++++-- modules/gltf/gltf_state.h | 9 ++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index 44b0d124e71..db468e2994e 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -267,6 +267,7 @@ + The folder path associated with this GLTF data. This is used to find other files the GLTF file references, like images or binary buffers. This will be set during import when appending from a file. @@ -275,6 +276,9 @@ + + The file name associated with this GLTF data. If it ends with [code].gltf[/code], this is text-based GLTF, otherwise this is binary GLB. This will be set during import when appending from a file. + diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 87d15066f01..c0ec004fd63 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -64,6 +64,8 @@ void GLTFState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_scene_name", "scene_name"), &GLTFState::set_scene_name); ClassDB::bind_method(D_METHOD("get_base_path"), &GLTFState::get_base_path); ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &GLTFState::set_base_path); + ClassDB::bind_method(D_METHOD("get_filename"), &GLTFState::get_filename); + ClassDB::bind_method(D_METHOD("set_filename", "filename"), &GLTFState::set_filename); ClassDB::bind_method(D_METHOD("get_root_nodes"), &GLTFState::get_root_nodes); ClassDB::bind_method(D_METHOD("set_root_nodes", "root_nodes"), &GLTFState::set_root_nodes); ClassDB::bind_method(D_METHOD("get_textures"), &GLTFState::get_textures); @@ -109,6 +111,7 @@ void GLTFState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_materials", "get_materials"); // Vector ADD_PROPERTY(PropertyInfo(Variant::STRING, "scene_name"), "set_scene_name", "get_scene_name"); // String ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_path"), "set_base_path", "get_base_path"); // String + ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename"), "set_filename", "get_filename"); // String ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "root_nodes"), "set_root_nodes", "get_root_nodes"); // Vector ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_textures", "get_textures"); // Vector> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "texture_samplers", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_texture_samplers", "get_texture_samplers"); //Vector> @@ -164,11 +167,11 @@ void GLTFState::set_minor_version(int p_minor_version) { minor_version = p_minor_version; } -String GLTFState::get_copyright() { +String GLTFState::get_copyright() const { return copyright; } -void GLTFState::set_copyright(String p_copyright) { +void GLTFState::set_copyright(const String &p_copyright) { copyright = p_copyright; } @@ -381,6 +384,14 @@ void GLTFState::set_base_path(String p_base_path) { base_path = p_base_path; } +String GLTFState::get_filename() const { + return filename; +} + +void GLTFState::set_filename(const String &p_filename) { + filename = p_filename; +} + Variant GLTFState::get_additional_data(const StringName &p_extension_name) { return additional_data[p_extension_name]; } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index d122049c0bb..91af8f91a4e 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -47,8 +47,8 @@ class GLTFState : public Resource { GDCLASS(GLTFState, Resource); friend class GLTFDocument; - String filename; String base_path; + String filename; Dictionary json; int major_version = 0; int minor_version = 0; @@ -126,8 +126,8 @@ public: int get_minor_version(); void set_minor_version(int p_minor_version); - String get_copyright(); - void set_copyright(String p_copyright); + String get_copyright() const; + void set_copyright(const String &p_copyright); Vector get_glb_data(); void set_glb_data(Vector p_glb_data); @@ -171,6 +171,9 @@ public: String get_base_path(); void set_base_path(String p_base_path); + String get_filename() const; + void set_filename(const String &p_filename); + PackedInt32Array get_root_nodes(); void set_root_nodes(PackedInt32Array p_root_nodes);