summaryrefslogtreecommitdiffstats
path: root/modules/gltf/editor
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2023-10-31 17:55:15 -0500
committerAaron Franke <arnfranke@yahoo.com>2023-11-03 12:07:25 -0500
commit58076b9ccba547e607ed2fe96a07fe94504735c9 (patch)
treea8ecf86af1a799781bba4a4bd75d5beffe461238 /modules/gltf/editor
parent5ee983188de97ae027f9b9c1443438063f708a7e (diff)
downloadredot-engine-58076b9ccba547e607ed2fe96a07fe94504735c9.tar.gz
Implement glTF compat version system for files from older Godot versions
Diffstat (limited to 'modules/gltf/editor')
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp13
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index ae2bd1f580..e35c0e9b9b 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -51,6 +51,10 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
gltf.instantiate();
Ref<GLTFState> state;
state.instantiate();
+ if (p_options.has("gltf/naming_version")) {
+ int naming_version = p_options["gltf/naming_version"];
+ gltf->set_naming_version(naming_version);
+ }
if (p_options.has("gltf/embedded_image_handling")) {
int32_t enum_option = p_options["gltf/embedded_image_handling"];
state->set_handle_binary_image(enum_option);
@@ -77,7 +81,16 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
void EditorSceneFormatImporterGLTF::get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) {
+ r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "gltf/naming_version", PROPERTY_HINT_ENUM, "Godot 4.1 or 4.0,Godot 4.2 or later"), 1));
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "gltf/embedded_image_handling", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed as Basis Universal,Embed as Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), GLTFState::HANDLE_BINARY_EXTRACT_TEXTURES));
}
+void EditorSceneFormatImporterGLTF::handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const {
+ if (!p_import_params.has("gltf/naming_version")) {
+ // If an existing import file is missing the glTF
+ // compatibility version, we need to use version 0.
+ p_import_params["gltf/naming_version"] = 0;
+ }
+}
+
#endif // TOOLS_ENABLED
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h
index ed57ec8cdb..7726c845bf 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor/editor_scene_importer_gltf.h
@@ -49,6 +49,7 @@ public:
List<String> *r_missing_deps, Error *r_err = nullptr) override;
virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override;
+ virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override;
};
#endif // TOOLS_ENABLED