summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct24
-rw-r--r--core/string/optimized_translation.cpp5
-rw-r--r--core/typedefs.h4
-rw-r--r--doc/classes/EditorPlugin.xml28
-rw-r--r--doc/classes/EditorSceneFormatImporter.xml (renamed from doc/classes/EditorSceneImporter.xml)2
-rw-r--r--doc/classes/EditorSceneFormatImporterFBX.xml (renamed from modules/fbx/doc_classes/EditorSceneImporterFBX.xml)2
-rw-r--r--doc/classes/EditorSceneFormatImporterGLTF.xml (renamed from modules/gltf/doc_classes/EditorSceneImporterGLTF.xml)2
-rw-r--r--doc/classes/EditorScenePostImportPlugin.xml116
-rw-r--r--editor/debugger/editor_visual_profiler.cpp4
-rw-r--r--editor/editor_node.cpp7
-rw-r--r--editor/editor_plugin.cpp17
-rw-r--r--editor/editor_plugin.h7
-rw-r--r--editor/editor_settings.cpp33
-rw-r--r--editor/import/editor_import_collada.cpp14
-rw-r--r--editor/import/editor_import_collada.h6
-rw-r--r--editor/import/resource_importer_obj.h4
-rw-r--r--editor/import/resource_importer_scene.cpp401
-rw-r--r--editor/import/resource_importer_scene.h116
-rw-r--r--editor/settings_config_dialog.cpp2
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp3
-rw-r--r--modules/fbx/editor_scene_importer_fbx.cpp22
-rw-r--r--modules/fbx/editor_scene_importer_fbx.h8
-rw-r--r--modules/fbx/register_types.cpp4
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp25
-rw-r--r--modules/gdscript/gdscript_analyzer.h4
-rw-r--r--modules/gdscript/gdscript_compiler.cpp11
-rw-r--r--modules/gdscript/gdscript_vm.cpp4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd8
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out6
-rw-r--r--modules/gltf/editor_scene_importer_gltf.cpp8
-rw-r--r--modules/gltf/editor_scene_importer_gltf.h4
-rw-r--r--modules/gltf/gltf_document.cpp8
-rw-r--r--modules/gltf/register_types.cpp4
-rw-r--r--modules/lightmapper_rd/lm_compute.glsl3
-rw-r--r--platform/android/detect.py5
-rw-r--r--platform/iphone/detect.py6
-rw-r--r--platform/iphone/export/export_plugin.cpp2
-rw-r--r--platform/javascript/detect.py3
-rw-r--r--platform/linuxbsd/detect.py3
-rw-r--r--platform/osx/detect.py3
-rw-r--r--platform/osx/export/export_plugin.cpp2
-rw-r--r--platform/uwp/detect.py3
-rw-r--r--platform/windows/detect.py6
-rw-r--r--platform/windows/display_server_windows.h2
-rw-r--r--scene/resources/importer_mesh.cpp6
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp3
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp3
-rw-r--r--servers/rendering/renderer_rd/pipeline_cache_rd.cpp6
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl2
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl2
50 files changed, 756 insertions, 217 deletions
diff --git a/SConstruct b/SConstruct
index b539dc59b7..83c89be5f9 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,7 +1,7 @@
#!/usr/bin/env python
EnsureSConsVersion(3, 0, 0)
-EnsurePythonVersion(3, 5)
+EnsurePythonVersion(3, 6)
# System
import atexit
@@ -308,21 +308,19 @@ env_base.Prepend(CPPPATH=["#"])
env_base.platform_exporters = platform_exporters
env_base.platform_apis = platform_apis
-if env_base["use_precise_math_checks"]:
- env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"])
+# Build type defines - more platform-specific ones can be in detect.py.
+if env_base["target"] == "release_debug" or env_base["target"] == "debug":
+ # DEBUG_ENABLED enables debugging *features* and debug-only code, which is intended
+ # to give *users* extra debugging information for their game development.
+ env_base.Append(CPPDEFINES=["DEBUG_ENABLED"])
if env_base["target"] == "debug":
- env_base.Append(CPPDEFINES=["DEBUG_MEMORY_ALLOC", "DISABLE_FORCED_INLINE"])
-
- # The two options below speed up incremental builds, but reduce the certainty that all files
- # will properly be rebuilt. As such, we only enable them for debug (dev) builds, not release.
+ # DEV_ENABLED enables *engine developer* code which should only be compiled for those
+ # working on the engine itself.
+ env_base.Append(CPPDEFINES=["DEV_ENABLED"])
- # To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed.
- # https://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792
- env_base.Decider("MD5-timestamp")
- # Use cached implicit dependencies by default. Can be overridden by specifying `--implicit-deps-changed` in the command line.
- # https://scons.org/doc/production/HTML/scons-user/ch06s04.html
- env_base.SetOption("implicit_cache", 1)
+if env_base["use_precise_math_checks"]:
+ env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"])
if env_base["no_editor_splash"]:
env_base.Append(CPPDEFINES=["NO_EDITOR_SPLASH"])
diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp
index 839b7a9c01..f8be564740 100644
--- a/core/string/optimized_translation.cpp
+++ b/core/string/optimized_translation.cpp
@@ -64,7 +64,6 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
int idx = 0;
int total_compression_size = 0;
- int total_string_size = 0;
for (const StringName &E : keys) {
//hash string
@@ -102,7 +101,6 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
compressed.write[idx] = ps;
total_compression_size += ps.compressed.size();
- total_string_size += src_s.size();
idx++;
}
@@ -147,15 +145,12 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
uint32_t *btw = (uint32_t *)&btwb[0];
int btindex = 0;
- int collisions = 0;
for (int i = 0; i < size; i++) {
const Map<uint32_t, int> &t = table[i];
if (t.size() == 0) {
htw[i] = 0xFFFFFFFF; //nothing
continue;
- } else if (t.size() > 1) {
- collisions += t.size() - 1;
}
htw[i] = btindex;
diff --git a/core/typedefs.h b/core/typedefs.h
index dde254af23..8ca3d13e63 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -62,9 +62,9 @@
#endif
#endif
-// Should always inline, except in debug builds because it makes debugging harder.
+// Should always inline, except in dev builds because it makes debugging harder.
#ifndef _FORCE_INLINE_
-#ifdef DISABLE_FORCED_INLINE
+#ifdef DEV_ENABLED
#define _FORCE_INLINE_ inline
#else
#define _FORCE_INLINE_ _ALWAYS_INLINE_
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index 4aa6963f57..f2764865df 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -381,7 +381,7 @@
<argument index="0" name="importer" type="EditorImportPlugin" />
<description>
Registers a new [EditorImportPlugin]. Import plugins are used to import custom and unsupported assets as a custom [Resource] type.
- [b]Note:[/b] If you want to import custom 3D asset formats use [method add_scene_import_plugin] instead.
+ [b]Note:[/b] If you want to import custom 3D asset formats use [method add_scene_format_importer_plugin] instead.
See [method add_inspector_plugin] for an example of how to register a plugin.
</description>
</method>
@@ -405,11 +405,18 @@
[/codeblocks]
</description>
</method>
- <method name="add_scene_import_plugin">
+ <method name="add_scene_format_importer_plugin">
<return type="void" />
- <argument index="0" name="scene_importer" type="EditorSceneImporter" />
+ <argument index="0" name="scene_format_importer" type="EditorSceneFormatImporter" />
<description>
- Registers a new [EditorSceneImporter]. Scene importers are used to import custom 3D asset formats as scenes.
+ Registers a new [EditorSceneFormatImporter]. Scene importers are used to import custom 3D asset formats as scenes.
+ </description>
+ </method>
+ <method name="add_scene_post_import_plugin">
+ <return type="void" />
+ <argument index="0" name="scene_import_plugin" type="EditorScenePostImportPlugin" />
+ <description>
+ Add a [EditorScenePostImportPlugin]. These plugins allow customizing the import process of 3D assets by adding new options to the import dialogs.
</description>
</method>
<method name="add_spatial_gizmo_plugin">
@@ -553,11 +560,18 @@
Removes an inspector plugin registered by [method add_import_plugin]
</description>
</method>
- <method name="remove_scene_import_plugin">
+ <method name="remove_scene_format_importer_plugin">
+ <return type="void" />
+ <argument index="0" name="scene_format_importer" type="EditorSceneFormatImporter" />
+ <description>
+ Removes a scene format importer registered by [method add_scene_format_importer_plugin].
+ </description>
+ </method>
+ <method name="remove_scene_post_import_plugin">
<return type="void" />
- <argument index="0" name="scene_importer" type="EditorSceneImporter" />
+ <argument index="0" name="scene_import_plugin" type="EditorScenePostImportPlugin" />
<description>
- Removes a scene importer registered by [method add_scene_import_plugin].
+ Remove the [EditorScenePostImportPlugin], added with [method add_scene_post_import_plugin].
</description>
</method>
<method name="remove_spatial_gizmo_plugin">
diff --git a/doc/classes/EditorSceneImporter.xml b/doc/classes/EditorSceneFormatImporter.xml
index a400db551f..d890188092 100644
--- a/doc/classes/EditorSceneImporter.xml
+++ b/doc/classes/EditorSceneFormatImporter.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="EditorSceneImporter" inherits="RefCounted" version="4.0">
+<class name="EditorSceneFormatImporter" inherits="RefCounted" version="4.0">
<brief_description>
Imports scenes from third-parties' 3D files.
</brief_description>
diff --git a/modules/fbx/doc_classes/EditorSceneImporterFBX.xml b/doc/classes/EditorSceneFormatImporterFBX.xml
index 6f83871772..117030dfd5 100644
--- a/modules/fbx/doc_classes/EditorSceneImporterFBX.xml
+++ b/doc/classes/EditorSceneFormatImporterFBX.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="EditorSceneImporterFBX" inherits="EditorSceneImporter" version="4.0">
+<class name="EditorSceneFormatImporterFBX" inherits="EditorSceneFormatImporter" version="4.0">
<brief_description>
FBX 3D asset importer.
</brief_description>
diff --git a/modules/gltf/doc_classes/EditorSceneImporterGLTF.xml b/doc/classes/EditorSceneFormatImporterGLTF.xml
index c85fce7b9d..1476a22aef 100644
--- a/modules/gltf/doc_classes/EditorSceneImporterGLTF.xml
+++ b/doc/classes/EditorSceneFormatImporterGLTF.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="EditorSceneImporterGLTF" inherits="EditorSceneImporter" version="4.0">
+<class name="EditorSceneFormatImporterGLTF" inherits="EditorSceneFormatImporter" version="4.0">
<brief_description>
</brief_description>
<description>
diff --git a/doc/classes/EditorScenePostImportPlugin.xml b/doc/classes/EditorScenePostImportPlugin.xml
new file mode 100644
index 0000000000..07d8fa28b9
--- /dev/null
+++ b/doc/classes/EditorScenePostImportPlugin.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="EditorScenePostImportPlugin" inherits="RefCounted" version="4.0">
+ <brief_description>
+ Plugin to control and modifying the process of importing a scene.
+ </brief_description>
+ <description>
+ This plugin type exists to modify the process of importing scenes, allowing to change the content as well as add importer options at every stage of the process.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_import_options" qualifiers="virtual">
+ <return type="void" />
+ <description>
+ Override to add general import options. These will appear in the main import dock on the editor. Add options via [method add_import_option] and [method add_import_option_advanced].
+ </description>
+ </method>
+ <method name="_get_internal_import_options" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="category" type="int" />
+ <description>
+ Override to add internal import options. These will appear in the 3D scene import dialog. Add options via [method add_import_option] and [method add_import_option_advanced].
+ </description>
+ </method>
+ <method name="_get_internal_option_update_view_required" qualifiers="virtual const">
+ <return type="Variant" />
+ <argument index="0" name="category" type="int" />
+ <argument index="1" name="option" type="String" />
+ <description>
+ Return true whether updating the 3D view of the import dialog needs to be updated if an option has changed.
+ </description>
+ </method>
+ <method name="_get_internal_option_visibility" qualifiers="virtual const">
+ <return type="Variant" />
+ <argument index="0" name="category" type="int" />
+ <argument index="1" name="option" type="String" />
+ <description>
+ Return true or false whether a given option should be visible. Return null to ignore.
+ </description>
+ </method>
+ <method name="_get_option_visibility" qualifiers="virtual const">
+ <return type="Variant" />
+ <argument index="0" name="option" type="String" />
+ <description>
+ Return true or false whether a given option should be visible. Return null to ignore.
+ </description>
+ </method>
+ <method name="_internal_process" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="category" type="int" />
+ <argument index="1" name="base_node" type="Node" />
+ <argument index="2" name="node" type="Node" />
+ <argument index="3" name="resource" type="Resource" />
+ <description>
+ Process a specific node or resource for a given category.
+ </description>
+ </method>
+ <method name="_post_process" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="scene" type="Node" />
+ <description>
+ Post process the scene. This function is called after the final scene has been configured.
+ </description>
+ </method>
+ <method name="_pre_process" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="scene" type="Node" />
+ <description>
+ Pre Process the scene. This function is called right after the scene format loader loaded the scene and no changes have been made.
+ </description>
+ </method>
+ <method name="add_import_option">
+ <return type="void" />
+ <argument index="0" name="name" type="String" />
+ <argument index="1" name="value" type="Variant" />
+ <description>
+ Add a specific import option (name and default value only). This function can only be called from [method _get_import_options] and [method _get_internal_import_options].
+ </description>
+ </method>
+ <method name="add_import_option_advanced">
+ <return type="void" />
+ <argument index="0" name="type" type="int" enum="Variant.Type" />
+ <argument index="1" name="name" type="String" />
+ <argument index="2" name="default_value" type="Variant" />
+ <argument index="3" name="hint" type="int" enum="PropertyHint" default="0" />
+ <argument index="4" name="hint_string" type="String" default="&quot;&quot;" />
+ <argument index="5" name="usage_flags" type="int" default="7" />
+ <description>
+ Add a specific import option. This function can only be called from [method _get_import_options] and [method _get_internal_import_options].
+ </description>
+ </method>
+ <method name="get_option_value" qualifiers="const">
+ <return type="Variant" />
+ <argument index="0" name="name" type="StringName" />
+ <description>
+ Query the value of an option. This function can only be called from those querying visibility, or processing.
+ </description>
+ </method>
+ </methods>
+ <constants>
+ <constant name="INTERNAL_IMPORT_CATEGORY_NODE" value="0" enum="InternalImportCategory">
+ </constant>
+ <constant name="INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE" value="1" enum="InternalImportCategory">
+ </constant>
+ <constant name="INTERNAL_IMPORT_CATEGORY_MESH" value="2" enum="InternalImportCategory">
+ </constant>
+ <constant name="INTERNAL_IMPORT_CATEGORY_MATERIAL" value="3" enum="InternalImportCategory">
+ </constant>
+ <constant name="INTERNAL_IMPORT_CATEGORY_ANIMATION" value="4" enum="InternalImportCategory">
+ </constant>
+ <constant name="INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE" value="5" enum="InternalImportCategory">
+ </constant>
+ <constant name="INTERNAL_IMPORT_CATEGORY_MAX" value="6" enum="InternalImportCategory">
+ </constant>
+ </constants>
+</class>
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index f17ad0d36c..f25f18b7e4 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -370,8 +370,8 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
float total_gpu = E->get_metadata(2);
total_cpu += cpu_time;
total_gpu += gpu_time;
- E->set_metadata(1, cpu_time);
- E->set_metadata(2, gpu_time);
+ E->set_metadata(1, total_cpu);
+ E->set_metadata(2, total_gpu);
}
category->set_icon(0, track_icon);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9b7dc966e6..2f92f60d5e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3848,7 +3848,8 @@ void EditorNode::register_editor_types() {
GDREGISTER_VIRTUAL_CLASS(EditorInterface);
GDREGISTER_CLASS(EditorExportPlugin);
GDREGISTER_CLASS(EditorResourceConversionPlugin);
- GDREGISTER_CLASS(EditorSceneImporter);
+ GDREGISTER_CLASS(EditorSceneFormatImporter);
+ GDREGISTER_CLASS(EditorScenePostImportPlugin);
GDREGISTER_CLASS(EditorInspector);
GDREGISTER_CLASS(EditorInspectorPlugin);
GDREGISTER_CLASS(EditorProperty);
@@ -5935,7 +5936,7 @@ EditorNode::EditorNode() {
ResourceFormatImporter::get_singleton()->add_importer(import_scene);
{
- Ref<EditorSceneImporterCollada> import_collada;
+ Ref<EditorSceneFormatImporterCollada> import_collada;
import_collada.instantiate();
import_scene->add_importer(import_collada);
@@ -5943,7 +5944,7 @@ EditorNode::EditorNode() {
import_obj2.instantiate();
import_scene->add_importer(import_obj2);
- Ref<EditorSceneImporterESCN> import_escn;
+ Ref<EditorSceneFormatImporterESCN> import_escn;
import_escn.instantiate();
import_scene->add_importer(import_escn);
}
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index aee8322a97..61c01993ae 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -762,16 +762,23 @@ void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_p
EditorInspector::remove_inspector_plugin(p_plugin);
}
-void EditorPlugin::add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
+void EditorPlugin::add_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer) {
ERR_FAIL_COND(!p_importer.is_valid());
ResourceImporterScene::get_singleton()->add_importer(p_importer);
}
-void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
+void EditorPlugin::remove_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer) {
ERR_FAIL_COND(!p_importer.is_valid());
ResourceImporterScene::get_singleton()->remove_importer(p_importer);
}
+void EditorPlugin::add_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
+ ResourceImporterScene::get_singleton()->add_post_importer_plugin(p_plugin);
+}
+void EditorPlugin::remove_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
+ ResourceImporterScene::get_singleton()->remove_post_importer_plugin(p_plugin);
+}
+
int find(const PackedStringArray &a, const String &v) {
const String *r = a.ptr();
for (int j = 0; j < a.size(); ++j) {
@@ -879,8 +886,10 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_translation_parser_plugin", "parser"), &EditorPlugin::remove_translation_parser_plugin);
ClassDB::bind_method(D_METHOD("add_import_plugin", "importer"), &EditorPlugin::add_import_plugin);
ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
- ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin);
- ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin);
+ ClassDB::bind_method(D_METHOD("add_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::add_scene_format_importer_plugin);
+ ClassDB::bind_method(D_METHOD("remove_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::remove_scene_format_importer_plugin);
+ ClassDB::bind_method(D_METHOD("add_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::add_scene_post_import_plugin);
+ ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin);
ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
ClassDB::bind_method(D_METHOD("add_spatial_gizmo_plugin", "plugin"), &EditorPlugin::add_spatial_gizmo_plugin);
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 57830df327..278059f8c4 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -288,8 +288,11 @@ public:
void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
- void add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer);
- void remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer);
+ void add_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer);
+ void remove_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer);
+
+ void add_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_importer);
+ void remove_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_importer);
void add_autoload_singleton(const String &p_name, const String &p_path);
void remove_autoload_singleton(const String &p_name);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 43d458c58e..223cc6650c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -140,32 +140,37 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "shortcuts") {
Array save_array;
+ const OrderedHashMap<String, List<Ref<InputEvent>>> &builtin_list = InputMap::get_singleton()->get_builtins();
for (const KeyValue<String, Ref<Shortcut>> &shortcut_definition : shortcuts) {
Ref<Shortcut> sc = shortcut_definition.value;
- if (builtin_action_overrides.has(shortcut_definition.key)) {
+ if (builtin_list.has(shortcut_definition.key)) {
// This shortcut was auto-generated from built in actions: don't save.
+ // If the builtin is overriden, it will be saved in the "builtin_action_overrides" section below.
continue;
}
- if (optimize_save) {
- if (!sc->has_meta("original")) {
- continue; //this came from settings but is not any longer used
- }
+ Array shortcut_events = sc->get_events();
+
+ Dictionary dict;
+ dict["name"] = shortcut_definition.key;
+ dict["shortcuts"] = shortcut_events;
+
+ if (!sc->has_meta("original")) {
+ // Getting the meta when it doesn't exist will return an empty array. If the 'shortcut_events' have been cleared,
+ // we still want save the shortcut in this case so that shortcuts that the user has customised are not reset,
+ // even if the 'original' has not been populated yet. This can happen when calling save() from the Project Manager.
+ save_array.push_back(dict);
+ continue;
}
Array original_events = sc->get_meta("original");
- Array shortcut_events = sc->get_events();
bool is_same = Shortcut::is_event_array_equal(original_events, shortcut_events);
if (is_same) {
continue; // Not changed from default; don't save.
}
- Dictionary dict;
- dict["name"] = shortcut_definition.key;
- dict["shortcuts"] = shortcut_events;
-
save_array.push_back(dict);
}
r_ret = save_array;
@@ -1511,7 +1516,7 @@ void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, c
// Directly override the existing shortcut.
sc->set_events(events);
- sc->set_meta("original", events);
+ sc->set_meta("original", events.duplicate(true));
}
Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode) {
@@ -1545,21 +1550,21 @@ Ref<Shortcut> ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, cons
sc.instantiate();
sc->set_name(p_name);
sc->set_events(events);
- sc->set_meta("original", events);
+ sc->set_meta("original", events.duplicate(true));
return sc;
}
Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (sc.is_valid()) {
sc->set_name(p_name); //keep name (the ones that come from disk have no name)
- sc->set_meta("original", events); //to compare against changes
+ sc->set_meta("original", events.duplicate(true)); //to compare against changes
return sc;
}
sc.instantiate();
sc->set_name(p_name);
sc->set_events(events);
- sc->set_meta("original", events); //to compare against changes
+ sc->set_meta("original", events.duplicate(true)); //to compare against changes
EditorSettings::get_singleton()->add_shortcut(p_path, sc);
return sc;
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index d1bacf54de..4e343ce3ce 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1748,15 +1748,15 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
/*************************************** SCENE ***********************************/
/*********************************************************************************/
-uint32_t EditorSceneImporterCollada::get_import_flags() const {
+uint32_t EditorSceneFormatImporterCollada::get_import_flags() const {
return IMPORT_SCENE | IMPORT_ANIMATION;
}
-void EditorSceneImporterCollada::get_extensions(List<String> *r_extensions) const {
+void EditorSceneFormatImporterCollada::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("dae");
}
-Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
if (r_err) {
*r_err = OK;
}
@@ -1769,7 +1769,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
state.use_mesh_builtin_materials = true;
state.bake_fps = p_bake_fps;
- Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, false);
+ Error err = state.load(p_path, flags, p_flags & EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, false);
if (r_err) {
*r_err = err;
@@ -1812,12 +1812,12 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
return state.scene;
}
-Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
+Ref<Animation> EditorSceneFormatImporterCollada::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
ColladaImport state;
state.use_mesh_builtin_materials = false;
- Error err = state.load(p_path, Collada::IMPORT_FLAG_ANIMATION, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
+ Error err = state.load(p_path, Collada::IMPORT_FLAG_ANIMATION, p_flags & EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load animation from file '" + p_path + "'.");
state.create_animations(true);
@@ -1833,5 +1833,5 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path
return anim;
}
-EditorSceneImporterCollada::EditorSceneImporterCollada() {
+EditorSceneFormatImporterCollada::EditorSceneFormatImporterCollada() {
}
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index bf45322765..055a6fe178 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -33,8 +33,8 @@
#include "editor/import/resource_importer_scene.h"
-class EditorSceneImporterCollada : public EditorSceneImporter {
- GDCLASS(EditorSceneImporterCollada, EditorSceneImporter);
+class EditorSceneFormatImporterCollada : public EditorSceneFormatImporter {
+ GDCLASS(EditorSceneFormatImporterCollada, EditorSceneFormatImporter);
public:
virtual uint32_t get_import_flags() const override;
@@ -42,7 +42,7 @@ public:
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override;
virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) override;
- EditorSceneImporterCollada();
+ EditorSceneFormatImporterCollada();
};
#endif
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 1bb5ef33ce..d9f2f79903 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -33,8 +33,8 @@
#include "resource_importer_scene.h"
-class EditorOBJImporter : public EditorSceneImporter {
- GDCLASS(EditorOBJImporter, EditorSceneImporter);
+class EditorOBJImporter : public EditorSceneFormatImporter {
+ GDCLASS(EditorOBJImporter, EditorSceneFormatImporter);
public:
virtual uint32_t get_import_flags() const override;
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 35f1533dd0..c393d7f5fc 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -52,7 +52,7 @@
#include "scene/resources/surface_tool.h"
#include "scene/resources/world_boundary_shape_3d.h"
-uint32_t EditorSceneImporter::get_import_flags() const {
+uint32_t EditorSceneFormatImporter::get_import_flags() const {
int ret;
if (GDVIRTUAL_CALL(_get_import_flags, ret)) {
return ret;
@@ -61,7 +61,7 @@ uint32_t EditorSceneImporter::get_import_flags() const {
ERR_FAIL_V(0);
}
-void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
+void EditorSceneFormatImporter::get_extensions(List<String> *r_extensions) const {
Vector<String> arr;
if (GDVIRTUAL_CALL(_get_extensions, arr)) {
for (int i = 0; i < arr.size(); i++) {
@@ -73,7 +73,7 @@ void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
ERR_FAIL();
}
-Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
Object *ret;
if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, p_bake_fps, ret)) {
return Object::cast_to<Node>(ret);
@@ -82,7 +82,7 @@ Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags,
ERR_FAIL_V(nullptr);
}
-Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
+Ref<Animation> EditorSceneFormatImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
Ref<Animation> ret;
if (GDVIRTUAL_CALL(_import_animation, p_path, p_flags, p_bake_fps, ret)) {
return ret;
@@ -94,17 +94,17 @@ Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint3
//for documenters, these functions are useful when an importer calls an external conversion helper (like, fbx2gltf),
//and you want to load the resulting file
-Node *EditorSceneImporter::import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) {
+Node *EditorSceneFormatImporter::import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) {
return ResourceImporterScene::get_singleton()->import_scene_from_other_importer(this, p_path, p_flags, p_bake_fps);
}
-Ref<Animation> EditorSceneImporter::import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) {
+Ref<Animation> EditorSceneFormatImporter::import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) {
return ResourceImporterScene::get_singleton()->import_animation_from_other_importer(this, p_path, p_flags, p_bake_fps);
}
-void EditorSceneImporter::_bind_methods() {
- ClassDB::bind_method(D_METHOD("import_scene_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_scene_from_other_importer);
- ClassDB::bind_method(D_METHOD("import_animation_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_animation_from_other_importer);
+void EditorSceneFormatImporter::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("import_scene_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneFormatImporter::import_scene_from_other_importer);
+ ClassDB::bind_method(D_METHOD("import_animation_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneFormatImporter::import_animation_from_other_importer);
GDVIRTUAL_BIND(_get_import_flags);
GDVIRTUAL_BIND(_get_extensions);
@@ -144,6 +144,105 @@ void EditorScenePostImport::init(const String &p_source_file) {
EditorScenePostImport::EditorScenePostImport() {
}
+///////////////////////////////////////////////////////
+
+Variant EditorScenePostImportPlugin::get_option_value(const StringName &p_name) const {
+ ERR_FAIL_COND_V_MSG(current_options == nullptr && current_options_dict == nullptr, Variant(), "get_option_value called from a function where option values are not available.");
+ ERR_FAIL_COND_V_MSG(current_options && !current_options->has(p_name), Variant(), "get_option_value called with unexisting option argument: " + String(p_name));
+ ERR_FAIL_COND_V_MSG(current_options_dict && !current_options_dict->has(p_name), Variant(), "get_option_value called with unexisting option argument: " + String(p_name));
+ if (current_options) {
+ (*current_options)[p_name];
+ }
+ if (current_options_dict) {
+ (*current_options_dict)[p_name];
+ }
+ return Variant();
+}
+void EditorScenePostImportPlugin::add_import_option(const String &p_name, Variant p_default_value) {
+ ERR_FAIL_COND_MSG(current_option_list == nullptr, "add_import_option() can only be called from get_import_options()");
+ add_import_option_advanced(p_default_value.get_type(), p_name, p_default_value);
+}
+void EditorScenePostImportPlugin::add_import_option_advanced(Variant::Type p_type, const String &p_name, Variant p_default_value, PropertyHint p_hint, const String &p_hint_string, int p_usage_flags) {
+ ERR_FAIL_COND_MSG(current_option_list == nullptr, "add_import_option_advanced() can only be called from get_import_options()");
+ current_option_list->push_back(ResourceImporter::ImportOption(PropertyInfo(p_type, p_name, p_hint, p_hint_string, p_usage_flags), p_default_value));
+}
+
+void EditorScenePostImportPlugin::get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options) {
+ current_option_list = r_options;
+ GDVIRTUAL_CALL(_get_internal_import_options, p_category);
+ current_option_list = nullptr;
+}
+Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const {
+ current_options = &p_options;
+ Variant ret;
+ GDVIRTUAL_CALL(_get_internal_option_visibility, p_category, p_option, ret);
+ current_options = nullptr;
+ return ret;
+}
+Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const {
+ current_options = &p_options;
+ Variant ret;
+ GDVIRTUAL_CALL(_get_internal_option_update_view_required, p_category, p_option, ret);
+ current_options = nullptr;
+ return ret;
+}
+
+void EditorScenePostImportPlugin::internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, RES p_resource, const Dictionary &p_options) {
+ current_options_dict = &p_options;
+ GDVIRTUAL_CALL(_internal_process, p_category, p_base_scene, p_node, p_resource);
+ current_options_dict = nullptr;
+}
+
+void EditorScenePostImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options) {
+ current_option_list = r_options;
+ GDVIRTUAL_CALL(_get_import_options);
+ current_option_list = nullptr;
+}
+Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
+ current_options = &p_options;
+ Variant ret;
+ GDVIRTUAL_CALL(_get_option_visibility, p_option, ret);
+ current_options = nullptr;
+ return ret;
+}
+
+void EditorScenePostImportPlugin::pre_process(Node *p_scene, const Map<StringName, Variant> &p_options) {
+ current_options = &p_options;
+ GDVIRTUAL_CALL(_pre_process, p_scene);
+ current_options = nullptr;
+}
+void EditorScenePostImportPlugin::post_process(Node *p_scene, const Map<StringName, Variant> &p_options) {
+ current_options = &p_options;
+ GDVIRTUAL_CALL(_post_process, p_scene);
+ current_options = nullptr;
+}
+
+void EditorScenePostImportPlugin::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_option_value", "name"), &EditorScenePostImportPlugin::get_option_value);
+
+ ClassDB::bind_method(D_METHOD("add_import_option", "name", "value"), &EditorScenePostImportPlugin::add_import_option);
+ ClassDB::bind_method(D_METHOD("add_import_option_advanced", "type", "name", "default_value", "hint", "hint_string", "usage_flags"), &EditorScenePostImportPlugin::add_import_option_advanced, DEFVAL(PROPERTY_HINT_NONE), DEFVAL(""), DEFVAL(PROPERTY_USAGE_DEFAULT));
+
+ GDVIRTUAL_BIND(_get_internal_import_options, "category");
+ GDVIRTUAL_BIND(_get_internal_option_visibility, "category", "option");
+ GDVIRTUAL_BIND(_get_internal_option_update_view_required, "category", "option");
+ GDVIRTUAL_BIND(_internal_process, "category", "base_node", "node", "resource");
+ GDVIRTUAL_BIND(_get_import_options);
+ GDVIRTUAL_BIND(_get_option_visibility, "option");
+ GDVIRTUAL_BIND(_pre_process, "scene");
+ GDVIRTUAL_BIND(_post_process, "scene");
+
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_NODE);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_MESH);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_MATERIAL);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_ANIMATION);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE);
+ BIND_ENUM_CONSTANT(INTERNAL_IMPORT_CATEGORY_MAX);
+}
+
+/////////////////////////////////////////////////////////
+
String ResourceImporterScene::get_importer_name() const {
return "scene";
}
@@ -153,7 +252,7 @@ String ResourceImporterScene::get_visible_name() const {
}
void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const {
- for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
+ for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
E->get()->get_extensions(p_extensions);
}
}
@@ -181,6 +280,13 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const
return false;
}
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ Variant ret = post_importer_plugins.write[i]->get_option_visibility(p_option, p_options);
+ if (ret.get_type() == Variant::BOOL) {
+ return ret;
+ }
+ }
+
return true;
}
@@ -547,6 +653,26 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
return nullptr;
}
+ {
+ ObjectID node_id = p_node->get_instance_id();
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_NODE, p_root, p_node, RES(), node_settings);
+ if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
+ break;
+ }
+ }
+ }
+
+ if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
+ ObjectID node_id = p_node->get_instance_id();
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE, p_root, p_node, RES(), node_settings);
+ if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
+ break;
+ }
+ }
+ }
+
if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(p_node);
@@ -566,6 +692,11 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
if (mat_id != String() && p_material_data.has(mat_id)) {
Dictionary matdata = p_material_data[mat_id];
+
+ for (int j = 0; j < post_importer_plugins.size(); j++) {
+ post_importer_plugins.write[j]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MATERIAL, p_root, p_node, mat, matdata);
+ }
+
if (matdata.has("use_external/enabled") && bool(matdata["use_external/enabled"]) && matdata.has("use_external/path")) {
String path = matdata["use_external/path"];
Ref<Material> external_mat = ResourceLoader::load(path);
@@ -715,6 +846,10 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
}
}
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, p_root, p_node, RES(), node_settings);
+ }
+
bool use_optimizer = node_settings["optimizer/enabled"];
float anim_optimizer_linerr = node_settings["optimizer/max_linear_error"];
float anim_optimizer_angerr = node_settings["optimizer/max_angular_error"];
@@ -779,6 +914,41 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
}
}
}
+
+ AnimationImportTracks import_tracks_mode[TRACK_CHANNEL_MAX] = {
+ AnimationImportTracks(int(node_settings["import_tracks/position"])),
+ AnimationImportTracks(int(node_settings["import_tracks/rotation"])),
+ AnimationImportTracks(int(node_settings["import_tracks/scale"]))
+ };
+
+ if (anims.size() > 1 && (import_tracks_mode[0] != ANIMATION_IMPORT_TRACKS_IF_PRESENT || import_tracks_mode[1] != ANIMATION_IMPORT_TRACKS_IF_PRESENT || import_tracks_mode[2] != ANIMATION_IMPORT_TRACKS_IF_PRESENT)) {
+ _optimize_track_usage(ap, import_tracks_mode);
+ }
+ }
+
+ if (post_importer_plugins.size()) {
+ List<StringName> anims;
+ ap->get_animation_list(&anims);
+ for (const StringName &name : anims) {
+ if (p_animation_data.has(name)) {
+ Ref<Animation> anim = ap->get_animation(name);
+ Dictionary anim_settings = p_animation_data[name];
+ {
+ //fill with default values
+ List<ImportOption> iopts;
+ get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION, &iopts);
+ for (const ImportOption &F : iopts) {
+ if (!anim_settings.has(F.option.name)) {
+ anim_settings[F.option.name] = F.default_value;
+ }
+ }
+ }
+
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION, p_root, p_node, anim, node_settings);
+ }
+ }
+ }
}
}
@@ -1024,9 +1194,9 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "optimizer/max_linear_error"), 0.05));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "optimizer/max_angular_error"), 0.01));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "optimizer/max_angle"), 22));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/position", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Always,Never"), 1));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/rotation", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Always,Never"), 1));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/scale", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Always,Never"), 1));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/position", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Never"), 1));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/rotation", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Never"), 1));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_tracks/scale", PROPERTY_HINT_ENUM, "IfPresent,IfPresentForAll,Never"), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/amount", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
for (int i = 0; i < 256; i++) {
@@ -1042,6 +1212,10 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
default: {
}
}
+
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->get_internal_import_options(EditorScenePostImportPlugin::InternalImportCategory(p_category), r_options);
+ }
}
bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const {
@@ -1144,6 +1318,13 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
}
}
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ Variant ret = post_importer_plugins.write[i]->get_internal_option_visibility(EditorScenePostImportPlugin::InternalImportCategory(p_category), p_option, p_options);
+ if (ret.get_type() == Variant::BOOL) {
+ return ret;
+ }
+ }
+
return true;
}
@@ -1171,6 +1352,14 @@ bool ResourceImporterScene::get_internal_option_update_view_required(InternalImp
default: {
}
}
+
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ Variant ret = post_importer_plugins.write[i]->get_internal_option_update_view_required(EditorScenePostImportPlugin::InternalImportCategory(p_category), p_option, p_options);
+ if (ret.get_type() == Variant::BOOL) {
+ return ret;
+ }
+ }
+
return false;
}
@@ -1202,6 +1391,10 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "import_script/path", PROPERTY_HINT_FILE, script_ext_hint), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::DICTIONARY, "_subresources", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), Dictionary()));
+
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->get_import_options(r_options);
+ }
}
void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner) {
@@ -1215,11 +1408,11 @@ void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_
}
}
-Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) {
- Ref<EditorSceneImporter> importer;
+Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) {
+ Ref<EditorSceneFormatImporter> importer;
String ext = p_path.get_extension().to_lower();
- for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
+ for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
if (E->get().ptr() == p_exception) {
continue;
}
@@ -1245,11 +1438,11 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte
return importer->import_scene(p_path, p_flags, p_bake_fps, &missing, &err);
}
-Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) {
- Ref<EditorSceneImporter> importer;
+Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) {
+ Ref<EditorSceneFormatImporter> importer;
String ext = p_path.get_extension().to_lower();
- for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
+ for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
if (E->get().ptr() == p_exception) {
continue;
}
@@ -1346,6 +1539,10 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
save_to_file = "";
}
}
+
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH, nullptr, src_mesh_node, src_mesh_node->get_mesh(), mesh_settings);
+ }
}
if (generate_lods) {
@@ -1448,14 +1645,147 @@ void ResourceImporterScene::_add_shapes(Node *p_node, const Vector<Ref<Shape3D>>
}
}
+void ResourceImporterScene::_optimize_track_usage(AnimationPlayer *p_player, AnimationImportTracks *p_track_actions) {
+ List<StringName> anims;
+ p_player->get_animation_list(&anims);
+ Node *parent = p_player->get_parent();
+ ERR_FAIL_COND(parent == nullptr);
+ OrderedHashMap<NodePath, uint32_t> used_tracks[TRACK_CHANNEL_MAX];
+ bool tracks_to_add = false;
+ static const Animation::TrackType track_types[TRACK_CHANNEL_MAX] = { Animation::TYPE_POSITION_3D, Animation::TYPE_ROTATION_3D, Animation::TYPE_SCALE_3D };
+ for (const StringName &I : anims) {
+ Ref<Animation> anim = p_player->get_animation(I);
+ for (int i = 0; i < anim->get_track_count(); i++) {
+ for (int j = 0; j < TRACK_CHANNEL_MAX; j++) {
+ if (anim->track_get_type(i) != track_types[j]) {
+ continue;
+ }
+ switch (p_track_actions[j]) {
+ case ANIMATION_IMPORT_TRACKS_IF_PRESENT: {
+ // Do Nothing.
+ } break;
+ case ANIMATION_IMPORT_TRACKS_IF_PRESENT_FOR_ALL: {
+ used_tracks[j].insert(anim->track_get_path(i), 0);
+ tracks_to_add = true;
+ } break;
+ case ANIMATION_IMPORT_TRACKS_NEVER: {
+ anim->remove_track(i);
+ i--;
+ } break;
+ }
+ }
+ }
+ }
+
+ if (!tracks_to_add) {
+ return;
+ }
+
+ uint32_t pass = 0;
+ for (const StringName &I : anims) {
+ Ref<Animation> anim = p_player->get_animation(I);
+ for (int j = 0; j < TRACK_CHANNEL_MAX; j++) {
+ if (p_track_actions[j] != ANIMATION_IMPORT_TRACKS_IF_PRESENT_FOR_ALL) {
+ continue;
+ }
+
+ pass++;
+
+ for (int i = 0; i < anim->get_track_count(); i++) {
+ if (anim->track_get_type(i) != track_types[j]) {
+ continue;
+ }
+
+ NodePath path = anim->track_get_path(i);
+
+ ERR_CONTINUE(!used_tracks[j].has(path)); // Should never happen.
+
+ used_tracks[j][path] = pass;
+ }
+
+ for (OrderedHashMap<NodePath, uint32_t>::Element J = used_tracks[j].front(); J; J = J.next()) {
+ if (J.get() == pass) {
+ continue;
+ }
+
+ NodePath path = J.key();
+ Node *n = parent->get_node(path);
+ Skeleton3D *skel = Object::cast_to<Skeleton3D>(n);
+ Node3D *n3d = Object::cast_to<Node3D>(n);
+ Vector3 loc;
+ Quaternion rot;
+ Vector3 scale;
+ if (skel && path.get_subname_count() > 0) {
+ StringName bone = path.get_subname(0);
+ int bone_idx = skel->find_bone(bone);
+ if (bone_idx == -1) {
+ continue;
+ }
+ skel->get_bone_pose(bone_idx);
+ loc = skel->get_bone_pose_position(bone_idx);
+ rot = skel->get_bone_pose_rotation(bone_idx);
+ scale = skel->get_bone_pose_scale(bone_idx);
+ } else if (n3d) {
+ loc = n3d->get_position();
+ rot = n3d->get_transform().basis.get_rotation_quaternion();
+ scale = n3d->get_scale();
+ } else {
+ continue;
+ }
+
+ // Ensure insertion keeps tracks together and ordered by type (loc/rot/scale)
+ int insert_at_pos = -1;
+ for (int k = 0; k < anim->get_track_count(); k++) {
+ NodePath tpath = anim->track_get_path(k);
+
+ if (path == tpath) {
+ Animation::TrackType ttype = anim->track_get_type(k);
+ if (insert_at_pos == -1) {
+ // First insert, determine whether replacing or kicking back
+ if (track_types[j] < ttype) {
+ insert_at_pos = k;
+ break; // No point in continuing.
+ } else {
+ insert_at_pos = k + 1;
+ }
+ } else if (ttype < track_types[j]) {
+ // Kick back.
+ insert_at_pos = k + 1;
+ }
+ } else if (insert_at_pos >= 0) {
+ break;
+ }
+ }
+ int track_idx = anim->add_track(track_types[j], insert_at_pos);
+
+ anim->track_set_path(track_idx, path);
+ anim->track_set_imported(track_idx, true);
+ switch (j) {
+ case TRACK_CHANNEL_POSITION: {
+ anim->position_track_insert_key(track_idx, 0, loc);
+ } break;
+ case TRACK_CHANNEL_ROTATION: {
+ anim->rotation_track_insert_key(track_idx, 0, rot);
+ } break;
+ case TRACK_CHANNEL_SCALE: {
+ anim->scale_track_insert_key(track_idx, 0, scale);
+ } break;
+ default: {
+ }
+ }
+ }
+ }
+ }
+}
+
Node *ResourceImporterScene::pre_import(const String &p_source_file) {
- Ref<EditorSceneImporter> importer;
+ Ref<EditorSceneFormatImporter> importer;
String ext = p_source_file.get_extension().to_lower();
EditorProgress progress("pre-import", TTR("Pre-Import Scene"), 0);
progress.step(TTR("Importing Scene..."), 0);
- for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
+ for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
List<String> extensions;
E->get()->get_extensions(&extensions);
@@ -1474,7 +1804,7 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) {
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
Error err = OK;
- Node *scene = importer->import_scene(p_source_file, EditorSceneImporter::IMPORT_ANIMATION | EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, 15, nullptr, &err);
+ Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, 15, nullptr, &err);
if (!scene || err != OK) {
return nullptr;
}
@@ -1489,13 +1819,13 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) {
Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
const String &src_path = p_source_file;
- Ref<EditorSceneImporter> importer;
+ Ref<EditorSceneFormatImporter> importer;
String ext = src_path.get_extension().to_lower();
EditorProgress progress("import", TTR("Import Scene"), 104);
progress.step(TTR("Importing Scene..."), 0);
- for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
+ for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
List<String> extensions;
E->get()->get_extensions(&extensions);
@@ -1518,16 +1848,16 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
int import_flags = 0;
if (bool(p_options["animation/import"])) {
- import_flags |= EditorSceneImporter::IMPORT_ANIMATION;
+ import_flags |= EditorSceneFormatImporter::IMPORT_ANIMATION;
}
if (bool(p_options["skins/use_named_skins"])) {
- import_flags |= EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ import_flags |= EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
}
bool ensure_tangents = p_options["meshes/ensure_tangents"];
if (ensure_tangents) {
- import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
+ import_flags |= EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
}
Error err = OK;
@@ -1558,6 +1888,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
_pre_fix_node(scene, scene, collision_map);
+
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->pre_process(scene, p_options);
+ }
+
_post_fix_node(scene, scene, collision_map, scanned_meshes, node_data, material_data, animation_data, fps);
String root_type = p_options["nodes/root_type"];
@@ -1661,6 +1996,10 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
}
+ for (int i = 0; i < post_importer_plugins.size(); i++) {
+ post_importer_plugins.write[i]->post_process(scene, p_options);
+ }
+
progress.step(TTR("Saving..."), 104);
Ref<PackedScene> packer = memnew(PackedScene);
@@ -1692,15 +2031,15 @@ ResourceImporterScene::ResourceImporterScene() {
///////////////////////////////////////
-uint32_t EditorSceneImporterESCN::get_import_flags() const {
+uint32_t EditorSceneFormatImporterESCN::get_import_flags() const {
return IMPORT_SCENE;
}
-void EditorSceneImporterESCN::get_extensions(List<String> *r_extensions) const {
+void EditorSceneFormatImporterESCN::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("escn");
}
-Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
Error error;
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'.");
@@ -1711,6 +2050,6 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla
return scene;
}
-Ref<Animation> EditorSceneImporterESCN::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
+Ref<Animation> EditorSceneFormatImporterESCN::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
ERR_FAIL_V(Ref<Animation>());
}
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index eb17193c00..fab602b8ff 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -42,8 +42,8 @@ class Material;
class AnimationPlayer;
class ImporterMesh;
-class EditorSceneImporter : public RefCounted {
- GDCLASS(EditorSceneImporter, RefCounted);
+class EditorSceneFormatImporter : public RefCounted {
+ GDCLASS(EditorSceneFormatImporter, RefCounted);
protected:
static void _bind_methods();
@@ -65,19 +65,12 @@ public:
IMPORT_USE_NAMED_SKIN_BINDS = 16,
};
- enum AnimationImportBoneTracks {
- ANIMATION_IMPORT_BONE_TRACKS_IF_PRESENT,
- ANIMATION_IMPORT_BONE_TRACKS_IF_PRESENT_FOR_ALL,
- ANIMATION_IMPORT_BONE_TRACKS_ALWAYS,
- ANIMATION_IMPORT_BONE_TRACKS_NEVER,
- };
-
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr);
virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps);
- EditorSceneImporter() {}
+ EditorSceneFormatImporter() {}
};
class EditorScenePostImport : public RefCounted {
@@ -97,10 +90,64 @@ public:
EditorScenePostImport();
};
+class EditorScenePostImportPlugin : public RefCounted {
+ GDCLASS(EditorScenePostImportPlugin, RefCounted);
+
+public:
+ enum InternalImportCategory {
+ INTERNAL_IMPORT_CATEGORY_NODE,
+ INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE,
+ INTERNAL_IMPORT_CATEGORY_MESH,
+ INTERNAL_IMPORT_CATEGORY_MATERIAL,
+ INTERNAL_IMPORT_CATEGORY_ANIMATION,
+ INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE,
+ INTERNAL_IMPORT_CATEGORY_MAX
+ };
+
+private:
+ mutable const Map<StringName, Variant> *current_options = nullptr;
+ mutable const Dictionary *current_options_dict = nullptr;
+ List<ResourceImporter::ImportOption> *current_option_list = nullptr;
+ InternalImportCategory current_category = INTERNAL_IMPORT_CATEGORY_MAX;
+
+protected:
+ GDVIRTUAL1(_get_internal_import_options, int)
+ GDVIRTUAL2RC(Variant, _get_internal_option_visibility, int, String)
+ GDVIRTUAL2RC(Variant, _get_internal_option_update_view_required, int, String)
+ GDVIRTUAL4(_internal_process, int, Node *, Node *, RES)
+ GDVIRTUAL0(_get_import_options)
+ GDVIRTUAL1RC(Variant, _get_option_visibility, String)
+ GDVIRTUAL1(_pre_process, Node *)
+ GDVIRTUAL1(_post_process, Node *)
+
+ static void _bind_methods();
+
+public:
+ Variant get_option_value(const StringName &p_name) const;
+ void add_import_option(const String &p_name, Variant p_default_value);
+ void add_import_option_advanced(Variant::Type p_type, const String &p_name, Variant p_default_value, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = String(), int p_usage_flags = PROPERTY_USAGE_DEFAULT);
+
+ virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options);
+ virtual Variant get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
+ virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
+
+ virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, RES p_resource, const Dictionary &p_options);
+
+ virtual void get_import_options(List<ResourceImporter::ImportOption> *r_options);
+ virtual Variant get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
+
+ virtual void pre_process(Node *p_scene, const Map<StringName, Variant> &p_options);
+ virtual void post_process(Node *p_scene, const Map<StringName, Variant> &p_options);
+
+ EditorScenePostImportPlugin() {}
+};
+
+VARIANT_ENUM_CAST(EditorScenePostImportPlugin::InternalImportCategory)
+
class ResourceImporterScene : public ResourceImporter {
GDCLASS(ResourceImporterScene, ResourceImporter);
- Set<Ref<EditorSceneImporter>> importers;
+ Set<Ref<EditorSceneFormatImporter>> importers;
static ResourceImporterScene *singleton;
@@ -151,13 +198,32 @@ class ResourceImporterScene : public ResourceImporter {
void _generate_meshes(Node *p_node, const Dictionary &p_mesh_data, bool p_generate_lods, bool p_create_shadow_meshes, LightBakeMode p_light_bake_mode, float p_lightmap_texel_size, const Vector<uint8_t> &p_src_lightmap_cache, Vector<Vector<uint8_t>> &r_lightmap_caches);
void _add_shapes(Node *p_node, const Vector<Ref<Shape3D>> &p_shapes);
+ enum AnimationImportTracks {
+ ANIMATION_IMPORT_TRACKS_IF_PRESENT,
+ ANIMATION_IMPORT_TRACKS_IF_PRESENT_FOR_ALL,
+ ANIMATION_IMPORT_TRACKS_NEVER,
+ };
+ enum TrackChannel {
+ TRACK_CHANNEL_POSITION,
+ TRACK_CHANNEL_ROTATION,
+ TRACK_CHANNEL_SCALE,
+ TRACK_CHANNEL_MAX
+ };
+
+ void _optimize_track_usage(AnimationPlayer *p_player, AnimationImportTracks *p_track_actions);
+
+ mutable Vector<Ref<EditorScenePostImportPlugin>> post_importer_plugins;
+
public:
static ResourceImporterScene *get_singleton() { return singleton; }
- const Set<Ref<EditorSceneImporter>> &get_importers() const { return importers; }
+ void add_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) { post_importer_plugins.push_back(p_plugin); }
+ void remove_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) { post_importer_plugins.erase(p_plugin); }
+
+ const Set<Ref<EditorSceneFormatImporter>> &get_importers() const { return importers; }
- void add_importer(Ref<EditorSceneImporter> p_importer) { importers.insert(p_importer); }
- void remove_importer(Ref<EditorSceneImporter> p_importer) { importers.erase(p_importer); }
+ void add_importer(Ref<EditorSceneFormatImporter> p_importer) { importers.insert(p_importer); }
+ void remove_importer(Ref<EditorSceneFormatImporter> p_importer) { importers.erase(p_importer); }
virtual String get_importer_name() const override;
virtual String get_visible_name() const override;
@@ -170,13 +236,13 @@ public:
virtual String get_preset_name(int p_idx) const override;
enum InternalImportCategory {
- INTERNAL_IMPORT_CATEGORY_NODE,
- INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE,
- INTERNAL_IMPORT_CATEGORY_MESH,
- INTERNAL_IMPORT_CATEGORY_MATERIAL,
- INTERNAL_IMPORT_CATEGORY_ANIMATION,
- INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE,
- INTERNAL_IMPORT_CATEGORY_MAX
+ INTERNAL_IMPORT_CATEGORY_NODE = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_NODE,
+ INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE,
+ INTERNAL_IMPORT_CATEGORY_MESH = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH,
+ INTERNAL_IMPORT_CATEGORY_MATERIAL = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MATERIAL,
+ INTERNAL_IMPORT_CATEGORY_ANIMATION = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION,
+ INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE,
+ INTERNAL_IMPORT_CATEGORY_MAX = EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MAX
};
void get_internal_import_options(InternalImportCategory p_category, List<ImportOption> *r_options) const;
@@ -198,8 +264,8 @@ public:
Node *pre_import(const String &p_source_file);
virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
- Node *import_scene_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps);
- Ref<Animation> import_animation_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps);
+ Node *import_scene_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps);
+ Ref<Animation> import_animation_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps);
virtual bool has_advanced_options() const override;
virtual void show_advanced_options(const String &p_path) override;
@@ -215,8 +281,8 @@ public:
static Transform3D get_collision_shapes_transform(const M &p_options);
};
-class EditorSceneImporterESCN : public EditorSceneImporter {
- GDCLASS(EditorSceneImporterESCN, EditorSceneImporter);
+class EditorSceneFormatImporterESCN : public EditorSceneFormatImporter {
+ GDCLASS(EditorSceneFormatImporterESCN, EditorSceneFormatImporter);
public:
virtual uint32_t get_import_flags() const override;
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 9062169e06..78dc85aa7d 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -433,7 +433,7 @@ void EditorSettingsDialog::_update_shortcuts() {
}
Array original = sc->get_meta("original");
- Array shortcuts_array = sc->get_events();
+ Array shortcuts_array = sc->get_events().duplicate(true);
bool same_as_defaults = Shortcut::is_event_array_equal(original, shortcuts_array);
bool collapse = !collapsed.has(E) || (collapsed.has(E) && collapsed[E]);
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 7343bf87af..e1eacc68b3 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -357,7 +357,6 @@ ImporterMeshInstance3D *FBXMeshData::create_fbx_mesh(const ImportState &state, c
mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED);
// Add surfaces.
- int in_mesh_surface_id = 0;
for (const SurfaceId *surface_id = surfaces.next(nullptr); surface_id != nullptr; surface_id = surfaces.next(surface_id)) {
SurfaceData *surface = surfaces.getptr(*surface_id);
@@ -377,8 +376,6 @@ ImporterMeshInstance3D *FBXMeshData::create_fbx_mesh(const ImportState &state, c
} else {
mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, mesh_array, blend_shapes);
}
-
- in_mesh_surface_id += 1;
}
ImporterMeshInstance3D *godot_mesh = memnew(ImporterMeshInstance3D);
diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp
index 879f281292..9bdeafbf91 100644
--- a/modules/fbx/editor_scene_importer_fbx.cpp
+++ b/modules/fbx/editor_scene_importer_fbx.cpp
@@ -56,7 +56,7 @@
#include <string>
-void EditorSceneImporterFBX::get_extensions(List<String> *r_extensions) const {
+void EditorSceneFormatImporterFBX::get_extensions(List<String> *r_extensions) const {
// register FBX as the one and only format for FBX importing
const String import_setting_string = "filesystem/import/fbx/";
const String fbx_str = "fbx";
@@ -65,7 +65,7 @@ void EditorSceneImporterFBX::get_extensions(List<String> *r_extensions) const {
_register_project_setting_import(fbx_str, import_setting_string, exts, r_extensions, true);
}
-void EditorSceneImporterFBX::_register_project_setting_import(const String generic,
+void EditorSceneFormatImporterFBX::_register_project_setting_import(const String generic,
const String import_setting_string,
const Vector<String> &exts,
List<String> *r_extensions,
@@ -79,11 +79,11 @@ void EditorSceneImporterFBX::_register_project_setting_import(const String gener
}
}
-uint32_t EditorSceneImporterFBX::get_import_flags() const {
+uint32_t EditorSceneFormatImporterFBX::get_import_flags() const {
return IMPORT_SCENE;
}
-Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps,
+Node3D *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps,
List<String> *r_missing_deps, Error *r_err) {
// done for performance when re-importing lots of files when testing importer in verbose only!
if (OS::get_singleton()->is_stdout_verbose()) {
@@ -232,7 +232,7 @@ Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_fl
}
template <class T>
-struct EditorSceneImporterAssetImportInterpolate {
+struct EditorSceneFormatImporterAssetImportInterpolate {
T lerp(const T &a, const T &b, float c) const {
return a + (b - a) * c;
}
@@ -258,7 +258,7 @@ struct EditorSceneImporterAssetImportInterpolate {
//thank you for existing, partial specialization
template <>
-struct EditorSceneImporterAssetImportInterpolate<Quaternion> {
+struct EditorSceneFormatImporterAssetImportInterpolate<Quaternion> {
Quaternion lerp(const Quaternion &a, const Quaternion &b, float c) const {
ERR_FAIL_COND_V(!a.is_normalized(), Quaternion());
ERR_FAIL_COND_V(!b.is_normalized(), Quaternion());
@@ -282,7 +282,7 @@ struct EditorSceneImporterAssetImportInterpolate<Quaternion> {
};
template <class T>
-T EditorSceneImporterFBX::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time,
+T EditorSceneFormatImporterFBX::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time,
AssetImportAnimation::Interpolation p_interp) {
//could use binary search, worth it?
int idx = -1;
@@ -293,7 +293,7 @@ T EditorSceneImporterFBX::_interpolate_track(const Vector<float> &p_times, const
idx++;
}
- EditorSceneImporterAssetImportInterpolate<T> interp;
+ EditorSceneFormatImporterAssetImportInterpolate<T> interp;
switch (p_interp) {
case AssetImportAnimation::INTERP_LINEAR: {
@@ -352,7 +352,7 @@ T EditorSceneImporterFBX::_interpolate_track(const Vector<float> &p_times, const
ERR_FAIL_V(p_values[0]);
}
-Node3D *EditorSceneImporterFBX::_generate_scene(
+Node3D *EditorSceneFormatImporterFBX::_generate_scene(
const String &p_path,
const FBXDocParser::Document *p_document,
const uint32_t p_flags,
@@ -1294,7 +1294,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
return scene_root;
}
-void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
+void EditorSceneFormatImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
ImportState &state, const FBXDocParser::Document *p_doc,
uint64_t p_id) {
const std::vector<const FBXDocParser::Connection *> &conns = p_doc->GetConnectionsByDestinationSequenced(p_id, "Model");
@@ -1383,7 +1383,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
}
}
-void EditorSceneImporterFBX::BuildDocumentNodes(
+void EditorSceneFormatImporterFBX::BuildDocumentNodes(
Ref<PivotTransform> parent_transform,
ImportState &state,
const FBXDocParser::Document *p_doc,
diff --git a/modules/fbx/editor_scene_importer_fbx.h b/modules/fbx/editor_scene_importer_fbx.h
index 4a3b78480b..7845e079c2 100644
--- a/modules/fbx/editor_scene_importer_fbx.h
+++ b/modules/fbx/editor_scene_importer_fbx.h
@@ -57,9 +57,9 @@
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
-class EditorSceneImporterFBX : public EditorSceneImporter {
+class EditorSceneFormatImporterFBX : public EditorSceneFormatImporter {
private:
- GDCLASS(EditorSceneImporterFBX, EditorSceneImporter);
+ GDCLASS(EditorSceneFormatImporterFBX, EditorSceneFormatImporter);
struct AssetImportAnimation {
enum Interpolation {
@@ -122,8 +122,8 @@ private:
void _register_project_setting_import(const String generic, const String import_setting_string, const Vector<String> &exts, List<String> *r_extensions, const bool p_enabled) const;
public:
- EditorSceneImporterFBX() {}
- ~EditorSceneImporterFBX() {}
+ EditorSceneFormatImporterFBX() {}
+ ~EditorSceneFormatImporterFBX() {}
virtual void get_extensions(List<String> *r_extensions) const override;
virtual uint32_t get_import_flags() const override;
diff --git a/modules/fbx/register_types.cpp b/modules/fbx/register_types.cpp
index a75da8f3a9..d5e520a060 100644
--- a/modules/fbx/register_types.cpp
+++ b/modules/fbx/register_types.cpp
@@ -35,7 +35,7 @@
#ifdef TOOLS_ENABLED
static void _editor_init() {
- Ref<EditorSceneImporterFBX> import_fbx;
+ Ref<EditorSceneFormatImporterFBX> import_fbx;
import_fbx.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_fbx);
}
@@ -46,7 +46,7 @@ void register_fbx_types() {
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
- GDREGISTER_CLASS(EditorSceneImporterFBX);
+ GDREGISTER_CLASS(EditorSceneFormatImporterFBX);
ClassDB::set_current_api(prev_api);
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 7305b5d1fa..a5b75cbfe4 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -1070,7 +1070,7 @@ void GDScriptAnalyzer::resolve_node(GDScriptParser::Node *p_node) {
case GDScriptParser::Node::SUBSCRIPT:
case GDScriptParser::Node::TERNARY_OPERATOR:
case GDScriptParser::Node::UNARY_OPERATOR:
- reduce_expression(static_cast<GDScriptParser::ExpressionNode *>(p_node));
+ reduce_expression(static_cast<GDScriptParser::ExpressionNode *>(p_node), true);
break;
case GDScriptParser::Node::BREAK:
case GDScriptParser::Node::BREAKPOINT:
@@ -1659,7 +1659,7 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) {
p_return->set_datatype(result);
}
-void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expression) {
+void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expression, bool p_is_root) {
// This one makes some magic happen.
if (p_expression == nullptr) {
@@ -1687,7 +1687,7 @@ void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expre
reduce_binary_op(static_cast<GDScriptParser::BinaryOpNode *>(p_expression));
break;
case GDScriptParser::Node::CALL:
- reduce_call(static_cast<GDScriptParser::CallNode *>(p_expression));
+ reduce_call(static_cast<GDScriptParser::CallNode *>(p_expression), p_is_root);
break;
case GDScriptParser::Node::CAST:
reduce_cast(static_cast<GDScriptParser::CastNode *>(p_expression));
@@ -1929,16 +1929,25 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
p_await->set_datatype(await_type);
return;
}
+
+ GDScriptParser::DataType awaiting_type;
+
if (p_await->to_await->type == GDScriptParser::Node::CALL) {
reduce_call(static_cast<GDScriptParser::CallNode *>(p_await->to_await), true);
+ awaiting_type = p_await->to_await->get_datatype();
} else {
reduce_expression(p_await->to_await);
}
- p_await->is_constant = p_await->to_await->is_constant;
- p_await->reduced_value = p_await->to_await->reduced_value;
+ if (p_await->to_await->is_constant) {
+ p_await->is_constant = p_await->to_await->is_constant;
+ p_await->reduced_value = p_await->to_await->reduced_value;
- GDScriptParser::DataType awaiting_type = p_await->to_await->get_datatype();
+ awaiting_type = p_await->to_await->get_datatype();
+ } else {
+ awaiting_type.kind = GDScriptParser::DataType::VARIANT;
+ awaiting_type.type_source = GDScriptParser::DataType::UNDETECTED;
+ }
p_await->set_datatype(awaiting_type);
@@ -2058,7 +2067,7 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o
p_binary_op->set_datatype(result);
}
-void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_await) {
+void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_await, bool p_is_root) {
bool all_is_constant = true;
Map<int, GDScriptParser::ArrayNode *> arrays; // For array literal to potentially type when passing.
for (int i = 0; i < p_call->arguments.size(); i++) {
@@ -2417,7 +2426,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa
}
}
- if (call_type.is_coroutine && !is_await) {
+ if (call_type.is_coroutine && !p_is_await && !p_is_root) {
push_error(vformat(R"*(Function "%s()" is a coroutine, so it must be called with "await".)*", p_call->function_name), p_call->callee);
}
diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h
index 2e17e15452..ce4525190b 100644
--- a/modules/gdscript/gdscript_analyzer.h
+++ b/modules/gdscript/gdscript_analyzer.h
@@ -78,12 +78,12 @@ class GDScriptAnalyzer {
void resolve_return(GDScriptParser::ReturnNode *p_return);
// Reduction functions.
- void reduce_expression(GDScriptParser::ExpressionNode *p_expression);
+ void reduce_expression(GDScriptParser::ExpressionNode *p_expression, bool p_is_root = false);
void reduce_array(GDScriptParser::ArrayNode *p_array);
void reduce_assignment(GDScriptParser::AssignmentNode *p_assignment);
void reduce_await(GDScriptParser::AwaitNode *p_await);
void reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_op);
- void reduce_call(GDScriptParser::CallNode *p_call, bool is_await = false);
+ void reduce_call(GDScriptParser::CallNode *p_call, bool p_is_await = false, bool p_is_root = false);
void reduce_cast(GDScriptParser::CastNode *p_cast);
void reduce_dictionary(GDScriptParser::DictionaryNode *p_dictionary);
void reduce_get_node(GDScriptParser::GetNodeNode *p_get_node);
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 1f9aad40af..ab0fe5c37d 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -488,6 +488,9 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_expression);
GDScriptDataType type = _gdtype_from_datatype(call->get_datatype());
GDScriptCodeGenerator::Address result = codegen.add_temporary(type);
+ GDScriptCodeGenerator::Address nil = GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::NIL);
+
+ GDScriptCodeGenerator::Address return_addr = p_root ? nil : result;
Vector<GDScriptCodeGenerator::Address> arguments;
for (int i = 0; i < call->arguments.size(); i++) {
@@ -538,13 +541,13 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
if (within_await) {
gen->write_call_async(result, self, call->function_name, arguments);
} else {
- gen->write_call(result, self, call->function_name, arguments);
+ gen->write_call(return_addr, self, call->function_name, arguments);
}
} else {
if (within_await) {
gen->write_call_self_async(result, call->function_name, arguments);
} else {
- gen->write_call_self(result, call->function_name, arguments);
+ gen->write_call_self(return_addr, call->function_name, arguments);
}
}
} else if (callee->type == GDScriptParser::Node::SUBSCRIPT) {
@@ -579,12 +582,12 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
gen->write_call_method_bind(result, base, method, arguments);
}
} else {
- gen->write_call(result, base, call->function_name, arguments);
+ gen->write_call(return_addr, base, call->function_name, arguments);
}
} else if (base.type.has_type && base.type.kind == GDScriptDataType::BUILTIN) {
gen->write_call_builtin_type(result, base, base.type.builtin_type, call->function_name, arguments);
} else {
- gen->write_call(result, base, call->function_name, arguments);
+ gen->write_call(return_addr, base, call->function_name, arguments);
}
if (base.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
gen->pop_temporary();
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 1bc7ae086f..7018c339d7 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -2098,8 +2098,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
if (result.get_type() != Variant::SIGNAL) {
+ // Not async, return immediately using the target from OPCODE_AWAIT_RESUME.
+ GET_VARIANT_PTR(target, 3);
+ *target = result;
ip += 4; // Skip OPCODE_AWAIT_RESUME and its data.
- // The stack pointer should be the same, so we don't need to set a return value.
is_signal = false;
} else {
sig = result;
diff --git a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd
new file mode 100644
index 0000000000..9da61ab184
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd
@@ -0,0 +1,8 @@
+# https://github.com/godotengine/godot/issues/50894
+
+func test():
+ print(await not_coroutine())
+
+
+func not_coroutine():
+ return "awaited"
diff --git a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out
new file mode 100644
index 0000000000..c2ac488e9b
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out
@@ -0,0 +1,6 @@
+GDTEST_OK
+>> WARNING
+>> Line: 4
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+awaited
diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp
index 25875e7396..1a172877a0 100644
--- a/modules/gltf/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor_scene_importer_gltf.cpp
@@ -38,16 +38,16 @@
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
-uint32_t EditorSceneImporterGLTF::get_import_flags() const {
+uint32_t EditorSceneFormatImporterGLTF::get_import_flags() const {
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
}
-void EditorSceneImporterGLTF::get_extensions(List<String> *r_extensions) const {
+void EditorSceneFormatImporterGLTF::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("gltf");
r_extensions->push_back("glb");
}
-Node *EditorSceneImporterGLTF::import_scene(const String &p_path,
+Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path,
uint32_t p_flags, int p_bake_fps,
List<String> *r_missing_deps,
Error *r_err) {
@@ -56,7 +56,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path,
return doc->import_scene_gltf(p_path, p_flags, p_bake_fps, Ref<GLTFState>(), r_missing_deps, r_err);
}
-Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path,
+Ref<Animation> EditorSceneFormatImporterGLTF::import_animation(const String &p_path,
uint32_t p_flags,
int p_bake_fps) {
return Ref<Animation>();
diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h
index 90663612a1..28963adc28 100644
--- a/modules/gltf/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor_scene_importer_gltf.h
@@ -41,8 +41,8 @@
class Animation;
-class EditorSceneImporterGLTF : public EditorSceneImporter {
- GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter);
+class EditorSceneFormatImporterGLTF : public EditorSceneFormatImporter {
+ GDCLASS(EditorSceneFormatImporterGLTF, EditorSceneFormatImporter);
public:
virtual uint32_t get_import_flags() const override;
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 11f30be5a4..70df62de6a 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -5684,7 +5684,7 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> state, Node *scen
}
template <class T>
-struct EditorSceneImporterGLTFInterpolate {
+struct EditorSceneFormatImporterGLTFInterpolate {
T lerp(const T &a, const T &b, float c) const {
return a + (b - a) * c;
}
@@ -5710,7 +5710,7 @@ struct EditorSceneImporterGLTFInterpolate {
// thank you for existing, partial specialization
template <>
-struct EditorSceneImporterGLTFInterpolate<Quaternion> {
+struct EditorSceneFormatImporterGLTFInterpolate<Quaternion> {
Quaternion lerp(const Quaternion &a, const Quaternion &b, const float c) const {
ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quaternion(), "The quaternion \"a\" must be normalized.");
ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quaternion(), "The quaternion \"b\" must be normalized.");
@@ -5749,7 +5749,7 @@ T GLTFDocument::_interpolate_track(const Vector<float> &p_times, const Vector<T>
idx++;
}
- EditorSceneImporterGLTFInterpolate<T> interp;
+ EditorSceneFormatImporterGLTFInterpolate<T> interp;
switch (p_interp) {
case GLTFAnimation::INTERP_LINEAR: {
@@ -6833,7 +6833,7 @@ Node *GLTFDocument::import_scene_gltf(const String &p_path, uint32_t p_flags, in
r_state.instantiate();
}
r_state->use_named_skin_binds =
- p_flags & EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
Ref<GLTFDocument> gltf_document;
gltf_document.instantiate();
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index 0aceb838f7..5a60c2d328 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -52,7 +52,7 @@
#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED
static void _editor_init() {
- Ref<EditorSceneImporterGLTF> import_gltf;
+ Ref<EditorSceneFormatImporterGLTF> import_gltf;
import_gltf.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_gltf);
}
@@ -64,7 +64,7 @@ void register_gltf_types() {
#ifdef TOOLS_ENABLED
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
- GDREGISTER_CLASS(EditorSceneImporterGLTF);
+ GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
GDREGISTER_CLASS(GLTFMesh);
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
ClassDB::set_current_api(prev_api);
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl
index 6e5c9f25ba..158cd960c4 100644
--- a/modules/lightmapper_rd/lm_compute.glsl
+++ b/modules/lightmapper_rd/lm_compute.glsl
@@ -94,13 +94,14 @@ params;
//check it, but also return distance and barycentric coords (for uv lookup)
bool ray_hits_triangle(vec3 from, vec3 dir, float max_dist, vec3 p0, vec3 p1, vec3 p2, out float r_distance, out vec3 r_barycentric) {
+ const float EPSILON = 0.00001;
const vec3 e0 = p1 - p0;
const vec3 e1 = p0 - p2;
vec3 triangle_normal = cross(e1, e0);
float n_dot_dir = dot(triangle_normal, dir);
- if (abs(n_dot_dir) < 0.01) {
+ if (abs(n_dot_dir) < EPSILON) {
return false;
}
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 6b0c60fe8b..6f98dab2cc 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -197,13 +197,10 @@ def configure(env):
env.Append(CPPDEFINES=["NDEBUG"])
if can_vectorize:
env.Append(CCFLAGS=["-ftree-vectorize"])
- if env["target"] == "release_debug":
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
elif env["target"] == "debug":
env.Append(LINKFLAGS=["-O0"])
env.Append(CCFLAGS=["-O0", "-g", "-fno-limit-debug-info"])
- env.Append(CPPDEFINES=["_DEBUG", "DEBUG_ENABLED"])
- env.Append(CPPDEFINES=["DEV_ENABLED"])
+ env.Append(CPPDEFINES=["_DEBUG"])
env.Append(CPPFLAGS=["-UNDEBUG"])
# Compiler configuration
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index 3c6453ff9b..0d28aa2f06 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -53,13 +53,9 @@ def configure(env):
env.Append(CCFLAGS=["-Os", "-ftree-vectorize"])
env.Append(LINKFLAGS=["-Os"])
- if env["target"] == "release_debug":
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
-
elif env["target"] == "debug":
env.Append(CCFLAGS=["-gdwarf-2", "-O0"])
- env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1), "DEBUG_ENABLED"])
- env.Append(CPPDEFINES=["DEV_ENABLED"])
+ env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1)])
if env["use_lto"]:
env.Append(CCFLAGS=["-flto"])
diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp
index 69a8203e9f..a561da41c0 100644
--- a/platform/iphone/export/export_plugin.cpp
+++ b/platform/iphone/export/export_plugin.cpp
@@ -1427,7 +1427,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
}
bool found_library = false;
- int total_size = 0;
const String project_file = "godot_ios.xcodeproj/project.pbxproj";
Set<String> files_to_parse;
@@ -1523,7 +1522,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
file = file.replace("godot_ios", binary_name);
print_line("ADDING: " + file + " size: " + itos(data.size()));
- total_size += data.size();
/* write it into our folder structure */
file = dest_dir + file;
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 9494ab6fa5..891ae419bd 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -77,12 +77,9 @@ def configure(env):
env.Append(LINKFLAGS=["-Os"])
if env["target"] == "release_debug":
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
# Retain function names for backtraces at the cost of file size.
env.Append(LINKFLAGS=["--profiling-funcs"])
else: # "debug"
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
- env.Append(CPPDEFINES=["DEV_ENABLED"])
env.Append(CCFLAGS=["-O1", "-g"])
env.Append(LINKFLAGS=["-O1", "-g"])
env["use_assertions"] = True
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index afb7c7b2ab..8e0adc079b 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -105,15 +105,12 @@ def configure(env):
env.Prepend(CCFLAGS=["-O2"])
elif env["optimize"] == "size": # optimize for size
env.Prepend(CCFLAGS=["-Os"])
- env.Prepend(CPPDEFINES=["DEBUG_ENABLED"])
if env["debug_symbols"]:
env.Prepend(CCFLAGS=["-g2"])
elif env["target"] == "debug":
env.Prepend(CCFLAGS=["-g3"])
- env.Prepend(CPPDEFINES=["DEBUG_ENABLED"])
- env.Prepend(CPPDEFINES=["DEV_ENABLED"])
env.Append(LINKFLAGS=["-rdynamic"])
## Architecture
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index 10cf2b591e..3f967781b2 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -57,14 +57,11 @@ def configure(env):
env.Prepend(CCFLAGS=["-O2"])
elif env["optimize"] == "size": # optimize for size
env.Prepend(CCFLAGS=["-Os"])
- env.Prepend(CPPDEFINES=["DEBUG_ENABLED"])
if env["debug_symbols"]:
env.Prepend(CCFLAGS=["-g2"])
elif env["target"] == "debug":
env.Prepend(CCFLAGS=["-g3"])
- env.Prepend(CPPDEFINES=["DEBUG_ENABLED"])
- env.Prepend(CPPDEFINES=["DEV_ENABLED"])
env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"])
## Architecture
diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp
index 2404c20153..60a878d644 100644
--- a/platform/osx/export/export_plugin.cpp
+++ b/platform/osx/export/export_plugin.cpp
@@ -561,7 +561,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
// Now process our template.
bool found_binary = false;
- int total_size = 0;
Vector<String> dylibs_found;
while (ret == UNZ_OK && err == OK) {
@@ -649,7 +648,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
print_line("ADDING: " + file + " size: " + itos(data.size()));
- total_size += data.size();
// Write it into our application bundle.
file = tmp_app_path_name.plus_file(file);
diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py
index f31b43cd49..9c91378b22 100644
--- a/platform/uwp/detect.py
+++ b/platform/uwp/detect.py
@@ -64,15 +64,12 @@ def configure(env):
env.Append(CCFLAGS=["/MD"])
env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"])
env.AppendUnique(CPPDEFINES=["WINDOWS_SUBSYSTEM_CONSOLE"])
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
if env["optimize"] != "none":
env.Append(CCFLAGS=["/O2", "/Zi"])
elif env["target"] == "debug":
env.Append(CCFLAGS=["/Zi"])
env.Append(CCFLAGS=["/MDd"])
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
- env.Append(CPPDEFINES=["DEV_ENABLED"])
env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"])
env.AppendUnique(CPPDEFINES=["WINDOWS_SUBSYSTEM_CONSOLE"])
env.Append(LINKFLAGS=["/DEBUG"])
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 6f99368e99..6752885f37 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -203,12 +203,9 @@ def configure_msvc(env, manual_msvc_config):
elif env["optimize"] == "size": # optimize for size
env.Append(CCFLAGS=["/O1"])
env.Append(LINKFLAGS=["/OPT:REF"])
- env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"])
elif env["target"] == "debug":
env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"])
- env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"])
- env.AppendUnique(CPPDEFINES=["DEV_ENABLED"])
env.Append(LINKFLAGS=["/DEBUG"])
if env["debug_symbols"]:
@@ -352,7 +349,6 @@ def configure_mingw(env):
elif env["target"] == "release_debug":
env.Append(CCFLAGS=["-O2"])
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
if env["debug_symbols"]:
env.Prepend(CCFLAGS=["-g2"])
if env["optimize"] == "speed": # optimize for speed (default)
@@ -362,8 +358,6 @@ def configure_mingw(env):
elif env["target"] == "debug":
env.Append(CCFLAGS=["-g3"])
- env.Append(CPPDEFINES=["DEBUG_ENABLED"])
- env.Append(CPPDEFINES=["DEV_ENABLED"])
if env["windows_subsystem"] == "gui":
env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 6a90b28579..22c4f96a90 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -462,7 +462,7 @@ public:
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW) override;
- ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual void screen_set_keep_on(bool p_enable) override; //disable screensaver
virtual bool screen_is_kept_on() const override;
diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp
index 2572c5de33..076b8312b6 100644
--- a/scene/resources/importer_mesh.cpp
+++ b/scene/resources/importer_mesh.cpp
@@ -997,7 +997,7 @@ Ref<NavigationMesh> ImporterMesh::create_navigation_mesh() {
extern bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, const uint8_t *p_cache_data, bool *r_use_cache, uint8_t **r_mesh_cache, int *r_mesh_cache_size, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y);
-struct EditorSceneImporterMeshLightmapSurface {
+struct EditorSceneFormatImporterMeshLightmapSurface {
Ref<Material> material;
LocalVector<SurfaceTool::Vertex> vertices;
Mesh::PrimitiveType primitive = Mesh::PrimitiveType::PRIMITIVE_MAX;
@@ -1015,7 +1015,7 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
LocalVector<float> uv;
LocalVector<Pair<int, int>> uv_indices;
- Vector<EditorSceneImporterMeshLightmapSurface> lightmap_surfaces;
+ Vector<EditorSceneFormatImporterMeshLightmapSurface> lightmap_surfaces;
// Keep only the scale
Basis basis = p_base_transform.get_basis();
@@ -1027,7 +1027,7 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
Basis normal_basis = transform.basis.inverse().transposed();
for (int i = 0; i < get_surface_count(); i++) {
- EditorSceneImporterMeshLightmapSurface s;
+ EditorSceneFormatImporterMeshLightmapSurface s;
s.primitive = get_surface_primitive_type(i);
ERR_FAIL_COND_V_MSG(s.primitive != Mesh::PRIMITIVE_TRIANGLES, ERR_UNAVAILABLE, "Only triangles are supported for lightmap unwrap.");
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index 6a3b9726da..85ebf076cc 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -757,9 +757,6 @@ void RenderForwardClustered::_setup_environment(const RenderDataRD *p_render_dat
scene_state.ubo.fog_density = environment_get_fog_density(p_render_data->environment);
scene_state.ubo.fog_height = environment_get_fog_height(p_render_data->environment);
scene_state.ubo.fog_height_density = environment_get_fog_height_density(p_render_data->environment);
- if (scene_state.ubo.fog_height_density >= 0.0001) {
- scene_state.ubo.fog_height_density = 1.0 / scene_state.ubo.fog_height_density;
- }
scene_state.ubo.fog_aerial_perspective = environment_get_fog_aerial_perspective(p_render_data->environment);
Color fog_color = environment_get_fog_light_color(p_render_data->environment).to_linear();
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index 6937df85fb..5d80ae6212 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -1637,9 +1637,6 @@ void RenderForwardMobile::_setup_environment(const RenderDataRD *p_render_data,
scene_state.ubo.fog_density = environment_get_fog_density(p_render_data->environment);
scene_state.ubo.fog_height = environment_get_fog_height(p_render_data->environment);
scene_state.ubo.fog_height_density = environment_get_fog_height_density(p_render_data->environment);
- if (scene_state.ubo.fog_height_density >= 0.0001) {
- scene_state.ubo.fog_height_density = 1.0 / scene_state.ubo.fog_height_density;
- }
scene_state.ubo.fog_aerial_perspective = environment_get_fog_aerial_perspective(p_render_data->environment);
Color fog_color = environment_get_fog_light_color(p_render_data->environment).to_linear();
diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp
index aefe926cb0..0d60052666 100644
--- a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp
+++ b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp
@@ -35,8 +35,10 @@ RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD
RD::PipelineMultisampleState multisample_state_version = multisample_state;
multisample_state_version.sample_count = RD::get_singleton()->framebuffer_format_get_texture_samples(p_framebuffer_format_id, p_render_pass);
+ bool wireframe = p_wireframe || rasterization_state.wireframe;
+
RD::PipelineRasterizationState raster_state_version = rasterization_state;
- raster_state_version.wireframe = p_wireframe;
+ raster_state_version.wireframe = wireframe;
Vector<RD::PipelineSpecializationConstant> specialization_constants = base_specialization_constants;
@@ -59,7 +61,7 @@ RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD
versions = (Version *)memrealloc(versions, sizeof(Version) * (version_count + 1));
versions[version_count].framebuffer_id = p_framebuffer_format_id;
versions[version_count].vertex_id = p_vertex_format_id;
- versions[version_count].wireframe = p_wireframe;
+ versions[version_count].wireframe = wireframe;
versions[version_count].pipeline = pipeline;
versions[version_count].render_pass = p_render_pass;
versions[version_count].bool_specializations = p_bool_specializations;
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
index b3d106e47d..5261868155 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
@@ -531,7 +531,7 @@ vec4 fog_process(vec3 vertex) {
float y_dist = y - scene_data.fog_height;
- float vfog_amount = clamp(1.0 - exp(y_dist * scene_data.fog_height_density), 0.0, 1.0);
+ float vfog_amount = 1.0 - exp(min(0.0, y_dist * scene_data.fog_height_density));
fog_amount = max(vfog_amount, fog_amount);
}
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
index d0918994af..0ee68d5e10 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
@@ -557,7 +557,7 @@ vec4 fog_process(vec3 vertex) {
float y_dist = y - scene_data.fog_height;
- float vfog_amount = clamp(1.0 - exp(y_dist * scene_data.fog_height_density), 0.0, 1.0);
+ float vfog_amount = 1.0 - exp(min(0.0, y_dist * scene_data.fog_height_density));
fog_amount = max(vfog_amount, fog_amount);
}