diff options
189 files changed, 2333 insertions, 1633 deletions
diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index cf8b0f4132..a9808fee95 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -23,7 +23,7 @@ jobs: - name: Install Python dependencies and general setup run: | - pip3 install black==23.3.0 pytest==7.1.2 mypy==0.971 + pip3 install pytest==7.1.2 mypy==0.971 git config diff.wsErrorHighlight all - name: Get changed files @@ -46,6 +46,9 @@ jobs: run: | bash ./misc/scripts/gitignore_check.sh + - name: Style checks via pre-commit + uses: pre-commit/action@v3.0.1 + - name: File formatting checks (file_format.sh) run: | bash ./misc/scripts/file_format.sh changed.txt @@ -54,14 +57,6 @@ jobs: run: | bash ./misc/scripts/header_guards.sh changed.txt - - name: Python style checks via black (black_format.sh) - run: | - if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then - bash ./misc/scripts/black_format.sh - else - echo "Skipping Python formatting as no Python files were changed." - fi - - name: Python scripts static analysis (mypy_check.sh) run: | if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then @@ -92,12 +87,6 @@ jobs: - name: Documentation checks run: | doc/tools/doc_status.py doc/classes modules/*/doc_classes platform/*/doc_classes - doc/tools/make_rst.py --dry-run --color doc/classes modules platform - - - name: Style checks via clang-format (clang_format.sh) - run: | - clang-format --version - bash ./misc/scripts/clang_format.sh changed.txt - name: Style checks via dotnet format (dotnet_format.sh) run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..3493219ea7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v16.0.6 + hooks: + - id: clang-format + files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java|glsl)$ + types_or: [text] + exclude: | + (?x)^( + tests/python_build.*| + .*thirdparty.*| + .*platform/android/java/lib/src/com.*| + .*-so_wrap.* + ) + + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.3.0 + hooks: + - id: black + files: (\.py$|SConstruct|SCsub) + types_or: [text] + exclude: .*thirdparty.* + args: + - --line-length=120 + + - repo: local + hooks: + - id: make-rst + name: make-rst + entry: python3 doc/tools/make_rst.py doc/classes modules platform --dry-run --color + pass_filenames: false + language: python + files: ^(doc|modules|platform).*xml$ + + - id: copyright-headers + name: copyright-headers + language: python + files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java)$ + entry: python3 misc/scripts/copyright_headers.py + exclude: | + (?x)^( + tests/python_build.*| + .*thirdparty.*| + .*platform/android/java/lib/src/com.*| + .*-so_wrap.*| + platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView.*| + platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper.*| + platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.* + ) diff --git a/core/object/method_bind.h b/core/object/method_bind.h index a1723adb9a..88b867a1ca 100644 --- a/core/object/method_bind.h +++ b/core/object/method_bind.h @@ -226,7 +226,7 @@ class MethodBindVarArgT : public MethodBindVarArgBase<MethodBindVarArgT<T>, T, v public: virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == MethodBind::get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>::method)(p_args, p_arg_count, r_error); return {}; @@ -265,7 +265,7 @@ public: #endif virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == MethodBind::get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif return (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)(p_args, p_arg_count, r_error); } @@ -336,7 +336,7 @@ public: #endif virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_variant_args_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); @@ -348,7 +348,7 @@ public: virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_validated_object_instance_args(static_cast<T *>(p_object), method, p_args); @@ -359,7 +359,7 @@ public: virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_ptr_args<T, P...>(static_cast<T *>(p_object), method, p_args); @@ -420,7 +420,7 @@ public: #endif virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_variant_argsc_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); @@ -432,7 +432,7 @@ public: virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_validated_object_instance_argsc(static_cast<T *>(p_object), method, p_args); @@ -443,7 +443,7 @@ public: virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_ptr_argsc<T, P...>(static_cast<T *>(p_object), method, p_args); @@ -515,7 +515,7 @@ public: virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { Variant ret; #ifdef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder(), ret, vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), ret, vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_variant_args_ret_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); @@ -527,7 +527,7 @@ public: virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_validated_object_instance_args_ret(static_cast<T *>(p_object), method, p_args, r_ret); @@ -538,7 +538,7 @@ public: virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_ptr_args_ret<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret); @@ -611,7 +611,7 @@ public: virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { Variant ret; #ifdef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder(), ret, vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), ret, vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_variant_args_retc_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); @@ -623,7 +623,7 @@ public: virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_validated_object_instance_args_retc(static_cast<T *>(p_object), method, p_args, r_ret); @@ -634,7 +634,7 @@ public: virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override { #ifdef TOOLS_ENABLED - ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); + ERR_FAIL_COND_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); #endif #ifdef TYPED_METHOD_BIND call_with_ptr_args_retc<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret); diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 580756c12d..f9c9b72ed7 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -4,7 +4,7 @@ Provides access to engine properties. </brief_description> <description> - The [Engine] singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others. + The [Engine] singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others. It also stores information about the current build of Godot, such as the current version. </description> <tutorials> </tutorials> @@ -12,8 +12,8 @@ <method name="get_architecture_name" qualifiers="const"> <return type="String" /> <description> - Returns the name of the CPU architecture the Godot binary was built for. Possible return values are [code]x86_64[/code], [code]x86_32[/code], [code]arm64[/code], [code]arm32[/code], [code]rv64[/code], [code]riscv[/code], [code]ppc64[/code], [code]ppc[/code], [code]wasm64[/code] and [code]wasm32[/code]. - To detect whether the current CPU architecture is 64-bit, you can use the fact that all 64-bit architecture names have [code]64[/code] in their name: + Returns the name of the CPU architecture the Godot binary was built for. Possible return values include [code]"x86_64"[/code], [code]"x86_32"[/code], [code]"arm64"[/code], [code]"arm32"[/code], [code]"rv64"[/code], [code]"riscv"[/code], [code]"ppc64"[/code], [code]"ppc"[/code], [code]"wasm64"[/code], and [code]"wasm32"[/code]. + To detect whether the current build is 64-bit, you can use the fact that all 64-bit architecture names contain [code]64[/code] in their name: [codeblocks] [gdscript] if "64" in Engine.get_architecture_name(): @@ -28,74 +28,74 @@ GD.Print("Running a 32-bit build of Godot."); [/csharp] [/codeblocks] - [b]Note:[/b] [method get_architecture_name] does [i]not[/i] return the name of the host CPU architecture. For example, if running an x86_32 Godot binary on a x86_64 system, the returned value will be [code]x86_32[/code]. + [b]Note:[/b] This method does [i]not[/i] return the name of the system's CPU architecture (like [method OS.get_processor_name]). For example, when running a [code]x86_32[/code] Godot binary on a [code]x86_64[/code] system, the returned value will still be [code]"x86_32"[/code]. </description> </method> <method name="get_author_info" qualifiers="const"> <return type="Dictionary" /> <description> - Returns engine author information in a Dictionary. - [code]lead_developers[/code] - Array of Strings, lead developer names - [code]founders[/code] - Array of Strings, founder names - [code]project_managers[/code] - Array of Strings, project manager names - [code]developers[/code] - Array of Strings, developer names + Returns the engine author information as a [Dictionary], where each entry is an [Array] of strings with the names of notable contributors to the Godot Engine: [code]lead_developers[/code], [code]founders[/code], [code]project_managers[/code], and [code]developers[/code]. </description> </method> <method name="get_copyright_info" qualifiers="const"> <return type="Dictionary[]" /> <description> - Returns an Array of copyright information Dictionaries. - [code]name[/code] - String, component name - [code]parts[/code] - Array of Dictionaries {[code]files[/code], [code]copyright[/code], [code]license[/code]} describing subsections of the component + Returns an [Array] of dictionaries with copyright information for every component of Godot's source code. + Every [Dictionary] contains a [code]name[/code] identifier, and a [code]parts[/code] array of dictionaries. It describes the component in detail with the following entries: + - [code]files[/code] - [Array] of file paths from the source code affected by this component; + - [code]copyright[/code] - [Array] of owners of this component; + - [code]license[/code] - The license applied to this component (such as "[url=https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants]Expat[/url]" or "[url=https://creativecommons.org/licenses/by/4.0/]CC-BY-4.0[/url]"). </description> </method> <method name="get_donor_info" qualifiers="const"> <return type="Dictionary" /> <description> - Returns a Dictionary of Arrays of donor names. + Returns a [Dictionary] of categorized donor names. Each entry is an [Array] of strings: {[code]platinum_sponsors[/code], [code]gold_sponsors[/code], [code]silver_sponsors[/code], [code]bronze_sponsors[/code], [code]mini_sponsors[/code], [code]gold_donors[/code], [code]silver_donors[/code], [code]bronze_donors[/code]} </description> </method> <method name="get_frames_drawn"> <return type="int" /> <description> - Returns the total number of frames drawn. On headless platforms, or if the render loop is disabled with [code]--disable-render-loop[/code] via command line, [method get_frames_drawn] always returns [code]0[/code]. See [method get_process_frames]. + Returns the total number of frames drawn since the engine started. + [b]Note:[/b] On headless platforms, or if rendering is disabled with [code]--disable-render-loop[/code] via command line, this method always returns [code]0[/code]. See also [method get_process_frames]. </description> </method> <method name="get_frames_per_second" qualifiers="const"> <return type="float" /> <description> - Returns the frames per second of the running game. + Returns the average frames rendered every second (FPS), also known as the framerate. </description> </method> <method name="get_license_info" qualifiers="const"> <return type="Dictionary" /> <description> - Returns Dictionary of licenses used by Godot and included third party components. + Returns a [Dictionary] of licenses used by Godot and included third party components. Each entry is a license name (such as "[url=https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants]Expat[/url]") and its associated text. </description> </method> <method name="get_license_text" qualifiers="const"> <return type="String" /> <description> - Returns Godot license text. + Returns the full Godot license text. </description> </method> <method name="get_main_loop" qualifiers="const"> <return type="MainLoop" /> <description> - Returns the main loop object (see [MainLoop] and [SceneTree]). + Returns the instance of the [MainLoop]. This is usually the main [SceneTree] and is the same as [method Node.get_tree]. + [b]Note:[/b] The type instantiated as the main loop can changed with [member ProjectSettings.application/run/main_loop_type]. </description> </method> <method name="get_physics_frames" qualifiers="const"> <return type="int" /> <description> - Returns the total number of frames passed since engine initialization which is advanced on each [b]physics frame[/b]. See also [method get_process_frames]. - [method get_physics_frames] can be used to run expensive logic less often without relying on a [Timer]: + Returns the total number of frames passed since the engine started. This number is increased every [b]physics frame[/b]. See also [method get_process_frames]. + This method can be used to run expensive logic less often without relying on a [Timer]: [codeblocks] [gdscript] func _physics_process(_delta): if Engine.get_physics_frames() % 2 == 0: - pass # Run expensive logic only once every 2 physics frames here. + pass # Run expensive logic only once every 2 physics frames here. [/gdscript] [csharp] public override void _PhysicsProcess(double delta) @@ -120,22 +120,22 @@ <method name="get_process_frames" qualifiers="const"> <return type="int" /> <description> - Returns the total number of frames passed since engine initialization which is advanced on each [b]process frame[/b], regardless of whether the render loop is enabled. See also [method get_frames_drawn] and [method get_physics_frames]. - [method get_process_frames] can be used to run expensive logic less often without relying on a [Timer]: + Returns the total number of frames passed since the engine started. This number is increased every [b]process frame[/b], regardless of whether the render loop is enabled. See also [method get_frames_drawn] and [method get_physics_frames]. + This method can be used to run expensive logic less often without relying on a [Timer]: [codeblocks] [gdscript] func _process(_delta): - if Engine.get_process_frames() % 2 == 0: - pass # Run expensive logic only once every 2 process (render) frames here. + if Engine.get_process_frames() % 5 == 0: + pass # Run expensive logic only once every 5 process (render) frames here. [/gdscript] [csharp] public override void _Process(double delta) { base._Process(delta); - if (Engine.GetProcessFrames() % 2 == 0) + if (Engine.GetProcessFrames() % 5 == 0) { - // Run expensive logic only once every 2 physics frames here. + // Run expensive logic only once every 5 process (render) frames here. } } [/csharp] @@ -146,7 +146,7 @@ <return type="ScriptLanguage" /> <param index="0" name="index" type="int" /> <description> - Returns an instance of a [ScriptLanguage] with the given index. + Returns an instance of a [ScriptLanguage] with the given [param index]. </description> </method> <method name="get_script_language_count"> @@ -159,43 +159,45 @@ <return type="Object" /> <param index="0" name="name" type="StringName" /> <description> - Returns a global singleton with given [param name]. Often used for plugins, e.g. GodotPayments. + Returns the global singleton with the given [param name], or [code]null[/code] if it does not exist. Often used for plugins. See also [method has_singleton] and [method get_singleton_list]. + [b]Note:[/b] Global singletons are not the same as autoloaded nodes, which are configurable in the project settings. </description> </method> <method name="get_singleton_list" qualifiers="const"> <return type="PackedStringArray" /> <description> - Returns a list of available global singletons. + Returns a list of names of all available global singletons. See also [method get_singleton]. </description> </method> <method name="get_version_info" qualifiers="const"> <return type="Dictionary" /> <description> - Returns the current engine version information in a Dictionary. - [code]major[/code] - Holds the major version number as an int - [code]minor[/code] - Holds the minor version number as an int - [code]patch[/code] - Holds the patch version number as an int - [code]hex[/code] - Holds the full version number encoded as a hexadecimal int with one byte (2 places) per number (see example below) - [code]status[/code] - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String - [code]build[/code] - Holds the build name (e.g. "custom_build") as a String - [code]hash[/code] - Holds the full Git commit hash as a String - [code]string[/code] - [code]major[/code] + [code]minor[/code] + [code]patch[/code] + [code]status[/code] + [code]build[/code] in a single String - The [code]hex[/code] value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be [code]0x03010C[/code]. [b]Note:[/b] It's still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for easy version comparisons from code: + Returns the current engine version information as a [Dictionary] containing the following entries: + - [code]major[/code] - Major version number as an int; + - [code]minor[/code] - Minor version number as an int; + - [code]patch[/code] - Patch version number as an int; + - [code]hex[/code] - Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below); + - [code]status[/code] - Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String; + - [code]build[/code] - Build name (e.g. "custom_build") as a String; + - [code]hash[/code] - Full Git commit hash as a String; + - [code]string[/code] - [code]major[/code], [code]minor[/code], [code]patch[/code], [code]status[/code], and [code]build[/code] in a single String. + The [code]hex[/code] value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be [code]0x03010C[/code]. + [b]Note:[/b] The [code]hex[/code] value is still an [int] internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for quick version comparisons from code: [codeblocks] [gdscript] - if Engine.get_version_info().hex >= 0x030200: - # Do things specific to version 3.2 or later + if Engine.get_version_info().hex >= 0x040100: + pass # Do things specific to version 4.1 or later. else: - # Do things specific to versions before 3.2 + pass # Do things specific to versions before 4.1. [/gdscript] [csharp] - if ((int)Engine.GetVersionInfo()["hex"] >= 0x030200) + if ((int)Engine.GetVersionInfo()["hex"] >= 0x040100) { - // Do things specific to version 3.2 or later + // Do things specific to version 4.1 or later. } else { - // Do things specific to versions before 3.2 + // Do things specific to versions before 4.1. } [/csharp] [/codeblocks] @@ -204,20 +206,35 @@ <method name="get_write_movie_path" qualifiers="const"> <return type="String" /> <description> - Returns the path to the [MovieWriter]'s output file, or an empty string if the engine wasn't started in Movie Maker mode. This path can be absolute or relative depending on how the user specified it. + Returns the path to the [MovieWriter]'s output file, or an empty string if the engine wasn't started in Movie Maker mode. The default path can be changed in [member ProjectSettings.editor/movie_writer/movie_file]. </description> </method> <method name="has_singleton" qualifiers="const"> <return type="bool" /> <param index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if a singleton with given [param name] exists in global scope. + Returns [code]true[/code] if a singleton with the given [param name] exists in the global scope. See also [method get_singleton]. + [codeblocks] + [gdscript] + print(Engine.has_singleton("OS")) # Prints true + print(Engine.has_singleton("Engine")) # Prints true + print(Engine.has_singleton("AudioServer")) # Prints true + print(Engine.has_singleton("Unknown")) # Prints false + [/gdscript] + [csharp] + GD.Print(Engine.HasSingleton("OS")); // Prints true + GD.Print(Engine.HasSingleton("Engine")); // Prints true + GD.Print(Engine.HasSingleton("AudioServer")); // Prints true + GD.Print(Engine.HasSingleton("Unknown")); // Prints false + [/csharp] + [/codeblocks] + [b]Note:[/b] Global singletons are not the same as autoloaded nodes, which are configurable in the project settings. </description> </method> <method name="is_editor_hint" qualifiers="const"> <return type="bool" /> <description> - Returns [code]true[/code] if the script is currently running inside the editor, [code]false[/code] otherwise. This is useful for [code]@tool[/code] scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor: + Returns [code]true[/code] if the script is currently running inside the editor, otherwise returns [code]false[/code]. This is useful for [code]@tool[/code] scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor: [codeblocks] [gdscript] if Engine.is_editor_hint(): @@ -233,13 +250,25 @@ [/csharp] [/codeblocks] See [url=$DOCS_URL/tutorials/plugins/running_code_in_the_editor.html]Running code in the editor[/url] in the documentation for more information. - [b]Note:[/b] To detect whether the script is run from an editor [i]build[/i] (e.g. when pressing [kbd]F5[/kbd]), use [method OS.has_feature] with the [code]"editor"[/code] argument instead. [code]OS.has_feature("editor")[/code] will evaluate to [code]true[/code] both when the code is running in the editor and when running the project from the editor, but it will evaluate to [code]false[/code] when the code is run from an exported project. + [b]Note:[/b] To detect whether the script is running on an editor [i]build[/i] (such as when pressing [kbd]F5[/kbd]), use [method OS.has_feature] with the [code]"editor"[/code] argument instead. [code]OS.has_feature("editor")[/code] evaluate to [code]true[/code] both when the script is running in the editor and when running the project from the editor, but returns [code]false[/code] when run from an exported project. </description> </method> <method name="is_in_physics_frame" qualifiers="const"> <return type="bool" /> <description> - Returns [code]true[/code] if the game is inside the fixed process and physics phase of the game loop. + Returns [code]true[/code] if the engine is inside the fixed physics process step of the main loop. + [codeblock] + func _enter_tree(): + # Depending on when the node is added to the tree, + # prints either "true" or "false". + print(Engine.is_in_physics_frame()) + + func _process(delta): + print(Engine.is_in_physics_frame()) # Prints false + + func _physics_process(delta): + print(Engine.is_in_physics_frame()) # Prints true + [/codeblock] </description> </method> <method name="register_script_language"> @@ -248,9 +277,9 @@ <description> Registers a [ScriptLanguage] instance to be available with [code]ScriptServer[/code]. Returns: - - [constant OK] on success - - [constant ERR_UNAVAILABLE] if [code]ScriptServer[/code] has reached it limit and cannot register any new language - - [constant ERR_ALREADY_EXISTS] if [code]ScriptServer[/code] already contains a language with similar extension/name/type + - [constant OK] on success; + - [constant ERR_UNAVAILABLE] if [code]ScriptServer[/code] has reached the limit and cannot register any new language; + - [constant ERR_ALREADY_EXISTS] if [code]ScriptServer[/code] already contains a language with similar extension/name/type. </description> </method> <method name="register_singleton"> @@ -258,7 +287,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="instance" type="Object" /> <description> - Registers the given object as a singleton, globally available under [param name]. + Registers the given [Object] [param instance] as a singleton, available globally under [param name]. Useful for plugins. </description> </method> <method name="unregister_script_language"> @@ -267,33 +296,36 @@ <description> Unregisters the [ScriptLanguage] instance from [code]ScriptServer[/code]. Returns: - - [constant OK] on success - - [constant ERR_DOES_NOT_EXIST] if the language is already not registered in [code]ScriptServer[/code] + - [constant OK] on success; + - [constant ERR_DOES_NOT_EXIST] if the language is not registered in [code]ScriptServer[/code]. </description> </method> <method name="unregister_singleton"> <return type="void" /> <param index="0" name="name" type="StringName" /> <description> - Unregisters the singleton registered under [param name]. The singleton object is not freed. Only works with user-defined singletons created with [method register_singleton]. + Removes the singleton registered under [param name]. The singleton object is [i]not[/i] freed. Only works with user-defined singletons registered with [method register_singleton]. </description> </method> </methods> <members> <member name="max_fps" type="int" setter="set_max_fps" getter="get_max_fps" default="0"> - The maximum number of frames per second that can be rendered. A value of [code]0[/code] means "no limit". The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project logic and rendering. - Limiting the FPS can be useful to reduce system power consumption, which reduces heat and noise emissions (and improves battery life on mobile devices). - If [member ProjectSettings.display/window/vsync/vsync_mode] is [code]Enabled[/code] or [code]Adaptive[/code], it takes precedence and the forced FPS number cannot exceed the monitor's refresh rate. + The maximum number of frames per second (FPS) that can be rendered. A value of [code]0[/code] means the framerate is uncapped. + Limiting the FPS can be useful to reduce the host machine's power consumption, which reduces heat, noise emissions, and improves battery life. + If [member ProjectSettings.display/window/vsync/vsync_mode] is [code]Enabled[/code] or [code]Adaptive[/code], the setting takes precedence and the max FPS number cannot exceed the monitor's refresh rate. If [member ProjectSettings.display/window/vsync/vsync_mode] is [code]Enabled[/code], on monitors with variable refresh rate enabled (G-Sync/FreeSync), using a FPS limit a few frames lower than the monitor's refresh rate will [url=https://blurbusters.com/howto-low-lag-vsync-on/]reduce input lag while avoiding tearing[/url]. - If [member ProjectSettings.display/window/vsync/vsync_mode] is [code]Disabled[/code], limiting the FPS to a high value that can be consistently reached on the system can reduce input lag compared to an uncapped framerate. Since this works by ensuring the GPU load is lower than 100%, this latency reduction is only effective in GPU-bottlenecked scenarios, not CPU-bottlenecked scenarios. See also [member physics_ticks_per_second] and [member ProjectSettings.application/run/max_fps]. + [b]Note:[/b] The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project's logic and rendering. + [b]Note:[/b] If [member ProjectSettings.display/window/vsync/vsync_mode] is [code]Disabled[/code], limiting the FPS to a high value that can be consistently reached on the system can reduce input lag compared to an uncapped framerate. Since this works by ensuring the GPU load is lower than 100%, this latency reduction is only effective in GPU-bottlenecked scenarios, not CPU-bottlenecked scenarios. </member> <member name="max_physics_steps_per_frame" type="int" setter="set_max_physics_steps_per_frame" getter="get_max_physics_steps_per_frame" default="8"> - Controls the maximum number of physics steps that can be simulated each rendered frame. The default value is tuned to avoid "spiral of death" situations where expensive physics simulations trigger more expensive simulations indefinitely. However, the game will appear to slow down if the rendering FPS is less than [code]1 / max_physics_steps_per_frame[/code] of [member physics_ticks_per_second]. This occurs even if [code]delta[/code] is consistently used in physics calculations. To avoid this, increase [member max_physics_steps_per_frame] if you have increased [member physics_ticks_per_second] significantly above its default value. + The maximum number of physics steps that can be simulated each rendered frame. + [b]Note:[/b] The default value is tuned to prevent expensive physics simulations from triggering even more expensive simulations indefinitely. However, the game will appear to slow down if the rendering FPS is less than [code]1 / max_physics_steps_per_frame[/code] of [member physics_ticks_per_second]. This occurs even if [code]delta[/code] is consistently used in physics calculations. To avoid this, increase [member max_physics_steps_per_frame] if you have increased [member physics_ticks_per_second] significantly above its default value. </member> <member name="physics_jitter_fix" type="float" setter="set_physics_jitter_fix" getter="get_physics_jitter_fix" default="0.5"> - Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be good enough for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. - [b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics_jitter_fix] to [code]0[/code]. + How much physics ticks are synchronized with real time. If [code]0[/code] or less, the ticks are fully synchronized. Higher values cause the in-game clock to deviate more from the real clock, but they smooth out framerate jitters. + [b]Note:[/b] The default value of [code]0.5[/code] should be good enough for most cases; values above [code]2[/code] could cause the game to react to dropped frames with a noticeable delay and are not recommended. + [b]Note:[/b] When using a custom physics interpolation solution, or within a network game, it's recommended to disable the physics jitter fix by setting this property to [code]0[/code]. </member> <member name="physics_ticks_per_second" type="int" setter="set_physics_ticks_per_second" getter="get_physics_ticks_per_second" default="60"> The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run. This value should generally always be set to [code]60[/code] or above, as Godot doesn't interpolate the physics step. As a result, values lower than [code]60[/code] will look stuttery. This value can be increased to make input more reactive or work around collision tunneling issues, but keep in mind doing so will increase CPU usage. See also [member max_fps] and [member ProjectSettings.physics/common/physics_ticks_per_second]. @@ -301,13 +333,15 @@ </member> <member name="print_error_messages" type="bool" setter="set_print_error_messages" getter="is_printing_error_messages" default="true"> If [code]false[/code], stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the [member ProjectSettings.application/run/disable_stderr] project setting. - [b]Warning:[/b] If you set this to [code]false[/code] anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. If this is set to [code]false[/code] in a [code]@tool[/code] script, this will also impact the editor itself. Do [i]not[/i] report bugs before ensuring error messages are enabled (as they are by default). [b]Note:[/b] This property does not impact the editor's Errors tab when running a project from the editor. + [b]Warning:[/b] If set to [code]false[/code] anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. In a [code]@tool[/code] script, this will also impact the editor itself. Do [i]not[/i] report bugs before ensuring error messages are enabled (as they are by default). </member> <member name="time_scale" type="float" setter="set_time_scale" getter="get_time_scale" default="1.0"> - Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed. This also affects [Timer] and [SceneTreeTimer] (see [method SceneTree.create_timer] for how to control this). + The speed multiplier at which the in-game clock updates, compared to real time. For example, if set to [code]2.0[/code] the game runs twice as fast, and if set to [code]0.5[/code] the game runs half as fast. + This value affects [Timer], [SceneTreeTimer], and all other simulations that make use of [code]delta[/code] time (such as [method Node._process] and [method Node._physics_process]). + [b]Note:[/b] It's recommended to keep this property above [code]0.0[/code], as the game may behave unexpectedly otherwise. [b]Note:[/b] This does not affect audio playback speed. Use [member AudioServer.playback_speed_scale] to adjust audio playback speed independently of [member Engine.time_scale]. - [b]Note:[/b] This does not automatically adjust [member physics_ticks_per_second], which means that with time scales above 1.0, physics simulation may become less precise (as each physics tick will stretch over a larger period of engine time). If you're using [member Engine.time_scale] to speed up simulation by a large factor, consider increasing [member physics_ticks_per_second] as well to improve physics reliability. + [b]Note:[/b] This does not automatically adjust [member physics_ticks_per_second]. With values above [code]1.0[/code] physics simulation may become less precise, as each physics tick will stretch over a larger period of engine time. If you're modifying [member Engine.time_scale] to speed up simulation by a large factor, consider also increasing [member physics_ticks_per_second] to make the simulation more reliable. </member> </members> </class> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 47a1801f58..7c8910d060 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -210,6 +210,9 @@ <theme_item name="back_folder" data_type="icon" type="Texture2D"> Custom icon for the back arrow. </theme_item> + <theme_item name="create_folder" data_type="icon" type="Texture2D"> + Custom icon for the create folder button. + </theme_item> <theme_item name="file" data_type="icon" type="Texture2D"> Custom icon for files. </theme_item> diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index 2b2dc63a33..3f8ed91ad7 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -237,16 +237,16 @@ [PackedVector2Array] for second UV coordinates. </constant> <constant name="ARRAY_CUSTOM0" value="6" enum="ArrayType"> - Contains custom color channel 0. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM0_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RG_HALF] or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. + Contains custom color channel 0. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM0_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_SNORM], [constant ARRAY_CUSTOM_RG_HALF], or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. </constant> <constant name="ARRAY_CUSTOM1" value="7" enum="ArrayType"> - Contains custom color channel 1. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM1_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RG_HALF] or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. + Contains custom color channel 1. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM1_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_SNORM], [constant ARRAY_CUSTOM_RG_HALF], or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. </constant> <constant name="ARRAY_CUSTOM2" value="8" enum="ArrayType"> - Contains custom color channel 2. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM2_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RG_HALF] or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. + Contains custom color channel 2. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM2_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_SNORM], [constant ARRAY_CUSTOM_RG_HALF], or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. </constant> <constant name="ARRAY_CUSTOM3" value="9" enum="ArrayType"> - Contains custom color channel 3. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM3_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RG_HALF] or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. + Contains custom color channel 3. [PackedByteArray] if [code](format >> Mesh.ARRAY_FORMAT_CUSTOM3_SHIFT) & Mesh.ARRAY_FORMAT_CUSTOM_MASK[/code] is [constant ARRAY_CUSTOM_RGBA8_UNORM], [constant ARRAY_CUSTOM_RGBA8_SNORM], [constant ARRAY_CUSTOM_RG_HALF], or [constant ARRAY_CUSTOM_RGBA_HALF]. [PackedFloat32Array] otherwise. </constant> <constant name="ARRAY_BONES" value="10" enum="ArrayType"> [PackedFloat32Array] or [PackedInt32Array] of bone indices. Contains either 4 or 8 numbers per vertex depending on the presence of the [constant ARRAY_FLAG_USE_8_BONE_WEIGHTS] flag. diff --git a/doc/classes/PhysicalBone3D.xml b/doc/classes/PhysicalBone3D.xml index b62cebfdad..c3b202e0a5 100644 --- a/doc/classes/PhysicalBone3D.xml +++ b/doc/classes/PhysicalBone3D.xml @@ -61,6 +61,7 @@ </member> <member name="bounce" type="float" setter="set_bounce" getter="get_bounce" default="0.0"> The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness). + [b]Note:[/b] Even with [member bounce] set to [code]1.0[/code], some energy will be lost over time due to linear and angular damping. To have a [PhysicalBone3D] that preserves all its energy over time, set [member bounce] to [code]1.0[/code], [member linear_damp_mode] to [constant DAMP_MODE_REPLACE], [member linear_damp] to [code]0.0[/code], [member angular_damp_mode] to [constant DAMP_MODE_REPLACE], and [member angular_damp] to [code]0.0[/code]. </member> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> If [code]true[/code], the body is deactivated when there is no movement, so it will not take part in the simulation until it is awakened by an external force. diff --git a/doc/classes/PhysicsMaterial.xml b/doc/classes/PhysicsMaterial.xml index 30c2400775..1601a1040e 100644 --- a/doc/classes/PhysicsMaterial.xml +++ b/doc/classes/PhysicsMaterial.xml @@ -14,6 +14,7 @@ </member> <member name="bounce" type="float" setter="set_bounce" getter="get_bounce" default="0.0"> The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness). + [b]Note:[/b] Even with [member bounce] set to [code]1.0[/code], some energy will be lost over time due to linear and angular damping. To have a [PhysicsBody3D] that preserves all its energy over time, set [member bounce] to [code]1.0[/code], the body's linear damp mode to [b]Replace[/b] (if applicable), its linear damp to [code]0.0[/code], its angular damp mode to [b]Replace[/b] (if applicable), and its angular damp to [code]0.0[/code]. </member> <member name="friction" type="float" setter="set_friction" getter="get_friction" default="1.0"> The body's friction. Values range from [code]0[/code] (frictionless) to [code]1[/code] (maximum friction). diff --git a/doc/classes/ResourceImporterScene.xml b/doc/classes/ResourceImporterScene.xml index 6a88adf421..4e20fe150e 100644 --- a/doc/classes/ResourceImporterScene.xml +++ b/doc/classes/ResourceImporterScene.xml @@ -53,6 +53,9 @@ <member name="nodes/apply_root_scale" type="bool" setter="" getter="" default="true"> If [code]true[/code], [member nodes/root_scale] will be applied to the descendant nodes, meshes, animations, bones, etc. This means that if you add a child node later on within the imported scene, it won't be scaled. If [code]false[/code], [member nodes/root_scale] will multiply the scale of the root node instead. </member> + <member name="nodes/import_as_skeleton_bones" type="bool" setter="" getter="" default="false"> + Treat all nodes in the imported scene as if they are bones within a single [Skeleton3D]. Can be used to guarantee that imported animations target skeleton bones rather than nodes. May also be used to assign the [code]"Root"[/code] bone in a [BoneMap]. See [url=$DOCS_URL/tutorials/assets_pipeline/retargeting_3d_skeletons.html]Retargeting 3D Skeletons[/url] for more information. + </member> <member name="nodes/root_name" type="String" setter="" getter="" default=""""> Override for the root node name. If empty, the root node will use what the scene specifies, or the file name if the scene does not specify a root name. </member> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index 1a846140e5..aad2d853c2 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -4,9 +4,9 @@ Manages the game loop via a hierarchy of nodes. </brief_description> <description> - As one of the most important classes, the [SceneTree] manages the hierarchy of nodes in a scene as well as scenes themselves. Nodes can be added, retrieved and removed. The whole scene tree (and thus the current scene) can be paused. Scenes can be loaded, switched and reloaded. - You can also use the [SceneTree] to organize your nodes into groups: every node can be assigned as many groups as you want to create, e.g. an "enemy" group. You can then iterate these groups or even call methods and set properties on all the group's members at once. - [SceneTree] is the default [MainLoop] implementation used by scenes, and is thus in charge of the game loop. + As one of the most important classes, the [SceneTree] manages the hierarchy of nodes in a scene, as well as scenes themselves. Nodes can be added, fetched and removed. The whole scene tree (and thus the current scene) can be paused. Scenes can be loaded, switched and reloaded. + You can also use the [SceneTree] to organize your nodes into [b]groups[/b]: every node can be added to as many groups as you want to create, e.g. an "enemy" group. You can then iterate these groups or even call methods and set properties on all the nodes belonging to any given group. + [SceneTree] is the default [MainLoop] implementation used by the engine, and is thus in charge of the game loop. </description> <tutorials> <link title="SceneTree">$DOCS_URL/tutorials/scripting/scene_tree.html</link> @@ -18,8 +18,9 @@ <param index="0" name="group" type="StringName" /> <param index="1" name="method" type="StringName" /> <description> - Calls [param method] on each member of the given group. You can pass arguments to [param method] by specifying them at the end of the method call. If a node doesn't have the given method or the argument list does not match (either in count or in types), it will be skipped. - [b]Note:[/b] [method call_group] will call methods immediately on all members at once, which can cause stuttering if an expensive method is called on lots of members. + Calls [param method] on each node inside this tree added to the given [param group]. You can pass arguments to [param method] by specifying them at the end of this method call. Nodes that cannot call [param method] (either because the method doesn't exist or the arguments do not match) are ignored. See also [method set_group] and [method notify_group]. + [b]Note:[/b] This method acts immediately on all selected nodes at once, which may cause stuttering in some performance-intensive situations. + [b]Note:[/b] In C#, [param method] must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the [code]MethodName[/code] class to avoid allocating a new [StringName] on each call. </description> </method> <method name="call_group_flags" qualifiers="vararg"> @@ -28,12 +29,14 @@ <param index="1" name="group" type="StringName" /> <param index="2" name="method" type="StringName" /> <description> - Calls [param method] on each member of the given group, respecting the given [enum GroupCallFlags]. You can pass arguments to [param method] by specifying them at the end of the method call. If a node doesn't have the given method or the argument list does not match (either in count or in types), it will be skipped. + Calls the given [param method] on each node inside this tree added to the given [param group]. Use [param flags] to customize this method's behavior (see [enum GroupCallFlags]). Additional arguments for [param method] can be passed at the end of this method. Nodes that cannot call [param method] (either because the method doesn't exist or the arguments do not match) are ignored. [codeblock] - # Call the method in a deferred manner and in reverse order. - get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFERRED | SceneTree.GROUP_CALL_REVERSE) + # Calls "hide" to all nodes of the "enemies" group, at the end of the frame and in reverse tree order. + get_tree().call_group_flags( + SceneTree.GROUP_CALL_DEFERRED | SceneTree.GROUP_CALL_REVERSE, + "enemies", "hide") [/codeblock] - [b]Note:[/b] Group call flags are used to control the method calling behavior. By default, methods will be called immediately in a way similar to [method call_group]. However, if the [constant GROUP_CALL_DEFERRED] flag is present in the [param flags] argument, methods will be called at the end of the frame in a way similar to [method Object.set_deferred]. + [b]Note:[/b] In C#, [param method] must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the [code]MethodName[/code] class to avoid allocating a new [StringName] on each call. </description> </method> <method name="change_scene_to_file"> @@ -64,11 +67,11 @@ <param index="2" name="process_in_physics" type="bool" default="false" /> <param index="3" name="ignore_time_scale" type="bool" default="false" /> <description> - Returns a [SceneTreeTimer] which will emit [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this [SceneTree]. - If [param process_always] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer. - If [param process_in_physics] is set to [code]true[/code], will update the [SceneTreeTimer] during the physics frame instead of the process frame (fixed framerate processing). - If [param ignore_time_scale] is set to [code]true[/code], will ignore [member Engine.time_scale] and update the [SceneTreeTimer] with the actual frame delta. - Commonly used to create a one-shot delay timer as in the following example: + Returns a new [SceneTreeTimer]. After [param time_sec] in seconds have passed, the timer will emit [signal SceneTreeTimer.timeout] and will be automatically freed. + If [param process_always] is [code]false[/code], the timer will be paused when setting [member SceneTree.paused] to [code]true[/code]. + If [param process_in_physics] is [code]true[/code], the timer will update at the end of the physics frame, instead of the process frame. + If [param ignore_time_scale] is [code]true[/code], the timer will ignore [member Engine.time_scale] and update with the real, elapsed time. + This method is commonly used to create a one-shot delay timer, as in the following example: [codeblocks] [gdscript] func some_function(): @@ -85,28 +88,27 @@ } [/csharp] [/codeblocks] - The timer will be automatically freed after its time elapses. - [b]Note:[/b] The timer is processed after all of the nodes in the current frame, i.e. node's [method Node._process] method would be called before the timer (or [method Node._physics_process] if [param process_in_physics] is set to [code]true[/code]). + [b]Note:[/b] The timer is always updated [i]after[/i] all of the nodes in the tree. A node's [method Node._process] method would be called before the timer updates (or [method Node._physics_process] if [param process_in_physics] is set to [code]true[/code]). </description> </method> <method name="create_tween"> <return type="Tween" /> <description> - Creates and returns a new [Tween]. The Tween will start automatically on the next process frame or physics frame (depending on [enum Tween.TweenProcessMode]). - [b]Note:[/b] When creating a [Tween] using this method, the [Tween] will not be tied to the [Node] that called it. It will continue to animate even if the [Node] is freed, but it will automatically finish if there's nothing left to animate. If you want the [Tween] to be automatically killed when the [Node] is freed, use [method Node.create_tween] or [method Tween.bind_node]. + Creates and returns a new [Tween] processed in this tree. The Tween will start automatically on the next process frame or physics frame (depending on its [enum Tween.TweenProcessMode]). + [b]Note:[/b] A [Tween] created using this method is not bound to any [Node]. It may keep working until there is nothing left to animate. If you want the [Tween] to be automatically killed when the [Node] is freed, use [method Node.create_tween] or [method Tween.bind_node]. </description> </method> <method name="get_first_node_in_group"> <return type="Node" /> <param index="0" name="group" type="StringName" /> <description> - Returns the first node in the specified group, or [code]null[/code] if the group is empty or does not exist. + Returns the first [Node] found inside the tree, that has been added to the given [param group], in scene hierarchy order. Returns [code]null[/code] if no match is found. See also [method get_nodes_in_group]. </description> </method> <method name="get_frame" qualifiers="const"> <return type="int" /> <description> - Returns the current frame number, i.e. the total frame count since the application started. + Returns how many frames have been processed, since the application started. This is [i]not[/i] a measurement of elapsed time. </description> </method> <method name="get_multiplayer" qualifiers="const"> @@ -119,7 +121,7 @@ <method name="get_node_count" qualifiers="const"> <return type="int" /> <description> - Returns the number of nodes in this [SceneTree]. + Returns the number of nodes inside this tree. </description> </method> <method name="get_node_count_in_group" qualifiers="const"> @@ -133,21 +135,20 @@ <return type="Node[]" /> <param index="0" name="group" type="StringName" /> <description> - Returns a list of all nodes assigned to the given group. + Returns an [Array] containing all nodes inside this tree, that have been added to the given [param group], in scene hierarchy order. </description> </method> <method name="get_processed_tweens"> <return type="Tween[]" /> <description> - Returns an array of currently existing [Tween]s in the [SceneTree] (both running and paused). + Returns an [Array] of currently existing [Tween]s in the tree, including paused tweens. </description> </method> <method name="has_group" qualifiers="const"> <return type="bool" /> <param index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if the given group exists. - A group exists if any [Node] in the tree belongs to it (see [method Node.add_to_group]). Groups without nodes are removed automatically. + Returns [code]true[/code] if a node added to the given group [param name] exists in the tree. </description> </method> <method name="notify_group"> @@ -155,8 +156,8 @@ <param index="0" name="group" type="StringName" /> <param index="1" name="notification" type="int" /> <description> - Sends the given notification to all members of the [param group]. - [b]Note:[/b] [method notify_group] will immediately notify all members at once, which can cause stuttering if an expensive method is called as a result of sending the notification to lots of members. + Calls [method Object.notification] with the given [param notification] to all nodes inside this tree added to the [param group]. See also [method call_group] and [method set_group]. + [b]Note:[/b] This method acts immediately on all selected nodes at once, which may cause stuttering in some performance-intensive situations. </description> </method> <method name="notify_group_flags"> @@ -165,32 +166,30 @@ <param index="1" name="group" type="StringName" /> <param index="2" name="notification" type="int" /> <description> - Sends the given notification to all members of the [param group], respecting the given [enum GroupCallFlags]. - [b]Note:[/b] Group call flags are used to control the notification sending behavior. By default, notifications will be sent immediately in a way similar to [method notify_group]. However, if the [constant GROUP_CALL_DEFERRED] flag is present in the [param call_flags] argument, notifications will be sent at the end of the current frame in a way similar to using [code]Object.call_deferred("notification", ...)[/code]. + Calls [method Object.notification] with the given [param notification] to all nodes inside this tree added to the [param group]. Use [param call_flags] to customize this method's behavior (see [enum GroupCallFlags]). </description> </method> <method name="queue_delete"> <return type="void" /> <param index="0" name="obj" type="Object" /> <description> - Queues the given object for deletion, delaying the call to [method Object.free] to the end of the current frame. + Queues the given [param obj] to be deleted, calling its [method Object.free] at the end of the current frame. This method is similar to [method Node.queue_free]. </description> </method> <method name="quit"> <return type="void" /> <param index="0" name="exit_code" type="int" default="0" /> <description> - Quits the application at the end of the current iteration. Argument [param exit_code] can optionally be given (defaulting to 0) to customize the exit status code. - By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error. - For portability reasons, the exit code should be set between 0 and 125 (inclusive). - [b]Note:[/b] On iOS this method doesn't work. Instead, as recommended by the iOS Human Interface Guidelines, the user is expected to close apps via the Home button. + Quits the application at the end of the current iteration, with the given [param exit_code]. + By convention, an exit code of [code]0[/code] indicates success, whereas any other exit code indicates an error. For portability reasons, it should be between [code]0[/code] and [code]125[/code] (inclusive). + [b]Note:[/b] On iOS this method doesn't work. Instead, as recommended by the [url=https://developer.apple.com/library/archive/qa/qa1561/_index.html]iOS Human Interface Guidelines[/url], the user is expected to close apps via the Home button. </description> </method> <method name="reload_current_scene"> <return type="int" enum="Error" /> <description> - Reloads the currently active scene. - Returns [constant OK] on success, [constant ERR_UNCONFIGURED] if no [member current_scene] was defined yet, [constant ERR_CANT_OPEN] if [member current_scene] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if the scene cannot be instantiated. + Reloads the currently active scene, replacing [member current_scene] with a new instance of its original [PackedScene]. + Returns [constant OK] on success, [constant ERR_UNCONFIGURED] if no [member current_scene] is defined, [constant ERR_CANT_OPEN] if [member current_scene] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if the scene cannot be instantiated. </description> </method> <method name="set_group"> @@ -199,8 +198,9 @@ <param index="1" name="property" type="String" /> <param index="2" name="value" type="Variant" /> <description> - Sets the given [param property] to [param value] on all members of the given group. - [b]Note:[/b] [method set_group] will set the property immediately on all members at once, which can cause stuttering if a property with an expensive setter is set on lots of members. + Sets the given [param property] to [param value] on all nodes inside this tree added to the given [param group]. Nodes that do not have the [param property] are ignored. See also [method call_group] and [method notify_group]. + [b]Note:[/b] This method acts immediately on all selected nodes at once, which may cause stuttering in some performance-intensive situations. + [b]Note:[/b] In C#, [param property] must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the [code]PropertyName[/code] class to avoid allocating a new [StringName] on each call. </description> </method> <method name="set_group_flags"> @@ -210,8 +210,8 @@ <param index="2" name="property" type="String" /> <param index="3" name="value" type="Variant" /> <description> - Sets the given [param property] to [param value] on all members of the given group, respecting the given [enum GroupCallFlags]. - [b]Note:[/b] Group call flags are used to control the property setting behavior. By default, properties will be set immediately in a way similar to [method set_group]. However, if the [constant GROUP_CALL_DEFERRED] flag is present in the [param call_flags] argument, properties will be set at the end of the frame in a way similar to [method Object.call_deferred]. + Sets the given [param property] to [param value] on all nodes inside this tree added to the given [param group]. Nodes that do not have the [param property] are ignored. Use [param call_flags] to customize this method's behavior (see [enum GroupCallFlags]). + [b]Note:[/b] In C#, [param property] must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the [code]PropertyName[/code] class to avoid allocating a new [StringName] on each call. </description> </method> <method name="set_multiplayer"> @@ -236,8 +236,8 @@ For mobile platforms, see [member quit_on_go_back]. </member> <member name="current_scene" type="Node" setter="set_current_scene" getter="get_current_scene"> - Returns the root node of the currently running scene, regardless of its structure. - [b]Warning:[/b] Setting this directly might not work as expected, and will [i]not[/i] add or remove any nodes from the tree, consider using [method change_scene_to_file] or [method change_scene_to_packed] instead. + The root node of the currently loaded main scene, usually as a direct child of [member root]. See also [method change_scene_to_file], [method change_scene_to_packed], and [method reload_current_scene]. + [b]Warning:[/b] Setting this property directly may not work as expected, as it does [i]not[/i] add or remove any nodes from this tree. </member> <member name="debug_collisions_hint" type="bool" setter="set_debug_collisions_hint" getter="is_debugging_collisions_hint" default="false"> If [code]true[/code], collision shapes will be visible when running the game from the editor for debugging purposes. @@ -252,84 +252,86 @@ [b]Note:[/b] This property is not designed to be changed at run-time. Changing the value of [member debug_paths_hint] while the project is running will not have the desired effect. </member> <member name="edited_scene_root" type="Node" setter="set_edited_scene_root" getter="get_edited_scene_root"> - The root of the edited scene. + The root of the scene currently being edited in the editor. This is usually a direct child of [member root]. + [b]Note:[/b] This property does nothing in release builds. </member> <member name="multiplayer_poll" type="bool" setter="set_multiplayer_poll_enabled" getter="is_multiplayer_poll_enabled" default="true"> If [code]true[/code] (default value), enables automatic polling of the [MultiplayerAPI] for this SceneTree during [signal process_frame]. If [code]false[/code], you need to manually call [method MultiplayerAPI.poll] to process network packets and deliver RPCs. This allows running RPCs in a different loop (e.g. physics, thread, specific time step) and for manual [Mutex] protection when accessing the [MultiplayerAPI] from threads. </member> <member name="paused" type="bool" setter="set_pause" getter="is_paused" default="false"> - If [code]true[/code], the [SceneTree] is paused. Doing so will have the following behavior: - - 2D and 3D physics will be stopped. This includes signals and collision detection. - - [method Node._process], [method Node._physics_process] and [method Node._input] will not be called anymore in nodes. + If [code]true[/code], the scene tree is considered paused. This causes the following behavior: + - 2D and 3D physics will be stopped, as well as collision detection and related signals. + - Depending on each node's [member Node.process_mode], their [method Node._process], [method Node._physics_process] and [method Node._input] callback methods may not called anymore. </member> <member name="quit_on_go_back" type="bool" setter="set_quit_on_go_back" getter="is_quit_on_go_back" default="true"> If [code]true[/code], the application quits automatically when navigating back (e.g. using the system "Back" button on Android). To handle 'Go Back' button when this option is disabled, use [constant DisplayServer.WINDOW_EVENT_GO_BACK_REQUEST]. </member> <member name="root" type="Window" setter="" getter="get_root"> - The [SceneTree]'s root [Window]. + The tree's root [Window]. This is top-most [Node] of the scene tree, and is always present. An absolute [NodePath] always starts from this node. Children of the root node may include the loaded [member current_scene], as well as any [url=$DOCS_URL/tutorials/scripting/singletons_autoload.html]AutoLoad[/url] configured in the Project Settings. + [b]Warning:[/b] Do not delete this node. This will result in unstable behavior, followed by a crash. </member> </members> <signals> <signal name="node_added"> <param index="0" name="node" type="Node" /> <description> - Emitted whenever a node is added to the [SceneTree]. + Emitted when the [param node] enters this tree. </description> </signal> <signal name="node_configuration_warning_changed"> <param index="0" name="node" type="Node" /> <description> - Emitted when a node's configuration changed. Only emitted in [code]tool[/code] mode. + Emitted when the [param node]'s [method Node.update_configuration_warnings] is called. Only emitted in the editor. </description> </signal> <signal name="node_removed"> <param index="0" name="node" type="Node" /> <description> - Emitted whenever a node is removed from the [SceneTree]. + Emitted when the [param node] exits this tree. </description> </signal> <signal name="node_renamed"> <param index="0" name="node" type="Node" /> <description> - Emitted whenever a node is renamed. + Emitted when the [param node]'s [member Node.name] is changed. </description> </signal> <signal name="physics_frame"> <description> - Emitted immediately before [method Node._physics_process] is called on every node in the [SceneTree]. + Emitted immediately before [method Node._physics_process] is called on every node in this tree. </description> </signal> <signal name="process_frame"> <description> - Emitted immediately before [method Node._process] is called on every node in the [SceneTree]. + Emitted immediately before [method Node._process] is called on every node in this tree. </description> </signal> <signal name="tree_changed"> <description> - Emitted whenever the [SceneTree] hierarchy changed (children being moved or renamed, etc.). + Emitted any time the tree's hierarchy changes (nodes being moved, renamed, etc). </description> </signal> <signal name="tree_process_mode_changed"> <description> - This signal is only emitted in the editor, it allows the editor to update the visibility of disabled nodes. Emitted whenever any node's [member Node.process_mode] is changed. + Emitted when the [member Node.process_mode] of any node inside the tree is changed. Only emitted in the editor, to update the visibility of disabled nodes. </description> </signal> </signals> <constants> <constant name="GROUP_CALL_DEFAULT" value="0" enum="GroupCallFlags"> - Call a group with no flags (default). + Call nodes within a group with no special behavior (default). </constant> <constant name="GROUP_CALL_REVERSE" value="1" enum="GroupCallFlags"> - Call a group in reverse scene order. + Call nodes within a group in reverse tree hierarchy order (all nested children are called before their respective parent nodes). </constant> <constant name="GROUP_CALL_DEFERRED" value="2" enum="GroupCallFlags"> - Call a group at the end of the current frame (process or physics). + Call nodes within a group at the end of the current frame (can be either process or physics frame), similar to [method Object.call_deferred]. </constant> <constant name="GROUP_CALL_UNIQUE" value="4" enum="GroupCallFlags"> - Call a group only once even if the call is executed many times. - [b]Note:[/b] Arguments are not taken into account when deciding whether the call is unique or not. Therefore when the same method is called with different arguments, only the first call will be performed. + Call nodes within a group only once, even if the call is executed many times in the same frame. Must be combined with [constant GROUP_CALL_DEFERRED] to work. + [b]Note:[/b] Different arguments are not taken into account. Therefore, when the same call is executed with different arguments, only the first call will be performed. </constant> </constants> </class> diff --git a/drivers/gles3/effects/copy_effects.cpp b/drivers/gles3/effects/copy_effects.cpp index 43bc6d5476..6e64652982 100644 --- a/drivers/gles3/effects/copy_effects.cpp +++ b/drivers/gles3/effects/copy_effects.cpp @@ -207,8 +207,8 @@ void CopyEffects::bilinear_blur(GLuint p_source_texture, int p_mipmap_count, con glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[i % 2]); source_region = dest_region; } - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteFramebuffers(2, framebuffers); } @@ -274,7 +274,7 @@ void CopyEffects::gaussian_blur(GLuint p_source_texture, int p_mipmap_count, con source_region = dest_region; normalized_source_region = normalized_dest_region; } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteFramebuffers(1, &framebuffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); diff --git a/drivers/gles3/effects/glow.cpp b/drivers/gles3/effects/glow.cpp index 9fc2eef65b..9728b089aa 100644 --- a/drivers/gles3/effects/glow.cpp +++ b/drivers/gles3/effects/glow.cpp @@ -31,6 +31,7 @@ #ifdef GLES3_ENABLED #include "glow.h" +#include "../storage/texture_storage.h" using namespace GLES3; @@ -166,7 +167,7 @@ void Glow::process_glow(GLuint p_source_color, Size2i p_size, const Glow::GLOWLE glDepthMask(GL_TRUE); glUseProgram(0); glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } #endif // GLES3_ENABLED diff --git a/drivers/gles3/effects/post_effects.cpp b/drivers/gles3/effects/post_effects.cpp index 75af068ab5..8ad872f319 100644 --- a/drivers/gles3/effects/post_effects.cpp +++ b/drivers/gles3/effects/post_effects.cpp @@ -31,6 +31,7 @@ #ifdef GLES3_ENABLED #include "post_effects.h" +#include "../storage/texture_storage.h" using namespace GLES3; @@ -146,7 +147,7 @@ void PostEffects::post_copy(GLuint p_dest_framebuffer, Size2i p_dest_size, GLuin glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glUseProgram(0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } #endif // GLES3_ENABLED diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 80daa9a907..11975c1a75 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1689,7 +1689,7 @@ void RasterizerCanvasGLES3::light_update_shadow(RID p_rid, int p_shadow_index, c } glBindVertexArray(0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -1797,7 +1797,7 @@ void RasterizerCanvasGLES3::light_update_directional_shadow(RID p_rid, int p_sha cl->shadow.directional_xform = to_shadow * to_light_xform; glBindVertexArray(0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -1911,7 +1911,7 @@ void RasterizerCanvasGLES3::render_sdf(RID p_render_target, LightOccluderInstanc texture_storage->render_target_sdf_process(p_render_target); //done rendering, process it glBindVertexArray(0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } RID RasterizerCanvasGLES3::occluder_polygon_create() { diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index da2320c23d..73ee277074 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -418,7 +418,7 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display GL_COLOR_BUFFER_BIT, GL_NEAREST); if (read_fbo != 0) { - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteFramebuffers(1, &read_fbo); } } @@ -442,7 +442,7 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c Size2i win_size = DisplayServer::get_singleton()->window_get_size(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glViewport(0, 0, win_size.width, win_size.height); glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 59894ca4e3..f9af86e19b 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1107,7 +1107,7 @@ void RasterizerSceneGLES3::_filter_sky_radiance(Sky *p_sky, int p_base_layer) { } glBindVertexArray(0); glViewport(0, 0, p_sky->screen_size.x, p_sky->screen_size.y); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } Ref<Image> RasterizerSceneGLES3::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) { @@ -1148,7 +1148,7 @@ Ref<Image> RasterizerSceneGLES3::sky_bake_panorama(RID p_sky, float p_energy, bo copy_effects->copy_cube_to_panorama(p_bake_irradiance ? float(sky->mipmap_count) : 0.0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteFramebuffers(1, &rad_fbo); // Create a dummy texture so we can use texture_2d_get. RID tex_rid = GLES3::TextureStorage::get_singleton()->texture_allocate(); @@ -2303,7 +2303,7 @@ void RasterizerSceneGLES3::_render_shadow_pass(RID p_light, RID p_shadow_atlas, scene_state.enable_gl_depth_draw(true); glDisable(GL_CULL_FACE); scene_state.cull_mode = GLES3::SceneShaderData::CULL_DISABLED; - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_compositor, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RenderingMethod::RenderInfo *r_render_info) { @@ -3573,7 +3573,7 @@ void RasterizerSceneGLES3::render_particle_collider_heightfield(RID p_collider, _render_list_template<PASS_MODE_SHADOW>(&render_list_params, &render_data, 0, render_list[RENDER_LIST_SECONDARY].elements.size()); glColorMask(1, 1, 1, 1); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } void RasterizerSceneGLES3::_render_uv2(const PagedArray<RenderGeometryInstance *> &p_instances, GLuint p_framebuffer, const Rect2i &p_region) { @@ -3655,7 +3655,7 @@ void RasterizerSceneGLES3::_render_uv2(const PagedArray<RenderGeometryInstance * GLuint db = GL_COLOR_ATTACHMENT0; glDrawBuffers(1, &db); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } } @@ -3759,7 +3759,7 @@ void RasterizerSceneGLES3::_render_buffers_debug_draw(Ref<RenderSceneBuffersGLES copy_effects->copy_to_rect(Rect2(Vector2(), Vector2(0.5, 0.5))); glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } } if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS) { @@ -3969,6 +3969,10 @@ bool RasterizerSceneGLES3::free(RID p_rid) { } else if (RSG::camera_attributes->owns_camera_attributes(p_rid)) { //not much to delete, just free it RSG::camera_attributes->camera_attributes_free(p_rid); + } else if (is_compositor(p_rid)) { + compositor_free(p_rid); + } else if (is_compositor_effect(p_rid)) { + compositor_effect_free(p_rid); } else { return false; } diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp index 5421f57646..2259c61e5b 100644 --- a/drivers/gles3/storage/light_storage.cpp +++ b/drivers/gles3/storage/light_storage.cpp @@ -1044,7 +1044,7 @@ bool LightStorage::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_i glBindTexture(GL_TEXTURE_2D, 0); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); r_quadrant = qidx; r_shadow = shadow_atlas->quadrants[qidx].textures.size(); @@ -1135,7 +1135,7 @@ void LightStorage::update_directional_shadow_atlas() { glClear(GL_DEPTH_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } void LightStorage::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) { diff --git a/drivers/gles3/storage/light_storage.h b/drivers/gles3/storage/light_storage.h index 96e6200219..a6b236f3ec 100644 --- a/drivers/gles3/storage/light_storage.h +++ b/drivers/gles3/storage/light_storage.h @@ -686,7 +686,7 @@ public: glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, atlas->debug_texture, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); return atlas->debug_fbo; } diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 1dcd29553d..e073db3cfd 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -33,6 +33,7 @@ #include "mesh_storage.h" #include "config.h" #include "material_storage.h" +#include "texture_storage.h" #include "utilities.h" using namespace GLES3; @@ -1248,7 +1249,7 @@ void MeshStorage::update_mesh_instances() { } glEnable(GL_RASTERIZER_DISCARD); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); // Process skeletons and blend shapes using transform feedback while (dirty_mesh_instance_arrays.first()) { MeshInstance *mi = dirty_mesh_instance_arrays.first()->self(); diff --git a/drivers/gles3/storage/particles_storage.cpp b/drivers/gles3/storage/particles_storage.cpp index e263acf88b..c5a97bdbd5 100644 --- a/drivers/gles3/storage/particles_storage.cpp +++ b/drivers/gles3/storage/particles_storage.cpp @@ -818,7 +818,7 @@ void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p } glEnable(GL_RASTERIZER_DISCARD); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); _particles_update_instance_buffer(particles, axis, p_up_axis); glDisable(GL_RASTERIZER_DISCARD); } @@ -1002,7 +1002,7 @@ void ParticlesStorage::_particles_update_instance_buffer(Particles *particles, c void ParticlesStorage::update_particles() { glEnable(GL_RASTERIZER_DISCARD); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); GLuint global_buffer = GLES3::MaterialStorage::get_singleton()->global_shader_parameters_get_uniform_buffer(); @@ -1262,7 +1262,7 @@ GLuint ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_p particles_collision->heightfield_fb_size = size; glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } return particles_collision->heightfield_fb; diff --git a/drivers/gles3/storage/render_scene_buffers_gles3.cpp b/drivers/gles3/storage/render_scene_buffers_gles3.cpp index bd96442328..de0a64f5fe 100644 --- a/drivers/gles3/storage/render_scene_buffers_gles3.cpp +++ b/drivers/gles3/storage/render_scene_buffers_gles3.cpp @@ -121,7 +121,7 @@ GLuint RenderSceneBuffersGLES3::_rt_get_cached_fbo(GLuint p_color, GLuint p_dept msaa3d.cached_fbos.push_back(new_fbo); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); #endif return new_fbo.fbo; @@ -265,7 +265,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() { } glBindTexture(texture_target, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } if (msaa3d.mode != RS::VIEWPORT_MSAA_DISABLED) { @@ -316,7 +316,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() { } glBindRenderbuffer(GL_RENDERBUFFER, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); #if !defined(IOS_ENABLED) && !defined(WEB_ENABLED) } else if (use_multiview && !config->rt_msaa_multiview_supported) { // Render to texture extensions not supported? fall back to MSAA textures through GL_EXT_multiview_texture_multisample. @@ -362,7 +362,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() { } glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); #endif #if defined(ANDROID_ENABLED) || defined(WEB_ENABLED) // Only supported on OpenGLES! } else if (!use_internal_buffer) { @@ -390,7 +390,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() { WARN_PRINT("Could not create 3D MSAA framebuffer, status: " + texture_storage->get_framebuffer_error(status)); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); #endif } else { // HUH? how did we get here? @@ -531,7 +531,7 @@ void RenderSceneBuffersGLES3::check_backbuffer(bool p_need_color, bool p_need_de } glBindTexture(texture_target, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } void RenderSceneBuffersGLES3::_clear_back_buffers() { @@ -607,7 +607,7 @@ void RenderSceneBuffersGLES3::check_glow_buffers() { } glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } void RenderSceneBuffersGLES3::_clear_glow_buffers() { diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index e9df3c6fc8..ffbad4c83b 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1090,7 +1090,7 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const { glReadPixels(0, 0, texture->alloc_width, texture->alloc_height, GL_RGBA, GL_UNSIGNED_BYTE, &w[0]); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteTextures(1, &temp_color_texture); glDeleteFramebuffers(1, &temp_framebuffer); @@ -1162,7 +1162,7 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons glReadPixels(0, 0, texture->alloc_width, texture->alloc_height, GL_RGBA, GL_UNSIGNED_BYTE, &w[0]); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteTextures(1, &temp_color_texture); glDeleteFramebuffers(1, &temp_framebuffer); @@ -1265,7 +1265,7 @@ Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const { Vector<Ref<Image>> ret = _texture_3d_read_framebuffer(texture); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); glDeleteTextures(1, &temp_color_texture); glDeleteFramebuffers(1, &temp_framebuffer); @@ -1920,7 +1920,7 @@ void TextureStorage::update_texture_atlas() { copy_effects->copy_to_rect(t->uv_rect); } } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo); } /* DECAL API */ diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 1652c0b1f1..6f1439a91f 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -3828,7 +3828,7 @@ void AnimationTrackEditor::_insert_track(bool p_reset_wanted, bool p_create_bezi } } -void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant p_value) { +void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value) { ERR_FAIL_NULL(root); ERR_FAIL_COND_MSG( (p_type != Animation::TYPE_POSITION_3D && p_type != Animation::TYPE_ROTATION_3D && p_type != Animation::TYPE_SCALE_3D), @@ -4986,7 +4986,7 @@ void AnimationTrackEditor::_fetch_value_track_options(const NodePath &p_path, An } } -void AnimationTrackEditor::_new_track_property_selected(String p_name) { +void AnimationTrackEditor::_new_track_property_selected(const String &p_name) { String full_path = String(adding_track_path) + ":" + p_name; EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 0d6f93fefc..d0da7b0062 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -440,7 +440,7 @@ class AnimationTrackEditor : public VBoxContainer { void _add_track(int p_type); void _new_track_node_selected(NodePath p_path); - void _new_track_property_selected(String p_name); + void _new_track_property_selected(const String &p_name); void _update_step_spinbox(); @@ -699,7 +699,7 @@ public: void set_anim_pos(float p_pos); void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false); void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance); - void insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant p_value); + void insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value); bool has_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type); void make_insert_queue(); void commit_insert_queue(); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index d3872349e9..3efefe83c3 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1059,7 +1059,6 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_line_length_guidelines(TypedArray<int>()); } - _update_font_ligatures(); set_zoom_factor(zoom_factor); } @@ -1683,10 +1682,6 @@ void CodeTextEditor::goto_error() { } void CodeTextEditor::_update_text_editor_theme() { - if (!EditorThemeManager::is_generated_theme_outdated()) { - return; - } - emit_signal(SNAME("load_theme_settings")); error_button->set_icon(get_editor_theme_icon(SNAME("StatusError"))); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 9fef200611..19474d383d 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -236,7 +236,7 @@ void ConnectDialog::_remove_bind() { /* * Automatically generates a name for the callback method. */ -StringName ConnectDialog::generate_method_callback_name(Node *p_source, String p_signal_name, Node *p_target) { +StringName ConnectDialog::generate_method_callback_name(Node *p_source, const String &p_signal_name, Node *p_target) { String node_name = p_source->get_name(); for (int i = 0; i < node_name.length(); i++) { // TODO: Regex filter may be cleaner. char32_t c = node_name[i]; @@ -645,7 +645,7 @@ void ConnectDialog::init(const ConnectionData &p_cd, const PackedStringArray &p_ source_connection_data = p_cd; } -void ConnectDialog::popup_dialog(const String p_for_signal) { +void ConnectDialog::popup_dialog(const String &p_for_signal) { from_signal->set_text(p_for_signal); warning_label->add_theme_color_override("font_color", warning_label->get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index fb163fbb5f..8aa44dc91d 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -163,7 +163,7 @@ protected: static void _bind_methods(); public: - static StringName generate_method_callback_name(Node *p_source, String p_signal_name, Node *p_target); + static StringName generate_method_callback_name(Node *p_source, const String &p_signal_name, Node *p_target); Node *get_source() const; ConnectionData get_source_connection_data() const; StringName get_signal_name() const; @@ -184,7 +184,7 @@ public: void init(const ConnectionData &p_cd, const PackedStringArray &p_signal_args, bool p_edit = false); - void popup_dialog(const String p_for_signal); + void popup_dialog(const String &p_for_signal); ConnectDialog(); ~ConnectDialog(); }; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 604449b04b..603b3505d4 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -343,7 +343,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String } } -String CreateDialog::_top_result(const Vector<String> p_candidates, const String &p_search_text) const { +String CreateDialog::_top_result(const Vector<String> &p_candidates, const String &p_search_text) const { float highest_score = 0; int highest_index = 0; for (int i = 0; i < p_candidates.size(); i++) { diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 694efd1ee1..12385747c2 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -71,7 +71,7 @@ class CreateDialog : public ConfirmationDialog { bool _should_hide_type(const String &p_type) const; void _add_type(const String &p_type, const TypeCategory p_type_category); void _configure_search_option_item(TreeItem *r_item, const String &p_type, const TypeCategory p_type_category); - String _top_result(const Vector<String> p_candidates, const String &p_search_text) const; + String _top_result(const Vector<String> &p_candidates, const String &p_search_text) const; float _score_type(const String &p_type, const String &p_search) const; bool _is_type_preferred(const String &p_type) const; diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 5fe35bde84..b7719f6c97 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -557,7 +557,7 @@ void EditorDebuggerNode::_paused() { }); } -void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, String p_message, bool p_has_stackdump, int p_debugger) { +void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, const String &p_message, bool p_has_stackdump, int p_debugger) { if (get_current_debugger() != get_debugger(p_debugger)) { if (!p_breaked) { return; @@ -582,7 +582,7 @@ void EditorDebuggerNode::set_breakpoint(const String &p_path, int p_line, bool p emit_signal(SNAME("breakpoint_toggled"), p_path, p_line, p_enabled); } -void EditorDebuggerNode::set_breakpoints(const String &p_path, Array p_lines) { +void EditorDebuggerNode::set_breakpoints(const String &p_path, const Array &p_lines) { for (int i = 0; i < p_lines.size(); i++) { set_breakpoint(p_path, p_lines[i], true); } diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index d30f29c7c6..01aa522f40 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -149,7 +149,7 @@ protected: void _text_editor_stack_clear(const ScriptEditorDebugger *p_debugger); void _stack_frame_selected(int p_debugger); void _error_selected(const String &p_file, int p_line, int p_debugger); - void _breaked(bool p_breaked, bool p_can_debug, String p_message, bool p_has_stackdump, int p_debugger); + void _breaked(bool p_breaked, bool p_can_debug, const String &p_message, bool p_has_stackdump, int p_debugger); void _paused(); void _break_state_changed(); void _menu_option(int p_id); @@ -186,7 +186,7 @@ public: bool is_skip_breakpoints() const; void set_breakpoint(const String &p_path, int p_line, bool p_enabled); - void set_breakpoints(const String &p_path, Array p_lines); + void set_breakpoints(const String &p_path, const Array &p_lines); void reload_all_scripts(); void reload_scripts(const Vector<String> &p_script_paths); diff --git a/editor/debugger/editor_file_server.cpp b/editor/debugger/editor_file_server.cpp index c12cec1e74..e84eb14636 100644 --- a/editor/debugger/editor_file_server.cpp +++ b/editor/debugger/editor_file_server.cpp @@ -98,7 +98,7 @@ void EditorFileServer::_scan_files_changed(EditorFileSystemDirectory *efd, const } } -static void _add_custom_file(const String f, HashMap<String, uint64_t> &files_to_send, HashMap<String, uint64_t> &cached_files) { +static void _add_custom_file(const String &f, HashMap<String, uint64_t> &files_to_send, HashMap<String, uint64_t> &cached_files) { if (!FileAccess::exists(f)) { return; } diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 37e13b59cc..ffff362a94 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -38,7 +38,7 @@ EditorPerformanceProfiler::Monitor::Monitor() {} -EditorPerformanceProfiler::Monitor::Monitor(String p_name, String p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item) { +EditorPerformanceProfiler::Monitor::Monitor(const String &p_name, const String &p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item) { type = p_type; item = p_item; frame_index = p_frame_index; diff --git a/editor/debugger/editor_performance_profiler.h b/editor/debugger/editor_performance_profiler.h index 6211cc39a4..4afe82b4bd 100644 --- a/editor/debugger/editor_performance_profiler.h +++ b/editor/debugger/editor_performance_profiler.h @@ -54,7 +54,7 @@ private: int frame_index = 0; Monitor(); - Monitor(String p_name, String p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item); + Monitor(const String &p_name, const String &p_base, int p_frame_index, Performance::MonitorType p_type, TreeItem *p_item); void update_value(float p_value); void reset(); }; diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 93dcc341c1..979834ebab 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -72,7 +72,7 @@ using CameraOverride = EditorDebuggerNode::CameraOverride; -void ScriptEditorDebugger::_put_msg(String p_message, Array p_data, uint64_t p_thread_id) { +void ScriptEditorDebugger::_put_msg(const String &p_message, const Array &p_data, uint64_t p_thread_id) { ERR_FAIL_COND(p_thread_id == Thread::UNASSIGNED_ID); if (is_session_active()) { Array msg; diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index 589e82ef25..bd0b0c7d85 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -222,7 +222,7 @@ private: void _item_menu_id_pressed(int p_option); void _tab_changed(int p_tab); - void _put_msg(String p_message, Array p_data, uint64_t p_thread_id = Thread::MAIN_ID); + void _put_msg(const String &p_message, const Array &p_data, uint64_t p_thread_id = Thread::MAIN_ID); void _export_csv(); void _clear_execution(); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 4d5393299c..0e46990b41 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -382,17 +382,17 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { add_autoload->set_disabled(false); } -void EditorAutoloadSettings::_autoload_text_submitted(const String p_name) { +void EditorAutoloadSettings::_autoload_text_submitted(const String &p_name) { if (!autoload_add_path->get_text().is_empty() && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } -void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { +void EditorAutoloadSettings::_autoload_path_text_changed(const String &p_path) { add_autoload->set_disabled(!_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); } -void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { +void EditorAutoloadSettings::_autoload_text_changed(const String &p_name) { String error_string; bool is_name_valid = _autoload_name_is_valid(p_name, &error_string); add_autoload->set_disabled(!is_name_valid); diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index cd025e0fc7..11d7cdbe4d 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -83,9 +83,9 @@ class EditorAutoloadSettings : public VBoxContainer { void _autoload_edited(); void _autoload_button_pressed(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button); void _autoload_activated(); - void _autoload_path_text_changed(const String p_path); - void _autoload_text_submitted(const String p_name); - void _autoload_text_changed(const String p_name); + void _autoload_path_text_changed(const String &p_path); + void _autoload_text_submitted(const String &p_name); + void _autoload_text_changed(const String &p_name); void _autoload_open(const String &fpath); void _autoload_file_callback(const String &p_path); Node *_create_autoload(const String &p_path); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index b4cf6d8de1..47642c1592 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -266,7 +266,7 @@ Vector<EditorPlugin *> EditorData::get_handling_sub_editors(Object *p_object) { return sub_plugins; } -EditorPlugin *EditorData::get_editor_by_name(String p_name) { +EditorPlugin *EditorData::get_editor_by_name(const String &p_name) { for (int i = editor_plugins.size() - 1; i > -1; i--) { if (editor_plugins[i]->get_name() == p_name) { return editor_plugins[i]; diff --git a/editor/editor_data.h b/editor/editor_data.h index d1af400e87..d71a2b3ed3 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -152,7 +152,7 @@ private: public: EditorPlugin *get_handling_main_editor(Object *p_object); Vector<EditorPlugin *> get_handling_sub_editors(Object *p_object); - EditorPlugin *get_editor_by_name(String p_name); + EditorPlugin *get_editor_by_name(const String &p_name); void copy_object_params(Object *p_object); void paste_object_params(Object *p_object); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 5021b814ea..fa6a02f9d4 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -524,7 +524,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return false; //nothing changed } -bool EditorFileSystem::_scan_import_support(Vector<String> reimports) { +bool EditorFileSystem::_scan_import_support(const Vector<String> &reimports) { if (import_support_queries.size() == 0) { return false; } @@ -1161,7 +1161,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } } -void EditorFileSystem::_delete_internal_files(String p_file) { +void EditorFileSystem::_delete_internal_files(const String &p_file) { if (FileAccess::exists(p_file + ".import")) { List<String> paths; ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index d099a6fedc..818d725281 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -221,7 +221,7 @@ class EditorFileSystem : public Node { void _scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress); - void _delete_internal_files(String p_file); + void _delete_internal_files(const String &p_file); HashSet<String> textfile_extensions; HashSet<String> valid_extensions; @@ -298,7 +298,7 @@ class EditorFileSystem : public Node { static ResourceUID::ID _resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate); bool _scan_extensions(); - bool _scan_import_support(Vector<String> reimports); + bool _scan_import_support(const Vector<String> &reimports); Vector<Ref<EditorFileSystemImportFormatSupportQuery>> import_support_queries; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index e4a5ab86d9..02c6925f14 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2066,7 +2066,7 @@ void EditorInspectorArray::_new_size_spin_box_value_changed(float p_value) { resize_dialog->get_ok_button()->set_disabled(int(p_value) == count); } -void EditorInspectorArray::_new_size_spin_box_text_submitted(String p_text) { +void EditorInspectorArray::_new_size_spin_box_text_submitted(const String &p_text) { _resize_dialog_confirmed(); } @@ -2306,7 +2306,7 @@ void EditorInspectorArray::_bind_methods() { ADD_SIGNAL(MethodInfo("page_change_request")); } -void EditorInspectorArray::setup_with_move_element_function(Object *p_object, String p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable, bool p_numbered, int p_page_length, const String &p_add_item_text) { +void EditorInspectorArray::setup_with_move_element_function(Object *p_object, const String &p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable, bool p_numbered, int p_page_length, const String &p_add_item_text) { count_property = ""; mode = MODE_USE_MOVE_ARRAY_ELEMENT_FUNCTION; array_element_prefix = p_array_element_prefix; @@ -2320,7 +2320,7 @@ void EditorInspectorArray::setup_with_move_element_function(Object *p_object, St _setup(); } -void EditorInspectorArray::setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable, bool p_numbered, int p_page_length, const String &p_add_item_text, const String &p_swap_method) { +void EditorInspectorArray::setup_with_count_property(Object *p_object, const String &p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable, bool p_numbered, int p_page_length, const String &p_add_item_text, const String &p_swap_method) { count_property = p_count_property; mode = MODE_USE_COUNT_PROPERTY; array_element_prefix = p_array_element_prefix; @@ -2412,7 +2412,7 @@ void EditorPaginator::_prev_page_button_pressed() { emit_signal("page_changed", MAX(0, page - 1)); } -void EditorPaginator::_page_line_edit_text_submitted(String p_text) { +void EditorPaginator::_page_line_edit_text_submitted(const String &p_text) { if (p_text.is_valid_int()) { int new_page = p_text.to_int() - 1; new_page = MIN(MAX(0, new_page), max_page); @@ -3829,7 +3829,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v } } -void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing) { +void EditorInspector::_multiple_properties_changed(const Vector<String> &p_paths, const Array &p_values, bool p_changing) { ERR_FAIL_COND(p_paths.is_empty() || p_values.is_empty()); ERR_FAIL_COND(p_paths.size() != p_values.size()); String names; diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 0e908b7a14..8c55950a2b 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -406,7 +406,7 @@ class EditorInspectorArray : public EditorInspectorSection { int _drop_position() const; void _new_size_spin_box_value_changed(float p_value); - void _new_size_spin_box_text_submitted(String p_text); + void _new_size_spin_box_text_submitted(const String &p_text); void _resize_dialog_confirmed(); void _update_elements_visibility(); @@ -423,8 +423,8 @@ protected: static void _bind_methods(); public: - void setup_with_move_element_function(Object *p_object, String p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = ""); - void setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "", const String &p_swap_method = ""); + void setup_with_move_element_function(Object *p_object, const String &p_label, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = ""); + void setup_with_count_property(Object *p_object, const String &p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "", const String &p_swap_method = ""); VBoxContainer *get_vbox(int p_index); EditorInspectorArray(bool p_read_only); @@ -444,7 +444,7 @@ class EditorPaginator : public HBoxContainer { void _first_page_button_pressed(); void _prev_page_button_pressed(); - void _page_line_edit_text_submitted(String p_text); + void _page_line_edit_text_submitted(const String &p_text); void _next_page_button_pressed(); void _last_page_button_pressed(); @@ -520,7 +520,7 @@ class EditorInspector : public ScrollContainer { void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field); void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false, bool p_update_all = false); - void _multiple_properties_changed(Vector<String> p_paths, Array p_values, bool p_changing = false); + void _multiple_properties_changed(const Vector<String> &p_paths, const Array &p_values, bool p_changing = false); void _property_keyed(const String &p_path, bool p_advance); void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance); void _property_deleted(const String &p_path); diff --git a/editor/editor_log.h b/editor/editor_log.h index 03a0a071c6..601e63b9fe 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -64,7 +64,7 @@ private: LogMessage() {} - LogMessage(const String p_text, MessageType p_type, bool p_clear) : + LogMessage(const String &p_text, MessageType p_type, bool p_clear) : text(p_text), type(p_type), clear(p_clear) { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 0517abac2b..73a0768a72 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -254,7 +254,7 @@ void EditorPropertyTextEnum::_set_read_only(bool p_read_only) { edit_button->set_disabled(p_read_only); } -void EditorPropertyTextEnum::_emit_changed_value(String p_string) { +void EditorPropertyTextEnum::_emit_changed_value(const String &p_string) { if (string_name) { emit_changed(get_edited_property(), StringName(p_string)); } else { @@ -272,7 +272,7 @@ void EditorPropertyTextEnum::_edit_custom_value() { custom_value_edit->grab_focus(); } -void EditorPropertyTextEnum::_custom_value_submitted(String p_value) { +void EditorPropertyTextEnum::_custom_value_submitted(const String &p_value) { edit_custom_layout->hide(); default_layout->show(); @@ -2897,7 +2897,7 @@ void EditorPropertyNodePath::update_property() { assign->set_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node")); } -void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root, bool p_editing_node) { +void EditorPropertyNodePath::setup(const NodePath &p_base_hint, const Vector<StringName> &p_valid_types, bool p_use_path_from_scene_root, bool p_editing_node) { base_hint = p_base_hint; valid_types = p_valid_types; editing_node = p_editing_node; diff --git a/editor/editor_properties.h b/editor/editor_properties.h index b7ae4bd1ca..fa759d5d19 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -116,11 +116,11 @@ class EditorPropertyTextEnum : public EditorProperty { bool string_name = false; bool loose_mode = false; - void _emit_changed_value(String p_string); + void _emit_changed_value(const String &p_string); void _option_selected(int p_which); void _edit_custom_value(); - void _custom_value_submitted(String p_value); + void _custom_value_submitted(const String &p_value); void _custom_value_accepted(); void _custom_value_canceled(); @@ -677,7 +677,7 @@ protected: public: virtual void update_property() override; - void setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root = true, bool p_editing_node = false); + void setup(const NodePath &p_base_hint, const Vector<StringName> &p_valid_types, bool p_use_path_from_scene_root = true, bool p_editing_node = false); EditorPropertyNodePath(); }; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 2d11c2e2d1..8a15f4912a 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -1287,7 +1287,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() { ///////////////////// LOCALIZABLE STRING /////////////////////////// -void EditorPropertyLocalizableString::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void EditorPropertyLocalizableString::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { if (p_property.begins_with("indices")) { int index = p_property.get_slice("/", 1).to_int(); diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index f157da00c2..0e81a0fae3 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -214,7 +214,7 @@ class EditorPropertyLocalizableString : public EditorProperty { void _page_changed(int p_page); void _edit_pressed(); void _remove_item(Object *p_button, int p_index); - void _property_changed(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false); + void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false); void _add_locale_popup(); void _add_locale(const String &p_locale); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 95436427ad..963ddb6329 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -654,7 +654,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { return false; } -bool EditorResourcePicker::_is_type_valid(const String p_type_name, const HashSet<StringName> &p_allowed_types) const { +bool EditorResourcePicker::_is_type_valid(const String &p_type_name, const HashSet<StringName> &p_allowed_types) const { for (const StringName &E : p_allowed_types) { String at = E; if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) { diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index fb54455e89..8146c02dff 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -99,7 +99,7 @@ class EditorResourcePicker : public HBoxContainer { String _get_resource_type(const Ref<Resource> &p_resource) const; void _get_allowed_types(bool p_with_convert, HashSet<StringName> *p_vector) const; bool _is_drop_valid(const Dictionary &p_drag_data) const; - bool _is_type_valid(const String p_type_name, const HashSet<StringName> &p_allowed_types) const; + bool _is_type_valid(const String &p_type_name, const HashSet<StringName> &p_allowed_types) const; Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index fc1dda9669..94bf15ae66 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -351,7 +351,7 @@ void EditorResourcePreview::_iterate() { _preview_ready(item.path, 0, texture, small_texture, item.id, item.function, item.userdata, preview_metadata); } -void EditorResourcePreview::_write_preview_cache(Ref<FileAccess> p_file, int p_thumbnail_size, bool p_has_small_texture, uint64_t p_modified_time, String p_hash, const Dictionary &p_metadata) { +void EditorResourcePreview::_write_preview_cache(Ref<FileAccess> p_file, int p_thumbnail_size, bool p_has_small_texture, uint64_t p_modified_time, const String &p_hash, const Dictionary &p_metadata) { p_file->store_line(itos(p_thumbnail_size)); p_file->store_line(itos(p_has_small_texture)); p_file->store_line(itos(p_modified_time)); diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 3cad56f75e..8461651732 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -117,7 +117,7 @@ class EditorResourcePreview : public Node { static void _idle_callback(); // For other rendering drivers (i.e., OpenGL). void _iterate(); - void _write_preview_cache(Ref<FileAccess> p_file, int p_thumbnail_size, bool p_has_small_texture, uint64_t p_modified_time, String p_hash, const Dictionary &p_metadata); + void _write_preview_cache(Ref<FileAccess> p_file, int p_thumbnail_size, bool p_has_small_texture, uint64_t p_modified_time, const String &p_hash, const Dictionary &p_metadata); void _read_preview_cache(Ref<FileAccess> p_file, int *r_thumbnail_size, bool *r_has_small_texture, uint64_t *r_modified_time, String *r_hash, Dictionary *r_metadata); Vector<Ref<EditorResourcePreviewGenerator>> preview_generators; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 853a4cd410..199fa3f6c9 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -934,7 +934,7 @@ void EditorSettings::_load_default_visual_shader_editor_theme() { _initial_set("editors/visual_editors/category_colors/particle_color", Color(0.12, 0.358, 0.8)); } -bool EditorSettings::_save_text_editor_theme(String p_file) { +bool EditorSettings::_save_text_editor_theme(const String &p_file) { String theme_section = "color_theme"; Ref<ConfigFile> cf = memnew(ConfigFile); // hex is better? @@ -957,7 +957,7 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { return err == OK; } -bool EditorSettings::_is_default_text_editor_theme(String p_theme_name) { +bool EditorSettings::_is_default_text_editor_theme(const String &p_theme_name) { return p_theme_name == "default" || p_theme_name == "godot 2" || p_theme_name == "custom"; } @@ -1251,7 +1251,7 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) { // Metadata -void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, Variant p_data) { +void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, const Variant &p_data) { const String path = _get_project_metadata_path(); if (project_metadata.is_null()) { @@ -1268,7 +1268,7 @@ void EditorSettings::set_project_metadata(const String &p_section, const String ERR_FAIL_COND_MSG(err != OK, "Cannot save project metadata to file '" + path + "'."); } -Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const { +Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, const Variant &p_default) const { if (project_metadata.is_null()) { project_metadata.instantiate(); @@ -1409,7 +1409,7 @@ void EditorSettings::load_text_editor_theme() { // if it doesn't load just use what is currently loaded } -bool EditorSettings::import_text_editor_theme(String p_file) { +bool EditorSettings::import_text_editor_theme(const String &p_file) { if (!p_file.ends_with(".tet")) { return false; } else { diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 5783bac770..4995558e2b 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -111,8 +111,8 @@ private: void _load_defaults(Ref<ConfigFile> p_extra_config = Ref<ConfigFile>()); void _load_godot2_text_editor_theme(); void _load_default_visual_shader_editor_theme(); - bool _save_text_editor_theme(String p_file); - bool _is_default_text_editor_theme(String p_theme_name); + bool _save_text_editor_theme(const String &p_file); + bool _is_default_text_editor_theme(const String &p_theme_name); const String _get_project_metadata_path() const; protected: @@ -155,8 +155,8 @@ public: void set_resource_clipboard(const Ref<Resource> &p_resource) { clipboard = p_resource; } Ref<Resource> get_resource_clipboard() const { return clipboard; } - void set_project_metadata(const String &p_section, const String &p_key, Variant p_data); - Variant get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const; + void set_project_metadata(const String &p_section, const String &p_key, const Variant &p_data); + Variant get_project_metadata(const String &p_section, const String &p_key, const Variant &p_default) const; void set_favorites(const Vector<String> &p_favorites); Vector<String> get_favorites() const; @@ -166,7 +166,7 @@ public: void list_text_editor_themes(); void load_text_editor_theme(); - bool import_text_editor_theme(String p_file); + bool import_text_editor_theme(const String &p_file); bool save_text_editor_theme(); bool save_text_editor_theme_as(String p_file); bool is_default_text_editor_theme(); diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index 1f76c94655..7d39dc8715 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -34,18 +34,18 @@ EditorVCSInterface *EditorVCSInterface::singleton = nullptr; -void EditorVCSInterface::popup_error(String p_msg) { +void EditorVCSInterface::popup_error(const String &p_msg) { // TRANSLATORS: %s refers to the name of a version control system (e.g. "Git"). EditorNode::get_singleton()->show_warning(p_msg.strip_edges(), vformat(TTR("%s Error"), get_vcs_name())); } -bool EditorVCSInterface::initialize(String p_project_path) { +bool EditorVCSInterface::initialize(const String &p_project_path) { bool result = false; GDVIRTUAL_REQUIRED_CALL(_initialize, p_project_path, result); return result; } -void EditorVCSInterface::set_credentials(String p_username, String p_password, String p_ssh_public_key, String p_ssh_private_key, String p_ssh_passphrase) { +void EditorVCSInterface::set_credentials(const String &p_username, const String &p_password, const String &p_ssh_public_key, const String &p_ssh_private_key, const String &p_ssh_passphrase) { GDVIRTUAL_REQUIRED_CALL(_set_credentials, p_username, p_password, p_ssh_public_key, p_ssh_private_key, p_ssh_passphrase); } @@ -75,23 +75,23 @@ List<EditorVCSInterface::StatusFile> EditorVCSInterface::get_modified_files_data return status_files; } -void EditorVCSInterface::stage_file(String p_file_path) { +void EditorVCSInterface::stage_file(const String &p_file_path) { GDVIRTUAL_REQUIRED_CALL(_stage_file, p_file_path); } -void EditorVCSInterface::unstage_file(String p_file_path) { +void EditorVCSInterface::unstage_file(const String &p_file_path) { GDVIRTUAL_REQUIRED_CALL(_unstage_file, p_file_path); } -void EditorVCSInterface::discard_file(String p_file_path) { +void EditorVCSInterface::discard_file(const String &p_file_path) { GDVIRTUAL_REQUIRED_CALL(_discard_file, p_file_path); } -void EditorVCSInterface::commit(String p_msg) { +void EditorVCSInterface::commit(const String &p_msg) { GDVIRTUAL_REQUIRED_CALL(_commit, p_msg); } -List<EditorVCSInterface::DiffFile> EditorVCSInterface::get_diff(String p_identifier, TreeArea p_area) { +List<EditorVCSInterface::DiffFile> EditorVCSInterface::get_diff(const String &p_identifier, TreeArea p_area) { TypedArray<Dictionary> result; if (!GDVIRTUAL_REQUIRED_CALL(_get_diff, p_identifier, int(p_area), result)) { return {}; @@ -130,19 +130,19 @@ List<String> EditorVCSInterface::get_branch_list() { return branch_list; } -void EditorVCSInterface::create_branch(String p_branch_name) { +void EditorVCSInterface::create_branch(const String &p_branch_name) { GDVIRTUAL_REQUIRED_CALL(_create_branch, p_branch_name); } -void EditorVCSInterface::create_remote(String p_remote_name, String p_remote_url) { +void EditorVCSInterface::create_remote(const String &p_remote_name, const String &p_remote_url) { GDVIRTUAL_REQUIRED_CALL(_create_remote, p_remote_name, p_remote_url); } -void EditorVCSInterface::remove_branch(String p_branch_name) { +void EditorVCSInterface::remove_branch(const String &p_branch_name) { GDVIRTUAL_REQUIRED_CALL(_remove_branch, p_branch_name); } -void EditorVCSInterface::remove_remote(String p_remote_name) { +void EditorVCSInterface::remove_remote(const String &p_remote_name) { GDVIRTUAL_REQUIRED_CALL(_remove_remote, p_remote_name); } @@ -152,25 +152,25 @@ String EditorVCSInterface::get_current_branch_name() { return result; } -bool EditorVCSInterface::checkout_branch(String p_branch_name) { +bool EditorVCSInterface::checkout_branch(const String &p_branch_name) { bool result = false; GDVIRTUAL_REQUIRED_CALL(_checkout_branch, p_branch_name, result); return result; } -void EditorVCSInterface::pull(String p_remote) { +void EditorVCSInterface::pull(const String &p_remote) { GDVIRTUAL_REQUIRED_CALL(_pull, p_remote); } -void EditorVCSInterface::push(String p_remote, bool p_force) { +void EditorVCSInterface::push(const String &p_remote, bool p_force) { GDVIRTUAL_REQUIRED_CALL(_push, p_remote, p_force); } -void EditorVCSInterface::fetch(String p_remote) { +void EditorVCSInterface::fetch(const String &p_remote) { GDVIRTUAL_REQUIRED_CALL(_fetch, p_remote); } -List<EditorVCSInterface::DiffHunk> EditorVCSInterface::get_line_diff(String p_file_path, String p_text) { +List<EditorVCSInterface::DiffHunk> EditorVCSInterface::get_line_diff(const String &p_file_path, const String &p_text) { TypedArray<Dictionary> result; if (!GDVIRTUAL_REQUIRED_CALL(_get_line_diff, p_file_path, p_text, result)) { return {}; @@ -195,7 +195,7 @@ String EditorVCSInterface::get_vcs_name() { return result; } -Dictionary EditorVCSInterface::create_diff_line(int p_new_line_no, int p_old_line_no, String p_content, String p_status) { +Dictionary EditorVCSInterface::create_diff_line(int p_new_line_no, int p_old_line_no, const String &p_content, const String &p_status) { Dictionary diff_line; diff_line["new_line_no"] = p_new_line_no; diff_line["old_line_no"] = p_old_line_no; @@ -220,7 +220,7 @@ Dictionary EditorVCSInterface::add_line_diffs_into_diff_hunk(Dictionary p_diff_h return p_diff_hunk; } -Dictionary EditorVCSInterface::create_diff_file(String p_new_file, String p_old_file) { +Dictionary EditorVCSInterface::create_diff_file(const String &p_new_file, const String &p_old_file) { Dictionary file_diff; file_diff["new_file"] = p_new_file; file_diff["old_file"] = p_old_file; @@ -228,7 +228,7 @@ Dictionary EditorVCSInterface::create_diff_file(String p_new_file, String p_old_ return file_diff; } -Dictionary EditorVCSInterface::create_commit(String p_msg, String p_author, String p_id, int64_t p_unix_timestamp, int64_t p_offset_minutes) { +Dictionary EditorVCSInterface::create_commit(const String &p_msg, const String &p_author, const String &p_id, int64_t p_unix_timestamp, int64_t p_offset_minutes) { Dictionary commit_info; commit_info["message"] = p_msg; commit_info["author"] = p_author; @@ -243,7 +243,7 @@ Dictionary EditorVCSInterface::add_diff_hunks_into_diff_file(Dictionary p_diff_f return p_diff_file; } -Dictionary EditorVCSInterface::create_status_file(String p_file_path, ChangeType p_change, TreeArea p_area) { +Dictionary EditorVCSInterface::create_status_file(const String &p_file_path, ChangeType p_change, TreeArea p_area) { Dictionary sf; sf["file_path"] = p_file_path; sf["change_type"] = p_change; @@ -251,7 +251,7 @@ Dictionary EditorVCSInterface::create_status_file(String p_file_path, ChangeType return sf; } -EditorVCSInterface::DiffLine EditorVCSInterface::_convert_diff_line(Dictionary p_diff_line) { +EditorVCSInterface::DiffLine EditorVCSInterface::_convert_diff_line(const Dictionary &p_diff_line) { DiffLine d; d.new_line_no = p_diff_line["new_line_no"]; d.old_line_no = p_diff_line["old_line_no"]; @@ -260,7 +260,7 @@ EditorVCSInterface::DiffLine EditorVCSInterface::_convert_diff_line(Dictionary p return d; } -EditorVCSInterface::DiffHunk EditorVCSInterface::_convert_diff_hunk(Dictionary p_diff_hunk) { +EditorVCSInterface::DiffHunk EditorVCSInterface::_convert_diff_hunk(const Dictionary &p_diff_hunk) { DiffHunk dh; dh.new_lines = p_diff_hunk["new_lines"]; dh.old_lines = p_diff_hunk["old_lines"]; @@ -274,7 +274,7 @@ EditorVCSInterface::DiffHunk EditorVCSInterface::_convert_diff_hunk(Dictionary p return dh; } -EditorVCSInterface::DiffFile EditorVCSInterface::_convert_diff_file(Dictionary p_diff_file) { +EditorVCSInterface::DiffFile EditorVCSInterface::_convert_diff_file(const Dictionary &p_diff_file) { DiffFile df; df.new_file = p_diff_file["new_file"]; df.old_file = p_diff_file["old_file"]; @@ -286,7 +286,7 @@ EditorVCSInterface::DiffFile EditorVCSInterface::_convert_diff_file(Dictionary p return df; } -EditorVCSInterface::Commit EditorVCSInterface::_convert_commit(Dictionary p_commit) { +EditorVCSInterface::Commit EditorVCSInterface::_convert_commit(const Dictionary &p_commit) { EditorVCSInterface::Commit c; c.msg = p_commit["message"]; c.author = p_commit["author"]; @@ -296,7 +296,7 @@ EditorVCSInterface::Commit EditorVCSInterface::_convert_commit(Dictionary p_comm return c; } -EditorVCSInterface::StatusFile EditorVCSInterface::_convert_status_file(Dictionary p_status_file) { +EditorVCSInterface::StatusFile EditorVCSInterface::_convert_status_file(const Dictionary &p_status_file) { StatusFile sf; sf.file_path = p_status_file["file_path"]; sf.change_type = (ChangeType)(int)p_status_file["change_type"]; diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index 84f2cf9281..8fcd45756a 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -99,11 +99,11 @@ protected: static void _bind_methods(); - DiffLine _convert_diff_line(Dictionary p_diff_line); - DiffHunk _convert_diff_hunk(Dictionary p_diff_hunk); - DiffFile _convert_diff_file(Dictionary p_diff_file); - Commit _convert_commit(Dictionary p_commit); - StatusFile _convert_status_file(Dictionary p_status_file); + DiffLine _convert_diff_line(const Dictionary &p_diff_line); + DiffHunk _convert_diff_hunk(const Dictionary &p_diff_hunk); + DiffFile _convert_diff_file(const Dictionary &p_diff_file); + Commit _convert_commit(const Dictionary &p_commit); + StatusFile _convert_status_file(const Dictionary &p_status_file); // Proxy endpoints for extensions to implement GDVIRTUAL1R(bool, _initialize, String); @@ -141,40 +141,40 @@ public: static void create_vcs_metadata_files(VCSMetadata p_vcs_metadata_type, String &p_dir); // Proxies to the editor for use - bool initialize(String p_project_path); - void set_credentials(String p_username, String p_password, String p_ssh_public_key_path, String p_ssh_private_key_path, String p_ssh_passphrase); + bool initialize(const String &p_project_path); + void set_credentials(const String &p_username, const String &p_password, const String &p_ssh_public_key_path, const String &p_ssh_private_key_path, const String &p_ssh_passphrase); List<StatusFile> get_modified_files_data(); - void stage_file(String p_file_path); - void unstage_file(String p_file_path); - void discard_file(String p_file_path); - void commit(String p_msg); - List<DiffFile> get_diff(String p_identifier, TreeArea p_area); + void stage_file(const String &p_file_path); + void unstage_file(const String &p_file_path); + void discard_file(const String &p_file_path); + void commit(const String &p_msg); + List<DiffFile> get_diff(const String &p_identifier, TreeArea p_area); bool shut_down(); String get_vcs_name(); List<Commit> get_previous_commits(int p_max_commits); List<String> get_branch_list(); List<String> get_remotes(); - void create_branch(String p_branch_name); - void remove_branch(String p_branch_name); - void create_remote(String p_remote_name, String p_remote_url); - void remove_remote(String p_remote_name); + void create_branch(const String &p_branch_name); + void remove_branch(const String &p_branch_name); + void create_remote(const String &p_remote_name, const String &p_remote_url); + void remove_remote(const String &p_remote_name); String get_current_branch_name(); - bool checkout_branch(String p_branch_name); - void pull(String p_remote); - void push(String p_remote, bool p_force); - void fetch(String p_remote); - List<DiffHunk> get_line_diff(String p_file_path, String p_text); + bool checkout_branch(const String &p_branch_name); + void pull(const String &p_remote); + void push(const String &p_remote, bool p_force); + void fetch(const String &p_remote); + List<DiffHunk> get_line_diff(const String &p_file_path, const String &p_text); // Helper functions to create and convert Dictionary into data structures - Dictionary create_diff_line(int p_new_line_no, int p_old_line_no, String p_content, String p_status); + Dictionary create_diff_line(int p_new_line_no, int p_old_line_no, const String &p_content, const String &p_status); Dictionary create_diff_hunk(int p_old_start, int p_new_start, int p_old_lines, int p_new_lines); - Dictionary create_diff_file(String p_new_file, String p_old_file); - Dictionary create_commit(String p_msg, String p_author, String p_id, int64_t p_unix_timestamp, int64_t p_offset_minutes); - Dictionary create_status_file(String p_file_path, ChangeType p_change, TreeArea p_area); + Dictionary create_diff_file(const String &p_new_file, const String &p_old_file); + Dictionary create_commit(const String &p_msg, const String &p_author, const String &p_id, int64_t p_unix_timestamp, int64_t p_offset_minutes); + Dictionary create_status_file(const String &p_file_path, ChangeType p_change, TreeArea p_area); Dictionary add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, TypedArray<Dictionary> p_line_diffs); Dictionary add_diff_hunks_into_diff_file(Dictionary p_diff_file, TypedArray<Dictionary> p_diff_hunks); - void popup_error(String p_msg); + void popup_error(const String &p_msg); }; VARIANT_ENUM_CAST(EditorVCSInterface::ChangeType); diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 9d65821ccd..b9dc52511e 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -329,7 +329,7 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { } } -String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { +String EditorExportPlatform::find_export_template(const String &template_file_name, String *err) const { String current_version = VERSION_FULL_CONFIG; String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(current_version).path_join(template_file_name); @@ -344,7 +344,7 @@ String EditorExportPlatform::find_export_template(String template_file_name, Str return String(); } -bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const { +bool EditorExportPlatform::exists_export_template(const String &template_file_name, String *err) const { return find_export_template(template_file_name, err) != ""; } diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 8f2288d409..26e1f86c8b 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -132,8 +132,8 @@ protected: HashSet<String> get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const; - bool exists_export_template(String template_file_name, String *err) const; - String find_export_template(String template_file_name, String *err = nullptr) const; + bool exists_export_template(const String &template_file_name, String *err) const; + String find_export_template(const String &template_file_name, String *err = nullptr) const; void gen_export_flags(Vector<String> &r_flags, int p_flags); void gen_debug_flags(Vector<String> &r_flags, int p_flags); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 0356d0d3ad..a7e40ce5b9 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -80,7 +80,7 @@ Control *FileSystemList::make_custom_tooltip(const String &p_text) const { return FileSystemDock::get_singleton()->create_tooltip_for_path(get_item_metadata(idx)); } -void FileSystemList::_line_editor_submit(String p_text) { +void FileSystemList::_line_editor_submit(const String &p_text) { popup_editor->hide(); emit_signal(SNAME("item_edited")); @@ -173,7 +173,7 @@ FileSystemList::FileSystemList() { FileSystemDock *FileSystemDock::singleton = nullptr; -Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, String p_file_type) { +Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, const String &p_file_type) { Ref<Texture2D> file_icon; if (!p_is_valid) { file_icon = get_editor_theme_icon(SNAME("ImportFail")); @@ -1678,7 +1678,7 @@ void FileSystemDock::_resource_removed(const Ref<Resource> &p_resource) { emit_signal(SNAME("resource_removed"), p_resource); } -void FileSystemDock::_file_removed(String p_file) { +void FileSystemDock::_file_removed(const String &p_file) { emit_signal(SNAME("file_removed"), p_file); // Find the closest parent directory available, in case multiple items were deleted along the same path. @@ -1691,7 +1691,7 @@ void FileSystemDock::_file_removed(String p_file) { current_path_line_edit->set_text(current_path); } -void FileSystemDock::_folder_removed(String p_folder) { +void FileSystemDock::_folder_removed(const String &p_folder) { emit_signal(SNAME("folder_removed"), p_folder); // Find the closest parent directory available, in case multiple items were deleted along the same path. @@ -2986,7 +2986,7 @@ void FileSystemDock::_folder_color_index_pressed(int p_index, PopupMenu *p_menu) _update_file_list(true); } -void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options) { +void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vector<String> &p_paths, bool p_display_path_dependent_options) { // Add options for files and folders. ERR_FAIL_COND_MSG(p_paths.is_empty(), "Path cannot be empty."); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index c9d2bc535e..06bf3eda52 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -64,7 +64,7 @@ class FileSystemList : public ItemList { LineEdit *line_editor = nullptr; virtual Control *make_custom_tooltip(const String &p_text) const override; - void _line_editor_submit(String p_text); + void _line_editor_submit(const String &p_text); void _text_editor_popup_modal_close(); protected: @@ -245,7 +245,7 @@ private: void _tree_mouse_exited(); void _reselect_items_selected_on_drag_begin(bool reset = false); - Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, String p_file_type); + Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, const String &p_file_type); bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false); void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false); @@ -281,8 +281,8 @@ private: void _update_folder_colors_setting(); void _resource_removed(const Ref<Resource> &p_resource); - void _file_removed(String p_file); - void _folder_removed(String p_folder); + void _file_removed(const String &p_file); + void _folder_removed(const String &p_folder); void _resource_created(); void _make_scene_confirm(); @@ -313,7 +313,7 @@ private: void _file_sort_popup(int p_id); void _folder_color_index_pressed(int p_index, PopupMenu *p_menu); - void _file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options = true); + void _file_and_folders_fill_popup(PopupMenu *p_popup, const Vector<String> &p_paths, bool p_display_path_dependent_options = true); void _tree_rmb_select(const Vector2 &p_pos, MouseButton p_button); void _file_list_item_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index); void _file_list_empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index c6087f5b13..6d690cf31b 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -55,7 +55,7 @@ inline void pop_back(T &container) { container.resize(container.size() - 1); } -static bool find_next(const String &line, String pattern, int from, bool match_case, bool whole_words, int &out_begin, int &out_end) { +static bool find_next(const String &line, const String &pattern, int from, bool match_case, bool whole_words, int &out_begin, int &out_end) { int end = from; while (true) { @@ -84,7 +84,7 @@ static bool find_next(const String &line, String pattern, int from, bool match_c //-------------------------------------------------------------------------------- -void FindInFiles::set_search_text(String p_pattern) { +void FindInFiles::set_search_text(const String &p_pattern) { _pattern = p_pattern; } @@ -96,7 +96,7 @@ void FindInFiles::set_match_case(bool p_match_case) { _match_case = p_match_case; } -void FindInFiles::set_folder(String folder) { +void FindInFiles::set_folder(const String &folder) { _root_dir = folder; } @@ -213,7 +213,7 @@ float FindInFiles::get_progress() const { return 0; } -void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan) { +void FindInFiles::_scan_dir(const String &path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan) { Ref<DirAccess> dir = DirAccess::open(path); if (dir.is_null()) { print_verbose("Cannot open directory! " + path); @@ -258,7 +258,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders, PackedS } } -void FindInFiles::_scan_file(String fpath) { +void FindInFiles::_scan_file(const String &fpath) { Ref<FileAccess> f = FileAccess::open(fpath, FileAccess::READ); if (f.is_null()) { print_verbose(String("Cannot open file ") + fpath); @@ -397,12 +397,12 @@ FindInFilesDialog::FindInFilesDialog() { _mode = SEARCH_MODE; } -void FindInFilesDialog::set_search_text(String text) { +void FindInFilesDialog::set_search_text(const String &text) { _search_text_line_edit->set_text(text); _on_search_text_modified(text); } -void FindInFilesDialog::set_replace_text(String text) { +void FindInFilesDialog::set_replace_text(const String &text) { _replace_text_line_edit->set_text(text); } @@ -505,7 +505,7 @@ void FindInFilesDialog::custom_action(const String &p_action) { } } -void FindInFilesDialog::_on_search_text_modified(String text) { +void FindInFilesDialog::_on_search_text_modified(const String &text) { ERR_FAIL_NULL(_find_button); ERR_FAIL_NULL(_replace_button); @@ -513,7 +513,7 @@ void FindInFilesDialog::_on_search_text_modified(String text) { _replace_button->set_disabled(get_search_text().is_empty()); } -void FindInFilesDialog::_on_search_text_submitted(String text) { +void FindInFilesDialog::_on_search_text_submitted(const String &text) { // This allows to trigger a global search without leaving the keyboard. if (!_find_button->is_disabled()) { if (_mode == SEARCH_MODE) { @@ -528,7 +528,7 @@ void FindInFilesDialog::_on_search_text_submitted(String text) { } } -void FindInFilesDialog::_on_replace_text_submitted(String text) { +void FindInFilesDialog::_on_replace_text_submitted(const String &text) { // This allows to trigger a global search without leaving the keyboard. if (!_replace_button->is_disabled()) { if (_mode == REPLACE_MODE) { @@ -653,7 +653,7 @@ void FindInFilesPanel::set_with_replace(bool with_replace) { } } -void FindInFilesPanel::set_replace_text(String text) { +void FindInFilesPanel::set_replace_text(const String &text) { _replace_line_edit->set_text(text); } @@ -710,7 +710,7 @@ void FindInFilesPanel::_notification(int p_what) { } } -void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin, int end, String text) { +void FindInFilesPanel::_on_result_found(const String &fpath, int line_number, int begin, int end, String text) { TreeItem *file_item; HashMap<String, TreeItem *>::Iterator E = _file_items.find(fpath); @@ -844,7 +844,7 @@ void FindInFilesPanel::_on_result_selected() { emit_signal(SNAME(SIGNAL_RESULT_SELECTED), fpath, r.line_number, r.begin, r.end); } -void FindInFilesPanel::_on_replace_text_changed(String text) { +void FindInFilesPanel::_on_replace_text_changed(const String &text) { update_replace_buttons(); } @@ -914,7 +914,7 @@ private: Vector<char> _line_buffer; }; -void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result> &locations, String new_text) { +void FindInFilesPanel::apply_replaces_in_file(const String &fpath, const Vector<Result> &locations, const String &new_text) { // If the file is already open, I assume the editor will reload it. // If there are unsaved changes, the user will be asked on focus, // however that means either losing changes or losing replaces. diff --git a/editor/find_in_files.h b/editor/find_in_files.h index fcf5dd6281..7885931514 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -42,10 +42,10 @@ public: static const char *SIGNAL_RESULT_FOUND; static const char *SIGNAL_FINISHED; - void set_search_text(String p_pattern); + void set_search_text(const String &p_pattern); void set_whole_words(bool p_whole_word); void set_match_case(bool p_match_case); - void set_folder(String folder); + void set_folder(const String &folder); void set_filter(const HashSet<String> &exts); String get_search_text() const { return _pattern; } @@ -67,8 +67,8 @@ protected: private: void _process(); void _iterate(); - void _scan_dir(String path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan); - void _scan_file(String fpath); + void _scan_dir(const String &path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan); + void _scan_file(const String &fpath); // Config String _pattern; @@ -105,8 +105,8 @@ public: FindInFilesDialog(); - void set_search_text(String text); - void set_replace_text(String text); + void set_search_text(const String &text); + void set_replace_text(const String &text); void set_find_in_files_mode(FindInFilesMode p_mode); @@ -127,9 +127,9 @@ protected: private: void _on_folder_button_pressed(); void _on_folder_selected(String path); - void _on_search_text_modified(String text); - void _on_search_text_submitted(String text); - void _on_replace_text_submitted(String text); + void _on_search_text_modified(const String &text); + void _on_search_text_submitted(const String &text); + void _on_replace_text_submitted(const String &text); FindInFilesMode _mode; LineEdit *_search_text_line_edit = nullptr; @@ -165,7 +165,7 @@ public: FindInFiles *get_finder() const { return _finder; } void set_with_replace(bool with_replace); - void set_replace_text(String text); + void set_replace_text(const String &text); void start_search(); void stop_search(); @@ -176,13 +176,13 @@ protected: void _notification(int p_what); private: - void _on_result_found(String fpath, int line_number, int begin, int end, String text); + void _on_result_found(const String &fpath, int line_number, int begin, int end, String text); void _on_finished(); void _on_refresh_button_clicked(); void _on_cancel_button_clicked(); void _on_result_selected(); void _on_item_edited(); - void _on_replace_text_changed(String text); + void _on_replace_text_changed(const String &text); void _on_replace_all_clicked(); struct Result { @@ -192,7 +192,7 @@ private: int begin_trimmed = 0; }; - void apply_replaces_in_file(String fpath, const Vector<Result> &locations, String new_text); + void apply_replaces_in_file(const String &fpath, const Vector<Result> &locations, const String &new_text); void update_replace_buttons(); String get_replace_text(); diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index 2dada25728..d0b78a35cf 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -86,6 +86,7 @@ void EditorFileDialog::_update_theme_item_cache() { theme_cache.mode_list = get_editor_theme_icon(SNAME("FileList")); theme_cache.favorites_up = get_editor_theme_icon(SNAME("MoveUp")); theme_cache.favorites_down = get_editor_theme_icon(SNAME("MoveDown")); + theme_cache.create_folder = get_editor_theme_icon(SNAME("FolderCreate")); theme_cache.folder = get_editor_theme_icon(SNAME("Folder")); theme_cache.folder_icon_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); @@ -287,7 +288,7 @@ void EditorFileDialog::update_dir() { } } -void EditorFileDialog::_dir_submitted(String p_dir) { +void EditorFileDialog::_dir_submitted(const String &p_dir) { dir_access->change_dir(p_dir); invalidate(); update_dir(); @@ -1328,6 +1329,7 @@ void EditorFileDialog::_update_icons() { refresh->set_icon(theme_cache.reload); favorite->set_icon(theme_cache.favorite); show_hidden->set_icon(theme_cache.toggle_hidden); + makedir->set_icon(theme_cache.create_folder); fav_up->set_icon(theme_cache.favorites_up); fav_down->set_icon(theme_cache.favorites_down); @@ -1875,8 +1877,11 @@ EditorFileDialog::EditorFileDialog() { drives->connect("item_selected", callable_mp(this, &EditorFileDialog::_select_drive)); pathhb->add_child(drives); + pathhb->add_child(memnew(VSeparator)); + makedir = memnew(Button); - makedir->set_text(TTR("Create Folder")); + makedir->set_theme_type_variation("FlatButton"); + makedir->set_tooltip_text(TTR("Create a new folder.")); makedir->connect("pressed", callable_mp(this, &EditorFileDialog::_make_dir)); pathhb->add_child(makedir); diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h index e0f53ace96..1e1c99bc76 100644 --- a/editor/gui/editor_file_dialog.h +++ b/editor/gui/editor_file_dialog.h @@ -155,6 +155,7 @@ private: Ref<Texture2D> favorite; Ref<Texture2D> mode_thumbnails; Ref<Texture2D> mode_list; + Ref<Texture2D> create_folder; Ref<Texture2D> favorites_up; Ref<Texture2D> favorites_down; @@ -199,7 +200,7 @@ private: void _item_menu_id_pressed(int p_option); void _select_drive(int p_idx); - void _dir_submitted(String p_dir); + void _dir_submitted(const String &p_dir); void _action_pressed(); void _save_confirm_pressed(); void _cancel_pressed(); diff --git a/editor/gui/editor_toaster.cpp b/editor/gui/editor_toaster.cpp index 69a129e73c..970bf4cb3e 100644 --- a/editor/gui/editor_toaster.cpp +++ b/editor/gui/editor_toaster.cpp @@ -342,7 +342,7 @@ void EditorToaster::_repop_old() { } } -Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_time, String p_tooltip) { +Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_time, const String &p_tooltip) { // Create the panel according to the severity. PanelContainer *panel = memnew(PanelContainer); panel->set_tooltip_text(p_tooltip); @@ -398,7 +398,7 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_ return panel; } -void EditorToaster::popup_str(String p_message, Severity p_severity, String p_tooltip) { +void EditorToaster::popup_str(const String &p_message, Severity p_severity, const String &p_tooltip) { if (is_processing_error) { return; } @@ -410,7 +410,7 @@ void EditorToaster::popup_str(String p_message, Severity p_severity, String p_to is_processing_error = false; } -void EditorToaster::_popup_str(String p_message, Severity p_severity, String p_tooltip) { +void EditorToaster::_popup_str(const String &p_message, Severity p_severity, const String &p_tooltip) { is_processing_error = true; // Check if we already have a popup with the given message. Control *control = nullptr; diff --git a/editor/gui/editor_toaster.h b/editor/gui/editor_toaster.h index 5034cb66fc..4bf32d94ba 100644 --- a/editor/gui/editor_toaster.h +++ b/editor/gui/editor_toaster.h @@ -100,7 +100,7 @@ private: void _set_notifications_enabled(bool p_enabled); void _repop_old(); - void _popup_str(String p_message, Severity p_severity, String p_tooltip); + void _popup_str(const String &p_message, Severity p_severity, const String &p_tooltip); void _close_button_theme_changed(Control *p_close_button); protected: @@ -111,8 +111,8 @@ protected: public: static EditorToaster *get_singleton(); - Control *popup(Control *p_control, Severity p_severity = SEVERITY_INFO, double p_time = 0.0, String p_tooltip = String()); - void popup_str(String p_message, Severity p_severity = SEVERITY_INFO, String p_tooltip = String()); + Control *popup(Control *p_control, Severity p_severity = SEVERITY_INFO, double p_time = 0.0, const String &p_tooltip = String()); + void popup_str(const String &p_message, Severity p_severity = SEVERITY_INFO, const String &p_tooltip = String()); void close(Control *p_control); EditorToaster(); diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index f54ded7c74..766566bf2b 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -750,7 +750,7 @@ bool SceneTreeEditor::_update_filter(TreeItem *p_parent, bool p_scroll_to_select return p_parent->is_visible(); } -bool SceneTreeEditor::_item_matches_all_terms(TreeItem *p_item, PackedStringArray p_terms) { +bool SceneTreeEditor::_item_matches_all_terms(TreeItem *p_item, const PackedStringArray &p_terms) { if (p_terms.is_empty()) { return true; } diff --git a/editor/gui/scene_tree_editor.h b/editor/gui/scene_tree_editor.h index 179050daeb..fe2396d438 100644 --- a/editor/gui/scene_tree_editor.h +++ b/editor/gui/scene_tree_editor.h @@ -79,7 +79,7 @@ class SceneTreeEditor : public Control { void _add_nodes(Node *p_node, TreeItem *p_parent); void _test_update_tree(); bool _update_filter(TreeItem *p_parent = nullptr, bool p_scroll_to_selected = false); - bool _item_matches_all_terms(TreeItem *p_item, PackedStringArray p_terms); + bool _item_matches_all_terms(TreeItem *p_item, const PackedStringArray &p_terms); void _tree_changed(); void _tree_process_mode_changed(); void _node_removed(Node *p_node); diff --git a/editor/icons/FolderCreate.svg b/editor/icons/FolderCreate.svg new file mode 100644 index 0000000000..80a3f90e2a --- /dev/null +++ b/editor/icons/FolderCreate.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M2 3a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8v-1H8v-4h2V8h4v2h1V7a1 1 0 0 0-1-1h-4a1 1 0 0 1-1-1V4a1 1 0 0 0-1-1Z" fill="#e0e0e0"/><path d="M13 13h2v-2h-2V9h-2v2H9v2h2v2h2z" fill="#5fff97"/></svg>
\ No newline at end of file diff --git a/editor/import/3d/collada.cpp b/editor/import/3d/collada.cpp index d484476b35..29c373be96 100644 --- a/editor/import/3d/collada.cpp +++ b/editor/import/3d/collada.cpp @@ -834,7 +834,7 @@ void Collada::_parse_light(XMLParser &p_parser) { COLLADA_PRINT("Light ID:" + id); } -void Collada::_parse_curve_geometry(XMLParser &p_parser, String p_id, String p_name) { +void Collada::_parse_curve_geometry(XMLParser &p_parser, const String &p_id, const String &p_name) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!p_parser.is_empty()) { p_parser.skip_section(); @@ -916,7 +916,7 @@ void Collada::_parse_curve_geometry(XMLParser &p_parser, String p_id, String p_n } } -void Collada::_parse_mesh_geometry(XMLParser &p_parser, String p_id, String p_name) { +void Collada::_parse_mesh_geometry(XMLParser &p_parser, const String &p_id, const String &p_name) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!p_parser.is_empty()) { p_parser.skip_section(); @@ -1070,7 +1070,7 @@ void Collada::_parse_mesh_geometry(XMLParser &p_parser, String p_id, String p_na } } -void Collada::_parse_skin_controller(XMLParser &p_parser, String p_id) { +void Collada::_parse_skin_controller(XMLParser &p_parser, const String &p_id) { state.skin_controller_data_map[p_id] = SkinControllerData(); SkinControllerData &skindata = state.skin_controller_data_map[p_id]; @@ -1224,7 +1224,7 @@ void Collada::_parse_skin_controller(XMLParser &p_parser, String p_id) { } } -void Collada::_parse_morph_controller(XMLParser &p_parser, String p_id) { +void Collada::_parse_morph_controller(XMLParser &p_parser, const String &p_id) { state.morph_controller_data_map[p_id] = MorphControllerData(); MorphControllerData &morphdata = state.morph_controller_data_map[p_id]; @@ -2311,7 +2311,7 @@ void Collada::_optimize() { } } -int Collada::get_uv_channel(String p_name) { +int Collada::get_uv_channel(const String &p_name) { if (!channel_map.has(p_name)) { ERR_FAIL_COND_V(channel_map.size() == 2, 0); diff --git a/editor/import/3d/collada.h b/editor/import/3d/collada.h index 7877b1e86d..416b917a46 100644 --- a/editor/import/3d/collada.h +++ b/editor/import/3d/collada.h @@ -521,7 +521,7 @@ public: Transform3D get_root_transform() const; - int get_uv_channel(String p_name); + int get_uv_channel(const String &p_name); private: // private stuff HashMap<String, int> channel_map; @@ -535,11 +535,11 @@ private: // private stuff void _parse_light(XMLParser &p_parser); void _parse_animation_clip(XMLParser &p_parser); - void _parse_mesh_geometry(XMLParser &p_parser, String p_id, String p_name); - void _parse_curve_geometry(XMLParser &p_parser, String p_id, String p_name); + void _parse_mesh_geometry(XMLParser &p_parser, const String &p_id, const String &p_name); + void _parse_curve_geometry(XMLParser &p_parser, const String &p_id, const String &p_name); - void _parse_skin_controller(XMLParser &p_parser, String p_id); - void _parse_morph_controller(XMLParser &p_parser, String p_id); + void _parse_skin_controller(XMLParser &p_parser, const String &p_id); + void _parse_morph_controller(XMLParser &p_parser, const String &p_id); void _parse_controller(XMLParser &p_parser); Node *_parse_visual_instance_geometry(XMLParser &p_parser); diff --git a/editor/import/3d/editor_import_collada.cpp b/editor/import/3d/editor_import_collada.cpp index b7dabf027b..58aa6a462d 100644 --- a/editor/import/3d/editor_import_collada.cpp +++ b/editor/import/3d/editor_import_collada.cpp @@ -88,7 +88,7 @@ struct ColladaImport { Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_material(const String &p_target); - Error _create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes = Vector<Ref<ImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); + Error _create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, const Vector<Ref<ImporterMesh>> &p_morph_meshes = Vector<Ref<ImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false); void _fix_param_animation_tracks(); void create_animation(int p_clip, bool p_import_value_tracks); @@ -467,7 +467,7 @@ Error ColladaImport::_create_material(const String &p_target) { return OK; } -Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { +Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p_mesh, const HashMap<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, const Vector<Ref<ImporterMesh>> &p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { bool local_xform_mirror = p_local_xform.basis.determinant() < 0; if (p_morph_data) { @@ -938,11 +938,11 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p if (binormal_src && tangent_src) { surftool->set_tangent(vertex_array[k].tangent); } else if (generate_dummy_tangents) { - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(vertex_array[k].normal); + Vector3 tan = Vector3(vertex_array[k].normal.z, -vertex_array[k].normal.x, vertex_array[k].normal.y).cross(vertex_array[k].normal.normalized()).normalized(); surftool->set_tangent(Plane(tan.x, tan.y, tan.z, 1.0)); } } else { - // No normals, use a dummy normal since normals will be generated. + // No normals, use a dummy tangent since normals will be generated. if (generate_dummy_tangents) { surftool->set_tangent(Plane(1.0, 0.0, 0.0, 1.0)); } @@ -1008,6 +1008,19 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p Array d = surftool->commit_to_arrays(); d.resize(RS::ARRAY_MAX); + if (mesh_flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && (generate_dummy_tangents || generate_tangents)) { + // Compression is enabled, so let's validate that the normals and tangents are correct. + Vector<Vector3> normals = d[Mesh::ARRAY_NORMAL]; + Vector<float> tangents = d[Mesh::ARRAY_TANGENT]; + for (int vert = 0; vert < normals.size(); vert++) { + Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]); + if (abs(tan.dot(normals[vert])) > 0.0001) { + // Tangent is not perpendicular to the normal, so we can't use compression. + mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; + } + } + } + Array mr; //////////////////////////// diff --git a/editor/import/3d/post_import_plugin_skeleton_rest_fixer.cpp b/editor/import/3d/post_import_plugin_skeleton_rest_fixer.cpp index 53bf24fb7e..d2318c0c69 100644 --- a/editor/import/3d/post_import_plugin_skeleton_rest_fixer.cpp +++ b/editor/import/3d/post_import_plugin_skeleton_rest_fixer.cpp @@ -42,6 +42,7 @@ void PostImportPluginSkeletonRestFixer::get_internal_import_options(InternalImpo r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "retarget/rest_fixer/apply_node_transforms"), true)); r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "retarget/rest_fixer/normalize_position_tracks"), true)); r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "retarget/rest_fixer/overwrite_axis"), true)); + r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "retarget/rest_fixer/reset_all_bone_poses_after_import"), true)); r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "retarget/rest_fixer/fix_silhouette/enable"), false)); // TODO: PostImportPlugin need to be implemented such as validate_option(PropertyInfo &property, const Dictionary &p_options). // get_internal_option_visibility() is not sufficient because it can only retrieve options implemented in the core and can only read option values. @@ -113,6 +114,10 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory Vector<int> bones_to_process = src_skeleton->get_parentless_bones(); for (int i = 0; i < bones_to_process.size(); i++) { src_skeleton->set_bone_rest(bones_to_process[i], global_transform.orthonormalized() * src_skeleton->get_bone_rest(bones_to_process[i])); + + src_skeleton->set_bone_pose_position(bones_to_process[i], global_transform.orthonormalized().xform(src_skeleton->get_bone_pose_position(bones_to_process[i]))); + src_skeleton->set_bone_pose_rotation(bones_to_process[i], global_transform.basis.get_rotation_quaternion() * src_skeleton->get_bone_pose_rotation(bones_to_process[i])); + src_skeleton->set_bone_pose_scale(bones_to_process[i], (global_transform.orthonormalized().basis * Basis().scaled(src_skeleton->get_bone_pose_scale((bones_to_process[i])))).get_scale()); } while (bones_to_process.size() > 0) { @@ -123,6 +128,7 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory bones_to_process.push_back(src_children[i]); } src_skeleton->set_bone_rest(src_idx, Transform3D(src_skeleton->get_bone_rest(src_idx).basis, src_skeleton->get_bone_rest(src_idx).origin * scl)); + src_skeleton->set_bone_pose_position(src_idx, src_skeleton->get_bone_pose_position(src_idx) * scl); } // Fix animation. @@ -603,6 +609,30 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory } } } + if (p_options.has("retarget/rest_fixer/reset_all_bone_poses_after_import") && !bool(p_options["retarget/rest_fixer/reset_all_bone_poses_after_import"])) { + // If Reset All Bone Poses After Import is disabled, preserve the original bone pose, adjusted for the new bone rolls. + for (int bone_idx = 0; bone_idx < src_skeleton->get_bone_count(); bone_idx++) { + Transform3D old_rest = old_skeleton_rest[bone_idx]; + Transform3D new_rest = src_skeleton->get_bone_rest(bone_idx); + Transform3D old_pg; + Transform3D new_pg; + int parent_idx = src_skeleton->get_bone_parent(bone_idx); + if (parent_idx >= 0) { + old_pg = old_skeleton_global_rest[parent_idx]; + new_pg = src_skeleton->get_bone_global_rest(parent_idx); + } + + Quaternion old_pg_q = old_pg.basis.get_rotation_quaternion(); + Quaternion new_pg_q = new_pg.basis.get_rotation_quaternion(); + Quaternion qt = src_skeleton->get_bone_pose_rotation(bone_idx); + src_skeleton->set_bone_pose_rotation(bone_idx, new_pg_q.inverse() * old_pg_q * qt * old_rest.basis.get_rotation_quaternion().inverse() * old_pg_q.inverse() * new_pg_q * new_rest.basis.get_rotation_quaternion()); + + Basis sc = Basis().scaled(src_skeleton->get_bone_pose_scale(bone_idx)); + src_skeleton->set_bone_pose_scale(bone_idx, (new_pg.basis.inverse() * old_pg.basis * sc * old_rest.basis.inverse() * old_pg.basis.inverse() * new_pg.basis * new_rest.basis).get_scale()); + Vector3 ps = src_skeleton->get_bone_pose_position(bone_idx); + src_skeleton->set_bone_pose_position(bone_idx, new_pg_q.xform_inv(old_pg_q.xform(ps - old_rest.origin)) + new_rest.origin); + } + } is_rest_changed = true; } @@ -669,12 +699,14 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory } } - // Init skeleton pose to new rest. - for (int i = 0; i < src_skeleton->get_bone_count(); i++) { - Transform3D fixed_rest = src_skeleton->get_bone_rest(i); - src_skeleton->set_bone_pose_position(i, fixed_rest.origin); - src_skeleton->set_bone_pose_rotation(i, fixed_rest.basis.get_rotation_quaternion()); - src_skeleton->set_bone_pose_scale(i, fixed_rest.basis.get_scale()); + if (!p_options.has("retarget/rest_fixer/reset_all_bone_poses_after_import") || bool(p_options["retarget/rest_fixer/reset_all_bone_poses_after_import"])) { + // Init skeleton pose to new rest. + for (int i = 0; i < src_skeleton->get_bone_count(); i++) { + Transform3D fixed_rest = src_skeleton->get_bone_rest(i); + src_skeleton->set_bone_pose_position(i, fixed_rest.origin); + src_skeleton->set_bone_pose_rotation(i, fixed_rest.basis.get_rotation_quaternion()); + src_skeleton->set_bone_pose_scale(i, fixed_rest.basis.get_scale()); + } } } diff --git a/editor/import/3d/resource_importer_obj.cpp b/editor/import/3d/resource_importer_obj.cpp index 52d1b45ac2..62643eaa25 100644 --- a/editor/import/3d/resource_importer_obj.cpp +++ b/editor/import/3d/resource_importer_obj.cpp @@ -329,11 +329,11 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes, surf_tool->set_normal(normals[norm]); if (generate_tangents && uvs.is_empty()) { // We can't generate tangents without UVs, so create dummy tangents. - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(normals[norm]); + Vector3 tan = Vector3(normals[norm].z, -normals[norm].x, normals[norm].y).cross(normals[norm].normalized()).normalized(); surf_tool->set_tangent(Plane(tan.x, tan.y, tan.z, 1.0)); } } else { - // No normals, use a dummy normal since normals will be generated. + // No normals, use a dummy tangent since normals and tangents will be generated. if (generate_tangents && uvs.is_empty()) { // We can't generate tangents without UVs, so create dummy tangents. surf_tool->set_tangent(Plane(1.0, 0.0, 0.0, 1.0)); @@ -415,6 +415,20 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes, mesh->set_surface_name(mesh->get_surface_count() - 1, current_group); } Array array = surf_tool->commit_to_arrays(); + + if (mesh_flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && generate_tangents) { + // Compression is enabled, so let's validate that the normals and tangents are correct. + Vector<Vector3> norms = array[Mesh::ARRAY_NORMAL]; + Vector<float> tangents = array[Mesh::ARRAY_TANGENT]; + for (int vert = 0; vert < norms.size(); vert++) { + Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]); + if (abs(tan.dot(norms[vert])) > 0.0001) { + // Tangent is not perpendicular to the normal, so we can't use compression. + mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; + } + } + } + mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, array, TypedArray<Array>(), Dictionary(), material, name, mesh_flags); print_verbose("OBJ: Added surface :" + mesh->get_surface_name(mesh->get_surface_count() - 1)); diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 3310d6f298..38977d11e0 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -156,11 +156,11 @@ Variant EditorScenePostImportPlugin::get_option_value(const StringName &p_name) } return Variant(); } -void EditorScenePostImportPlugin::add_import_option(const String &p_name, Variant p_default_value) { +void EditorScenePostImportPlugin::add_import_option(const String &p_name, const Variant &p_default_value) { ERR_FAIL_NULL_MSG(current_option_list, "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) { +void EditorScenePostImportPlugin::add_import_option_advanced(Variant::Type p_type, const String &p_name, const Variant &p_default_value, PropertyHint p_hint, const String &p_hint_string, int p_usage_flags) { ERR_FAIL_NULL_MSG(current_option_list, "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)); } @@ -1445,7 +1445,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap< return p_node; } -Ref<Animation> ResourceImporterScene::_save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, String p_save_to_path, bool p_keep_custom_tracks) { +Ref<Animation> ResourceImporterScene::_save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, const String &p_save_to_path, bool p_keep_custom_tracks) { if (!p_save_to_file || !p_save_to_path.is_resource_file()) { return anim; } @@ -1932,6 +1932,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/apply_root_scale"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/import_as_skeleton_bones"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/generate_lods"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/create_shadow_meshes"), true)); diff --git a/editor/import/3d/resource_importer_scene.h b/editor/import/3d/resource_importer_scene.h index dbf7794b61..2e682350bc 100644 --- a/editor/import/3d/resource_importer_scene.h +++ b/editor/import/3d/resource_importer_scene.h @@ -54,8 +54,8 @@ class EditorSceneFormatImporter : public RefCounted { protected: static void _bind_methods(); - Node *import_scene_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options); - Ref<Animation> import_animation_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options); + Node *import_scene_wrapper(const String &p_path, uint32_t p_flags, const Dictionary &p_options); + Ref<Animation> import_animation_wrapper(const String &p_path, uint32_t p_flags, const Dictionary &p_options); GDVIRTUAL0RC(uint32_t, _get_import_flags) GDVIRTUAL0RC(Vector<String>, _get_extensions) @@ -136,8 +136,8 @@ protected: 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); + void add_import_option(const String &p_name, const Variant &p_default_value); + void add_import_option_advanced(Variant::Type p_type, const String &p_name, const 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, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const; @@ -287,7 +287,7 @@ public: Node *_post_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, HashSet<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps, float p_applied_root_scale); Node *_post_fix_animations(Node *p_node, Node *p_root, const Dictionary &p_node_data, const Dictionary &p_animation_data, float p_animation_fps); - Ref<Animation> _save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, String p_save_to_path, bool p_keep_custom_tracks); + Ref<Animation> _save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, const String &p_save_to_path, bool p_keep_custom_tracks); void _create_slices(AnimationPlayer *ap, Ref<Animation> anim, const Array &p_clips, bool p_bake_all); void _optimize_animations(AnimationPlayer *anim, float p_max_vel_error, float p_max_ang_error, int p_prc_error); void _compress_animations(AnimationPlayer *anim, int p_page_size_kb); diff --git a/editor/import/3d/scene_import_settings.cpp b/editor/import/3d/scene_import_settings.cpp index aeff01fc85..f0de608cf5 100644 --- a/editor/import/3d/scene_import_settings.cpp +++ b/editor/import/3d/scene_import_settings.cpp @@ -432,6 +432,16 @@ void SceneImportSettingsDialog::_update_view_gizmos() { if (!is_visible()) { return; } + const HashMap<StringName, Variant> &main_settings = scene_import_settings_data->current; + if (main_settings.has("nodes/import_as_skeleton_bones")) { + bool new_import_as_skeleton = main_settings["nodes/import_as_skeleton_bones"]; + if (new_import_as_skeleton != previous_import_as_skeleton) { + previous_import_as_skeleton = new_import_as_skeleton; + _re_import(); + open_settings(base_path); + } + return; + } for (const KeyValue<String, NodeData> &e : node_map) { bool show_collider_view = false; if (e.value.settings.has(SNAME("generate/physics"))) { @@ -591,6 +601,7 @@ void SceneImportSettingsDialog::update_view() { void SceneImportSettingsDialog::open_settings(const String &p_path, bool p_for_animation) { if (scene) { + _cleanup(); memdelete(scene); scene = nullptr; } @@ -667,6 +678,10 @@ void SceneImportSettingsDialog::open_settings(const String &p_path, bool p_for_a first_aabb = false; } + const HashMap<StringName, Variant> &main_settings = scene_import_settings_data->current; + if (main_settings.has("nodes/import_as_skeleton_bones")) { + previous_import_as_skeleton = main_settings["nodes/import_as_skeleton_bones"]; + } popup_centered_ratio(); _update_view_gizmos(); _update_camera(); @@ -694,7 +709,7 @@ Node *SceneImportSettingsDialog::get_selected_node() { return node_map[selected_id].node; } -void SceneImportSettingsDialog::_select(Tree *p_from, String p_type, String p_id) { +void SceneImportSettingsDialog::_select(Tree *p_from, const String &p_type, const String &p_id) { selecting = true; scene_import_settings_data->hide_options = false; @@ -1137,6 +1152,7 @@ void SceneImportSettingsDialog::_re_import() { main_settings["_subresources"] = subresources; } + _cleanup(); // Prevent skeletons and other pointers from pointing to dangling references. EditorFileSystem::get_singleton()->reimport_file_with_custom_parameters(base_path, editing_animation ? "animation_library" : "scene", main_settings); } diff --git a/editor/import/3d/scene_import_settings.h b/editor/import/3d/scene_import_settings.h index 05682551b7..e1183dc5b0 100644 --- a/editor/import/3d/scene_import_settings.h +++ b/editor/import/3d/scene_import_settings.h @@ -96,6 +96,7 @@ class SceneImportSettingsDialog : public ConfirmationDialog { Button *animation_stop_button = nullptr; Animation::LoopMode animation_loop_mode = Animation::LOOP_NONE; bool animation_pingpong = false; + bool previous_import_as_skeleton = false; Ref<StandardMaterial3D> collider_mat; @@ -162,7 +163,7 @@ class SceneImportSettingsDialog : public ConfirmationDialog { void _update_view_gizmos(); void _update_camera(); - void _select(Tree *p_from, String p_type, String p_id); + void _select(Tree *p_from, const String &p_type, const String &p_id); void _inspector_property_edited(const String &p_name); void _reset_bone_transforms(); void _play_animation(); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 8a7eb80281..78ceb2ef6d 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -244,7 +244,7 @@ void InspectorDock::_load_resource(const String &p_type) { load_resource_dialog->popup_file_dialog(); } -void InspectorDock::_resource_file_selected(String p_file) { +void InspectorDock::_resource_file_selected(const String &p_file) { Ref<Resource> res; if (ResourceLoader::exists(p_file, "")) { res = ResourceLoader::load(p_file); diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 1ad4b52b7d..60ce8100aa 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -114,7 +114,7 @@ class InspectorDock : public VBoxContainer { void _new_resource(); void _load_resource(const String &p_type = ""); void _open_resource_selector() { _load_resource(); }; // just used to call from arg-less signal - void _resource_file_selected(String p_file); + void _resource_file_selected(const String &p_file); void _save_resource(bool save_as); void _unref_resource(); void _copy_resource(); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 2c86314ae2..e7a1d2735e 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -233,7 +233,7 @@ void AbstractPolygon2DEditor::_wip_close() { selected_point = Vertex(); } -void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_reason) { +void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, const String &p_reason) { _polygon_editing_enabled = !p_disable; button_create->set_disabled(p_disable); @@ -766,7 +766,7 @@ void AbstractPolygon2DEditorPlugin::make_visible(bool p_visible) { } } -AbstractPolygon2DEditorPlugin::AbstractPolygon2DEditorPlugin(AbstractPolygon2DEditor *p_polygon_editor, String p_class) : +AbstractPolygon2DEditorPlugin::AbstractPolygon2DEditorPlugin(AbstractPolygon2DEditor *p_polygon_editor, const String &p_class) : polygon_editor(p_polygon_editor), klass(p_class) { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(polygon_editor); diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index 31c20ac146..25b2e2603e 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -137,7 +137,7 @@ protected: virtual void _create_resource(); public: - void disable_polygon_editing(bool p_disable, String p_reason); + void disable_polygon_editing(bool p_disable, const String &p_reason); bool forward_gui_input(const Ref<InputEvent> &p_event); void forward_canvas_draw_over_viewport(Control *p_overlay); @@ -162,7 +162,7 @@ public: virtual bool handles(Object *p_object) const override; virtual void make_visible(bool p_visible) override; - AbstractPolygon2DEditorPlugin(AbstractPolygon2DEditor *p_polygon_editor, String p_class); + AbstractPolygon2DEditorPlugin(AbstractPolygon2DEditor *p_polygon_editor, const String &p_class); ~AbstractPolygon2DEditorPlugin(); }; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 22813124d0..0412141775 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -494,7 +494,7 @@ void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from, updating = false; } -void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, const String &p_node) { +void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, const Array &p_options, const String &p_node) { String option = p_options[p_index]; Ref<AnimationNodeAnimation> anim = blend_tree->get_node(p_node); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index 690b127938..ee6f087e07 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -111,7 +111,7 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _scroll_changed(const Vector2 &p_scroll); void _node_selected(Object *p_node); void _open_in_editor(const String &p_which); - void _anim_selected(int p_index, Array p_options, const String &p_node); + void _anim_selected(int p_index, const Array &p_options, const String &p_node); void _delete_node_request(const String &p_which); void _delete_nodes_request(const TypedArray<StringName> &p_nodes); diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index 58b1dbde8a..2af3811863 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -300,7 +300,7 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { } } -void AnimationLibraryEditor::_load_file(String p_path) { +void AnimationLibraryEditor::_load_file(const String &p_path) { switch (file_dialog_action) { case FILE_DIALOG_ACTION_SAVE_LIBRARY: { Ref<AnimationLibrary> al = mixer->get_animation_library(file_dialog_library); diff --git a/editor/plugins/animation_library_editor.h b/editor/plugins/animation_library_editor.h index c003e9a10b..a268e68932 100644 --- a/editor/plugins/animation_library_editor.h +++ b/editor/plugins/animation_library_editor.h @@ -100,7 +100,7 @@ class AnimationLibraryEditor : public AcceptDialog { void _add_library_validate(const String &p_name); void _add_library_confirm(); void _load_library(); - void _load_file(String p_path); + void _load_file(const String &p_path); void _load_files(const PackedStringArray &p_paths); void _item_renamed(); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 6b8943ee84..dbfb143b22 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1184,7 +1184,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { state_machine_play_pos->queue_redraw(); } -void AnimationNodeStateMachineEditor::_state_machine_pos_draw_individual(String p_name, float p_ratio) { +void AnimationNodeStateMachineEditor::_state_machine_pos_draw_individual(const String &p_name, float p_ratio) { AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree(); if (!tree) { return; diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 949fa84bce..860d0ed35d 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -134,7 +134,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { void _state_machine_draw(); - void _state_machine_pos_draw_individual(String p_name, float p_ratio); + void _state_machine_pos_draw_individual(const String &p_name, float p_ratio); void _state_machine_pos_draw_all(); void _update_graph(); diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp index e2ad69ac15..9c76b86d6a 100644 --- a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp +++ b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp @@ -43,7 +43,7 @@ bool AudioStreamRandomizerEditorPlugin::handles(Object *p_object) const { void AudioStreamRandomizerEditorPlugin::make_visible(bool p_visible) { } -void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { +void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos) { EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); ERR_FAIL_NULL(undo_redo_man); diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.h b/editor/plugins/audio_stream_randomizer_editor_plugin.h index 72cdaeee30..535ab4114b 100644 --- a/editor/plugins/audio_stream_randomizer_editor_plugin.h +++ b/editor/plugins/audio_stream_randomizer_editor_plugin.h @@ -38,7 +38,7 @@ class AudioStreamRandomizerEditorPlugin : public EditorPlugin { GDCLASS(AudioStreamRandomizerEditorPlugin, EditorPlugin); private: - void _move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos); + void _move_stream_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos); public: virtual String get_name() const override { return "AudioStreamRandomizer"; } diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp index 3256b90aba..d8c020eb29 100644 --- a/editor/plugins/bone_map_editor_plugin.cpp +++ b/editor/plugins/bone_map_editor_plugin.cpp @@ -136,7 +136,7 @@ void BoneMapperItem::_open_picker() { emit_signal(SNAME("pick"), profile_bone_name); } -void BoneMapperItem::_value_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void BoneMapperItem::_value_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { bone_map->set(p_property, p_value); } @@ -534,12 +534,12 @@ void BoneMapper::_clear_mapping_current_group() { } #ifdef MODULE_REGEX_ENABLED -bool BoneMapper::is_match_with_bone_name(String p_bone_name, String p_word) { +bool BoneMapper::is_match_with_bone_name(const String &p_bone_name, const String &p_word) { RegEx re = RegEx(p_word); return !re.search(p_bone_name.to_lower()).is_null(); } -int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_picklist, BoneSegregation p_segregation, int p_parent, int p_child, int p_children_count) { +int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, const Vector<String> &p_picklist, BoneSegregation p_segregation, int p_parent, int p_child, int p_children_count) { // There may be multiple candidates hit by existing the subsidiary bone. // The one with the shortest name is probably the original. LocalVector<String> hit_list; @@ -617,7 +617,7 @@ int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_pic return skeleton->find_bone(shortest); } -BoneMapper::BoneSegregation BoneMapper::guess_bone_segregation(String p_bone_name) { +BoneMapper::BoneSegregation BoneMapper::guess_bone_segregation(const String &p_bone_name) { String fixed_bn = p_bone_name.to_snake_case(); LocalVector<String> left_words; @@ -1279,12 +1279,12 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) { } #endif // MODULE_REGEX_ENABLED -void BoneMapper::_value_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void BoneMapper::_value_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { set(p_property, p_value); recreate_editor(); } -void BoneMapper::_profile_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void BoneMapper::_profile_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { bone_map->set(p_property, p_value); // Run auto mapping when setting SkeletonProfileHumanoid by GUI Editor. diff --git a/editor/plugins/bone_map_editor_plugin.h b/editor/plugins/bone_map_editor_plugin.h index 9479ed3730..2e7d1ff124 100644 --- a/editor/plugins/bone_map_editor_plugin.h +++ b/editor/plugins/bone_map_editor_plugin.h @@ -99,7 +99,7 @@ class BoneMapperItem : public VBoxContainer { protected: void _notification(int p_what); static void _bind_methods(); - virtual void _value_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing); + virtual void _value_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing); virtual void create_editor(); public: @@ -179,9 +179,9 @@ class BoneMapper : public VBoxContainer { BONE_SEGREGATION_LEFT, BONE_SEGREGATION_RIGHT }; - bool is_match_with_bone_name(String p_bone_name, String p_word); - int search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_picklist, BoneSegregation p_segregation = BONE_SEGREGATION_NONE, int p_parent = -1, int p_child = -1, int p_children_count = -1); - BoneSegregation guess_bone_segregation(String p_bone_name); + bool is_match_with_bone_name(const String &p_bone_name, const String &p_word); + int search_bone_by_name(Skeleton3D *p_skeleton, const Vector<String> &p_picklist, BoneSegregation p_segregation = BONE_SEGREGATION_NONE, int p_parent = -1, int p_child = -1, int p_children_count = -1); + BoneSegregation guess_bone_segregation(const String &p_bone_name); void auto_mapping_process(Ref<BoneMap> &p_bone_map); void _run_auto_mapping(); #endif // MODULE_REGEX_ENABLED @@ -189,8 +189,8 @@ class BoneMapper : public VBoxContainer { protected: void _notification(int p_what); static void _bind_methods(); - virtual void _value_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing); - virtual void _profile_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing); + virtual void _value_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing); + virtual void _profile_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing); public: void set_current_group_idx(int p_group_idx); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3bcc316f84..7446857582 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -861,7 +861,7 @@ void CanvasItemEditor::_restore_canvas_item_state(const List<CanvasItem *> &p_ca } } -void CanvasItemEditor::_commit_canvas_item_state(const List<CanvasItem *> &p_canvas_items, String action_name, bool commit_bones) { +void CanvasItemEditor::_commit_canvas_item_state(const List<CanvasItem *> &p_canvas_items, const String &action_name, bool commit_bones) { List<CanvasItem *> modified_canvas_items; for (CanvasItem *ci : p_canvas_items) { Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci)->undo_state; @@ -2708,7 +2708,7 @@ Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) con return c; } -void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) { +void CanvasItemEditor::_draw_text_at_position(Point2 p_position, const String &p_string, Side p_side) { Color color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)); color.a = 0.8; Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); @@ -3684,65 +3684,63 @@ void CanvasItemEditor::_draw_hover() { } } -void CanvasItemEditor::_draw_transform_message() { - if (drag_type == DRAG_NONE || drag_selection.is_empty() || !drag_selection.front()->get()) { - return; - } - String transform_message; - Transform2D current_transform = drag_selection.front()->get()->get_global_transform(); +void CanvasItemEditor::_draw_message() { + if (drag_type != DRAG_NONE && !drag_selection.is_empty() && drag_selection.front()->get()) { + Transform2D current_transform = drag_selection.front()->get()->get_global_transform(); - double snap = EDITOR_GET("interface/inspector/default_float_step"); - int snap_step_decimals = Math::range_step_decimals(snap); + double snap = EDITOR_GET("interface/inspector/default_float_step"); + int snap_step_decimals = Math::range_step_decimals(snap); #define FORMAT(value) (TS->format_number(String::num(value, snap_step_decimals))) - switch (drag_type) { - case DRAG_MOVE: - case DRAG_MOVE_X: - case DRAG_MOVE_Y: { - Vector2 delta = current_transform.get_origin() - original_transform.get_origin(); - if (drag_type == DRAG_MOVE) { - transform_message = TTR("Moving:") + " (" + FORMAT(delta.x) + ", " + FORMAT(delta.y) + ") px"; - } else if (drag_type == DRAG_MOVE_X) { - transform_message = TTR("Moving:") + " " + FORMAT(delta.x) + " px"; - } else if (drag_type == DRAG_MOVE_Y) { - transform_message = TTR("Moving:") + " " + FORMAT(delta.y) + " px"; - } - } break; - - case DRAG_ROTATE: { - real_t delta = Math::rad_to_deg(current_transform.get_rotation() - original_transform.get_rotation()); - transform_message = TTR("Rotating:") + " " + FORMAT(delta) + String::utf8(" °"); - } break; - - case DRAG_SCALE_X: - case DRAG_SCALE_Y: - case DRAG_SCALE_BOTH: { - Vector2 original_scale = (Math::is_zero_approx(original_transform.get_scale().x) || Math::is_zero_approx(original_transform.get_scale().y)) ? Vector2(CMP_EPSILON, CMP_EPSILON) : original_transform.get_scale(); - Vector2 delta = current_transform.get_scale() / original_scale; - if (drag_type == DRAG_SCALE_BOTH) { - transform_message = TTR("Scaling:") + String::utf8(" ×(") + FORMAT(delta.x) + ", " + FORMAT(delta.y) + ")"; - } else if (drag_type == DRAG_SCALE_X) { - transform_message = TTR("Scaling:") + String::utf8(" ×") + FORMAT(delta.x); - } else if (drag_type == DRAG_SCALE_Y) { - transform_message = TTR("Scaling:") + String::utf8(" ×") + FORMAT(delta.y); - } - } break; + switch (drag_type) { + case DRAG_MOVE: + case DRAG_MOVE_X: + case DRAG_MOVE_Y: { + Vector2 delta = current_transform.get_origin() - original_transform.get_origin(); + if (drag_type == DRAG_MOVE) { + message = TTR("Moving:") + " (" + FORMAT(delta.x) + ", " + FORMAT(delta.y) + ") px"; + } else if (drag_type == DRAG_MOVE_X) { + message = TTR("Moving:") + " " + FORMAT(delta.x) + " px"; + } else if (drag_type == DRAG_MOVE_Y) { + message = TTR("Moving:") + " " + FORMAT(delta.y) + " px"; + } + } break; + + case DRAG_ROTATE: { + real_t delta = Math::rad_to_deg(current_transform.get_rotation() - original_transform.get_rotation()); + message = TTR("Rotating:") + " " + FORMAT(delta) + String::utf8(" °"); + } break; + + case DRAG_SCALE_X: + case DRAG_SCALE_Y: + case DRAG_SCALE_BOTH: { + Vector2 original_scale = (Math::is_zero_approx(original_transform.get_scale().x) || Math::is_zero_approx(original_transform.get_scale().y)) ? Vector2(CMP_EPSILON, CMP_EPSILON) : original_transform.get_scale(); + Vector2 delta = current_transform.get_scale() / original_scale; + if (drag_type == DRAG_SCALE_BOTH) { + message = TTR("Scaling:") + String::utf8(" ×(") + FORMAT(delta.x) + ", " + FORMAT(delta.y) + ")"; + } else if (drag_type == DRAG_SCALE_X) { + message = TTR("Scaling:") + String::utf8(" ×") + FORMAT(delta.x); + } else if (drag_type == DRAG_SCALE_Y) { + message = TTR("Scaling:") + String::utf8(" ×") + FORMAT(delta.y); + } + } break; - default: - break; - } + default: + break; + } #undef FORMAT + } - if (transform_message.is_empty()) { + if (message.is_empty()) { return; } Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Point2 msgpos = Point2(RULER_WIDTH + 5 * EDSCALE, viewport->get_size().y - 20 * EDSCALE); - viewport->draw_string(font, msgpos + Point2(1, 1), transform_message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); - viewport->draw_string(font, msgpos + Point2(-1, -1), transform_message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); - viewport->draw_string(font, msgpos, transform_message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 1)); + viewport->draw_string(font, msgpos + Point2(1, 1), message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); + viewport->draw_string(font, msgpos + Point2(-1, -1), message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); + viewport->draw_string(font, msgpos, message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 1)); } void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) { @@ -3856,7 +3854,7 @@ void CanvasItemEditor::_draw_viewport() { _draw_smart_snapping(); _draw_focus(); _draw_hover(); - _draw_transform_message(); + _draw_message(); } void CanvasItemEditor::update_viewport() { @@ -4740,6 +4738,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { } void CanvasItemEditor::_reset_drag() { + message = ""; drag_type = DRAG_NONE; drag_selection.clear(); } @@ -5693,6 +5692,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons void CanvasItemEditorViewport::_remove_preview() { if (preview_node->get_parent()) { + canvas_item_editor->message = ""; for (int i = preview_node->get_child_count() - 1; i >= 0; i--) { Node *node = preview_node->get_child(i); node->queue_free(); @@ -5938,7 +5938,19 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian } Transform2D trans = canvas_item_editor->get_canvas_transform(); preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x); - label->set_text(vformat(TTR("Adding %s..."), default_texture_node_type)); + String scene_file_path = preview_node->get_child(0)->get_scene_file_path(); + if (scene_file_path.is_empty() || preview_node->get_tree()->get_edited_scene_root()) { + double snap = EDITOR_GET("interface/inspector/default_float_step"); + int snap_step_decimals = Math::range_step_decimals(snap); +#define FORMAT(value) (TS->format_number(String::num(value, snap_step_decimals))) + Vector2 preview_node_pos = preview_node->get_global_position(); + canvas_item_editor->message = TTR("Instantiating:") + " (" + FORMAT(preview_node_pos.x) + ", " + FORMAT(preview_node_pos.y) + ") px"; + label->set_text(vformat(TTR("Adding %s..."), default_texture_node_type)); + } else { + canvas_item_editor->message = TTR("Creating inherited scene from: ") + scene_file_path; + } + + canvas_item_editor->update_viewport(); } return can_instantiate; } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index bf36b6ec1d..4e160dde47 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -394,7 +394,7 @@ private: void _save_canvas_item_state(const List<CanvasItem *> &p_canvas_items, bool save_bones = false); void _restore_canvas_item_state(const List<CanvasItem *> &p_canvas_items, bool restore_bones = false); - void _commit_canvas_item_state(const List<CanvasItem *> &p_canvas_items, String action_name, bool commit_bones = false); + void _commit_canvas_item_state(const List<CanvasItem *> &p_canvas_items, const String &action_name, bool commit_bones = false); Vector2 _anchor_to_position(const Control *p_control, Vector2 anchor); Vector2 _position_to_anchor(const Control *p_control, Vector2 position); @@ -440,7 +440,7 @@ private: virtual void shortcut_input(const Ref<InputEvent> &p_ev) override; - void _draw_text_at_position(Point2 p_position, String p_string, Side p_side); + void _draw_text_at_position(Point2 p_position, const String &p_string, Side p_side); void _draw_margin_at_position(int p_value, Point2 p_position, Side p_side); void _draw_percentage_at_position(real_t p_value, Point2 p_position, Side p_side); void _draw_straight_line(Point2 p_from, Point2 p_to, Color p_color); @@ -458,7 +458,7 @@ private: void _draw_invisible_nodes_positions(Node *p_node, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D()); void _draw_locks_and_groups(Node *p_node, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D()); void _draw_hover(); - void _draw_transform_message(); + void _draw_message(); void _draw_viewport(); @@ -544,6 +544,8 @@ public: SNAP_DEFAULT = SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL, }; + String message; + Point2 snap_point(Point2 p_target, unsigned int p_modes = SNAP_DEFAULT, unsigned int p_forced_modes = 0, const CanvasItem *p_self_canvas_item = nullptr, const List<CanvasItem *> &p_other_nodes_exceptions = List<CanvasItem *>()); real_t snap_angle(real_t p_target, real_t p_start = 0) const; diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp index 9f495d5cd2..af9ff5056a 100644 --- a/editor/plugins/editor_debugger_plugin.cpp +++ b/editor/plugins/editor_debugger_plugin.cpp @@ -32,7 +32,7 @@ #include "editor/debugger/script_editor_debugger.h" -void EditorDebuggerSession::_breaked(bool p_really_did, bool p_can_debug, String p_message, bool p_has_stackdump) { +void EditorDebuggerSession::_breaked(bool p_really_did, bool p_can_debug, const String &p_message, bool p_has_stackdump) { if (p_really_did) { emit_signal(SNAME("breaked"), p_can_debug); } else { diff --git a/editor/plugins/editor_debugger_plugin.h b/editor/plugins/editor_debugger_plugin.h index 10c0e29f6e..41f34f67cf 100644 --- a/editor/plugins/editor_debugger_plugin.h +++ b/editor/plugins/editor_debugger_plugin.h @@ -43,7 +43,7 @@ private: ScriptEditorDebugger *debugger = nullptr; - void _breaked(bool p_really_did, bool p_can_debug, String p_message, bool p_has_stackdump); + void _breaked(bool p_really_did, bool p_can_debug, const String &p_message, bool p_has_stackdump); void _started(); void _stopped(); void _debugger_gone_away(); diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index f9b5e280c9..4011d36456 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -163,7 +163,7 @@ void EditorPropertyFontMetaOverride::_notification(int p_what) { } } -void EditorPropertyFontMetaOverride::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void EditorPropertyFontMetaOverride::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { if (p_property.begins_with("keys")) { Dictionary dict = object->get_dict(); String key = p_property.get_slice("/", 1); @@ -391,7 +391,7 @@ void EditorPropertyOTVariation::_notification(int p_what) { } } -void EditorPropertyOTVariation::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void EditorPropertyOTVariation::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { if (p_property.begins_with("keys")) { Dictionary dict = object->get_dict(); Dictionary defaults_dict = object->get_defaults(); @@ -559,7 +559,7 @@ void EditorPropertyOTFeatures::_notification(int p_what) { } } -void EditorPropertyOTFeatures::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void EditorPropertyOTFeatures::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { if (p_property.begins_with("keys")) { Dictionary dict = object->get_dict(); int key = p_property.get_slice("/", 1).to_int(); diff --git a/editor/plugins/font_config_plugin.h b/editor/plugins/font_config_plugin.h index 6cea5967b2..dc17a7717e 100644 --- a/editor/plugins/font_config_plugin.h +++ b/editor/plugins/font_config_plugin.h @@ -108,7 +108,7 @@ protected: void _edit_pressed(); void _page_changed(int p_page); - void _property_changed(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false); + void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false); void _remove(Object *p_button, const String &p_key); void _add_menu(); void _add_script(int p_option); @@ -144,7 +144,7 @@ protected: void _edit_pressed(); void _page_changed(int p_page); - void _property_changed(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false); + void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false); void _object_id_selected(const StringName &p_property, ObjectID p_id); public: @@ -193,7 +193,7 @@ protected: void _edit_pressed(); void _page_changed(int p_page); - void _property_changed(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false); + void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false); void _remove(Object *p_button, int p_key); void _add_menu(); void _add_feature(int p_option); diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h index c56591cc3a..28080ed559 100644 --- a/editor/plugins/gdextension_export_plugin.h +++ b/editor/plugins/gdextension_export_plugin.h @@ -93,7 +93,7 @@ void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p for (const String &arch_tag : archs) { PackedStringArray tags; String library_path = GDExtension::find_extension_library( - p_path, config, [features_wo_arch, arch_tag](String p_feature) { return features_wo_arch.has(p_feature) || (p_feature == arch_tag); }, &tags); + p_path, config, [features_wo_arch, arch_tag](const String &p_feature) { return features_wo_arch.has(p_feature) || (p_feature == arch_tag); }, &tags); if (libs_added.has(library_path)) { continue; // Universal library, already added for another arch, do not duplicate. } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index ba64c85b37..d3a0d56ec9 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -303,7 +303,7 @@ void EditorInspectorPluginMaterial::parse_begin(Object *p_object) { add_custom_control(editor); } -void EditorInspectorPluginMaterial::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { +void EditorInspectorPluginMaterial::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value) { EditorUndoRedoManager *undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); ERR_FAIL_NULL(undo_redo); diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 5d79d94aaf..c60de1ade9 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -110,7 +110,7 @@ public: virtual bool can_handle(Object *p_object) override; virtual void parse_begin(Object *p_object) override; - void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value); + void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value); EditorInspectorPluginMaterial(); }; diff --git a/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp b/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp index 5118f1d458..869f5b3b10 100644 --- a/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp +++ b/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp @@ -348,7 +348,7 @@ PackedVector2Array NavigationObstacle3DEditor::_get_polygon() { return PackedVector2Array(obstacle_node->call("get_polygon")); } -void NavigationObstacle3DEditor::_set_polygon(PackedVector2Array p_poly) { +void NavigationObstacle3DEditor::_set_polygon(const PackedVector2Array &p_poly) { ERR_FAIL_NULL_MSG(obstacle_node, "Edited object is not valid."); obstacle_node->call("set_polygon", p_poly); } diff --git a/editor/plugins/navigation_obstacle_3d_editor_plugin.h b/editor/plugins/navigation_obstacle_3d_editor_plugin.h index 1b125873d1..175fc75612 100644 --- a/editor/plugins/navigation_obstacle_3d_editor_plugin.h +++ b/editor/plugins/navigation_obstacle_3d_editor_plugin.h @@ -82,7 +82,7 @@ class NavigationObstacle3DEditor : public HBoxContainer { void _menu_option(int p_option); PackedVector2Array _get_polygon(); - void _set_polygon(PackedVector2Array p_poly); + void _set_polygon(const PackedVector2Array &p_poly); protected: void _notification(int p_what); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 4e462cfe34..26e33f5796 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2663,7 +2663,7 @@ void Node3DEditorViewport::_update_freelook(real_t delta) { cursor.eye_pos += motion; } -void Node3DEditorViewport::set_message(String p_message, float p_time) { +void Node3DEditorViewport::set_message(const String &p_message, float p_time) { message = p_message; message_time = p_time; } @@ -2972,6 +2972,10 @@ void Node3DEditorViewport::_notification(int p_what) { } if (preview_node->is_inside_tree()) { preview_node_pos = spatial_editor->snap_point(_get_instance_position(preview_node_viewport_pos)); + double snap = EDITOR_GET("interface/inspector/default_float_step"); + int snap_step_decimals = Math::range_step_decimals(snap); + set_message(TTR("Instantiating:") + " (" + String::num(preview_node_pos.x, snap_step_decimals) + ", " + + String::num(preview_node_pos.y, snap_step_decimals) + ", " + String::num(preview_node_pos.z, snap_step_decimals) + ")"); Transform3D preview_gl_transform = Transform3D(Basis(), preview_node_pos); preview_node->set_global_transform(preview_gl_transform); if (!preview_node->is_visible()) { @@ -4213,6 +4217,7 @@ void Node3DEditorViewport::_create_preview_node(const Vector<String> &files) con } void Node3DEditorViewport::_remove_preview_node() { + set_message(""); if (preview_node->get_parent()) { for (int i = preview_node->get_child_count() - 1; i >= 0; i--) { Node *node = preview_node->get_child(i); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 003d462552..13b51289a9 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -400,7 +400,7 @@ private: String message; double message_time; - void set_message(String p_message, float p_time = 5); + void set_message(const String &p_message, float p_time = 5); void _view_settings_confirmed(real_t p_interp_delta); void _update_camera(real_t p_interp_delta); diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp index 2ea251c455..da84afc4d7 100644 --- a/editor/plugins/polygon_3d_editor_plugin.cpp +++ b/editor/plugins/polygon_3d_editor_plugin.cpp @@ -364,7 +364,7 @@ PackedVector2Array Polygon3DEditor::_get_polygon() { return PackedVector2Array(obj->call("get_polygon")); } -void Polygon3DEditor::_set_polygon(PackedVector2Array p_poly) { +void Polygon3DEditor::_set_polygon(const PackedVector2Array &p_poly) { Object *obj = node_resource.is_valid() ? (Object *)node_resource.ptr() : node; ERR_FAIL_NULL_MSG(obj, "Edited object is not valid."); obj->call("set_polygon", p_poly); diff --git a/editor/plugins/polygon_3d_editor_plugin.h b/editor/plugins/polygon_3d_editor_plugin.h index 6cb9275dd6..6407e33f48 100644 --- a/editor/plugins/polygon_3d_editor_plugin.h +++ b/editor/plugins/polygon_3d_editor_plugin.h @@ -82,7 +82,7 @@ class Polygon3DEditor : public HBoxContainer { float _get_depth(); PackedVector2Array _get_polygon(); - void _set_polygon(PackedVector2Array p_poly); + void _set_polygon(const PackedVector2Array &p_poly); protected: void _notification(int p_what); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d639121ae0..5ff8cd17ea 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -60,6 +60,7 @@ #include "editor/plugins/shader_editor_plugin.h" #include "editor/plugins/text_shader_editor.h" #include "editor/themes/editor_scale.h" +#include "editor/themes/editor_theme_manager.h" #include "editor/window_wrapper.h" #include "scene/main/node.h" #include "scene/main/window.h" @@ -696,7 +697,7 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_help_overview_visibility(); } -void ScriptEditor::_add_recent_script(String p_path) { +void ScriptEditor::_add_recent_script(const String &p_path) { if (p_path.is_empty()) { return; } @@ -790,7 +791,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { _show_error_dialog(path); } -void ScriptEditor::_show_error_dialog(String p_path) { +void ScriptEditor::_show_error_dialog(const String &p_path) { error_dialog->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_path)); error_dialog->popup_centered(); } @@ -1109,7 +1110,7 @@ bool ScriptEditor::_test_script_times_on_disk(Ref<Resource> p_for_script) { return need_reload; } -void ScriptEditor::_file_dialog_action(String p_file) { +void ScriptEditor::_file_dialog_action(const String &p_file) { switch (file_dialog_option) { case FILE_NEW_TEXTFILE: { Error err; @@ -2784,7 +2785,8 @@ void ScriptEditor::_save_layout() { } void ScriptEditor::_editor_settings_changed() { - if (!EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor") && + if (!EditorThemeManager::is_generated_theme_outdated() && + !EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor") && !EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor") && !EditorSettings::get_singleton()->check_changed_settings_in_group("docks/filesystem")) { return; @@ -3628,7 +3630,7 @@ void ScriptEditor::set_live_auto_reload_running_scripts(bool p_enabled) { auto_reload_running_scripts = p_enabled; } -void ScriptEditor::_help_search(String p_text) { +void ScriptEditor::_help_search(const String &p_text) { help_search_dialog->popup_dialog(p_text); } @@ -3679,20 +3681,20 @@ void ScriptEditor::_script_changed() { NodeDock::get_singleton()->update_lists(); } -void ScriptEditor::_on_find_in_files_requested(String text) { +void ScriptEditor::_on_find_in_files_requested(const String &text) { find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::SEARCH_MODE); find_in_files_dialog->set_search_text(text); find_in_files_dialog->popup_centered(); } -void ScriptEditor::_on_replace_in_files_requested(String text) { +void ScriptEditor::_on_replace_in_files_requested(const String &text) { find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::REPLACE_MODE); find_in_files_dialog->set_search_text(text); find_in_files_dialog->set_replace_text(""); find_in_files_dialog->popup_centered(); } -void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) { +void ScriptEditor::_on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end) { if (ResourceLoader::exists(fpath)) { Ref<Resource> res = ResourceLoader::load(fpath); @@ -3814,7 +3816,7 @@ void ScriptEditor::_start_find_in_files(bool with_replace) { EditorNode::get_bottom_panel()->make_item_visible(find_in_files); } -void ScriptEditor::_on_find_in_files_modified_files(PackedStringArray paths) { +void ScriptEditor::_on_find_in_files_modified_files(const PackedStringArray &paths) { _test_script_times_on_disk(); _update_modified_scripts_for_external_editor(); } @@ -4217,7 +4219,7 @@ void ScriptEditorPlugin::_focus_another_editor() { } } -void ScriptEditorPlugin::_save_last_editor(String p_editor) { +void ScriptEditorPlugin::_save_last_editor(const String &p_editor) { if (p_editor != get_name()) { last_editor = p_editor; } diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 752c1a6a05..6d13c6af09 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -179,7 +179,7 @@ public: virtual PackedInt32Array get_breakpoints() = 0; virtual void set_breakpoint(int p_line, bool p_enabled) = 0; virtual void clear_breakpoints() = 0; - virtual void add_callback(const String &p_function, PackedStringArray p_args) = 0; + virtual void add_callback(const String &p_function, const PackedStringArray &p_args) = 0; virtual void update_settings() = 0; virtual void set_debugger_active(bool p_active) = 0; virtual bool can_lose_focus_on_node_selection() { return true; } @@ -362,11 +362,11 @@ class ScriptEditor : public PanelContainer { bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>()); - void _add_recent_script(String p_path); + void _add_recent_script(const String &p_path); void _update_recent_scripts(); void _open_recent_script(int p_idx); - void _show_error_dialog(String p_path); + void _show_error_dialog(const String &p_path); void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true); void _update_find_replace_bar(); @@ -462,7 +462,7 @@ class ScriptEditor : public PanelContainer { void _script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index); void _make_script_list_context_menu(); - void _help_search(String p_text); + void _help_search(const String &p_text); void _history_forward(); void _history_back(); @@ -481,7 +481,7 @@ class ScriptEditor : public PanelContainer { void _script_changed(); int file_dialog_option; - void _file_dialog_action(String p_file); + void _file_dialog_action(const String &p_file); Ref<Script> _get_current_script(); TypedArray<Script> _get_open_scripts() const; @@ -490,11 +490,11 @@ class ScriptEditor : public PanelContainer { Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const; Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path); - void _on_find_in_files_requested(String text); - void _on_replace_in_files_requested(String text); - void _on_find_in_files_result_selected(String fpath, int line_number, int begin, int end); + void _on_find_in_files_requested(const String &text); + void _on_replace_in_files_requested(const String &text); + void _on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end); void _start_find_in_files(bool with_replace); - void _on_find_in_files_modified_files(PackedStringArray paths); + void _on_find_in_files_modified_files(const PackedStringArray &paths); void _set_zoom_factor(float p_zoom_factor); @@ -579,7 +579,7 @@ class ScriptEditorPlugin : public EditorPlugin { void _focus_another_editor(); - void _save_last_editor(String p_editor); + void _save_last_editor(const String &p_editor); void _window_visibility_changed(bool p_visible); protected: diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index ee347538a4..4c08449b8d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -46,7 +46,7 @@ void ConnectionInfoDialog::ok_pressed() { } -void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_nodes) { +void ConnectionInfoDialog::popup_connections(const String &p_method, const Vector<Node *> &p_nodes) { method->set_text(p_method); tree->clear(); @@ -269,7 +269,7 @@ void ScriptTextEditor::_show_warnings_panel(bool p_show) { warnings_panel->set_visible(p_show); } -void ScriptTextEditor::_warning_clicked(Variant p_line) { +void ScriptTextEditor::_warning_clicked(const Variant &p_line) { if (p_line.get_type() == Variant::INT) { goto_line_centered(p_line.operator int64_t()); } else if (p_line.get_type() == Variant::DICTIONARY) { @@ -300,7 +300,7 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) { } } -void ScriptTextEditor::_error_clicked(Variant p_line) { +void ScriptTextEditor::_error_clicked(const Variant &p_line) { if (p_line.get_type() == Variant::INT) { code_editor->get_text_editor()->remove_secondary_carets(); code_editor->get_text_editor()->set_caret_line(p_line.operator int64_t()); @@ -344,7 +344,7 @@ void ScriptTextEditor::reload_text() { _validate_script(); } -void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray p_args) { +void ScriptTextEditor::add_callback(const String &p_function, const PackedStringArray &p_args) { ScriptLanguage *language = script->get_language(); if (!language->can_make_function()) { return; diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 820e86df61..2ea73d4c73 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -49,7 +49,7 @@ class ConnectionInfoDialog : public AcceptDialog { virtual void ok_pressed() override; public: - void popup_connections(String p_method, Vector<Node *> p_nodes); + void popup_connections(const String &p_method, const Vector<Node *> &p_nodes); ConnectionInfoDialog(); }; @@ -177,8 +177,8 @@ protected: void _set_theme_for_script(); void _show_errors_panel(bool p_show); void _show_warnings_panel(bool p_show); - void _error_clicked(Variant p_line); - void _warning_clicked(Variant p_line); + void _error_clicked(const Variant &p_line); + void _warning_clicked(const Variant &p_line); void _notification(int p_what); @@ -240,7 +240,7 @@ public: virtual void set_breakpoint(int p_line, bool p_enabled) override; virtual void clear_breakpoints() override; - virtual void add_callback(const String &p_function, PackedStringArray p_args) override; + virtual void add_callback(const String &p_function, const PackedStringArray &p_args) override; virtual void update_settings() override; virtual bool show_members_overview() override; diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index b6a6c8968e..701e848be1 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -113,7 +113,7 @@ void BoneTransformEditor::_notification(int p_what) { } } -void BoneTransformEditor::_value_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { +void BoneTransformEditor::_value_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) { if (updating) { return; } diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 839061a2fe..f62d017c40 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -75,7 +75,7 @@ class BoneTransformEditor : public VBoxContainer { void create_editors(); - void _value_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing); + void _value_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing); void _property_keyed(const String &p_path, bool p_advance); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 2eb914e976..6070e08739 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -140,7 +140,7 @@ void TextEditor::enable_editor(Control *p_shortcut_context) { } } -void TextEditor::add_callback(const String &p_function, PackedStringArray p_args) { +void TextEditor::add_callback(const String &p_function, const PackedStringArray &p_args) { } void TextEditor::set_debugger_active(bool p_active) { diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index 38dca9eb28..38fddc45df 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -142,7 +142,7 @@ public: virtual bool can_lose_focus_on_node_selection() override { return true; } virtual void set_debugger_active(bool p_active) override; virtual void set_tooltip_request_func(const Callable &p_toolip_callback) override; - virtual void add_callback(const String &p_function, PackedStringArray p_args) override; + virtual void add_callback(const String &p_function, const PackedStringArray &p_args) override; void update_toggle_scripts_button() override; virtual Control *get_edit_menu() override; diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index ad8674207b..5a1fe833d6 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -37,6 +37,7 @@ #include "editor/filesystem_dock.h" #include "editor/project_settings_editor.h" #include "editor/themes/editor_scale.h" +#include "editor/themes/editor_theme_manager.h" #include "scene/gui/split_container.h" #include "servers/rendering/shader_preprocessor.h" #include "servers/rendering/shader_types.h" @@ -740,7 +741,8 @@ void TextShaderEditor::_notification(int p_what) { } void TextShaderEditor::_editor_settings_changed() { - if (!EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor") && + if (!EditorThemeManager::is_generated_theme_outdated() && + !EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor") && !EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor")) { return; } @@ -758,7 +760,7 @@ void TextShaderEditor::_show_warnings_panel(bool p_show) { warnings_panel->set_visible(p_show); } -void TextShaderEditor::_warning_clicked(Variant p_line) { +void TextShaderEditor::_warning_clicked(const Variant &p_line) { if (p_line.get_type() == Variant::INT) { code_editor->get_text_editor()->set_caret_line(p_line.operator int64_t()); } diff --git a/editor/plugins/text_shader_editor.h b/editor/plugins/text_shader_editor.h index 73d7de98e4..be16148744 100644 --- a/editor/plugins/text_shader_editor.h +++ b/editor/plugins/text_shader_editor.h @@ -165,7 +165,7 @@ class TextShaderEditor : public MarginContainer { void _reload_shader_include_from_disk(); void _reload(); void _show_warnings_panel(bool p_show); - void _warning_clicked(Variant p_line); + void _warning_clicked(const Variant &p_line); void _update_warnings(bool p_validate); void _script_validated(bool p_valid) { diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp index e49ba5844a..e25005f996 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.cpp +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -42,7 +42,7 @@ void AtlasMergingDialog::_property_changed(const StringName &p_property, const V _set(p_property, p_value); } -void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns) { +void AtlasMergingDialog::_generate_merged(const Vector<Ref<TileSetAtlasSource>> &p_atlas_sources, int p_max_columns) { merged.instantiate(); merged_mapping.clear(); @@ -177,7 +177,7 @@ void AtlasMergingDialog::_update_texture() { } } -void AtlasMergingDialog::_merge_confirmed(String p_path) { +void AtlasMergingDialog::_merge_confirmed(const String &p_path) { ERR_FAIL_COND(!merged.is_valid()); Ref<ImageTexture> output_image_texture = merged->get_texture(); diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h index 2517db2ccd..83389c2e29 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.h +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -64,9 +64,9 @@ private: void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); - void _generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns); + void _generate_merged(const Vector<Ref<TileSetAtlasSource>> &p_atlas_sources, int p_max_columns); void _update_texture(); - void _merge_confirmed(String p_path); + void _merge_confirmed(const String &p_path); protected: virtual void ok_pressed() override; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index bd44c2965b..80490c9388 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -750,7 +750,7 @@ int GenericTilePolygonEditor::get_polygon_count() { return polygons.size(); } -int GenericTilePolygonEditor::add_polygon(Vector<Point2> p_polygon, int p_index) { +int GenericTilePolygonEditor::add_polygon(const Vector<Point2> &p_polygon, int p_index) { ERR_FAIL_COND_V(p_polygon.size() < 3, -1); ERR_FAIL_COND_V(!multiple_polygon_mode && polygons.size() >= 1, -1); @@ -782,7 +782,7 @@ void GenericTilePolygonEditor::clear_polygons() { base_control->queue_redraw(); } -void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector<Point2> p_polygon) { +void GenericTilePolygonEditor::set_polygon(int p_polygon_index, const Vector<Point2> &p_polygon) { ERR_FAIL_INDEX(p_polygon_index, (int)polygons.size()); ERR_FAIL_COND(p_polygon.size() < 3); polygons[p_polygon_index] = p_polygon; @@ -954,7 +954,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { _set_snap_option(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_snap_option", SNAP_NONE)); } -void TileDataDefaultEditor::_property_value_changed(const StringName &p_property, Variant p_value, const StringName &p_field) { +void TileDataDefaultEditor::_property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field) { ERR_FAIL_NULL(dummy_object); dummy_object->set(p_property, p_value); emit_signal(SNAME("needs_redraw")); @@ -975,7 +975,7 @@ void TileDataDefaultEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_at } } -void TileDataDefaultEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void TileDataDefaultEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_NULL(tile_data); tile_data->set(property, p_value); @@ -987,7 +987,7 @@ Variant TileDataDefaultEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_s return tile_data->get(property); } -void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) { +void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); @@ -1250,7 +1250,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2 } } -void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p_property, String p_label, Variant p_default_value) { +void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, const String &p_property, const String &p_label, const Variant &p_default_value) { ERR_FAIL_COND_MSG(!property.is_empty(), "Cannot setup TileDataDefaultEditor twice"); property = p_property; property_type = p_type; @@ -1446,7 +1446,7 @@ void TileDataOcclusionShapeEditor::_set_painted_value(TileSetAtlasSource *p_tile polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), tile_data->get_texture_origin(), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -void TileDataOcclusionShapeEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void TileDataOcclusionShapeEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_NULL(tile_data); Ref<OccluderPolygon2D> occluder_polygon = p_value; @@ -1461,7 +1461,7 @@ Variant TileDataOcclusionShapeEditor::_get_value(TileSetAtlasSource *p_tile_set_ return tile_data->get_occluder(occlusion_layer); } -void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) { +void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); @@ -1487,7 +1487,7 @@ TileDataOcclusionShapeEditor::TileDataOcclusionShapeEditor() { add_child(polygon_editor); } -void TileDataCollisionEditor::_property_value_changed(const StringName &p_property, Variant p_value, const StringName &p_field) { +void TileDataCollisionEditor::_property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field) { dummy_object->set(p_property, p_value); } @@ -1602,7 +1602,7 @@ void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), tile_data->get_texture_origin(), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -void TileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void TileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_NULL(tile_data); @@ -1640,7 +1640,7 @@ Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas return dict; } -void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) { +void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) { Dictionary new_dict = p_new_value; EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { @@ -1808,7 +1808,7 @@ void TileDataTerrainsEditor::_update_terrain_selector() { } } -void TileDataTerrainsEditor::_property_value_changed(const StringName &p_property, Variant p_value, const StringName &p_field) { +void TileDataTerrainsEditor::_property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field) { Variant old_value = dummy_object->get(p_property); dummy_object->set(p_property, p_value); if (p_property == "terrain_set") { @@ -2862,7 +2862,7 @@ void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), tile_data->get_texture_origin(), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } -void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { +void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_NULL(tile_data); Ref<NavigationPolygon> nav_polygon = p_value; @@ -2877,7 +2877,7 @@ Variant TileDataNavigationEditor::_get_value(TileSetAtlasSource *p_tile_set_atla return tile_data->get_navigation_polygon(navigation_layer); } -void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) { +void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); for (const KeyValue<TileMapCell, Variant> &E : p_previous_values) { Vector2i coords = E.key.get_atlas_coords(); diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index 27fe4316a0..40c049f70c 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -185,10 +185,10 @@ public: void set_background(Ref<Texture2D> p_texture, Rect2 p_region = Rect2(), Vector2 p_offset = Vector2(), bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false, Color p_modulate = Color(1.0, 1.0, 1.0, 0.0)); int get_polygon_count(); - int add_polygon(Vector<Point2> p_polygon, int p_index = -1); + int add_polygon(const Vector<Point2> &p_polygon, int p_index = -1); void remove_polygon(int p_index); void clear_polygons(); - void set_polygon(int p_polygon_index, Vector<Point2> p_polygon); + void set_polygon(int p_polygon_index, const Vector<Point2> &p_polygon); Vector<Point2> get_polygon(int p_polygon_index); void set_polygons_color(Color p_color); @@ -224,7 +224,7 @@ private: HashMap<TileMapCell, Variant, TileMapCell> drag_modified; Variant drag_painted_value; - void _property_value_changed(const StringName &p_property, Variant p_value, const StringName &p_field); + void _property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field); protected: DummyObject *dummy_object = memnew(DummyObject); @@ -236,9 +236,9 @@ protected: virtual Variant _get_painted_value(); virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value); + virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value); virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile); - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value); + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value); public: virtual Control *get_toolbar() override { return toolbar; }; @@ -248,7 +248,7 @@ public: virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override; virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override; - void setup_property_editor(Variant::Type p_type, String p_property, String p_label = "", Variant p_default_value = Variant()); + void setup_property_editor(Variant::Type p_type, const String &p_property, const String &p_label = "", const Variant &p_default_value = Variant()); Variant::Type get_property_type(); TileDataDefaultEditor(); @@ -285,13 +285,13 @@ private: // UI GenericTilePolygonEditor *polygon_editor = nullptr; - void _polygon_changed(PackedVector2Array p_polygon); + void _polygon_changed(const PackedVector2Array &p_polygon); virtual Variant _get_painted_value() override; virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; + virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override; virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) override; + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) override; protected: virtual void _tile_set_changed() override; @@ -316,15 +316,15 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { DummyObject *dummy_object = memnew(DummyObject); HashMap<StringName, EditorProperty *> property_editors; - void _property_value_changed(const StringName &p_property, Variant p_value, const StringName &p_field); + void _property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field); void _property_selected(const StringName &p_path, int p_focusable); void _polygons_changed(); virtual Variant _get_painted_value() override; virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; + virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override; virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) override; + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) override; protected: virtual void _tile_set_changed() override; @@ -368,7 +368,7 @@ private: EditorPropertyEnum *terrain_set_property_editor = nullptr; EditorPropertyEnum *terrain_property_editor = nullptr; - void _property_value_changed(const StringName &p_property, Variant p_value, const StringName &p_field); + void _property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field); void _update_terrain_selector(); @@ -399,13 +399,13 @@ private: // UI GenericTilePolygonEditor *polygon_editor = nullptr; - void _polygon_changed(PackedVector2Array p_polygon); + void _polygon_changed(const PackedVector2Array &p_polygon); virtual Variant _get_painted_value() override; virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override; + virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override; virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override; - virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, Variant p_new_value) override; + virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) override; protected: virtual void _tile_set_changed() override; diff --git a/editor/plugins/tiles/tile_map_layer_editor.cpp b/editor/plugins/tiles/tile_map_layer_editor.cpp index d24e7faeaf..ccadc0643b 100644 --- a/editor/plugins/tiles/tile_map_layer_editor.cpp +++ b/editor/plugins/tiles/tile_map_layer_editor.cpp @@ -445,7 +445,7 @@ void TileMapLayerEditorTilesPlugin::_update_scenes_collection_view() { scene_tiles_list->set_fixed_icon_size(Vector2(int_size, int_size)); } -void TileMapLayerEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) { +void TileMapLayerEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_ud) { int index = p_ud; if (index >= 0 && index < scene_tiles_list->get_item_count()) { @@ -3874,7 +3874,7 @@ void TileMapLayerEditor::_update_highlighting_toggle() { } } -void TileMapLayerEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { +void TileMapLayerEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos) { EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); ERR_FAIL_NULL(undo_redo_man); diff --git a/editor/plugins/tiles/tile_map_layer_editor.h b/editor/plugins/tiles/tile_map_layer_editor.h index 2a01a3c17a..a7fea2abcf 100644 --- a/editor/plugins/tiles/tile_map_layer_editor.h +++ b/editor/plugins/tiles/tile_map_layer_editor.h @@ -209,7 +209,7 @@ private: ItemList *scene_tiles_list = nullptr; void _update_scenes_collection_view(); - void _scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud); + void _scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_ud); void _scenes_list_multi_selected(int p_index, bool p_selected); void _scenes_list_lmb_empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index); @@ -382,7 +382,7 @@ private: void _update_highlighting_toggle(); // Inspector undo/redo callback. - void _move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos); + void _move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos); protected: void _notification(int p_what); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 176e8b7fee..d5aba35a8f 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -551,7 +551,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_bind_methods() { ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what"))); } -void TileSetAtlasSourceEditor::_inspector_property_selected(String p_property) { +void TileSetAtlasSourceEditor::_inspector_property_selected(const String &p_property) { selected_property = p_property; _update_atlas_view(); _update_current_tile_data_editor(); @@ -1701,7 +1701,7 @@ void TileSetAtlasSourceEditor::shortcut_input(const Ref<InputEvent> &p_event) { } } -void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) { +void TileSetAtlasSourceEditor::_set_selection_from_array(const Array &p_selection) { ERR_FAIL_COND((p_selection.size() % 2) != 0); selection.clear(); for (int i = 0; i < p_selection.size() / 2; i++) { @@ -2100,12 +2100,12 @@ void TileSetAtlasSourceEditor::_tile_set_changed() { tile_set_changed_needs_update = true; } -void TileSetAtlasSourceEditor::_tile_proxy_object_changed(String p_what) { +void TileSetAtlasSourceEditor::_tile_proxy_object_changed(const String &p_what) { tile_set_changed_needs_update = false; // Avoid updating too many things. _update_atlas_view(); } -void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) { +void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(const String &p_what) { if (p_what == "texture" && !atlas_source_proxy_object->get("texture").is_null()) { atlases_to_auto_create_tiles.clear(); atlases_to_auto_create_tiles.append(tile_set_atlas_source); @@ -2115,7 +2115,7 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) } } -void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { +void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value) { EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); ERR_FAIL_NULL(undo_redo_man); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index 322de81045..34077a55ad 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -153,7 +153,7 @@ private: EditorInspector *tile_inspector = nullptr; Label *tile_inspector_no_tile_selected_label = nullptr; String selected_property; - void _inspector_property_selected(String p_property); + void _inspector_property_selected(const String &p_property); TileSetAtlasSourceProxyObject *atlas_source_proxy_object = nullptr; EditorInspector *atlas_source_inspector = nullptr; @@ -229,7 +229,7 @@ private: // Selection. RBSet<TileSelection> selection; - void _set_selection_from_array(Array p_selection); + void _set_selection_from_array(const Array &p_selection); Array _get_selection_as_array(); // A control on the tile atlas to draw and handle input events. @@ -283,10 +283,10 @@ private: void _cleanup_outside_tiles(); void _tile_set_changed(); - void _tile_proxy_object_changed(String p_what); - void _atlas_source_proxy_object_changed(String p_what); + void _tile_proxy_object_changed(const String &p_what); + void _atlas_source_proxy_object_changed(const String &p_what); - void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value); + void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value); protected: void _notification(int p_what); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 06fcfbfb41..fe02e3096c 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -458,7 +458,7 @@ void TileSetEditor::_tab_changed(int p_tab_changed) { patterns_item_list->set_visible(p_tab_changed == 1); } -void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { +void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos) { EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); ERR_FAIL_NULL(undo_redo_man); @@ -668,7 +668,7 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ } } -void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { +void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value) { EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); ERR_FAIL_NULL(undo_redo_man); diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h index 68ab046ecf..106be5acbd 100644 --- a/editor/plugins/tiles/tile_set_editor.h +++ b/editor/plugins/tiles/tile_set_editor.h @@ -108,8 +108,8 @@ private: void _tile_set_changed(); void _tab_changed(int p_tab_changed); - void _move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos); - void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value); + void _move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos); + void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value); protected: void _notification(int p_what); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 1529ddadb6..e0151351b5 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -214,7 +214,7 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_bind_methods() ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what"))); } -void TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(String p_what) { +void TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(const String &p_what) { if (p_what == "id") { emit_signal(SNAME("source_id_changed"), scenes_collection_source_proxy_object->get_id()); } @@ -224,7 +224,7 @@ void TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_cha tile_set_scenes_collection_source_changed_needs_update = true; } -void TileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) { +void TileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_ud) { int index = p_ud; if (index >= 0 && index < scene_tiles_list->get_item_count()) { diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h index 5527685b24..b969421b29 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h @@ -118,8 +118,8 @@ private: EditorFileDialog *scene_select_dialog = nullptr; void _tile_set_scenes_collection_source_changed(); - void _scenes_collection_source_proxy_object_changed(String p_what); - void _scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud); + void _scenes_collection_source_proxy_object_changed(const String &p_what); + void _scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_ud); void _scenes_list_item_activated(int p_index); void _source_add_pressed(); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 06526fea28..86c7e31740 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -144,7 +144,7 @@ void VersionControlEditorPlugin::_set_credentials() { EditorSettings::get_singleton()->set_setting("version_control/ssh_private_key_path", ssh_private_key); } -bool VersionControlEditorPlugin::_load_plugin(String p_name) { +bool VersionControlEditorPlugin::_load_plugin(const String &p_name) { Object *extension_instance = ClassDB::instantiate(p_name); ERR_FAIL_NULL_V_MSG(extension_instance, false, "Received a nullptr VCS extension instance during construction."); @@ -168,7 +168,7 @@ bool VersionControlEditorPlugin::_load_plugin(String p_name) { return true; } -void VersionControlEditorPlugin::_update_set_up_warning(String p_new_text) { +void VersionControlEditorPlugin::_update_set_up_warning(const String &p_new_text) { bool empty_settings = set_up_username->get_text().strip_edges().is_empty() && set_up_password->get_text().is_empty() && set_up_ssh_public_key_path->get_text().strip_edges().is_empty() && @@ -305,15 +305,15 @@ void VersionControlEditorPlugin::_remote_selected(int p_index) { _refresh_remote_list(); } -void VersionControlEditorPlugin::_ssh_public_key_selected(String p_path) { +void VersionControlEditorPlugin::_ssh_public_key_selected(const String &p_path) { set_up_ssh_public_key_path->set_text(p_path); } -void VersionControlEditorPlugin::_ssh_private_key_selected(String p_path) { +void VersionControlEditorPlugin::_ssh_private_key_selected(const String &p_path) { set_up_ssh_private_key_path->set_text(p_path); } -void VersionControlEditorPlugin::_popup_file_dialog(Variant p_file_dialog_variant) { +void VersionControlEditorPlugin::_popup_file_dialog(const Variant &p_file_dialog_variant) { FileDialog *file_dialog = Object::cast_to<FileDialog>(p_file_dialog_variant); ERR_FAIL_NULL(file_dialog); @@ -345,11 +345,11 @@ void VersionControlEditorPlugin::_create_remote() { _refresh_remote_list(); } -void VersionControlEditorPlugin::_update_branch_create_button(String p_new_text) { +void VersionControlEditorPlugin::_update_branch_create_button(const String &p_new_text) { branch_create_ok->set_disabled(p_new_text.strip_edges().is_empty()); } -void VersionControlEditorPlugin::_update_remote_create_button(String p_new_text) { +void VersionControlEditorPlugin::_update_remote_create_button(const String &p_new_text) { remote_create_ok->set_disabled(p_new_text.strip_edges().is_empty()); } @@ -384,7 +384,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { version_commit_dock->set_name(commit_tab_title); } -void VersionControlEditorPlugin::_discard_file(String p_file_path, EditorVCSInterface::ChangeType p_change) { +void VersionControlEditorPlugin::_discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change) { CHECK_PLUGIN_INITIALIZED(); if (p_change == EditorVCSInterface::CHANGE_TYPE_NEW) { @@ -414,7 +414,7 @@ void VersionControlEditorPlugin::_discard_all() { _refresh_stage_area(); } -void VersionControlEditorPlugin::_add_new_item(Tree *p_tree, String p_file_path, EditorVCSInterface::ChangeType p_change) { +void VersionControlEditorPlugin::_add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change) { String change_text = p_file_path + " (" + change_type_to_strings[p_change] + ")"; TreeItem *new_item = p_tree->create_item(); diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h index ca55b86578..8ecb7c5029 100644 --- a/editor/plugins/version_control_editor_plugin.h +++ b/editor/plugins/version_control_editor_plugin.h @@ -142,15 +142,15 @@ private: void _initialize_vcs(); void _set_vcs_ui_state(bool p_enabled); void _set_credentials(); - void _ssh_public_key_selected(String p_path); - void _ssh_private_key_selected(String p_path); + void _ssh_public_key_selected(const String &p_path); + void _ssh_private_key_selected(const String &p_path); void _populate_available_vcs_names(); void _update_remotes_list(); - void _update_set_up_warning(String p_new_text); + void _update_set_up_warning(const String &p_new_text); void _update_opened_tabs(); void _update_extra_options(); - bool _load_plugin(String p_name); + bool _load_plugin(const String &p_name); void _pull(); void _push(); @@ -172,8 +172,8 @@ private: void _item_activated(Object *p_tree); void _create_branch(); void _create_remote(); - void _update_branch_create_button(String p_new_text); - void _update_remote_create_button(String p_new_text); + void _update_branch_create_button(const String &p_new_text); + void _update_remote_create_button(const String &p_new_text); void _branch_item_selected(int p_index); void _remote_selected(int p_index); void _remove_branch(); @@ -183,16 +183,16 @@ private: void _move_item(Tree *p_tree, TreeItem *p_itme); void _display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content); void _display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content); - void _discard_file(String p_file_path, EditorVCSInterface::ChangeType p_change); + void _discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change); void _cell_button_pressed(Object *p_item, int p_column, int p_id, int p_mouse_button_index); - void _add_new_item(Tree *p_tree, String p_file_path, EditorVCSInterface::ChangeType p_change); + void _add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change); void _update_commit_button(); void _commit_message_gui_input(const Ref<InputEvent> &p_event); void _extra_option_selected(int p_index); bool _is_staging_area_empty(); String _get_date_string_from(int64_t p_unix_timestamp, int64_t p_offset_minutes) const; void _create_vcs_metadata_files(); - void _popup_file_dialog(Variant p_file_dialog_variant); + void _popup_file_dialog(const Variant &p_file_dialog_variant); void _toggle_vcs_integration(bool p_toggled); friend class EditorVCSInterface; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 4261f6f32e..f5fadc2f1b 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -194,7 +194,7 @@ void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_ add_node(p_type, p_node_id, true); } -void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value) { +void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, const Variant &p_value) { if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id)) { return; } @@ -1211,7 +1211,7 @@ void VisualShaderEditedProperty::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::NIL, "edited_property", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_edited_property", "get_edited_property"); } -void VisualShaderEditedProperty::set_edited_property(Variant p_variant) { +void VisualShaderEditedProperty::set_edited_property(const Variant &p_variant) { edited_property = p_variant; } @@ -3116,7 +3116,7 @@ void VisualShaderEditor::_setup_node(VisualShaderNode *p_node, const Vector<Vari } } -void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, String p_resource_path, int p_node_idx) { +void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, const String &p_resource_path, int p_node_idx) { ERR_FAIL_INDEX(p_idx, add_options.size()); VisualShader::Type type = get_current_shader_type(); @@ -3799,7 +3799,7 @@ void VisualShaderEditor::_replace_node(VisualShader::Type p_type_id, int p_node_ undo_redo->add_undo_method(visual_shader.ptr(), "replace_node", p_type_id, p_node_id, p_from); } -void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) { +void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port) { Ref<VisualShaderNode> node = visual_shader->get_node(p_type_id, p_node_id); ERR_FAIL_COND(!node.is_valid()); ERR_FAIL_COND(!node->has_method("set_constant")); @@ -3809,7 +3809,7 @@ void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_no } } -void VisualShaderEditor::_update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) { +void VisualShaderEditor::_update_parameter(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port) { Ref<VisualShaderNodeParameter> parameter = visual_shader->get_node(p_type_id, p_node_id); ERR_FAIL_COND(!parameter.is_valid()); @@ -4715,7 +4715,7 @@ void VisualShaderEditor::_custom_mode_toggled(bool p_enabled) { _update_graph(); } -void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, String p_name) { +void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, const String &p_name) { String prev_name = p_input->get_input_name(); if (p_name == prev_name) { @@ -4787,7 +4787,7 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, undo_redo_man->commit_action(); } -void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name) { +void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, const String &p_name) { String prev_name = p_parameter_ref->get_parameter_name(); if (p_name == prev_name) { @@ -4831,7 +4831,7 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete undo_redo_man->commit_action(); } -void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name) { +void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, const String &p_name) { String prev_name = p_varying->get_varying_name(); if (p_name == prev_name) { @@ -6780,7 +6780,7 @@ public: } } - void setup(VisualShaderEditor *p_editor, Ref<Resource> p_parent_resource, Vector<EditorProperty *> p_properties, const Vector<StringName> &p_names, const HashMap<StringName, String> &p_overrided_names, Ref<VisualShaderNode> p_node) { + void setup(VisualShaderEditor *p_editor, Ref<Resource> p_parent_resource, const Vector<EditorProperty *> &p_properties, const Vector<StringName> &p_names, const HashMap<StringName, String> &p_overrided_names, Ref<VisualShaderNode> p_node) { editor = p_editor; parent_resource = p_parent_resource; updating = false; diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 2575866b10..683a6bc883 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -127,7 +127,7 @@ public: void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id, bool p_is_valid); void set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position); void refresh_node_ports(VisualShader::Type p_type, int p_node); - void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value); + void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, const Variant &p_value); void update_parameter_refs(); void set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name); void update_curve(int p_node_id); @@ -154,7 +154,7 @@ protected: static void _bind_methods(); public: - void set_edited_property(Variant p_variant); + void set_edited_property(const Variant &p_variant); Variant get_edited_property() const; VisualShaderEditedProperty() {} @@ -360,7 +360,7 @@ class VisualShaderEditor : public VBoxContainer { void _draw_color_over_button(Object *p_obj, Color p_color); void _setup_node(VisualShaderNode *p_node, const Vector<Variant> &p_ops); - void _add_node(int p_idx, const Vector<Variant> &p_ops, String p_resource_path = "", int p_node_idx = -1); + void _add_node(int p_idx, const Vector<Variant> &p_ops, const String &p_resource_path = "", int p_node_idx = -1); void _add_varying(const String &p_name, VisualShader::VaryingMode p_mode, VisualShader::VaryingType p_type); void _remove_varying(const String &p_name); void _update_options_menu(); @@ -416,8 +416,8 @@ class VisualShaderEditor : public VBoxContainer { void _convert_constants_to_parameters(bool p_vice_versa); void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to); - void _update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); - void _update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); + void _update_constant(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port); + void _update_parameter(VisualShader::Type p_type_id, int p_node_id, const Variant &p_var, int p_preview_port); void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position); void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position); @@ -470,9 +470,9 @@ class VisualShaderEditor : public VBoxContainer { void _mode_selected(int p_id); void _custom_mode_toggled(bool p_enabled); - void _input_select_item(Ref<VisualShaderNodeInput> p_input, String p_name); - void _parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name); - void _varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name); + void _input_select_item(Ref<VisualShaderNodeInput> p_input, const String &p_name); + void _parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, const String &p_name); + void _varying_select_item(Ref<VisualShaderNodeVarying> p_varying, const String &p_name); void _float_constant_selected(int p_which); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index c8197e2246..b295e5733e 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -47,15 +47,15 @@ #include "modules/regex/regex.h" // Find "OS.set_property(x)", capturing x into $1. -static String make_regex_gds_os_property_set(String name_set) { +static String make_regex_gds_os_property_set(const String &name_set) { return String("\\bOS\\.") + name_set + "\\s*\\((.*)\\)"; } // Find "OS.property = x", capturing x into $1 or $2. -static String make_regex_gds_os_property_assign(String name) { +static String make_regex_gds_os_property_assign(const String &name) { return String("\\bOS\\.") + name + "\\s*=\\s*([^#]+)"; } // Find "OS.property" OR "OS.get_property()" / "OS.is_property()". -static String make_regex_gds_os_property_get(String name, String get) { +static String make_regex_gds_os_property_get(const String &name, const String &get) { return String("\\bOS\\.(") + get + "_)?" + name + "(\\s*\\(\\s*\\))?"; } @@ -746,7 +746,7 @@ Vector<SourceLine> ProjectConverter3To4::split_lines(const String &text) { } // Test expected results of gdscript -bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) { +bool ProjectConverter3To4::test_conversion_gdscript_builtin(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), const String &what, const RegExContainer ®_container, bool builtin_script) { Vector<SourceLine> got = split_lines(name); (this->*func)(got, reg_container, builtin_script); @@ -756,7 +756,7 @@ bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String return true; } -bool ProjectConverter3To4::test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), String what, const RegExContainer ®_container) { +bool ProjectConverter3To4::test_conversion_with_regex(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), const String &what, const RegExContainer ®_container) { Vector<SourceLine> got = split_lines(name); (this->*func)(got, reg_container); @@ -766,7 +766,7 @@ bool ProjectConverter3To4::test_conversion_with_regex(String name, String expect return true; } -bool ProjectConverter3To4::test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what) { +bool ProjectConverter3To4::test_conversion_basic(const String &name, const String &expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, const String &what) { Vector<SourceLine> got = split_lines(name); rename_common(array, regex_cache, got); @@ -1638,7 +1638,7 @@ Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector< return found_renames; } -bool ProjectConverter3To4::contains_function_call(String &line, String function) const { +bool ProjectConverter3To4::contains_function_call(const String &line, const String &function) const { // We want to convert the function only if it is completely standalone. // For example, when we search for "connect(", we don't want to accidentally convert "reconnect(". if (!line.contains(function)) { @@ -2834,7 +2834,7 @@ Vector<String> ProjectConverter3To4::check_for_rename_input_map_scancode(Vector< return found_renames; } -void ProjectConverter3To4::custom_rename(Vector<SourceLine> &source_lines, String from, String to) { +void ProjectConverter3To4::custom_rename(Vector<SourceLine> &source_lines, const String &from, const String &to) { RegEx reg = RegEx(String("\\b") + from + "\\b"); CRASH_COND(!reg.is_valid()); for (SourceLine &source_line : source_lines) { @@ -2849,7 +2849,7 @@ void ProjectConverter3To4::custom_rename(Vector<SourceLine> &source_lines, Strin } }; -Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, String from, String to) { +Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, const String &from, const String &to) { Vector<String> found_renames; RegEx reg = RegEx(String("\\b") + from + "\\b"); diff --git a/editor/project_converter_3_to_4.h b/editor/project_converter_3_to_4.h index 2afd0a24e8..0f90028bc8 100644 --- a/editor/project_converter_3_to_4.h +++ b/editor/project_converter_3_to_4.h @@ -101,8 +101,8 @@ class ProjectConverter3To4 { void rename_joypad_buttons_and_axes(Vector<SourceLine> &source_lines, const RegExContainer ®_container); Vector<String> check_for_rename_joypad_buttons_and_axes(Vector<String> &lines, const RegExContainer ®_container); - void custom_rename(Vector<SourceLine> &source_lines, String from, String to); - Vector<String> check_for_custom_rename(Vector<String> &lines, String from, String to); + void custom_rename(Vector<SourceLine> &source_lines, const String &from, const String &to); + Vector<String> check_for_custom_rename(Vector<String> &lines, const String &from, const String &to); void rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<SourceLine> &source_lines); Vector<String> check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines); @@ -114,7 +114,7 @@ class ProjectConverter3To4 { String connect_arguments(const Vector<String> &line, int from, int to = -1) const; String get_starting_space(const String &line) const; String get_object_of_execution(const String &line) const; - bool contains_function_call(String &line, String function) const; + bool contains_function_call(const String &line, const String &function) const; String line_formatter(int current_line, String from, String to, String line); String simple_line_formatter(int current_line, String old_line, String line); @@ -122,9 +122,9 @@ class ProjectConverter3To4 { Vector<SourceLine> split_lines(const String &text); bool test_single_array(const char *array[][2], bool ignore_second_check = false); - bool test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin); - bool test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), String what, const RegExContainer ®_container); - bool test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what); + bool test_conversion_gdscript_builtin(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &, bool), const String &what, const RegExContainer ®_container, bool builtin); + bool test_conversion_with_regex(const String &name, const String &expected, void (ProjectConverter3To4::*func)(Vector<SourceLine> &, const RegExContainer &), const String &what, const RegExContainer ®_container); + bool test_conversion_basic(const String &name, const String &expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, const String &what); bool test_array_names(); bool test_conversion(RegExContainer ®_container); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 367dd324c2..6a43d60cc7 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -380,7 +380,7 @@ void RenameDialog::_update_preview_int(int new_value) { _update_preview(); } -void RenameDialog::_update_preview(String new_text) { +void RenameDialog::_update_preview(const String &new_text) { if (lock_preview_update || preview_node == nullptr) { return; } @@ -637,7 +637,7 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) { (line_edit == lne_search || line_edit == lne_replace || line_edit == lne_prefix || line_edit == lne_suffix); } -void RenameDialog::_insert_text(String text) { +void RenameDialog::_insert_text(const String &text) { LineEdit *focus_owner = Object::cast_to<LineEdit>(get_viewport()->gui_get_focus_owner()); if (_is_main_field(focus_owner)) { diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 6821cab982..37d159b4e2 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -52,7 +52,7 @@ class RenameDialog : public ConfirmationDialog { virtual void ok_pressed() override { rename(); }; void _cancel_pressed() {} void _features_toggled(bool pressed); - void _insert_text(String text); + void _insert_text(const String &text); void _update_substitute(); bool _is_main_field(LineEdit *line_edit); @@ -61,7 +61,7 @@ class RenameDialog : public ConfirmationDialog { String _substitute(const String &subject, const Node *node, int count); String _regex(const String &pattern, const String &subject, const String &replacement); String _postprocess(const String &subject); - void _update_preview(String new_text = ""); + void _update_preview(const String &new_text = ""); void _update_preview_int(int new_value = 0); static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index f8e0628072..66b82ee648 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1356,7 +1356,7 @@ void SceneTreeDock::_property_selected(int p_idx) { property_drop_node = nullptr; } -void SceneTreeDock::_perform_property_drop(Node *p_node, String p_property, Ref<Resource> p_res) { +void SceneTreeDock::_perform_property_drop(Node *p_node, const String &p_property, Ref<Resource> p_res) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(vformat(TTR("Set %s"), p_property)); undo_redo->add_do_property(p_node, p_property, p_res); @@ -2957,7 +2957,7 @@ void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) { scene_tree->set_selected(p_node, p_emit_selected); } -void SceneTreeDock::_new_scene_from(String p_file) { +void SceneTreeDock::_new_scene_from(const String &p_file) { List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() != 1) { @@ -3105,7 +3105,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { } } -void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_type) { +void SceneTreeDock::_files_dropped(const Vector<String> &p_files, NodePath p_to, int p_type) { Node *node = get_node(p_to); ERR_FAIL_NULL(node); @@ -3156,7 +3156,7 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_ } } -void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { +void SceneTreeDock::_script_dropped(const String &p_file, NodePath p_to) { Ref<Script> scr = ResourceLoader::load(p_file); ERR_FAIL_COND(!scr.is_valid()); Node *n = get_node(p_to); @@ -3206,7 +3206,7 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { } } -void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { +void SceneTreeDock::_nodes_dragged(const Array &p_nodes, NodePath p_to, int p_type) { if (!_validate_no_foreign()) { return; } @@ -3581,7 +3581,7 @@ void SceneTreeDock::set_filter(const String &p_filter) { scene_tree->set_filter(p_filter); } -void SceneTreeDock::save_branch_to_file(String p_directory) { +void SceneTreeDock::save_branch_to_file(const String &p_directory) { new_scene_from_dialog->set_current_dir(p_directory); _tool_selected(TOOL_NEW_SCENE_FROM); } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index a6d2eab2e2..4c1eb5715a 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -139,7 +139,7 @@ class SceneTreeDock : public VBoxContainer { Node *property_drop_node = nullptr; String resource_drop_path; - void _perform_property_drop(Node *p_node, String p_property, Ref<Resource> p_res); + void _perform_property_drop(Node *p_node, const String &p_property, Ref<Resource> p_res); EditorData *editor_data = nullptr; EditorSelection *editor_selection = nullptr; @@ -238,7 +238,7 @@ class SceneTreeDock : public VBoxContainer { virtual void shortcut_input(const Ref<InputEvent> &p_event) override; void _scene_tree_gui_input(Ref<InputEvent> p_event); - void _new_scene_from(String p_file); + void _new_scene_from(const String &p_file); void _set_node_owner_recursive(Node *p_node, Node *p_owner, const HashMap<const Node *, Node *> &p_inverse_duplimap); bool _validate_no_foreign(); @@ -251,9 +251,9 @@ class SceneTreeDock : public VBoxContainer { void _normalize_drop(Node *&to_node, int &to_pos, int p_type); - void _nodes_dragged(Array p_nodes, NodePath p_to, int p_type); - void _files_dropped(Vector<String> p_files, NodePath p_to, int p_type); - void _script_dropped(String p_file, NodePath p_to); + void _nodes_dragged(const Array &p_nodes, NodePath p_to, int p_type); + void _files_dropped(const Vector<String> &p_files, NodePath p_to, int p_type); + void _script_dropped(const String &p_file, NodePath p_to); void _quick_open(); void _tree_rmb(const Vector2 &p_menu_pos); @@ -306,7 +306,7 @@ protected: public: String get_filter(); void set_filter(const String &p_filter); - void save_branch_to_file(String p_directory); + void save_branch_to_file(const String &p_directory); void _focus_node(); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 1da8fa49b4..d111fe8f36 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -46,7 +46,7 @@ #include "scene/gui/grid_container.h" #include "scene/gui/line_edit.h" -static String _get_parent_class_of_script(String p_path) { +static String _get_parent_class_of_script(const String &p_path) { if (!ResourceLoader::exists(p_path, "Script")) { return "Object"; // A script eventually inherits from Object. } @@ -73,7 +73,7 @@ static String _get_parent_class_of_script(String p_path) { return _get_parent_class_of_script(base->get_path()); } -static Vector<String> _get_hierarchy(String p_class_name) { +static Vector<String> _get_hierarchy(const String &p_class_name) { Vector<String> hierarchy; String class_name = p_class_name; diff --git a/editor/themes/editor_color_map.cpp b/editor/themes/editor_color_map.cpp index 0b3a237244..99bcf109d0 100644 --- a/editor/themes/editor_color_map.cpp +++ b/editor/themes/editor_color_map.cpp @@ -33,7 +33,7 @@ HashMap<Color, Color> EditorColorMap::color_conversion_map; HashSet<StringName> EditorColorMap::color_conversion_exceptions; -void EditorColorMap::add_conversion_color_pair(const String p_from_color, const String p_to_color) { +void EditorColorMap::add_conversion_color_pair(const String &p_from_color, const String &p_to_color) { color_conversion_map[Color::html(p_from_color)] = Color::html(p_to_color); } diff --git a/editor/themes/editor_color_map.h b/editor/themes/editor_color_map.h index 4debd37faf..c1176749f2 100644 --- a/editor/themes/editor_color_map.h +++ b/editor/themes/editor_color_map.h @@ -47,7 +47,7 @@ class EditorColorMap { static HashSet<StringName> color_conversion_exceptions; public: - static void add_conversion_color_pair(const String p_from_color, const String p_to_color); + static void add_conversion_color_pair(const String &p_from_color, const String &p_to_color); static void add_conversion_exception(const StringName &p_icon_name); static HashMap<Color, Color> &get_color_conversion_map() { return color_conversion_map; }; diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index 4a67bd6b31..f55ac6f59a 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -1035,7 +1035,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the p_theme->set_color("font_hovered_color", "ItemList", p_config.mono_color); p_theme->set_color("font_selected_color", "ItemList", p_config.mono_color); p_theme->set_color("font_outline_color", "ItemList", p_config.font_outline_color); - p_theme->set_color("guide_color", "ItemList", guide_color); + p_theme->set_color("guide_color", "ItemList", Color(1, 1, 1, 0)); p_theme->set_constant("v_separation", "ItemList", p_config.forced_even_separation * 0.5 * EDSCALE); p_theme->set_constant("h_separation", "ItemList", (p_config.increased_margin + 2) * EDSCALE); p_theme->set_constant("icon_margin", "ItemList", (p_config.increased_margin + 2) * EDSCALE); @@ -1279,6 +1279,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the p_theme->set_icon("forward_folder", "FileDialog", p_theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons))); p_theme->set_icon("reload", "FileDialog", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons))); p_theme->set_icon("toggle_hidden", "FileDialog", p_theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons))); + p_theme->set_icon("create_folder", "FileDialog", p_theme->get_icon(SNAME("FolderCreate"), EditorStringName(EditorIcons))); // Use a different color for folder icons to make them easier to distinguish from files. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color. p_theme->set_color("folder_icon_color", "FileDialog", (p_config.dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(p_config.accent_color, 0.7)); @@ -1748,10 +1749,14 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme Ref<StyleBoxFlat> menu_transparent_style = p_config.button_style->duplicate(); menu_transparent_style->set_bg_color(Color(1, 1, 1, 0)); menu_transparent_style->set_border_width_all(0); + Ref<StyleBoxFlat> main_screen_button_transparent = menu_transparent_style->duplicate(); + for (int i = 0; i < 4; i++) { + menu_transparent_style->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); + } p_theme->set_stylebox("MenuTransparent", EditorStringName(EditorStyles), menu_transparent_style); p_theme->set_stylebox("MenuHover", EditorStringName(EditorStyles), p_config.button_style_hover); - p_theme->set_stylebox("normal", "MainScreenButton", menu_transparent_style); - p_theme->set_stylebox("pressed", "MainScreenButton", menu_transparent_style); + p_theme->set_stylebox("normal", "MainScreenButton", main_screen_button_transparent); + p_theme->set_stylebox("pressed", "MainScreenButton", main_screen_button_transparent); p_theme->set_stylebox("hover_pressed", "MainScreenButton", p_config.button_style_hover); // Run bar. @@ -1810,11 +1815,14 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme // Flat button variations. { Ref<StyleBoxEmpty> style_flat_button = make_empty_stylebox(); + Ref<StyleBoxFlat> style_flat_button_hover = p_config.button_style_hover->duplicate(); + Ref<StyleBoxFlat> style_flat_button_pressed = p_config.button_style_pressed->duplicate(); + for (int i = 0; i < 4; i++) { style_flat_button->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); + style_flat_button_hover->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); + style_flat_button_pressed->set_content_margin((Side)i, p_config.button_style->get_margin((Side)i) + p_config.button_style->get_border_width((Side)i)); } - - Ref<StyleBoxFlat> style_flat_button_pressed = p_config.button_style_pressed->duplicate(); Color flat_pressed_color = p_config.dark_color_1.lightened(0.24).lerp(p_config.accent_color, 0.2) * Color(0.8, 0.8, 0.8, 0.85); if (p_config.dark_theme) { flat_pressed_color = p_config.dark_color_1.lerp(p_config.accent_color, 0.12) * Color(0.6, 0.6, 0.6, 0.85); @@ -1822,12 +1830,12 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme style_flat_button_pressed->set_bg_color(flat_pressed_color); p_theme->set_stylebox("normal", "FlatButton", style_flat_button); - p_theme->set_stylebox("hover", "FlatButton", p_config.button_style_hover); + p_theme->set_stylebox("hover", "FlatButton", style_flat_button_hover); p_theme->set_stylebox("pressed", "FlatButton", style_flat_button_pressed); p_theme->set_stylebox("disabled", "FlatButton", style_flat_button); p_theme->set_stylebox("normal", "FlatMenuButton", style_flat_button); - p_theme->set_stylebox("hover", "FlatMenuButton", p_config.button_style_hover); + p_theme->set_stylebox("hover", "FlatMenuButton", style_flat_button_hover); p_theme->set_stylebox("pressed", "FlatMenuButton", style_flat_button_pressed); p_theme->set_stylebox("disabled", "FlatMenuButton", style_flat_button); diff --git a/editor/window_wrapper.cpp b/editor/window_wrapper.cpp index b2b237269a..b810ec7fa2 100644 --- a/editor/window_wrapper.cpp +++ b/editor/window_wrapper.cpp @@ -286,7 +286,7 @@ void WindowWrapper::enable_window_on_screen(int p_screen, bool p_auto_scale) { } } -void WindowWrapper::set_window_title(const String p_title) { +void WindowWrapper::set_window_title(const String &p_title) { if (!is_window_available()) { return; } diff --git a/editor/window_wrapper.h b/editor/window_wrapper.h index e8fcb13c92..a07e95f09e 100644 --- a/editor/window_wrapper.h +++ b/editor/window_wrapper.h @@ -78,7 +78,7 @@ public: void restore_window_from_saved_position(const Rect2 p_window_rect, int p_screen, const Rect2 p_screen_rect); void enable_window_on_screen(int p_screen = -1, bool p_auto_scale = false); - void set_window_title(const String p_title); + void set_window_title(const String &p_title); void set_margins_enabled(bool p_enabled); WindowWrapper(); diff --git a/misc/hooks/README.md b/misc/hooks/README.md deleted file mode 100644 index 573f8fe350..0000000000 --- a/misc/hooks/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Git hooks for Godot Engine - -This folder contains Git hooks meant to be installed locally by Godot Engine -contributors to make sure they comply with our requirements. - -## List of hooks - -- Pre-commit hook for `clang-format`: Applies `clang-format` to the staged - files before accepting a commit; blocks the commit and generates a patch if - the style is not respected. - You may need to edit the file if your `clang-format` binary is not in the - `PATH`, or if you want to enable colored output with `pygmentize`. -- Pre-commit hook for `black`: Applies `black` to the staged Python files - before accepting a commit. -- Pre-commit hook for `make_rst`: Checks the class reference syntax using - `make_rst.py`. - -## Installation - -Copy all the files from this folder into your `.git/hooks` folder, and make -sure the hooks and helper scripts are executable. - -#### Linux/macOS - -The hooks rely on bash scripts and tools which should be in the system `PATH`, -so they should work out of the box on Linux/macOS. - -#### Windows - -##### clang-format -- Download LLVM for Windows (version 13 or later) from - <https://github.com/llvm/llvm-project/releases> -- Make sure LLVM is added to the `PATH` during installation - -##### black -- Python installation: make sure Python is added to the `PATH` -- Install `black` - in any console: `pip3 install black` - -## Custom hooks - -The pre-commit hook will run any other script in `.git/hooks` whose filename -matches `pre-commit-custom-*`, after the Godot ones. diff --git a/misc/hooks/asmessage.applescript b/misc/hooks/asmessage.applescript deleted file mode 100644 index 15ba94dc37..0000000000 --- a/misc/hooks/asmessage.applescript +++ /dev/null @@ -1,59 +0,0 @@ -on run argv - set vButtons to { "OK" } - set vButtonCodes to { 0 } - set vDbutton to "OK" - set vText to "" - set vTitle to "" - set vTimeout to -1 - - repeat with i from 1 to length of argv - try - set vArg to item i of argv - if vArg = "-buttons" then - set vButtonsAndCodes to my fSplit(item (i + 1) of argv, ",") - set vButtons to {} - set vButtonCodes to {} - repeat with j from 1 to length of vButtonsAndCodes - set vBtn to my fSplit(item j of vButtonsAndCodes, ":") - copy (item 1 of vBtn) to the end of the vButtons - copy (item 2 of vBtn) to the end of the vButtonCodes - end repeat - else if vArg = "-title" then - set vTitle to item (i + 1) of argv - else if vArg = "-center" then - -- not supported - else if vArg = "-default" then - set vDbutton to item (i + 1) of argv - else if vArg = "-geometry" then - -- not supported - else if vArg = "-nearmouse" then - -- not supported - else if vArg = "-timeout" then - set vTimeout to item (i + 1) of argv as integer - else if vArg = "-file" then - set vText to read (item (i + 1) of argv) as string - else if vArg = "-text" then - set vText to item (i + 1) of argv - end if - end try - end repeat - - set vDlg to display dialog vText buttons vButtons default button vDbutton with title vTitle giving up after vTimeout with icon stop - set vRet to button returned of vDlg - repeat with i from 1 to length of vButtons - set vBtn to item i of vButtons - if vBtn = vRet - return item i of vButtonCodes - end if - end repeat - - return 0 -end run - -on fSplit(vString, vDelimiter) - set oldDelimiters to AppleScript's text item delimiters - set AppleScript's text item delimiters to vDelimiter - set vArray to every text item of vString - set AppleScript's text item delimiters to oldDelimiters - return vArray -end fSplit diff --git a/misc/hooks/canonicalize_filename.sh b/misc/hooks/canonicalize_filename.sh deleted file mode 100755 index fe66999d8c..0000000000 --- a/misc/hooks/canonicalize_filename.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -# Provide the canonicalize filename (physical filename with out any symlinks) -# like the GNU version readlink with the -f option regardless of the version of -# readlink (GNU or BSD). - -# This file is part of a set of unofficial pre-commit hooks available -# at github. -# Link: https://github.com/githubbrowser/Pre-commit-hooks -# Contact: David Martin, david.martin.mailbox@googlemail.com - -########################################################### -# There should be no need to change anything below this line. - -# Canonicalize by recursively following every symlink in every component of the -# specified filename. This should reproduce the results of the GNU version of -# readlink with the -f option. -# -# Reference: https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac -canonicalize_filename () { - local target_file="$1" - local physical_directory="" - local result="" - - # Need to restore the working directory after work. - local working_dir="`pwd`" - - cd -- "$(dirname -- "$target_file")" - target_file="$(basename -- "$target_file")" - - # Iterate down a (possible) chain of symlinks - while [ -L "$target_file" ] - do - target_file="$(readlink -- "$target_file")" - cd -- "$(dirname -- "$target_file")" - target_file="$(basename -- "$target_file")" - done - - # Compute the canonicalized name by finding the physical path - # for the directory we're in and appending the target file. - physical_directory="`pwd -P`" - result="$physical_directory/$target_file" - - # restore the working directory after work. - cd -- "$working_dir" - - echo "$result" -} diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit deleted file mode 100755 index 6359161260..0000000000 --- a/misc/hooks/pre-commit +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# Git pre-commit hook that runs multiple hooks specified in $HOOKS. -# Make sure this script is executable. Bypass hooks with git commit --no-verify. - -# This file is part of a set of unofficial pre-commit hooks available -# at github. -# Link: https://github.com/githubbrowser/Pre-commit-hooks -# Contact: David Martin, david.martin.mailbox@googlemail.com - - -########################################################### -# CONFIGURATION: -# pre-commit hooks to be executed. They should be in the same .git/hooks/ folder -# as this script. Hooks should return 0 if successful and nonzero to cancel the -# commit. They are executed in the order in which they are listed. -HOOKS="pre-commit-clang-format pre-commit-black pre-commit-make-rst" -HOOKS="$HOOKS $(find $(dirname -- "$0") -type f -name 'pre-commit-custom-*' -exec basename {} \;)" -########################################################### -# There should be no need to change anything below this line. - -. "$(dirname -- "$0")/canonicalize_filename.sh" - -# exit on error -set -e - -# Absolute path to this script, e.g. /home/user/bin/foo.sh -SCRIPT="$(canonicalize_filename "$0")" - -# Absolute path this script is in, thus /home/user/bin -SCRIPTPATH="$(dirname -- "$SCRIPT")" - - -for hook in $HOOKS -do - echo "Running hook: $hook" - # run hook if it exists - # if it returns with nonzero exit with 1 and thus abort the commit - if [ -f "$SCRIPTPATH/$hook" ]; then - "$SCRIPTPATH/$hook" - if [ $? != 0 ]; then - exit 1 - fi - else - echo "Error: file $hook not found." - echo "Aborting commit. Make sure the hook is in $SCRIPTPATH and executable." - echo "You can disable it by removing it from the list in $SCRIPT." - echo "You can skip all pre-commit hooks with --no-verify (not recommended)." - exit 1 - fi -done diff --git a/misc/hooks/pre-commit-black b/misc/hooks/pre-commit-black deleted file mode 100755 index bbad6a690a..0000000000 --- a/misc/hooks/pre-commit-black +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env bash - -# git pre-commit hook that runs a black stylecheck. -# Based on pre-commit-clang-format. - -################################################################## -# SETTINGS -# Set path to black binary. -BLACK=`which black 2>/dev/null` -BLACK_OPTIONS="-l 120" - -# Remove any older patches from previous commits. Set to true or false. -DELETE_OLD_PATCHES=false - -# File types to parse. -FILE_NAMES="SConstruct SCsub" -FILE_EXTS=".py" - -# Use pygmentize instead of cat to parse diff with highlighting. -# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac) -PYGMENTIZE=`which pygmentize 2>/dev/null` -if [ ! -z "$PYGMENTIZE" ]; then - READER="pygmentize -l diff" -else - READER=cat -fi - -# Path to zenity -ZENITY=`which zenity 2>/dev/null` - -# Path to xmessage -XMSG=`which xmessage 2>/dev/null` - -# Path to powershell (Windows only) -PWSH=`which powershell 2>/dev/null` - -# Path to osascript (macOS only) -OSA=`which osascript 2>/dev/null` - -################################################################## -# There should be no need to change anything below this line. - -. "$(dirname -- "$0")/canonicalize_filename.sh" - -# exit on error -set -e - -# check whether the given file matches any of the set extensions -matches_name_or_extension() { - local filename=$(basename "$1") - local extension=".${filename##*.}" - - for name in $FILE_NAMES; do [[ "$name" == "$filename" ]] && return 0; done - for ext in $FILE_EXTS; do [[ "$ext" == "$extension" ]] && return 0; done - - return 1 -} - -# necessary check for initial commit -if git rev-parse --verify HEAD >/dev/null 2>&1 ; then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -if [ ! -x "$BLACK" ] ; then - if [ ! -t 1 ] ; then - if [ -x "$ZENITY" ] ; then - $ZENITY --error --title="Error" --text="Error: black executable not found." - exit 1 - elif [ -x "$XMSG" ] ; then - $XMSG -center -title "Error" "Error: black executable not found." - exit 1 - elif [ -x "$OSA" ] ; then - asmessage="$(canonicalize_filename "$(dirname -- "$0")/asmessage.applescript")" - $OSA "$asmessage" -center -title "Error" --text "Error: black executable not found." - exit 1 - elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" - $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "Error: black executable not found." - exit 1 - fi - fi - printf "Error: black executable not found.\n" - printf "Set the correct path in $(canonicalize_filename "$0").\n" - exit 1 -fi - -# create a random filename to store our generated patch -prefix="pre-commit-black" -suffix="$(date +%s)" -patch="/tmp/$prefix-$suffix.patch" - -# clean up any older black patches -$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch - -# create one patch containing all changes to the files -git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; -do - # ignore thirdparty files - if grep -q "thirdparty" <<< $file; then - continue; - fi - - # ignore file if not one of the names or extensions we handle - if ! matches_name_or_extension "$file"; then - continue; - fi - - # format our file with black, create a patch with diff and append it to our $patch - # The sed call is necessary to transform the patch from - # --- $file timestamp - # +++ $file timestamp - # to both lines working on the same file and having a/ and b/ prefix. - # Else it can not be applied with 'git apply'. - "$BLACK" "$BLACK_OPTIONS" --diff "$file" | \ - sed -e "1s|--- |--- a/|" -e "2s|+++ |+++ b/|" >> "$patch" -done - -# if no patch has been generated all is ok, clean up the file stub and exit -if [ ! -s "$patch" ] ; then - printf "Files in this commit comply with the black formatter rules.\n" - rm -f "$patch" - exit 0 -fi - -# a patch has been created, notify the user and exit -printf "\nThe following differences were found between the code to commit " -printf "and the black formatter rules:\n\n" - -if [ -t 1 ] ; then - $READER "$patch" - printf "\n" - # Allows us to read user input below, assigns stdin to keyboard - exec < /dev/tty - terminal="1" -else - cat "$patch" - printf "\n" - # Allows non zero zenity/powershell output - set +e - terminal="0" -fi - -while true; do - if [ $terminal = "0" ] ; then - if [ -x "$ZENITY" ] ; then - choice=$($ZENITY --text-info --filename="$patch" --width=800 --height=600 --title="Do you want to apply that patch?" --ok-label="Apply" --cancel-label="Do not apply" --extra-button="Apply and stage") - if [ "$?" = "0" ] ; then - yn="Y" - else - if [ "$choice" = "Apply and stage" ] ; then - yn="S" - else - yn="N" - fi - fi - elif [ -x "$XMSG" ] ; then - $XMSG -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" - choice=$? - if [ "$choice" = "100" ] ; then - yn="Y" - elif [ "$choice" = "200" ] ; then - yn="S" - else - yn="N" - fi - elif [ -x "$OSA" ] ; then - asmessage="$(canonicalize_filename "$(dirname -- "$0")/asmessage.applescript")" - choice=`$OSA "$asmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"` - if [ "$choice" = "100" ] ; then - yn="Y" - elif [ "$choice" = "200" ] ; then - yn="S" - else - yn="N" - fi - elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" - $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" - choice=$? - if [ "$choice" = "100" ] ; then - yn="Y" - elif [ "$choice" = "200" ] ; then - yn="S" - else - yn="N" - fi - else - printf "Error: zenity, xmessage, osascript, or powershell executable not found.\n" - exit 1 - fi - else - read -p "Do you want to apply that patch (Y - Apply, N - Do not apply, S - Apply and stage files)? [Y/N/S] " yn - fi - case $yn in - [Yy] ) git apply $patch; - printf "The patch was applied. You can now stage the changes and commit again.\n\n"; - break - ;; - [Nn] ) printf "\nYou can apply these changes with:\n git apply $patch\n"; - printf "(may need to be called from the root directory of your repository)\n"; - printf "Aborting commit. Apply changes and commit again or skip checking with"; - printf " --no-verify (not recommended).\n\n"; - break - ;; - [Ss] ) git apply $patch; - git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; - do git add $file; - done - printf "The patch was applied and the changed files staged. You can now commit.\n\n"; - break - ;; - * ) echo "Please answer yes or no." - ;; - esac -done -exit 1 # we don't commit in any case diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format deleted file mode 100755 index eddbc59364..0000000000 --- a/misc/hooks/pre-commit-clang-format +++ /dev/null @@ -1,262 +0,0 @@ -#!/usr/bin/env bash - -# git pre-commit hook that runs a clang-format stylecheck. -# Features: -# - abort commit when commit does not comply with the style guidelines -# - create a patch of the proposed style changes -# Modifications for clang-format by rene.milk@wwu.de - -# This file is part of a set of unofficial pre-commit hooks available -# at github. -# Link: https://github.com/githubbrowser/Pre-commit-hooks -# Contact: David Martin, david.martin.mailbox@googlemail.com - -# Some quality of life modifications made for Godot Engine. - -################################################################## -# SETTINGS -# Set path to clang-format binary. -CLANG_FORMAT=`which clang-format 2>/dev/null` - -# Remove any older patches from previous commits. Set to true or false. -DELETE_OLD_PATCHES=false - -# Only parse files with the extensions in FILE_EXTS. Set to true or false. -# If false every changed file in the commit will be parsed with clang-format. -# If true only files matching one of the extensions are parsed with clang-format. -PARSE_EXTS=true - -# File types to parse. Only effective when PARSE_EXTS is true. -FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl" - -# Use pygmentize instead of cat to parse diff with highlighting. -# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac) -PYGMENTIZE=`which pygmentize 2>/dev/null` -if [ ! -z "$PYGMENTIZE" ]; then - READER="pygmentize -l diff" -else - READER=cat -fi - -# Path to zenity -ZENITY=`which zenity 2>/dev/null` - -# Path to xmessage -XMSG=`which xmessage 2>/dev/null` - -# Path to powershell (Windows only) -PWSH=`which powershell 2>/dev/null` - -# Path to osascript (macOS only) -OSA=`which osascript 2>/dev/null` - -################################################################## -# There should be no need to change anything below this line. - -. "$(dirname -- "$0")/canonicalize_filename.sh" - -# exit on error -set -e - -# check whether the given file matches any of the set extensions -matches_extension() { - local filename=$(basename "$1") - local extension=".${filename##*.}" - local ext - - for ext in $FILE_EXTS; do [[ "$ext" == "$extension" ]] && return 0; done - - return 1 -} - -# necessary check for initial commit -if git rev-parse --verify HEAD >/dev/null 2>&1 ; then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# To get consistent formatting, we recommend contributors to use the same -# clang-format version as CI. -RECOMMENDED_CLANG_FORMAT_MAJOR_MIN="13" -RECOMMENDED_CLANG_FORMAT_MAJOR_MAX="16" - -if [ ! -x "$CLANG_FORMAT" ] ; then - message="Error: clang-format executable not found. Please install clang-format $RECOMMENDED_CLANG_FORMAT_MAJOR_MAX." - - if [ ! -t 1 ] ; then - if [ -x "$ZENITY" ] ; then - $ZENITY --error --title="Error" --text="$message" - exit 1 - elif [ -x "$XMSG" ] ; then - $XMSG -center -title "Error" "$message" - exit 1 - elif [ -x "$OSA" ] ; then - asmessage="$(canonicalize_filename "$(dirname -- "$0")/asmessage.applescript")" - $OSA "$asmessage" -center -title "Error" --text "$message" - exit 1 - elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" - $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "$message" - exit 1 - fi - fi - printf "$message\n" - printf "Set the correct path in $(canonicalize_filename "$0").\n" - exit 1 -fi - -# The returned string can be inconsistent depending on where clang-format comes from. -# Example output strings reported by `clang-format --version`: -# - Ubuntu: "Ubuntu clang-format version 11.0.0-2" -# - Fedora: "clang-format version 11.0.0 (Fedora 11.0.0-2.fc33)" -CLANG_FORMAT_VERSION="$(clang-format --version | sed "s/[^0-9\.]*\([0-9\.]*\).*/\1/")" -CLANG_FORMAT_MAJOR="$(echo "$CLANG_FORMAT_VERSION" | cut -d. -f1)" - -if [[ "$CLANG_FORMAT_MAJOR" -lt "$RECOMMENDED_CLANG_FORMAT_MAJOR_MIN" || "$CLANG_FORMAT_MAJOR" -gt "$RECOMMENDED_CLANG_FORMAT_MAJOR_MAX" ]]; then - echo "Warning: Your clang-format binary is the wrong version ($CLANG_FORMAT_VERSION, expected between $RECOMMENDED_CLANG_FORMAT_MAJOR_MIN and $RECOMMENDED_CLANG_FORMAT_MAJOR_MAX)." - echo " Consider upgrading or downgrading clang-format as formatting may not be applied correctly." -fi - -# create a random filename to store our generated patch -prefix="pre-commit-clang-format" -suffix="$(date +%s)" -patch="/tmp/$prefix-$suffix.patch" - -# clean up any older clang-format patches -$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch - -# create one patch containing all changes to the files -git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; -do - # ignore thirdparty files - if grep -q "thirdparty" <<< $file; then - continue; - fi - if grep -q "platform/android/java/lib/src/com" <<< $file; then - continue; - fi - if grep -q "\-so_wrap." <<< $file; then - continue; - fi - if grep -q "tests/python_build" <<< $file; then - continue; - fi - - # ignore file if we do check for file extensions and the file - # does not match any of the extensions specified in $FILE_EXTS - if $PARSE_EXTS && ! matches_extension "$file"; then - continue; - fi - - # clang-format our sourcefile, create a patch with diff and append it to our $patch - # The sed call is necessary to transform the patch from - # --- $file timestamp - # +++ - timestamp - # to both lines working on the same file and having a/ and b/ prefix. - # Else it can not be applied with 'git apply'. - "$CLANG_FORMAT" -style=file "$file" --Wno-error=unknown | \ - diff -u "$file" - | \ - sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch" -done - -# if no patch has been generated all is ok, clean up the file stub and exit -if [ ! -s "$patch" ] ; then - printf "Files in this commit comply with the clang-format rules.\n" - rm -f "$patch" - exit 0 -fi - -# a patch has been created, notify the user and exit -printf "\nThe following differences were found between the code to commit " -printf "and the clang-format rules:\n\n" - -if [ -t 1 ] ; then - $READER "$patch" - printf "\n" - # Allows us to read user input below, assigns stdin to keyboard - exec < /dev/tty - terminal="1" -else - cat "$patch" - printf "\n" - # Allows non zero zenity/powershell output - set +e - terminal="0" -fi - -while true; do - if [ $terminal = "0" ] ; then - if [ -x "$ZENITY" ] ; then - choice=$($ZENITY --text-info --filename="$patch" --width=800 --height=600 --title="Do you want to apply that patch?" --ok-label="Apply" --cancel-label="Do not apply" --extra-button="Apply and stage") - if [ "$?" = "0" ] ; then - yn="Y" - else - if [ "$choice" = "Apply and stage" ] ; then - yn="S" - else - yn="N" - fi - fi - elif [ -x "$XMSG" ] ; then - $XMSG -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" - choice=$? - if [ "$choice" = "100" ] ; then - yn="Y" - elif [ "$choice" = "200" ] ; then - yn="S" - else - yn="N" - fi - elif [ -x "$OSA" ] ; then - asmessage="$(canonicalize_filename "$(dirname -- "$0")/asmessage.applescript")" - choice=`$OSA "$asmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"` - if [ "$choice" = "100" ] ; then - yn="Y" - elif [ "$choice" = "200" ] ; then - yn="S" - else - yn="N" - fi - elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" - $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" - choice=$? - if [ "$choice" = "100" ] ; then - yn="Y" - elif [ "$choice" = "200" ] ; then - yn="S" - else - yn="N" - fi - else - printf "Error: zenity, xmessage, osascript, or powershell executable not found.\n" - exit 1 - fi - else - read -p "Do you want to apply that patch (Y - Apply, N - Do not apply, S - Apply and stage files)? [Y/N/S] " yn - fi - case $yn in - [Yy] ) git apply $patch; - printf "The patch was applied. You can now stage the changes and commit again.\n\n"; - break - ;; - [Nn] ) printf "\nYou can apply these changes with:\n git apply $patch\n"; - printf "(may need to be called from the root directory of your repository)\n"; - printf "Aborting commit. Apply changes and commit again or skip checking with"; - printf " --no-verify (not recommended).\n\n"; - break - ;; - [Ss] ) git apply $patch; - git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; - do git add $file; - done - printf "The patch was applied and the changed files staged. You can now commit.\n\n"; - break - ;; - * ) echo "Please answer yes or no." - ;; - esac -done -exit 1 # we don't commit in any case diff --git a/misc/hooks/pre-commit-make-rst b/misc/hooks/pre-commit-make-rst deleted file mode 100755 index 3737272a6d..0000000000 --- a/misc/hooks/pre-commit-make-rst +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# Git pre-commit hook that checks the class reference syntax using make_rst.py. - -# Workaround because we can't execute the .py file directly on windows -PYTHON=python -py_ver=$($PYTHON -c "import sys; print(sys.version_info.major)") -if [[ "$py_ver" != "3" ]]; then - PYTHON+=3 -fi - -$PYTHON doc/tools/make_rst.py doc/classes modules platform --dry-run --color diff --git a/misc/hooks/winmessage.ps1 b/misc/hooks/winmessage.ps1 deleted file mode 100644 index 3672579544..0000000000 --- a/misc/hooks/winmessage.ps1 +++ /dev/null @@ -1,103 +0,0 @@ -Param ( - [string]$file = "", - [string]$text = "", - [string]$buttons = "OK:0", - [string]$default = "", - [switch]$nearmouse = $false, - [switch]$center = $false, - [string]$geometry = "", - [int32]$timeout = 0, - [string]$title = "Message" -) -Add-Type -assembly System.Windows.Forms - -$global:Result = 0 - -$main_form = New-Object System.Windows.Forms.Form -$main_form.Text = $title - -$geometry_data = $geometry.Split("+") -if ($geometry_data.Length -ge 1) { - $size_data = $geometry_data[0].Split("x") - if ($size_data.Length -eq 2) { - $main_form.Width = $size_data[0] - $main_form.Height = $size_data[1] - } -} -if ($geometry_data.Length -eq 3) { - $main_form.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual - $main_form.Location = New-Object System.Drawing.Point($geometry_data[1], $geometry_data[2]) -} -if ($nearmouse) { - $main_form.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual - $main_form.Location = System.Windows.Forms.Cursor.Position -} -if ($center) { - $main_form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen -} - -$main_form.SuspendLayout() - -$button_panel = New-Object System.Windows.Forms.FlowLayoutPanel -$button_panel.SuspendLayout() -$button_panel.FlowDirection = [System.Windows.Forms.FlowDirection]::RightToLeft -$button_panel.Dock = [System.Windows.Forms.DockStyle]::Bottom -$button_panel.Autosize = $true - -if ($file -ne "") { - $text = [IO.File]::ReadAllText($file).replace("`n", "`r`n") -} - -if ($text -ne "") { - $text_box = New-Object System.Windows.Forms.TextBox - $text_box.Multiline = $true - $text_box.ReadOnly = $true - $text_box.Autosize = $true - $text_box.Text = $text - $text_box.Select(0,0) - $text_box.Dock = [System.Windows.Forms.DockStyle]::Fill - $main_form.Controls.Add($text_box) -} - -$buttons_array = $buttons.Split(",") -foreach ($button in $buttons_array) { - $button_data = $button.Split(":") - $button_ctl = New-Object System.Windows.Forms.Button - if ($button_data.Length -eq 2) { - $button_ctl.Tag = $button_data[1] - } else { - $button_ctl.Tag = 100 + $buttons_array.IndexOf($button) - } - if ($default -eq $button_data[0]) { - $main_form.AcceptButton = $button_ctl - } - $button_ctl.Autosize = $true - $button_ctl.Text = $button_data[0] - $button_ctl.Add_Click( - { - Param($sender) - $global:Result = $sender.Tag - $main_form.Close() - } - ) - $button_panel.Controls.Add($button_ctl) -} -$main_form.Controls.Add($button_panel) - -$button_panel.ResumeLayout($false) -$main_form.ResumeLayout($false) - -if ($timeout -gt 0) { - $timer = New-Object System.Windows.Forms.Timer - $timer.Add_Tick( - { - $global:Result = 0 - $main_form.Close() - } - ) - $timer.Interval = $timeout - $timer.Start() -} -$dlg_res = $main_form.ShowDialog() - -[Environment]::Exit($global:Result) diff --git a/misc/scripts/black_format.sh b/misc/scripts/black_format.sh deleted file mode 100755 index 48dc14c734..0000000000 --- a/misc/scripts/black_format.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# This script runs black on all Python files in the repo. - -set -uo pipefail - -# Apply black. -echo -e "Formatting Python files..." -PY_FILES=$(git ls-files -- '*SConstruct' '*SCsub' '*.py' ':!:.git/*' ':!:thirdparty/*') -black -l 120 $PY_FILES - -diff=$(git diff --color) - -# If no diff has been generated all is OK, clean up, and exit. -if [ -z "$diff" ] ; then - printf "\e[1;32m*** Files in this commit comply with the black style rules.\e[0m\n" - exit 0 -fi - -# A diff has been created, notify the user, clean up, and exit. -printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n" -# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`. -printf "%s\n" "$diff" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge' - -printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n" -exit 1 diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh deleted file mode 100755 index 8b59519606..0000000000 --- a/misc/scripts/clang_format.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -# This script runs clang-format and fixes copyright headers on all relevant files in the repo. -# This is the primary script responsible for fixing style violations. - -set -uo pipefail - -if [ $# -eq 0 ]; then - # Loop through all code files tracked by Git. - files=$(git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \ - ':!:.git/*' ':!:thirdparty/*' ':!:*/thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' \ - ':!:*-so_wrap.*' ':!:tests/python_build/*') -else - # $1 should be a file listing file paths to process. Used in CI. - files=$(cat "$1" | grep -v "thirdparty/" | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$" | grep -v "platform/android/java/lib/src/com/google/" | grep -v "\-so_wrap\." | grep -v "tests/python_build/") -fi - -if [ ! -z "$files" ]; then - clang-format --Wno-error=unknown -i $files -fi - -# Fix copyright headers, but not all files get them. -for f in $files; do - if [[ "$f" == *"inc" && "$f" != *"compat.inc" ]]; then - continue - elif [[ "$f" == *"glsl" ]]; then - continue - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView"* ]]; then - continue - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper"* ]]; then - continue - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix"* ]]; then - continue - fi - - python misc/scripts/copyright_headers.py "$f" -done - -diff=$(git diff --color) - -# If no diff has been generated all is OK, clean up, and exit. -if [ -z "$diff" ] ; then - printf "\e[1;32m*** Files in this commit comply with the clang-format style rules.\e[0m\n" - exit 0 -fi - -# A diff has been created, notify the user, clean up, and exit. -printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n" -# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`. -printf "%s\n" "$diff" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge' - -printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n" -exit 1 diff --git a/modules/fbx/editor/editor_scene_importer_fbx2gltf.cpp b/modules/fbx/editor/editor_scene_importer_fbx2gltf.cpp index 8207149d16..3ef54ec0df 100644 --- a/modules/fbx/editor/editor_scene_importer_fbx2gltf.cpp +++ b/modules/fbx/editor/editor_scene_importer_fbx2gltf.cpp @@ -104,6 +104,9 @@ Node *EditorSceneFormatImporterFBX2GLTF::import_scene(const String &p_path, uint gltf.instantiate(); Ref<GLTFState> state; state.instantiate(); + if (p_options.has(SNAME("nodes/import_as_skeleton_bones")) ? (bool)p_options[SNAME("nodes/import_as_skeleton_bones")] : false) { + state->set_import_as_skeleton_bones(true); + } print_verbose(vformat("glTF path: %s", sink)); Error err = gltf->append_from_file(sink, state, p_flags, p_path.get_base_dir()); if (err != OK) { diff --git a/modules/fbx/editor/editor_scene_importer_ufbx.cpp b/modules/fbx/editor/editor_scene_importer_ufbx.cpp index 721caedc7c..241fdba0c5 100644 --- a/modules/fbx/editor/editor_scene_importer_ufbx.cpp +++ b/modules/fbx/editor/editor_scene_importer_ufbx.cpp @@ -73,6 +73,12 @@ Node *EditorSceneFormatImporterUFBX::import_scene(const String &p_path, uint32_t int32_t enum_option = p_options["fbx/embedded_image_handling"]; state->set_handle_binary_image(enum_option); } + if (p_options.has(SNAME("nodes/import_as_skeleton_bones")) ? (bool)p_options[SNAME("nodes/import_as_skeleton_bones")] : false) { + state->set_import_as_skeleton_bones(true); + } + if (p_options.has(SNAME("nodes/import_as_skeleton_bones")) ? (bool)p_options[SNAME("nodes/import_as_skeleton_bones")] : false) { + state->set_import_as_skeleton_bones(true); + } p_flags |= EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS; Error err = fbx->append_from_file(path, state, p_flags, p_path.get_base_dir()); if (err != OK) { diff --git a/modules/fbx/fbx_document.cpp b/modules/fbx/fbx_document.cpp index 2f8fd79be5..367117edcb 100644 --- a/modules/fbx/fbx_document.cpp +++ b/modules/fbx/fbx_document.cpp @@ -2086,7 +2086,7 @@ Error FBXDocument::_parse_fbx_state(Ref<FBXState> p_state, const String &p_searc ERR_FAIL_COND_V(err != OK, ERR_PARSE_ERROR); /* DETERMINE SKELETONS */ - err = SkinTool::_determine_skeletons(p_state->skins, p_state->nodes, p_state->skeletons); + err = SkinTool::_determine_skeletons(p_state->skins, p_state->nodes, p_state->skeletons, p_state->get_import_as_skeleton_bones() ? p_state->root_nodes : Vector<GLTFNodeIndex>()); ERR_FAIL_COND_V(err != OK, ERR_PARSE_ERROR); /* CREATE SKELETONS */ diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index 100750f400..6c7c5ee0e6 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -289,8 +289,13 @@ The file name associated with this GLTF data. If it ends with [code].gltf[/code], this is text-based GLTF, otherwise this is binary GLB. This will be set during import when appending from a file, and will be set during export when writing to a file. If writing to a buffer, this will be an empty string. </member> <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()"> + The binary buffer attached to a .glb file. + </member> + <member name="import_as_skeleton_bones" type="bool" setter="set_import_as_skeleton_bones" getter="get_import_as_skeleton_bones" default="false"> + True to force all GLTFNodes in the document to be bones of a single Skeleton3D godot node. </member> <member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}"> + The original raw JSON document corresponding to this GLTFState. </member> <member name="major_version" type="int" setter="set_major_version" getter="get_major_version" default="0"> </member> diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index a91856c4a1..c6e92de762 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -287,6 +287,9 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ if (p_options.has(SNAME("blender/materials/unpack_enabled")) && p_options[SNAME("blender/materials/unpack_enabled")]) { base_dir = sink.get_base_dir(); } + if (p_options.has(SNAME("nodes/import_as_skeleton_bones")) ? (bool)p_options[SNAME("nodes/import_as_skeleton_bones")] : false) { + state->set_import_as_skeleton_bones(true); + } state->set_scene_name(blend_basename); err = gltf->append_from_file(sink.get_basename() + ".gltf", state, p_flags, base_dir); if (err != OK) { diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 740c9a2aa7..0ed2100041 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -2796,7 +2796,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) { Vector<Vector3> normals = array[Mesh::ARRAY_NORMAL]; for (int k = 0; k < vertex_num; k++) { - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(normals[k]); + Vector3 tan = Vector3(normals[i].z, -normals[i].x, normals[i].y).cross(normals[k].normalized()).normalized(); tangentsw[k * 4 + 0] = tan.x; tangentsw[k * 4 + 1] = tan.y; tangentsw[k * 4 + 2] = tan.z; @@ -2822,6 +2822,19 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) { } array = mesh_surface_tool->commit_to_arrays(); + if ((flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && a.has("NORMAL") && (a.has("TANGENT") || generate_tangents)) { + // Compression is enabled, so let's validate that the normals and tangents are correct. + Vector<Vector3> normals = array[Mesh::ARRAY_NORMAL]; + Vector<float> tangents = array[Mesh::ARRAY_TANGENT]; + for (int vert = 0; vert < normals.size(); vert++) { + Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]); + if (abs(tan.dot(normals[vert])) > 0.0001) { + // Tangent is not perpendicular to the normal, so we can't use compression. + flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; + } + } + } + Array morphs; //blend shapes if (p.has("targets")) { @@ -6924,7 +6937,7 @@ Error GLTFDocument::_parse_gltf_state(Ref<GLTFState> p_state, const String &p_se ERR_FAIL_COND_V(err != OK, ERR_PARSE_ERROR); /* DETERMINE SKELETONS */ - err = SkinTool::_determine_skeletons(p_state->skins, p_state->nodes, p_state->skeletons); + err = SkinTool::_determine_skeletons(p_state->skins, p_state->nodes, p_state->skeletons, p_state->get_import_as_skeleton_bones() ? p_state->root_nodes : Vector<GLTFNodeIndex>()); ERR_FAIL_COND_V(err != OK, ERR_PARSE_ERROR); /* PARSE MESHES (we have enough info now) */ diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 0c47d5777c..ed31aadc01 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -90,6 +90,8 @@ void GLTFState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons); ClassDB::bind_method(D_METHOD("get_create_animations"), &GLTFState::get_create_animations); ClassDB::bind_method(D_METHOD("set_create_animations", "create_animations"), &GLTFState::set_create_animations); + ClassDB::bind_method(D_METHOD("get_import_as_skeleton_bones"), &GLTFState::get_import_as_skeleton_bones); + ClassDB::bind_method(D_METHOD("set_import_as_skeleton_bones", "import_as_skeleton_bones"), &GLTFState::set_import_as_skeleton_bones); ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations); ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations); ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node); @@ -125,6 +127,7 @@ void GLTFState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>> ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations"), "set_create_animations", "get_create_animations"); // bool + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "import_as_skeleton_bones"), "set_import_as_skeleton_bones", "get_import_as_skeleton_bones"); // bool ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>> ADD_PROPERTY(PropertyInfo(Variant::INT, "handle_binary_image", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed as Basis Universal,Embed as Uncompressed", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_handle_binary_image", "get_handle_binary_image"); // enum @@ -337,6 +340,14 @@ void GLTFState::set_create_animations(bool p_create_animations) { create_animations = p_create_animations; } +bool GLTFState::get_import_as_skeleton_bones() { + return import_as_skeleton_bones; +} + +void GLTFState::set_import_as_skeleton_bones(bool p_import_as_skeleton_bones) { + import_as_skeleton_bones = p_import_as_skeleton_bones; +} + TypedArray<GLTFAnimation> GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index c7171e0e68..c9efffa3ae 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -64,6 +64,7 @@ protected: bool force_generate_tangents = false; bool create_animations = true; bool force_disable_compression = false; + bool import_as_skeleton_bones = false; int handle_binary_image = HANDLE_BINARY_EXTRACT_TEXTURES; @@ -213,6 +214,9 @@ public: bool get_create_animations(); void set_create_animations(bool p_create_animations); + bool get_import_as_skeleton_bones(); + void set_import_as_skeleton_bones(bool p_import_as_skeleton_bones); + TypedArray<GLTFAnimation> get_animations(); void set_animations(TypedArray<GLTFAnimation> p_animations); diff --git a/modules/gltf/skin_tool.cpp b/modules/gltf/skin_tool.cpp index a008e870e6..2fb55a5f9e 100644 --- a/modules/gltf/skin_tool.cpp +++ b/modules/gltf/skin_tool.cpp @@ -285,7 +285,18 @@ void SkinTool::_recurse_children( Error SkinTool::_determine_skeletons( Vector<Ref<GLTFSkin>> &skins, Vector<Ref<GLTFNode>> &nodes, - Vector<Ref<GLTFSkeleton>> &skeletons) { + Vector<Ref<GLTFSkeleton>> &skeletons, + const Vector<GLTFNodeIndex> &p_single_skeleton_roots) { + if (!p_single_skeleton_roots.is_empty()) { + Ref<GLTFSkin> skin; + skin.instantiate(); + skin->set_name("godot_single_skeleton_root"); + for (GLTFNodeIndex i = 0; i < p_single_skeleton_roots.size(); i++) { + skin->joints.push_back(p_single_skeleton_roots[i]); + } + skins.push_back(skin); + } + // Using a disjoint set, we are going to potentially combine all skins that are actually branches // of a main skeleton, or treat skins defining the same set of nodes as ONE skeleton. // This is another unclear issue caused by the current glTF specification. diff --git a/modules/gltf/skin_tool.h b/modules/gltf/skin_tool.h index 8f7ab011ba..1ba95853f3 100644 --- a/modules/gltf/skin_tool.h +++ b/modules/gltf/skin_tool.h @@ -84,7 +84,8 @@ public: static Error _determine_skeletons( Vector<Ref<GLTFSkin>> &r_skins, Vector<Ref<GLTFNode>> &r_nodes, - Vector<Ref<GLTFSkeleton>> &r_skeletons); + Vector<Ref<GLTFSkeleton>> &r_skeletons, + const Vector<GLTFNodeIndex> &p_single_skeleton_roots); static Error _create_skeletons( HashSet<String> &r_unique_names, Vector<Ref<GLTFSkin>> &r_skins, diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index b4adc94c64..bf6cab11c7 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -511,6 +511,7 @@ namespace GodotTools FocusMode = Control.FocusModeEnum.None, Shortcut = EditorDefShortcut("mono/build_solution", "Build Project".TTR(), (Key)KeyModifierMask.MaskAlt | Key.B), ShortcutInTooltip = true, + ThemeTypeVariation = "RunBarButton", }; EditorShortcutOverride("mono/build_solution", "macos", (Key)KeyModifierMask.MaskMeta | (Key)KeyModifierMask.MaskCtrl | Key.B); diff --git a/modules/noise/noise_texture_3d.cpp b/modules/noise/noise_texture_3d.cpp index f2e01b0612..1e929e6f63 100644 --- a/modules/noise/noise_texture_3d.cpp +++ b/modules/noise/noise_texture_3d.cpp @@ -142,6 +142,8 @@ TypedArray<Image> NoiseTexture3D::_generate_texture() { return TypedArray<Image>(); } + ERR_FAIL_COND_V_MSG((int64_t)width * height * depth > Image::MAX_PIXELS, TypedArray<Image>(), "The NoiseTexture3D is too big, consider lowering its width, height, or depth."); + Vector<Ref<Image>> images; if (seamless) { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 471fda74bf..53182b8e2d 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -416,7 +416,7 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) { } } - if (EDITOR_GET("export/android/shutdown_adb_on_exit")) { + if (ea->has_runnable_preset.is_set() && EDITOR_GET("export/android/shutdown_adb_on_exit")) { String adb = get_adb_path(); if (!FileAccess::exists(adb)) { return; //adb not configured diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 2e5fd6180c..56c582e2d7 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -54,11 +54,11 @@ Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = { }; void Tweener::set_tween(const Ref<Tween> &p_tween) { - tween = p_tween; + tween_id = p_tween->get_instance_id(); } -void Tweener::clear_tween() { - tween.unref(); +Ref<Tween> Tweener::_get_tween() { + return Ref<Tween>(ObjectDB::get_instance(tween_id)); } void Tweener::_bind_methods() { @@ -192,12 +192,6 @@ bool Tween::is_valid() { void Tween::clear() { valid = false; - - for (List<Ref<Tweener>> &step : tweeners) { - for (Ref<Tweener> &tweener : step) { - tweener->clear_tween(); - } - } tweeners.clear(); } @@ -504,6 +498,7 @@ Tween::Tween(bool p_valid) { } Ref<PropertyTweener> PropertyTweener::from(const Variant &p_value) { + Ref<Tween> tween = _get_tween(); ERR_FAIL_COND_V(tween.is_null(), nullptr); Variant from_value = p_value; @@ -592,6 +587,8 @@ bool PropertyTweener::step(double &r_delta) { do_continue_delayed = false; } + Ref<Tween> tween = _get_tween(); + double time = MIN(elapsed_time - delay, duration); if (time < duration) { if (custom_method.is_valid()) { @@ -623,12 +620,12 @@ bool PropertyTweener::step(double &r_delta) { } void PropertyTweener::set_tween(const Ref<Tween> &p_tween) { - tween = p_tween; + Tweener::set_tween(p_tween); if (trans_type == Tween::TRANS_MAX) { - trans_type = tween->get_trans(); + trans_type = p_tween->get_trans(); } if (ease_type == Tween::EASE_MAX) { - ease_type = tween->get_ease(); + ease_type = p_tween->get_ease(); } } @@ -781,6 +778,8 @@ bool MethodTweener::step(double &r_delta) { return true; } + Ref<Tween> tween = _get_tween(); + Variant current_val; double time = MIN(elapsed_time - delay, duration); if (time < duration) { @@ -810,12 +809,12 @@ bool MethodTweener::step(double &r_delta) { } void MethodTweener::set_tween(const Ref<Tween> &p_tween) { - tween = p_tween; + Tweener::set_tween(p_tween); if (trans_type == Tween::TRANS_MAX) { - trans_type = tween->get_trans(); + trans_type = p_tween->get_trans(); } if (ease_type == Tween::EASE_MAX) { - ease_type = tween->get_ease(); + ease_type = p_tween->get_ease(); } } diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 8dcc3ad7b6..f5ae5e9776 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -39,16 +39,18 @@ class Node; class Tweener : public RefCounted { GDCLASS(Tweener, RefCounted); + ObjectID tween_id; + public: virtual void set_tween(const Ref<Tween> &p_tween); virtual void start() = 0; virtual bool step(double &r_delta) = 0; - void clear_tween(); protected: static void _bind_methods(); - Ref<Tween> tween; + Ref<Tween> _get_tween(); + double elapsed_time = 0; bool finished = false; }; @@ -291,7 +293,6 @@ private: Tween::TransitionType trans_type = Tween::TRANS_MAX; Tween::EaseType ease_type = Tween::EASE_MAX; - Ref<Tween> tween; Variant initial_val; Variant delta_val; Variant final_val; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 8f58c1e6f5..178af01a3e 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -187,6 +187,7 @@ void FileDialog::_notification(int p_what) { } refresh->set_icon(theme_cache.reload); show_hidden->set_icon(theme_cache.toggle_hidden); + makedir->set_icon(theme_cache.create_folder); dir_up->begin_bulk_theme_override(); dir_up->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); @@ -223,6 +224,13 @@ void FileDialog::_notification(int p_what) { show_hidden->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); show_hidden->end_bulk_theme_override(); + makedir->begin_bulk_theme_override(); + makedir->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); + makedir->add_theme_color_override("icon_hover_color", theme_cache.icon_hover_color); + makedir->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); + makedir->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); + makedir->end_bulk_theme_override(); + invalidate(); } break; @@ -1331,6 +1339,7 @@ void FileDialog::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, toggle_hidden); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, folder); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, file); + BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, create_folder); BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, FileDialog, folder_icon_color); BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, FileDialog, file_icon_color); @@ -1426,7 +1435,8 @@ FileDialog::FileDialog() { hbc->add_child(shortcuts_container); makedir = memnew(Button); - makedir->set_text(RTR("Create Folder")); + makedir->set_theme_type_variation("FlatButton"); + makedir->set_tooltip_text(RTR("Create a new folder.")); makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir)); hbc->add_child(makedir); vbox->add_child(hbc); diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 7356e1c9e3..1b53c7e05e 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -120,6 +120,7 @@ private: Ref<Texture2D> toggle_hidden; Ref<Texture2D> folder; Ref<Texture2D> file; + Ref<Texture2D> create_folder; Color folder_icon_color; Color file_icon_color; diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index a51e28c9fe..907c0ab4ca 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -208,7 +208,7 @@ void ImmediateMesh::surface_end() { if (uses_tangents) { t = tangents[i].normal.octahedron_tangent_encode(tangents[i].d); } else { - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(normals[i].normalized()); + Vector3 tan = Vector3(normals[i].z, -normals[i].x, normals[i].y).cross(normals[i].normalized()).normalized(); t = tan.octahedron_tangent_encode(1.0); } diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 653f234d3d..f51d8dd0bf 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -880,9 +880,9 @@ void SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays v.normal = narr[i]; } if (lformat & RS::ARRAY_FORMAT_TANGENT) { - Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]); - v.tangent = p.normal; - v.binormal = p.normal.cross(v.tangent).normalized() * p.d; + v.tangent = Vector3(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2]); + float d = tarr[i * 4 + 3]; + v.binormal = v.normal.cross(v.tangent).normalized() * d; } if (lformat & RS::ARRAY_FORMAT_COLOR) { v.color = carr[i]; diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index fa83e06315..634b32c9f6 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -651,6 +651,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_icon("toggle_hidden", "FileDialog", icons["visibility_visible"]); theme->set_icon("folder", "FileDialog", icons["folder"]); theme->set_icon("file", "FileDialog", icons["file"]); + theme->set_icon("create_folder", "FileDialog", icons["folder_create"]); theme->set_color("folder_icon_color", "FileDialog", Color(1, 1, 1)); theme->set_color("file_icon_color", "FileDialog", Color(1, 1, 1)); theme->set_color("file_disabled_color", "FileDialog", Color(1, 1, 1, 0.25)); diff --git a/scene/theme/icons/folder_create.svg b/scene/theme/icons/folder_create.svg new file mode 100644 index 0000000000..d11d0715a1 --- /dev/null +++ b/scene/theme/icons/folder_create.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M2 3a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8v-1H8v-4h2V8h4v2h1V7a1 1 0 0 0-1-1h-4a1 1 0 0 1-1-1V4a1 1 0 0 0-1-1Z" fill="#b2b2b2"/><path d="M13 13h2v-2h-2V9h-2v2H9v2h2v2h2z" fill="#fefffe"/></svg>
\ No newline at end of file diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 6e9b525f31..e5d8800366 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -340,7 +340,7 @@ void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r if (d < 0.0) { r_angle = CLAMP((1.0 - r_angle / Math_PI) * 0.5, 0.0, 0.49999); } else { - r_angle = (r_angle / Math_PI) * 0.5 + 0.5; + r_angle = CLAMP((r_angle / Math_PI) * 0.5 + 0.5, 0.500008, 1.0); } } @@ -566,7 +566,8 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint float angle; Vector3 axis; // Generate an arbitrary vector that is tangential to normal. - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(normal_src[i].normalized()); + // This assumes that the normal is never (0,0,0). + Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized(); Vector4 tangent = Vector4(tan.x, tan.y, tan.z, 1.0); _get_axis_angle(normal_src[i], tangent, angle, axis); @@ -689,7 +690,8 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint // Set data for tangent. for (int i = 0; i < p_vertex_array_len; i++) { // Generate an arbitrary vector that is tangential to normal. - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(normal_src[i].normalized()); + // This assumes that the normal is never (0,0,0). + Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized(); Vector2 res = tan.octahedron_tangent_encode(1.0); uint16_t vector[2] = { (uint16_t)CLAMP(res.x * 65535, 0, 65535), diff --git a/thirdparty/README.md b/thirdparty/README.md index 69a9d70756..4c276b3c00 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -724,7 +724,7 @@ with the provided patch. ## openxr - Upstream: https://github.com/KhronosGroup/OpenXR-SDK -- Version: 1.0.33 (dc1e23937fe45eabcce80f6588cf47449edb29d1, 2024) +- Version: 1.0.34 (288d3a7ebc1ad959f62d51da75baa3d27438c499, 2024) - License: Apache 2.0 Files extracted from upstream source: diff --git a/thirdparty/openxr/include/openxr/openxr.h b/thirdparty/openxr/include/openxr/openxr.h index 3e9d6599bb..c0c826b981 100644 --- a/thirdparty/openxr/include/openxr/openxr.h +++ b/thirdparty/openxr/include/openxr/openxr.h @@ -25,7 +25,7 @@ extern "C" { ((((major) & 0xffffULL) << 48) | (((minor) & 0xffffULL) << 32) | ((patch) & 0xffffffffULL)) // OpenXR current version number. -#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 33) +#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 34) #define XR_VERSION_MAJOR(version) (uint16_t)(((uint64_t)(version) >> 48)& 0xffffULL) #define XR_VERSION_MINOR(version) (uint16_t)(((uint64_t)(version) >> 32) & 0xffffULL) @@ -549,11 +549,19 @@ typedef enum XrStructureType { XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB = 1000238001, XR_TYPE_SPACE_USER_CREATE_INFO_FB = 1000241001, XR_TYPE_SYSTEM_HEADSET_ID_PROPERTIES_META = 1000245000, + XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_META = 1000254000, + XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_GET_INFO_META = 1000254001, XR_TYPE_SYSTEM_PASSTHROUGH_COLOR_LUT_PROPERTIES_META = 1000266000, XR_TYPE_PASSTHROUGH_COLOR_LUT_CREATE_INFO_META = 1000266001, XR_TYPE_PASSTHROUGH_COLOR_LUT_UPDATE_INFO_META = 1000266002, XR_TYPE_PASSTHROUGH_COLOR_MAP_LUT_META = 1000266100, XR_TYPE_PASSTHROUGH_COLOR_MAP_INTERPOLATED_LUT_META = 1000266101, + XR_TYPE_SPACE_TRIANGLE_MESH_GET_INFO_META = 1000269001, + XR_TYPE_SPACE_TRIANGLE_MESH_META = 1000269002, + XR_TYPE_SYSTEM_FACE_TRACKING_PROPERTIES2_FB = 1000287013, + XR_TYPE_FACE_TRACKER_CREATE_INFO2_FB = 1000287014, + XR_TYPE_FACE_EXPRESSION_INFO2_FB = 1000287015, + XR_TYPE_FACE_EXPRESSION_WEIGHTS2_FB = 1000287016, XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC = 1000317001, XR_TYPE_PASSTHROUGH_COLOR_HTC = 1000317002, XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC = 1000317003, @@ -575,6 +583,8 @@ typedef enum XrStructureType { XR_TYPE_PLANE_DETECTOR_LOCATION_EXT = 1000429005, XR_TYPE_PLANE_DETECTOR_POLYGON_BUFFER_EXT = 1000429006, XR_TYPE_SYSTEM_PLANE_DETECTION_PROPERTIES_EXT = 1000429007, + XR_TYPE_EVENT_DATA_USER_PRESENCE_CHANGED_EXT = 1000470000, + XR_TYPE_SYSTEM_USER_PRESENCE_PROPERTIES_EXT = 1000470001, XR_TYPE_GRAPHICS_BINDING_VULKAN2_KHR = XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR, XR_TYPE_SWAPCHAIN_IMAGE_VULKAN2_KHR = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR, XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR, @@ -672,6 +682,7 @@ typedef enum XrObjectType { XR_OBJECT_TYPE_VIRTUAL_KEYBOARD_META = 1000219000, XR_OBJECT_TYPE_SPACE_USER_FB = 1000241000, XR_OBJECT_TYPE_PASSTHROUGH_COLOR_LUT_META = 1000266000, + XR_OBJECT_TYPE_FACE_TRACKER2_FB = 1000287012, XR_OBJECT_TYPE_PASSTHROUGH_HTC = 1000317000, XR_OBJECT_TYPE_PLANE_DETECTOR_EXT = 1000429000, XR_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF @@ -3616,7 +3627,7 @@ typedef struct XrHandTrackingCapsulesStateFB { #define XR_FB_spatial_entity 1 XR_DEFINE_ATOM(XrAsyncRequestIdFB) #define XR_UUID_SIZE_EXT 16 -#define XR_FB_spatial_entity_SPEC_VERSION 2 +#define XR_FB_spatial_entity_SPEC_VERSION 3 #define XR_FB_SPATIAL_ENTITY_EXTENSION_NAME "XR_FB_spatial_entity" typedef enum XrSpaceComponentTypeFB { @@ -3628,6 +3639,7 @@ typedef enum XrSpaceComponentTypeFB { XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB = 5, XR_SPACE_COMPONENT_TYPE_ROOM_LAYOUT_FB = 6, XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB = 7, + XR_SPACE_COMPONENT_TYPE_TRIANGLE_MESH_META = 1000269000, XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB = 0x7FFFFFFF } XrSpaceComponentTypeFB; // XrSystemSpatialEntityPropertiesFB extends XrSystemProperties @@ -4332,6 +4344,11 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetViewOffsetVARJO( #endif /* !XR_NO_PROTOTYPES */ +#define XR_VARJO_xr4_controller_interaction 1 +#define XR_VARJO_xr4_controller_interaction_SPEC_VERSION 1 +#define XR_VARJO_XR4_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_VARJO_xr4_controller_interaction" + + #define XR_ML_ml2_controller_interaction 1 #define XR_ML_ml2_controller_interaction_SPEC_VERSION 1 #define XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_ML_ml2_controller_interaction" @@ -5151,13 +5168,14 @@ typedef struct XrHapticAmplitudeEnvelopeVibrationFB { #define XR_FB_scene 1 -#define XR_FB_scene_SPEC_VERSION 3 +#define XR_FB_scene_SPEC_VERSION 4 #define XR_FB_SCENE_EXTENSION_NAME "XR_FB_scene" typedef XrFlags64 XrSemanticLabelsSupportFlagsFB; // Flag bits for XrSemanticLabelsSupportFlagsFB static const XrSemanticLabelsSupportFlagsFB XR_SEMANTIC_LABELS_SUPPORT_MULTIPLE_SEMANTIC_LABELS_BIT_FB = 0x00000001; static const XrSemanticLabelsSupportFlagsFB XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_DESK_TO_TABLE_MIGRATION_BIT_FB = 0x00000002; +static const XrSemanticLabelsSupportFlagsFB XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_INVISIBLE_WALL_FACE_BIT_FB = 0x00000004; typedef struct XrExtent3DfFB { float width; @@ -5612,6 +5630,7 @@ static const XrCompositionLayerSettingsFlagsFB XR_COMPOSITION_LAYER_SETTINGS_NOR static const XrCompositionLayerSettingsFlagsFB XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB = 0x00000002; static const XrCompositionLayerSettingsFlagsFB XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB = 0x00000004; static const XrCompositionLayerSettingsFlagsFB XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB = 0x00000008; +static const XrCompositionLayerSettingsFlagsFB XR_COMPOSITION_LAYER_SETTINGS_AUTO_LAYER_FILTER_BIT_META = 0x00000020; // XrCompositionLayerSettingsFB extends XrCompositionLayerBaseHeader typedef struct XrCompositionLayerSettingsFB { @@ -6115,7 +6134,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrDestroySpaceUserFB( #define XR_META_headset_id 1 -#define XR_META_headset_id_SPEC_VERSION 1 +#define XR_META_headset_id_SPEC_VERSION 2 #define XR_META_HEADSET_ID_EXTENSION_NAME "XR_META_headset_id" // XrSystemHeadsetIdPropertiesMETA extends XrSystemProperties typedef struct XrSystemHeadsetIdPropertiesMETA { @@ -6126,6 +6145,35 @@ typedef struct XrSystemHeadsetIdPropertiesMETA { +#define XR_META_recommended_layer_resolution 1 +#define XR_META_recommended_layer_resolution_SPEC_VERSION 1 +#define XR_META_RECOMMENDED_LAYER_RESOLUTION_EXTENSION_NAME "XR_META_recommended_layer_resolution" +typedef struct XrRecommendedLayerResolutionMETA { + XrStructureType type; + void* XR_MAY_ALIAS next; + XrExtent2Di recommendedImageDimensions; + XrBool32 isValid; +} XrRecommendedLayerResolutionMETA; + +typedef struct XrRecommendedLayerResolutionGetInfoMETA { + XrStructureType type; + const void* XR_MAY_ALIAS next; + const XrCompositionLayerBaseHeader* layer; + XrTime predictedDisplayTime; +} XrRecommendedLayerResolutionGetInfoMETA; + +typedef XrResult (XRAPI_PTR *PFN_xrGetRecommendedLayerResolutionMETA)(XrSession session, const XrRecommendedLayerResolutionGetInfoMETA* info, XrRecommendedLayerResolutionMETA* resolution); + +#ifndef XR_NO_PROTOTYPES +#ifdef XR_EXTENSION_PROTOTYPES +XRAPI_ATTR XrResult XRAPI_CALL xrGetRecommendedLayerResolutionMETA( + XrSession session, + const XrRecommendedLayerResolutionGetInfoMETA* info, + XrRecommendedLayerResolutionMETA* resolution); +#endif /* XR_EXTENSION_PROTOTYPES */ +#endif /* !XR_NO_PROTOTYPES */ + + #define XR_META_passthrough_color_lut 1 XR_DEFINE_HANDLE(XrPassthroughColorLutMETA) #define XR_META_passthrough_color_lut_SPEC_VERSION 1 @@ -6200,11 +6248,201 @@ XRAPI_ATTR XrResult XRAPI_CALL xrUpdatePassthroughColorLutMETA( #endif /* !XR_NO_PROTOTYPES */ +#define XR_META_spatial_entity_mesh 1 +#define XR_META_spatial_entity_mesh_SPEC_VERSION 1 +#define XR_META_SPATIAL_ENTITY_MESH_EXTENSION_NAME "XR_META_spatial_entity_mesh" +typedef struct XrSpaceTriangleMeshGetInfoMETA { + XrStructureType type; + const void* XR_MAY_ALIAS next; +} XrSpaceTriangleMeshGetInfoMETA; + +typedef struct XrSpaceTriangleMeshMETA { + XrStructureType type; + void* XR_MAY_ALIAS next; + uint32_t vertexCapacityInput; + uint32_t vertexCountOutput; + XrVector3f* vertices; + uint32_t indexCapacityInput; + uint32_t indexCountOutput; + uint32_t* indices; +} XrSpaceTriangleMeshMETA; + +typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceTriangleMeshMETA)(XrSpace space, const XrSpaceTriangleMeshGetInfoMETA* getInfo, XrSpaceTriangleMeshMETA* triangleMeshOutput); + +#ifndef XR_NO_PROTOTYPES +#ifdef XR_EXTENSION_PROTOTYPES +XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceTriangleMeshMETA( + XrSpace space, + const XrSpaceTriangleMeshGetInfoMETA* getInfo, + XrSpaceTriangleMeshMETA* triangleMeshOutput); +#endif /* XR_EXTENSION_PROTOTYPES */ +#endif /* !XR_NO_PROTOTYPES */ + + +#define XR_META_automatic_layer_filter 1 +#define XR_META_automatic_layer_filter_SPEC_VERSION 1 +#define XR_META_AUTOMATIC_LAYER_FILTER_EXTENSION_NAME "XR_META_automatic_layer_filter" + + #define XR_META_touch_controller_plus 1 #define XR_META_touch_controller_plus_SPEC_VERSION 1 #define XR_META_TOUCH_CONTROLLER_PLUS_EXTENSION_NAME "XR_META_touch_controller_plus" +#define XR_FB_face_tracking2 1 +XR_DEFINE_HANDLE(XrFaceTracker2FB) +#define XR_FB_face_tracking2_SPEC_VERSION 1 +#define XR_FB_FACE_TRACKING2_EXTENSION_NAME "XR_FB_face_tracking2" + +typedef enum XrFaceExpression2FB { + XR_FACE_EXPRESSION2_BROW_LOWERER_L_FB = 0, + XR_FACE_EXPRESSION2_BROW_LOWERER_R_FB = 1, + XR_FACE_EXPRESSION2_CHEEK_PUFF_L_FB = 2, + XR_FACE_EXPRESSION2_CHEEK_PUFF_R_FB = 3, + XR_FACE_EXPRESSION2_CHEEK_RAISER_L_FB = 4, + XR_FACE_EXPRESSION2_CHEEK_RAISER_R_FB = 5, + XR_FACE_EXPRESSION2_CHEEK_SUCK_L_FB = 6, + XR_FACE_EXPRESSION2_CHEEK_SUCK_R_FB = 7, + XR_FACE_EXPRESSION2_CHIN_RAISER_B_FB = 8, + XR_FACE_EXPRESSION2_CHIN_RAISER_T_FB = 9, + XR_FACE_EXPRESSION2_DIMPLER_L_FB = 10, + XR_FACE_EXPRESSION2_DIMPLER_R_FB = 11, + XR_FACE_EXPRESSION2_EYES_CLOSED_L_FB = 12, + XR_FACE_EXPRESSION2_EYES_CLOSED_R_FB = 13, + XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_L_FB = 14, + XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_R_FB = 15, + XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_L_FB = 16, + XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_R_FB = 17, + XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_L_FB = 18, + XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_R_FB = 19, + XR_FACE_EXPRESSION2_EYES_LOOK_UP_L_FB = 20, + XR_FACE_EXPRESSION2_EYES_LOOK_UP_R_FB = 21, + XR_FACE_EXPRESSION2_INNER_BROW_RAISER_L_FB = 22, + XR_FACE_EXPRESSION2_INNER_BROW_RAISER_R_FB = 23, + XR_FACE_EXPRESSION2_JAW_DROP_FB = 24, + XR_FACE_EXPRESSION2_JAW_SIDEWAYS_LEFT_FB = 25, + XR_FACE_EXPRESSION2_JAW_SIDEWAYS_RIGHT_FB = 26, + XR_FACE_EXPRESSION2_JAW_THRUST_FB = 27, + XR_FACE_EXPRESSION2_LID_TIGHTENER_L_FB = 28, + XR_FACE_EXPRESSION2_LID_TIGHTENER_R_FB = 29, + XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_L_FB = 30, + XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_R_FB = 31, + XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_L_FB = 32, + XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_R_FB = 33, + XR_FACE_EXPRESSION2_LIP_FUNNELER_LB_FB = 34, + XR_FACE_EXPRESSION2_LIP_FUNNELER_LT_FB = 35, + XR_FACE_EXPRESSION2_LIP_FUNNELER_RB_FB = 36, + XR_FACE_EXPRESSION2_LIP_FUNNELER_RT_FB = 37, + XR_FACE_EXPRESSION2_LIP_PRESSOR_L_FB = 38, + XR_FACE_EXPRESSION2_LIP_PRESSOR_R_FB = 39, + XR_FACE_EXPRESSION2_LIP_PUCKER_L_FB = 40, + XR_FACE_EXPRESSION2_LIP_PUCKER_R_FB = 41, + XR_FACE_EXPRESSION2_LIP_STRETCHER_L_FB = 42, + XR_FACE_EXPRESSION2_LIP_STRETCHER_R_FB = 43, + XR_FACE_EXPRESSION2_LIP_SUCK_LB_FB = 44, + XR_FACE_EXPRESSION2_LIP_SUCK_LT_FB = 45, + XR_FACE_EXPRESSION2_LIP_SUCK_RB_FB = 46, + XR_FACE_EXPRESSION2_LIP_SUCK_RT_FB = 47, + XR_FACE_EXPRESSION2_LIP_TIGHTENER_L_FB = 48, + XR_FACE_EXPRESSION2_LIP_TIGHTENER_R_FB = 49, + XR_FACE_EXPRESSION2_LIPS_TOWARD_FB = 50, + XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_L_FB = 51, + XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_R_FB = 52, + XR_FACE_EXPRESSION2_MOUTH_LEFT_FB = 53, + XR_FACE_EXPRESSION2_MOUTH_RIGHT_FB = 54, + XR_FACE_EXPRESSION2_NOSE_WRINKLER_L_FB = 55, + XR_FACE_EXPRESSION2_NOSE_WRINKLER_R_FB = 56, + XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_L_FB = 57, + XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_R_FB = 58, + XR_FACE_EXPRESSION2_UPPER_LID_RAISER_L_FB = 59, + XR_FACE_EXPRESSION2_UPPER_LID_RAISER_R_FB = 60, + XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_L_FB = 61, + XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_R_FB = 62, + XR_FACE_EXPRESSION2_TONGUE_TIP_INTERDENTAL_FB = 63, + XR_FACE_EXPRESSION2_TONGUE_TIP_ALVEOLAR_FB = 64, + XR_FACE_EXPRESSION2_TONGUE_FRONT_DORSAL_PALATE_FB = 65, + XR_FACE_EXPRESSION2_TONGUE_MID_DORSAL_PALATE_FB = 66, + XR_FACE_EXPRESSION2_TONGUE_BACK_DORSAL_VELAR_FB = 67, + XR_FACE_EXPRESSION2_TONGUE_OUT_FB = 68, + XR_FACE_EXPRESSION2_TONGUE_RETREAT_FB = 69, + XR_FACE_EXPRESSION2_COUNT_FB = 70, + XR_FACE_EXPRESSION_2FB_MAX_ENUM_FB = 0x7FFFFFFF +} XrFaceExpression2FB; + +typedef enum XrFaceExpressionSet2FB { + XR_FACE_EXPRESSION_SET2_DEFAULT_FB = 0, + XR_FACE_EXPRESSION_SET_2FB_MAX_ENUM_FB = 0x7FFFFFFF +} XrFaceExpressionSet2FB; + +typedef enum XrFaceTrackingDataSource2FB { + XR_FACE_TRACKING_DATA_SOURCE2_VISUAL_FB = 0, + XR_FACE_TRACKING_DATA_SOURCE2_AUDIO_FB = 1, + XR_FACE_TRACKING_DATA_SOURCE_2FB_MAX_ENUM_FB = 0x7FFFFFFF +} XrFaceTrackingDataSource2FB; + +typedef enum XrFaceConfidence2FB { + XR_FACE_CONFIDENCE2_LOWER_FACE_FB = 0, + XR_FACE_CONFIDENCE2_UPPER_FACE_FB = 1, + XR_FACE_CONFIDENCE2_COUNT_FB = 2, + XR_FACE_CONFIDENCE_2FB_MAX_ENUM_FB = 0x7FFFFFFF +} XrFaceConfidence2FB; +// XrSystemFaceTrackingProperties2FB extends XrSystemProperties +typedef struct XrSystemFaceTrackingProperties2FB { + XrStructureType type; + void* XR_MAY_ALIAS next; + XrBool32 supportsVisualFaceTracking; + XrBool32 supportsAudioFaceTracking; +} XrSystemFaceTrackingProperties2FB; + +typedef struct XrFaceTrackerCreateInfo2FB { + XrStructureType type; + const void* XR_MAY_ALIAS next; + XrFaceExpressionSet2FB faceExpressionSet; + uint32_t requestedDataSourceCount; + XrFaceTrackingDataSource2FB* requestedDataSources; +} XrFaceTrackerCreateInfo2FB; + +typedef struct XrFaceExpressionInfo2FB { + XrStructureType type; + const void* XR_MAY_ALIAS next; + XrTime time; +} XrFaceExpressionInfo2FB; + +typedef struct XrFaceExpressionWeights2FB { + XrStructureType type; + void* XR_MAY_ALIAS next; + uint32_t weightCount; + float* weights; + uint32_t confidenceCount; + float* confidences; + XrBool32 isValid; + XrBool32 isEyeFollowingBlendshapesValid; + XrFaceTrackingDataSource2FB dataSource; + XrTime time; +} XrFaceExpressionWeights2FB; + +typedef XrResult (XRAPI_PTR *PFN_xrCreateFaceTracker2FB)(XrSession session, const XrFaceTrackerCreateInfo2FB* createInfo, XrFaceTracker2FB* faceTracker); +typedef XrResult (XRAPI_PTR *PFN_xrDestroyFaceTracker2FB)(XrFaceTracker2FB faceTracker); +typedef XrResult (XRAPI_PTR *PFN_xrGetFaceExpressionWeights2FB)(XrFaceTracker2FB faceTracker, const XrFaceExpressionInfo2FB* expressionInfo, XrFaceExpressionWeights2FB* expressionWeights); + +#ifndef XR_NO_PROTOTYPES +#ifdef XR_EXTENSION_PROTOTYPES +XRAPI_ATTR XrResult XRAPI_CALL xrCreateFaceTracker2FB( + XrSession session, + const XrFaceTrackerCreateInfo2FB* createInfo, + XrFaceTracker2FB* faceTracker); + +XRAPI_ATTR XrResult XRAPI_CALL xrDestroyFaceTracker2FB( + XrFaceTracker2FB faceTracker); + +XRAPI_ATTR XrResult XRAPI_CALL xrGetFaceExpressionWeights2FB( + XrFaceTracker2FB faceTracker, + const XrFaceExpressionInfo2FB* expressionInfo, + XrFaceExpressionWeights2FB* expressionWeights); +#endif /* XR_EXTENSION_PROTOTYPES */ +#endif /* !XR_NO_PROTOTYPES */ + + #define XR_EXT_uuid 1 #define XR_EXT_uuid_SPEC_VERSION 1 #define XR_EXT_UUID_EXTENSION_NAME "XR_EXT_uuid" @@ -6667,6 +6905,25 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetPlanePolygonBufferEXT( #define XR_OPPO_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_OPPO_controller_interaction" +#define XR_EXT_user_presence 1 +#define XR_EXT_user_presence_SPEC_VERSION 1 +#define XR_EXT_USER_PRESENCE_EXTENSION_NAME "XR_EXT_user_presence" +typedef struct XrEventDataUserPresenceChangedEXT { + XrStructureType type; + const void* XR_MAY_ALIAS next; + XrSession session; + XrBool32 isUserPresent; +} XrEventDataUserPresenceChangedEXT; + +// XrSystemUserPresencePropertiesEXT extends XrSystemProperties +typedef struct XrSystemUserPresencePropertiesEXT { + XrStructureType type; + void* XR_MAY_ALIAS next; + XrBool32 supportsUserPresence; +} XrSystemUserPresencePropertiesEXT; + + + #define XR_ML_user_calibration 1 #define XR_ML_user_calibration_SPEC_VERSION 1 #define XR_ML_USER_CALIBRATION_EXTENSION_NAME "XR_ML_user_calibration" diff --git a/thirdparty/openxr/include/openxr/openxr_reflection.h b/thirdparty/openxr/include/openxr/openxr_reflection.h index f6d66363bf..b449c7099b 100644 --- a/thirdparty/openxr/include/openxr/openxr_reflection.h +++ b/thirdparty/openxr/include/openxr/openxr_reflection.h @@ -444,11 +444,19 @@ XR_ENUM_STR(XrResult); _(XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB, 1000238001) \ _(XR_TYPE_SPACE_USER_CREATE_INFO_FB, 1000241001) \ _(XR_TYPE_SYSTEM_HEADSET_ID_PROPERTIES_META, 1000245000) \ + _(XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_META, 1000254000) \ + _(XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_GET_INFO_META, 1000254001) \ _(XR_TYPE_SYSTEM_PASSTHROUGH_COLOR_LUT_PROPERTIES_META, 1000266000) \ _(XR_TYPE_PASSTHROUGH_COLOR_LUT_CREATE_INFO_META, 1000266001) \ _(XR_TYPE_PASSTHROUGH_COLOR_LUT_UPDATE_INFO_META, 1000266002) \ _(XR_TYPE_PASSTHROUGH_COLOR_MAP_LUT_META, 1000266100) \ _(XR_TYPE_PASSTHROUGH_COLOR_MAP_INTERPOLATED_LUT_META, 1000266101) \ + _(XR_TYPE_SPACE_TRIANGLE_MESH_GET_INFO_META, 1000269001) \ + _(XR_TYPE_SPACE_TRIANGLE_MESH_META, 1000269002) \ + _(XR_TYPE_SYSTEM_FACE_TRACKING_PROPERTIES2_FB, 1000287013) \ + _(XR_TYPE_FACE_TRACKER_CREATE_INFO2_FB, 1000287014) \ + _(XR_TYPE_FACE_EXPRESSION_INFO2_FB, 1000287015) \ + _(XR_TYPE_FACE_EXPRESSION_WEIGHTS2_FB, 1000287016) \ _(XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC, 1000317001) \ _(XR_TYPE_PASSTHROUGH_COLOR_HTC, 1000317002) \ _(XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC, 1000317003) \ @@ -470,6 +478,8 @@ XR_ENUM_STR(XrResult); _(XR_TYPE_PLANE_DETECTOR_LOCATION_EXT, 1000429005) \ _(XR_TYPE_PLANE_DETECTOR_POLYGON_BUFFER_EXT, 1000429006) \ _(XR_TYPE_SYSTEM_PLANE_DETECTION_PROPERTIES_EXT, 1000429007) \ + _(XR_TYPE_EVENT_DATA_USER_PRESENCE_CHANGED_EXT, 1000470000) \ + _(XR_TYPE_SYSTEM_USER_PRESENCE_PROPERTIES_EXT, 1000470001) \ _(XR_STRUCTURE_TYPE_MAX_ENUM, 0x7FFFFFFF) #define XR_LIST_ENUM_XrFormFactor(_) \ @@ -555,6 +565,7 @@ XR_ENUM_STR(XrResult); _(XR_OBJECT_TYPE_VIRTUAL_KEYBOARD_META, 1000219000) \ _(XR_OBJECT_TYPE_SPACE_USER_FB, 1000241000) \ _(XR_OBJECT_TYPE_PASSTHROUGH_COLOR_LUT_META, 1000266000) \ + _(XR_OBJECT_TYPE_FACE_TRACKER2_FB, 1000287012) \ _(XR_OBJECT_TYPE_PASSTHROUGH_HTC, 1000317000) \ _(XR_OBJECT_TYPE_PLANE_DETECTOR_EXT, 1000429000) \ _(XR_OBJECT_TYPE_MAX_ENUM, 0x7FFFFFFF) @@ -891,6 +902,7 @@ XR_ENUM_STR(XrResult); _(XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB, 5) \ _(XR_SPACE_COMPONENT_TYPE_ROOM_LAYOUT_FB, 6) \ _(XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB, 7) \ + _(XR_SPACE_COMPONENT_TYPE_TRIANGLE_MESH_META, 1000269000) \ _(XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB, 0x7FFFFFFF) #define XR_LIST_ENUM_XrFoveationLevelFB(_) \ @@ -1209,6 +1221,95 @@ XR_ENUM_STR(XrResult); _(XR_PASSTHROUGH_COLOR_LUT_CHANNELS_RGBA_META, 2) \ _(XR_PASSTHROUGH_COLOR_LUT_CHANNELS_MAX_ENUM_META, 0x7FFFFFFF) +#define XR_LIST_ENUM_XrFaceExpression2FB(_) \ + _(XR_FACE_EXPRESSION2_BROW_LOWERER_L_FB, 0) \ + _(XR_FACE_EXPRESSION2_BROW_LOWERER_R_FB, 1) \ + _(XR_FACE_EXPRESSION2_CHEEK_PUFF_L_FB, 2) \ + _(XR_FACE_EXPRESSION2_CHEEK_PUFF_R_FB, 3) \ + _(XR_FACE_EXPRESSION2_CHEEK_RAISER_L_FB, 4) \ + _(XR_FACE_EXPRESSION2_CHEEK_RAISER_R_FB, 5) \ + _(XR_FACE_EXPRESSION2_CHEEK_SUCK_L_FB, 6) \ + _(XR_FACE_EXPRESSION2_CHEEK_SUCK_R_FB, 7) \ + _(XR_FACE_EXPRESSION2_CHIN_RAISER_B_FB, 8) \ + _(XR_FACE_EXPRESSION2_CHIN_RAISER_T_FB, 9) \ + _(XR_FACE_EXPRESSION2_DIMPLER_L_FB, 10) \ + _(XR_FACE_EXPRESSION2_DIMPLER_R_FB, 11) \ + _(XR_FACE_EXPRESSION2_EYES_CLOSED_L_FB, 12) \ + _(XR_FACE_EXPRESSION2_EYES_CLOSED_R_FB, 13) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_L_FB, 14) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_R_FB, 15) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_L_FB, 16) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_R_FB, 17) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_L_FB, 18) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_R_FB, 19) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_UP_L_FB, 20) \ + _(XR_FACE_EXPRESSION2_EYES_LOOK_UP_R_FB, 21) \ + _(XR_FACE_EXPRESSION2_INNER_BROW_RAISER_L_FB, 22) \ + _(XR_FACE_EXPRESSION2_INNER_BROW_RAISER_R_FB, 23) \ + _(XR_FACE_EXPRESSION2_JAW_DROP_FB, 24) \ + _(XR_FACE_EXPRESSION2_JAW_SIDEWAYS_LEFT_FB, 25) \ + _(XR_FACE_EXPRESSION2_JAW_SIDEWAYS_RIGHT_FB, 26) \ + _(XR_FACE_EXPRESSION2_JAW_THRUST_FB, 27) \ + _(XR_FACE_EXPRESSION2_LID_TIGHTENER_L_FB, 28) \ + _(XR_FACE_EXPRESSION2_LID_TIGHTENER_R_FB, 29) \ + _(XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_L_FB, 30) \ + _(XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_R_FB, 31) \ + _(XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_L_FB, 32) \ + _(XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_R_FB, 33) \ + _(XR_FACE_EXPRESSION2_LIP_FUNNELER_LB_FB, 34) \ + _(XR_FACE_EXPRESSION2_LIP_FUNNELER_LT_FB, 35) \ + _(XR_FACE_EXPRESSION2_LIP_FUNNELER_RB_FB, 36) \ + _(XR_FACE_EXPRESSION2_LIP_FUNNELER_RT_FB, 37) \ + _(XR_FACE_EXPRESSION2_LIP_PRESSOR_L_FB, 38) \ + _(XR_FACE_EXPRESSION2_LIP_PRESSOR_R_FB, 39) \ + _(XR_FACE_EXPRESSION2_LIP_PUCKER_L_FB, 40) \ + _(XR_FACE_EXPRESSION2_LIP_PUCKER_R_FB, 41) \ + _(XR_FACE_EXPRESSION2_LIP_STRETCHER_L_FB, 42) \ + _(XR_FACE_EXPRESSION2_LIP_STRETCHER_R_FB, 43) \ + _(XR_FACE_EXPRESSION2_LIP_SUCK_LB_FB, 44) \ + _(XR_FACE_EXPRESSION2_LIP_SUCK_LT_FB, 45) \ + _(XR_FACE_EXPRESSION2_LIP_SUCK_RB_FB, 46) \ + _(XR_FACE_EXPRESSION2_LIP_SUCK_RT_FB, 47) \ + _(XR_FACE_EXPRESSION2_LIP_TIGHTENER_L_FB, 48) \ + _(XR_FACE_EXPRESSION2_LIP_TIGHTENER_R_FB, 49) \ + _(XR_FACE_EXPRESSION2_LIPS_TOWARD_FB, 50) \ + _(XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_L_FB, 51) \ + _(XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_R_FB, 52) \ + _(XR_FACE_EXPRESSION2_MOUTH_LEFT_FB, 53) \ + _(XR_FACE_EXPRESSION2_MOUTH_RIGHT_FB, 54) \ + _(XR_FACE_EXPRESSION2_NOSE_WRINKLER_L_FB, 55) \ + _(XR_FACE_EXPRESSION2_NOSE_WRINKLER_R_FB, 56) \ + _(XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_L_FB, 57) \ + _(XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_R_FB, 58) \ + _(XR_FACE_EXPRESSION2_UPPER_LID_RAISER_L_FB, 59) \ + _(XR_FACE_EXPRESSION2_UPPER_LID_RAISER_R_FB, 60) \ + _(XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_L_FB, 61) \ + _(XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_R_FB, 62) \ + _(XR_FACE_EXPRESSION2_TONGUE_TIP_INTERDENTAL_FB, 63) \ + _(XR_FACE_EXPRESSION2_TONGUE_TIP_ALVEOLAR_FB, 64) \ + _(XR_FACE_EXPRESSION2_TONGUE_FRONT_DORSAL_PALATE_FB, 65) \ + _(XR_FACE_EXPRESSION2_TONGUE_MID_DORSAL_PALATE_FB, 66) \ + _(XR_FACE_EXPRESSION2_TONGUE_BACK_DORSAL_VELAR_FB, 67) \ + _(XR_FACE_EXPRESSION2_TONGUE_OUT_FB, 68) \ + _(XR_FACE_EXPRESSION2_TONGUE_RETREAT_FB, 69) \ + _(XR_FACE_EXPRESSION2_COUNT_FB, 70) \ + _(XR_FACE_EXPRESSION_2FB_MAX_ENUM_FB, 0x7FFFFFFF) + +#define XR_LIST_ENUM_XrFaceExpressionSet2FB(_) \ + _(XR_FACE_EXPRESSION_SET2_DEFAULT_FB, 0) \ + _(XR_FACE_EXPRESSION_SET_2FB_MAX_ENUM_FB, 0x7FFFFFFF) + +#define XR_LIST_ENUM_XrFaceTrackingDataSource2FB(_) \ + _(XR_FACE_TRACKING_DATA_SOURCE2_VISUAL_FB, 0) \ + _(XR_FACE_TRACKING_DATA_SOURCE2_AUDIO_FB, 1) \ + _(XR_FACE_TRACKING_DATA_SOURCE_2FB_MAX_ENUM_FB, 0x7FFFFFFF) + +#define XR_LIST_ENUM_XrFaceConfidence2FB(_) \ + _(XR_FACE_CONFIDENCE2_LOWER_FACE_FB, 0) \ + _(XR_FACE_CONFIDENCE2_UPPER_FACE_FB, 1) \ + _(XR_FACE_CONFIDENCE2_COUNT_FB, 2) \ + _(XR_FACE_CONFIDENCE_2FB_MAX_ENUM_FB, 0x7FFFFFFF) + #define XR_LIST_ENUM_XrTrackingOptimizationSettingsDomainQCOM(_) \ _(XR_TRACKING_OPTIMIZATION_SETTINGS_DOMAIN_ALL_QCOM, 1) \ _(XR_TRACKING_OPTIMIZATION_SETTINGS_DOMAIN_MAX_ENUM_QCOM, 0x7FFFFFFF) @@ -1437,6 +1538,7 @@ XR_ENUM_STR(XrResult); #define XR_LIST_BITS_XrSemanticLabelsSupportFlagsFB(_) \ _(XR_SEMANTIC_LABELS_SUPPORT_MULTIPLE_SEMANTIC_LABELS_BIT_FB, 0x00000001) \ _(XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_DESK_TO_TABLE_MIGRATION_BIT_FB, 0x00000002) \ + _(XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_INVISIBLE_WALL_FACE_BIT_FB, 0x00000004) \ #define XR_LIST_BITS_XrDigitalLensControlFlagsALMALENCE(_) \ _(XR_DIGITAL_LENS_CONTROL_PROCESSING_DISABLE_BIT_ALMALENCE, 0x00000001) \ @@ -1451,6 +1553,7 @@ XR_ENUM_STR(XrResult); _(XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB, 0x00000002) \ _(XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB, 0x00000004) \ _(XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB, 0x00000008) \ + _(XR_COMPOSITION_LAYER_SETTINGS_AUTO_LAYER_FILTER_BIT_META, 0x00000020) \ #define XR_LIST_BITS_XrPassthroughPreferenceFlagsMETA(_) \ _(XR_PASSTHROUGH_PREFERENCE_DEFAULT_TO_ACTIVE_BIT_META, 0x00000001) \ @@ -4141,6 +4244,20 @@ XR_ENUM_STR(XrResult); _(next) \ _(id) \ +/// Calls your macro with the name of each member of XrRecommendedLayerResolutionMETA, in order. +#define XR_LIST_STRUCT_XrRecommendedLayerResolutionMETA(_) \ + _(type) \ + _(next) \ + _(recommendedImageDimensions) \ + _(isValid) \ + +/// Calls your macro with the name of each member of XrRecommendedLayerResolutionGetInfoMETA, in order. +#define XR_LIST_STRUCT_XrRecommendedLayerResolutionGetInfoMETA(_) \ + _(type) \ + _(next) \ + _(layer) \ + _(predictedDisplayTime) \ + /// Calls your macro with the name of each member of XrPassthroughColorLutDataMETA, in order. #define XR_LIST_STRUCT_XrPassthroughColorLutDataMETA(_) \ _(bufferSize) \ @@ -4181,6 +4298,56 @@ XR_ENUM_STR(XrResult); _(next) \ _(maxColorLutResolution) \ +/// Calls your macro with the name of each member of XrSpaceTriangleMeshGetInfoMETA, in order. +#define XR_LIST_STRUCT_XrSpaceTriangleMeshGetInfoMETA(_) \ + _(type) \ + _(next) \ + +/// Calls your macro with the name of each member of XrSpaceTriangleMeshMETA, in order. +#define XR_LIST_STRUCT_XrSpaceTriangleMeshMETA(_) \ + _(type) \ + _(next) \ + _(vertexCapacityInput) \ + _(vertexCountOutput) \ + _(vertices) \ + _(indexCapacityInput) \ + _(indexCountOutput) \ + _(indices) \ + +/// Calls your macro with the name of each member of XrSystemFaceTrackingProperties2FB, in order. +#define XR_LIST_STRUCT_XrSystemFaceTrackingProperties2FB(_) \ + _(type) \ + _(next) \ + _(supportsVisualFaceTracking) \ + _(supportsAudioFaceTracking) \ + +/// Calls your macro with the name of each member of XrFaceTrackerCreateInfo2FB, in order. +#define XR_LIST_STRUCT_XrFaceTrackerCreateInfo2FB(_) \ + _(type) \ + _(next) \ + _(faceExpressionSet) \ + _(requestedDataSourceCount) \ + _(requestedDataSources) \ + +/// Calls your macro with the name of each member of XrFaceExpressionInfo2FB, in order. +#define XR_LIST_STRUCT_XrFaceExpressionInfo2FB(_) \ + _(type) \ + _(next) \ + _(time) \ + +/// Calls your macro with the name of each member of XrFaceExpressionWeights2FB, in order. +#define XR_LIST_STRUCT_XrFaceExpressionWeights2FB(_) \ + _(type) \ + _(next) \ + _(weightCount) \ + _(weights) \ + _(confidenceCount) \ + _(confidences) \ + _(isValid) \ + _(isEyeFollowingBlendshapesValid) \ + _(dataSource) \ + _(time) \ + /// Calls your macro with the name of each member of XrPassthroughCreateInfoHTC, in order. #define XR_LIST_STRUCT_XrPassthroughCreateInfoHTC(_) \ _(type) \ @@ -4372,6 +4539,19 @@ XR_ENUM_STR(XrResult); _(vertexCountOutput) \ _(vertices) \ +/// Calls your macro with the name of each member of XrEventDataUserPresenceChangedEXT, in order. +#define XR_LIST_STRUCT_XrEventDataUserPresenceChangedEXT(_) \ + _(type) \ + _(next) \ + _(session) \ + _(isUserPresent) \ + +/// Calls your macro with the name of each member of XrSystemUserPresencePropertiesEXT, in order. +#define XR_LIST_STRUCT_XrSystemUserPresencePropertiesEXT(_) \ + _(type) \ + _(next) \ + _(supportsUserPresence) \ + /// Calls your macro with the name of each member of XrEventDataHeadsetFitChangedML, in order. #define XR_LIST_STRUCT_XrEventDataHeadsetFitChangedML(_) \ _(type) \ @@ -4680,11 +4860,19 @@ XR_ENUM_STR(XrResult); _(XrEventDataSpaceListSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB) \ _(XrSpaceUserCreateInfoFB, XR_TYPE_SPACE_USER_CREATE_INFO_FB) \ _(XrSystemHeadsetIdPropertiesMETA, XR_TYPE_SYSTEM_HEADSET_ID_PROPERTIES_META) \ + _(XrRecommendedLayerResolutionMETA, XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_META) \ + _(XrRecommendedLayerResolutionGetInfoMETA, XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_GET_INFO_META) \ _(XrPassthroughColorLutCreateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_CREATE_INFO_META) \ _(XrPassthroughColorLutUpdateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_UPDATE_INFO_META) \ _(XrPassthroughColorMapLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_LUT_META) \ _(XrPassthroughColorMapInterpolatedLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_INTERPOLATED_LUT_META) \ _(XrSystemPassthroughColorLutPropertiesMETA, XR_TYPE_SYSTEM_PASSTHROUGH_COLOR_LUT_PROPERTIES_META) \ + _(XrSpaceTriangleMeshGetInfoMETA, XR_TYPE_SPACE_TRIANGLE_MESH_GET_INFO_META) \ + _(XrSpaceTriangleMeshMETA, XR_TYPE_SPACE_TRIANGLE_MESH_META) \ + _(XrSystemFaceTrackingProperties2FB, XR_TYPE_SYSTEM_FACE_TRACKING_PROPERTIES2_FB) \ + _(XrFaceTrackerCreateInfo2FB, XR_TYPE_FACE_TRACKER_CREATE_INFO2_FB) \ + _(XrFaceExpressionInfo2FB, XR_TYPE_FACE_EXPRESSION_INFO2_FB) \ + _(XrFaceExpressionWeights2FB, XR_TYPE_FACE_EXPRESSION_WEIGHTS2_FB) \ _(XrPassthroughCreateInfoHTC, XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC) \ _(XrPassthroughColorHTC, XR_TYPE_PASSTHROUGH_COLOR_HTC) \ _(XrPassthroughMeshTransformInfoHTC, XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC) \ @@ -4706,6 +4894,8 @@ XR_ENUM_STR(XrResult); _(XrPlaneDetectorLocationEXT, XR_TYPE_PLANE_DETECTOR_LOCATION_EXT) \ _(XrPlaneDetectorLocationsEXT, XR_TYPE_PLANE_DETECTOR_LOCATIONS_EXT) \ _(XrPlaneDetectorPolygonBufferEXT, XR_TYPE_PLANE_DETECTOR_POLYGON_BUFFER_EXT) \ + _(XrEventDataUserPresenceChangedEXT, XR_TYPE_EVENT_DATA_USER_PRESENCE_CHANGED_EXT) \ + _(XrSystemUserPresencePropertiesEXT, XR_TYPE_SYSTEM_USER_PRESENCE_PROPERTIES_EXT) \ _(XrEventDataHeadsetFitChangedML, XR_TYPE_EVENT_DATA_HEADSET_FIT_CHANGED_ML) \ _(XrEventDataEyeCalibrationChangedML, XR_TYPE_EVENT_DATA_EYE_CALIBRATION_CHANGED_ML) \ _(XrUserCalibrationEnableEventsInfoML, XR_TYPE_USER_CALIBRATION_ENABLE_EVENTS_INFO_ML) \ @@ -4960,6 +5150,7 @@ XR_ENUM_STR(XrResult); _(XR_VARJO_environment_depth_estimation, 124) \ _(XR_VARJO_marker_tracking, 125) \ _(XR_VARJO_view_offset, 126) \ + _(XR_VARJO_xr4_controller_interaction, 130) \ _(XR_ML_ml2_controller_interaction, 135) \ _(XR_ML_frame_end_info, 136) \ _(XR_ML_global_dimmer, 137) \ @@ -5003,8 +5194,12 @@ XR_ENUM_STR(XrResult); _(XR_FB_spatial_entity_storage_batch, 239) \ _(XR_FB_spatial_entity_user, 242) \ _(XR_META_headset_id, 246) \ + _(XR_META_recommended_layer_resolution, 255) \ _(XR_META_passthrough_color_lut, 267) \ + _(XR_META_spatial_entity_mesh, 270) \ + _(XR_META_automatic_layer_filter, 272) \ _(XR_META_touch_controller_plus, 280) \ + _(XR_FB_face_tracking2, 288) \ _(XR_EXT_uuid, 300) \ _(XR_EXT_hand_interaction, 303) \ _(XR_QCOM_tracking_optimization_settings, 307) \ @@ -5018,9 +5213,830 @@ XR_ENUM_STR(XrResult); _(XR_EXT_hand_tracking_data_source, 429) \ _(XR_EXT_plane_detection, 430) \ _(XR_OPPO_controller_interaction, 454) \ + _(XR_EXT_user_presence, 471) \ _(XR_ML_user_calibration, 473) \ _(XR_YVR_controller_interaction, 498) \ + +/// For every function defined by XR_VERSION_1_0 in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_VERSION_1_0(_) \ + _(GetInstanceProcAddr, VERSION_1_0) \ + _(EnumerateApiLayerProperties, VERSION_1_0) \ + _(EnumerateInstanceExtensionProperties, VERSION_1_0) \ + _(CreateInstance, VERSION_1_0) \ + _(DestroyInstance, VERSION_1_0) \ + _(GetInstanceProperties, VERSION_1_0) \ + _(PollEvent, VERSION_1_0) \ + _(ResultToString, VERSION_1_0) \ + _(StructureTypeToString, VERSION_1_0) \ + _(GetSystem, VERSION_1_0) \ + _(GetSystemProperties, VERSION_1_0) \ + _(EnumerateEnvironmentBlendModes, VERSION_1_0) \ + _(CreateSession, VERSION_1_0) \ + _(DestroySession, VERSION_1_0) \ + _(EnumerateReferenceSpaces, VERSION_1_0) \ + _(CreateReferenceSpace, VERSION_1_0) \ + _(GetReferenceSpaceBoundsRect, VERSION_1_0) \ + _(CreateActionSpace, VERSION_1_0) \ + _(LocateSpace, VERSION_1_0) \ + _(DestroySpace, VERSION_1_0) \ + _(EnumerateViewConfigurations, VERSION_1_0) \ + _(GetViewConfigurationProperties, VERSION_1_0) \ + _(EnumerateViewConfigurationViews, VERSION_1_0) \ + _(EnumerateSwapchainFormats, VERSION_1_0) \ + _(CreateSwapchain, VERSION_1_0) \ + _(DestroySwapchain, VERSION_1_0) \ + _(EnumerateSwapchainImages, VERSION_1_0) \ + _(AcquireSwapchainImage, VERSION_1_0) \ + _(WaitSwapchainImage, VERSION_1_0) \ + _(ReleaseSwapchainImage, VERSION_1_0) \ + _(BeginSession, VERSION_1_0) \ + _(EndSession, VERSION_1_0) \ + _(RequestExitSession, VERSION_1_0) \ + _(WaitFrame, VERSION_1_0) \ + _(BeginFrame, VERSION_1_0) \ + _(EndFrame, VERSION_1_0) \ + _(LocateViews, VERSION_1_0) \ + _(StringToPath, VERSION_1_0) \ + _(PathToString, VERSION_1_0) \ + _(CreateActionSet, VERSION_1_0) \ + _(DestroyActionSet, VERSION_1_0) \ + _(CreateAction, VERSION_1_0) \ + _(DestroyAction, VERSION_1_0) \ + _(SuggestInteractionProfileBindings, VERSION_1_0) \ + _(AttachSessionActionSets, VERSION_1_0) \ + _(GetCurrentInteractionProfile, VERSION_1_0) \ + _(GetActionStateBoolean, VERSION_1_0) \ + _(GetActionStateFloat, VERSION_1_0) \ + _(GetActionStateVector2f, VERSION_1_0) \ + _(GetActionStatePose, VERSION_1_0) \ + _(SyncActions, VERSION_1_0) \ + _(EnumerateBoundSourcesForAction, VERSION_1_0) \ + _(GetInputSourceLocalizedName, VERSION_1_0) \ + _(ApplyHapticFeedback, VERSION_1_0) \ + _(StopHapticFeedback, VERSION_1_0) \ + + +/// For every function defined by XR_LOADER_VERSION_1_0 in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_LOADER_VERSION_1_0(_) \ + _(CreateApiLayerInstance, LOADER_VERSION_1_0) \ + _(NegotiateLoaderRuntimeInterface, LOADER_VERSION_1_0) \ + _(NegotiateLoaderApiLayerInterface, LOADER_VERSION_1_0) \ + + +/// For every function defined by XR_KHR_android_thread_settings in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_android_thread_settings(_) \ + _(SetAndroidApplicationThreadKHR, KHR_android_thread_settings) \ + + +/// For every function defined by XR_KHR_android_surface_swapchain in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_android_surface_swapchain(_) \ + _(CreateSwapchainAndroidSurfaceKHR, KHR_android_surface_swapchain) \ + + +/// For every function defined by XR_KHR_opengl_enable in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_opengl_enable(_) \ + _(GetOpenGLGraphicsRequirementsKHR, KHR_opengl_enable) \ + + +/// For every function defined by XR_KHR_opengl_es_enable in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_opengl_es_enable(_) \ + _(GetOpenGLESGraphicsRequirementsKHR, KHR_opengl_es_enable) \ + + +/// For every function defined by XR_KHR_vulkan_enable in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_vulkan_enable(_) \ + _(GetVulkanInstanceExtensionsKHR, KHR_vulkan_enable) \ + _(GetVulkanDeviceExtensionsKHR, KHR_vulkan_enable) \ + _(GetVulkanGraphicsDeviceKHR, KHR_vulkan_enable) \ + _(GetVulkanGraphicsRequirementsKHR, KHR_vulkan_enable) \ + + +/// For every function defined by XR_KHR_D3D11_enable in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_D3D11_enable(_) \ + _(GetD3D11GraphicsRequirementsKHR, KHR_D3D11_enable) \ + + +/// For every function defined by XR_KHR_D3D12_enable in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_D3D12_enable(_) \ + _(GetD3D12GraphicsRequirementsKHR, KHR_D3D12_enable) \ + + +/// For every function defined by XR_KHR_visibility_mask in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_visibility_mask(_) \ + _(GetVisibilityMaskKHR, KHR_visibility_mask) \ + + +/// For every function defined by XR_KHR_win32_convert_performance_counter_time in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_win32_convert_performance_counter_time(_) \ + _(ConvertWin32PerformanceCounterToTimeKHR, KHR_win32_convert_performance_counter_time) \ + _(ConvertTimeToWin32PerformanceCounterKHR, KHR_win32_convert_performance_counter_time) \ + + +/// For every function defined by XR_KHR_convert_timespec_time in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_convert_timespec_time(_) \ + _(ConvertTimespecTimeToTimeKHR, KHR_convert_timespec_time) \ + _(ConvertTimeToTimespecTimeKHR, KHR_convert_timespec_time) \ + + +/// For every function defined by XR_KHR_loader_init in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_loader_init(_) \ + _(InitializeLoaderKHR, KHR_loader_init) \ + + +/// For every function defined by XR_KHR_vulkan_enable2 in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_KHR_vulkan_enable2(_) \ + _(CreateVulkanInstanceKHR, KHR_vulkan_enable2) \ + _(CreateVulkanDeviceKHR, KHR_vulkan_enable2) \ + _(GetVulkanGraphicsDevice2KHR, KHR_vulkan_enable2) \ + + +/// For every function defined by XR_EXT_performance_settings in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_EXT_performance_settings(_) \ + _(PerfSettingsSetPerformanceLevelEXT, EXT_performance_settings) \ + + +/// For every function defined by XR_EXT_thermal_query in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_EXT_thermal_query(_) \ + _(ThermalGetTemperatureTrendEXT, EXT_thermal_query) \ + + +/// For every function defined by XR_EXT_debug_utils in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_EXT_debug_utils(_) \ + _(SetDebugUtilsObjectNameEXT, EXT_debug_utils) \ + _(CreateDebugUtilsMessengerEXT, EXT_debug_utils) \ + _(DestroyDebugUtilsMessengerEXT, EXT_debug_utils) \ + _(SubmitDebugUtilsMessageEXT, EXT_debug_utils) \ + _(SessionBeginDebugUtilsLabelRegionEXT, EXT_debug_utils) \ + _(SessionEndDebugUtilsLabelRegionEXT, EXT_debug_utils) \ + _(SessionInsertDebugUtilsLabelEXT, EXT_debug_utils) \ + + +/// For every function defined by XR_MSFT_spatial_anchor in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_spatial_anchor(_) \ + _(CreateSpatialAnchorMSFT, MSFT_spatial_anchor) \ + _(CreateSpatialAnchorSpaceMSFT, MSFT_spatial_anchor) \ + _(DestroySpatialAnchorMSFT, MSFT_spatial_anchor) \ + + +/// For every function defined by XR_EXT_conformance_automation in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_EXT_conformance_automation(_) \ + _(SetInputDeviceActiveEXT, EXT_conformance_automation) \ + _(SetInputDeviceStateBoolEXT, EXT_conformance_automation) \ + _(SetInputDeviceStateFloatEXT, EXT_conformance_automation) \ + _(SetInputDeviceStateVector2fEXT, EXT_conformance_automation) \ + _(SetInputDeviceLocationEXT, EXT_conformance_automation) \ + + +/// For every function defined by XR_MSFT_spatial_graph_bridge in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_spatial_graph_bridge(_) \ + _(CreateSpatialGraphNodeSpaceMSFT, MSFT_spatial_graph_bridge) \ + _(TryCreateSpatialGraphStaticNodeBindingMSFT, MSFT_spatial_graph_bridge) \ + _(DestroySpatialGraphNodeBindingMSFT, MSFT_spatial_graph_bridge) \ + _(GetSpatialGraphNodeBindingPropertiesMSFT, MSFT_spatial_graph_bridge) \ + + +/// For every function defined by XR_EXT_hand_tracking in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_EXT_hand_tracking(_) \ + _(CreateHandTrackerEXT, EXT_hand_tracking) \ + _(DestroyHandTrackerEXT, EXT_hand_tracking) \ + _(LocateHandJointsEXT, EXT_hand_tracking) \ + + +/// For every function defined by XR_MSFT_hand_tracking_mesh in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_hand_tracking_mesh(_) \ + _(CreateHandMeshSpaceMSFT, MSFT_hand_tracking_mesh) \ + _(UpdateHandMeshMSFT, MSFT_hand_tracking_mesh) \ + + +/// For every function defined by XR_MSFT_controller_model in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_controller_model(_) \ + _(GetControllerModelKeyMSFT, MSFT_controller_model) \ + _(LoadControllerModelMSFT, MSFT_controller_model) \ + _(GetControllerModelPropertiesMSFT, MSFT_controller_model) \ + _(GetControllerModelStateMSFT, MSFT_controller_model) \ + + +/// For every function defined by XR_MSFT_perception_anchor_interop in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_perception_anchor_interop(_) \ + _(CreateSpatialAnchorFromPerceptionAnchorMSFT, MSFT_perception_anchor_interop) \ + _(TryGetPerceptionAnchorFromSpatialAnchorMSFT, MSFT_perception_anchor_interop) \ + + +/// For every function defined by XR_MSFT_composition_layer_reprojection in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_composition_layer_reprojection(_) \ + _(EnumerateReprojectionModesMSFT, MSFT_composition_layer_reprojection) \ + + +/// For every function defined by XR_FB_swapchain_update_state in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_swapchain_update_state(_) \ + _(UpdateSwapchainFB, FB_swapchain_update_state) \ + _(GetSwapchainStateFB, FB_swapchain_update_state) \ + + +/// For every function defined by XR_FB_body_tracking in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_body_tracking(_) \ + _(CreateBodyTrackerFB, FB_body_tracking) \ + _(DestroyBodyTrackerFB, FB_body_tracking) \ + _(LocateBodyJointsFB, FB_body_tracking) \ + _(GetBodySkeletonFB, FB_body_tracking) \ + + +/// For every function defined by XR_MSFT_scene_understanding in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_scene_understanding(_) \ + _(EnumerateSceneComputeFeaturesMSFT, MSFT_scene_understanding) \ + _(CreateSceneObserverMSFT, MSFT_scene_understanding) \ + _(DestroySceneObserverMSFT, MSFT_scene_understanding) \ + _(CreateSceneMSFT, MSFT_scene_understanding) \ + _(DestroySceneMSFT, MSFT_scene_understanding) \ + _(ComputeNewSceneMSFT, MSFT_scene_understanding) \ + _(GetSceneComputeStateMSFT, MSFT_scene_understanding) \ + _(GetSceneComponentsMSFT, MSFT_scene_understanding) \ + _(LocateSceneComponentsMSFT, MSFT_scene_understanding) \ + _(GetSceneMeshBuffersMSFT, MSFT_scene_understanding) \ + + +/// For every function defined by XR_MSFT_scene_understanding_serialization in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_scene_understanding_serialization(_) \ + _(DeserializeSceneMSFT, MSFT_scene_understanding_serialization) \ + _(GetSerializedSceneFragmentDataMSFT, MSFT_scene_understanding_serialization) \ + + +/// For every function defined by XR_FB_display_refresh_rate in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_display_refresh_rate(_) \ + _(EnumerateDisplayRefreshRatesFB, FB_display_refresh_rate) \ + _(GetDisplayRefreshRateFB, FB_display_refresh_rate) \ + _(RequestDisplayRefreshRateFB, FB_display_refresh_rate) \ + + +/// For every function defined by XR_HTCX_vive_tracker_interaction in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_HTCX_vive_tracker_interaction(_) \ + _(EnumerateViveTrackerPathsHTCX, HTCX_vive_tracker_interaction) \ + + +/// For every function defined by XR_HTC_facial_tracking in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_HTC_facial_tracking(_) \ + _(CreateFacialTrackerHTC, HTC_facial_tracking) \ + _(DestroyFacialTrackerHTC, HTC_facial_tracking) \ + _(GetFacialExpressionsHTC, HTC_facial_tracking) \ + + +/// For every function defined by XR_FB_color_space in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_color_space(_) \ + _(EnumerateColorSpacesFB, FB_color_space) \ + _(SetColorSpaceFB, FB_color_space) \ + + +/// For every function defined by XR_FB_hand_tracking_mesh in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_hand_tracking_mesh(_) \ + _(GetHandMeshFB, FB_hand_tracking_mesh) \ + + +/// For every function defined by XR_FB_spatial_entity in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity(_) \ + _(CreateSpatialAnchorFB, FB_spatial_entity) \ + _(GetSpaceUuidFB, FB_spatial_entity) \ + _(EnumerateSpaceSupportedComponentsFB, FB_spatial_entity) \ + _(SetSpaceComponentStatusFB, FB_spatial_entity) \ + _(GetSpaceComponentStatusFB, FB_spatial_entity) \ + + +/// For every function defined by XR_FB_foveation in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_foveation(_) \ + _(CreateFoveationProfileFB, FB_foveation) \ + _(DestroyFoveationProfileFB, FB_foveation) \ + + +/// For every function defined by XR_FB_keyboard_tracking in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_keyboard_tracking(_) \ + _(QuerySystemTrackedKeyboardFB, FB_keyboard_tracking) \ + _(CreateKeyboardSpaceFB, FB_keyboard_tracking) \ + + +/// For every function defined by XR_FB_triangle_mesh in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_triangle_mesh(_) \ + _(CreateTriangleMeshFB, FB_triangle_mesh) \ + _(DestroyTriangleMeshFB, FB_triangle_mesh) \ + _(TriangleMeshGetVertexBufferFB, FB_triangle_mesh) \ + _(TriangleMeshGetIndexBufferFB, FB_triangle_mesh) \ + _(TriangleMeshBeginUpdateFB, FB_triangle_mesh) \ + _(TriangleMeshEndUpdateFB, FB_triangle_mesh) \ + _(TriangleMeshBeginVertexBufferUpdateFB, FB_triangle_mesh) \ + _(TriangleMeshEndVertexBufferUpdateFB, FB_triangle_mesh) \ + + +/// For every function defined by XR_FB_passthrough in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_passthrough(_) \ + _(CreatePassthroughFB, FB_passthrough) \ + _(DestroyPassthroughFB, FB_passthrough) \ + _(PassthroughStartFB, FB_passthrough) \ + _(PassthroughPauseFB, FB_passthrough) \ + _(CreatePassthroughLayerFB, FB_passthrough) \ + _(DestroyPassthroughLayerFB, FB_passthrough) \ + _(PassthroughLayerPauseFB, FB_passthrough) \ + _(PassthroughLayerResumeFB, FB_passthrough) \ + _(PassthroughLayerSetStyleFB, FB_passthrough) \ + _(CreateGeometryInstanceFB, FB_passthrough) \ + _(DestroyGeometryInstanceFB, FB_passthrough) \ + _(GeometryInstanceSetTransformFB, FB_passthrough) \ + + +/// For every function defined by XR_FB_render_model in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_render_model(_) \ + _(EnumerateRenderModelPathsFB, FB_render_model) \ + _(GetRenderModelPropertiesFB, FB_render_model) \ + _(LoadRenderModelFB, FB_render_model) \ + + +/// For every function defined by XR_VARJO_environment_depth_estimation in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_VARJO_environment_depth_estimation(_) \ + _(SetEnvironmentDepthEstimationVARJO, VARJO_environment_depth_estimation) \ + + +/// For every function defined by XR_VARJO_marker_tracking in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_VARJO_marker_tracking(_) \ + _(SetMarkerTrackingVARJO, VARJO_marker_tracking) \ + _(SetMarkerTrackingTimeoutVARJO, VARJO_marker_tracking) \ + _(SetMarkerTrackingPredictionVARJO, VARJO_marker_tracking) \ + _(GetMarkerSizeVARJO, VARJO_marker_tracking) \ + _(CreateMarkerSpaceVARJO, VARJO_marker_tracking) \ + + +/// For every function defined by XR_VARJO_view_offset in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_VARJO_view_offset(_) \ + _(SetViewOffsetVARJO, VARJO_view_offset) \ + + +/// For every function defined by XR_ML_compat in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_ML_compat(_) \ + _(CreateSpaceFromCoordinateFrameUIDML, ML_compat) \ + + +/// For every function defined by XR_ML_marker_understanding in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_ML_marker_understanding(_) \ + _(CreateMarkerDetectorML, ML_marker_understanding) \ + _(DestroyMarkerDetectorML, ML_marker_understanding) \ + _(SnapshotMarkerDetectorML, ML_marker_understanding) \ + _(GetMarkerDetectorStateML, ML_marker_understanding) \ + _(GetMarkersML, ML_marker_understanding) \ + _(GetMarkerReprojectionErrorML, ML_marker_understanding) \ + _(GetMarkerLengthML, ML_marker_understanding) \ + _(GetMarkerNumberML, ML_marker_understanding) \ + _(GetMarkerStringML, ML_marker_understanding) \ + _(CreateMarkerSpaceML, ML_marker_understanding) \ + + +/// For every function defined by XR_ML_localization_map in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_ML_localization_map(_) \ + _(EnableLocalizationEventsML, ML_localization_map) \ + _(QueryLocalizationMapsML, ML_localization_map) \ + _(RequestMapLocalizationML, ML_localization_map) \ + _(ImportLocalizationMapML, ML_localization_map) \ + _(CreateExportedLocalizationMapML, ML_localization_map) \ + _(DestroyExportedLocalizationMapML, ML_localization_map) \ + _(GetExportedLocalizationMapDataML, ML_localization_map) \ + + +/// For every function defined by XR_MSFT_spatial_anchor_persistence in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_spatial_anchor_persistence(_) \ + _(CreateSpatialAnchorStoreConnectionMSFT, MSFT_spatial_anchor_persistence) \ + _(DestroySpatialAnchorStoreConnectionMSFT, MSFT_spatial_anchor_persistence) \ + _(PersistSpatialAnchorMSFT, MSFT_spatial_anchor_persistence) \ + _(EnumeratePersistedSpatialAnchorNamesMSFT, MSFT_spatial_anchor_persistence) \ + _(CreateSpatialAnchorFromPersistedNameMSFT, MSFT_spatial_anchor_persistence) \ + _(UnpersistSpatialAnchorMSFT, MSFT_spatial_anchor_persistence) \ + _(ClearSpatialAnchorStoreMSFT, MSFT_spatial_anchor_persistence) \ + + +/// For every function defined by XR_MSFT_scene_marker in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MSFT_scene_marker(_) \ + _(GetSceneMarkerRawDataMSFT, MSFT_scene_marker) \ + _(GetSceneMarkerDecodedStringMSFT, MSFT_scene_marker) \ + + +/// For every function defined by XR_FB_spatial_entity_query in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity_query(_) \ + _(QuerySpacesFB, FB_spatial_entity_query) \ + _(RetrieveSpaceQueryResultsFB, FB_spatial_entity_query) \ + + +/// For every function defined by XR_FB_spatial_entity_storage in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity_storage(_) \ + _(SaveSpaceFB, FB_spatial_entity_storage) \ + _(EraseSpaceFB, FB_spatial_entity_storage) \ + + +/// For every function defined by XR_OCULUS_audio_device_guid in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_OCULUS_audio_device_guid(_) \ + _(GetAudioOutputDeviceGuidOculus, OCULUS_audio_device_guid) \ + _(GetAudioInputDeviceGuidOculus, OCULUS_audio_device_guid) \ + + +/// For every function defined by XR_FB_spatial_entity_sharing in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity_sharing(_) \ + _(ShareSpacesFB, FB_spatial_entity_sharing) \ + + +/// For every function defined by XR_FB_scene in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_scene(_) \ + _(GetSpaceBoundingBox2DFB, FB_scene) \ + _(GetSpaceBoundingBox3DFB, FB_scene) \ + _(GetSpaceSemanticLabelsFB, FB_scene) \ + _(GetSpaceBoundary2DFB, FB_scene) \ + _(GetSpaceRoomLayoutFB, FB_scene) \ + + +/// For every function defined by XR_ALMALENCE_digital_lens_control in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_ALMALENCE_digital_lens_control(_) \ + _(SetDigitalLensControlALMALENCE, ALMALENCE_digital_lens_control) \ + + +/// For every function defined by XR_FB_scene_capture in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_scene_capture(_) \ + _(RequestSceneCaptureFB, FB_scene_capture) \ + + +/// For every function defined by XR_FB_spatial_entity_container in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity_container(_) \ + _(GetSpaceContainerFB, FB_spatial_entity_container) \ + + +/// For every function defined by XR_META_foveation_eye_tracked in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_foveation_eye_tracked(_) \ + _(GetFoveationEyeTrackedStateMETA, META_foveation_eye_tracked) \ + + +/// For every function defined by XR_FB_face_tracking in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_face_tracking(_) \ + _(CreateFaceTrackerFB, FB_face_tracking) \ + _(DestroyFaceTrackerFB, FB_face_tracking) \ + _(GetFaceExpressionWeightsFB, FB_face_tracking) \ + + +/// For every function defined by XR_FB_eye_tracking_social in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_eye_tracking_social(_) \ + _(CreateEyeTrackerFB, FB_eye_tracking_social) \ + _(DestroyEyeTrackerFB, FB_eye_tracking_social) \ + _(GetEyeGazesFB, FB_eye_tracking_social) \ + + +/// For every function defined by XR_FB_passthrough_keyboard_hands in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_passthrough_keyboard_hands(_) \ + _(PassthroughLayerSetKeyboardHandsIntensityFB, FB_passthrough_keyboard_hands) \ + + +/// For every function defined by XR_FB_haptic_pcm in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_haptic_pcm(_) \ + _(GetDeviceSampleRateFB, FB_haptic_pcm) \ + + +/// For every function defined by XR_META_passthrough_preferences in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_passthrough_preferences(_) \ + _(GetPassthroughPreferencesMETA, META_passthrough_preferences) \ + + +/// For every function defined by XR_META_virtual_keyboard in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_virtual_keyboard(_) \ + _(CreateVirtualKeyboardMETA, META_virtual_keyboard) \ + _(DestroyVirtualKeyboardMETA, META_virtual_keyboard) \ + _(CreateVirtualKeyboardSpaceMETA, META_virtual_keyboard) \ + _(SuggestVirtualKeyboardLocationMETA, META_virtual_keyboard) \ + _(GetVirtualKeyboardScaleMETA, META_virtual_keyboard) \ + _(SetVirtualKeyboardModelVisibilityMETA, META_virtual_keyboard) \ + _(GetVirtualKeyboardModelAnimationStatesMETA, META_virtual_keyboard) \ + _(GetVirtualKeyboardDirtyTexturesMETA, META_virtual_keyboard) \ + _(GetVirtualKeyboardTextureDataMETA, META_virtual_keyboard) \ + _(SendVirtualKeyboardInputMETA, META_virtual_keyboard) \ + _(ChangeVirtualKeyboardTextContextMETA, META_virtual_keyboard) \ + + +/// For every function defined by XR_OCULUS_external_camera in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_OCULUS_external_camera(_) \ + _(EnumerateExternalCamerasOCULUS, OCULUS_external_camera) \ + + +/// For every function defined by XR_META_performance_metrics in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_performance_metrics(_) \ + _(EnumeratePerformanceMetricsCounterPathsMETA, META_performance_metrics) \ + _(SetPerformanceMetricsStateMETA, META_performance_metrics) \ + _(GetPerformanceMetricsStateMETA, META_performance_metrics) \ + _(QueryPerformanceMetricsCounterMETA, META_performance_metrics) \ + + +/// For every function defined by XR_FB_spatial_entity_storage_batch in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity_storage_batch(_) \ + _(SaveSpaceListFB, FB_spatial_entity_storage_batch) \ + + +/// For every function defined by XR_FB_spatial_entity_user in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_spatial_entity_user(_) \ + _(CreateSpaceUserFB, FB_spatial_entity_user) \ + _(GetSpaceUserIdFB, FB_spatial_entity_user) \ + _(DestroySpaceUserFB, FB_spatial_entity_user) \ + + +/// For every function defined by XR_META_recommended_layer_resolution in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_recommended_layer_resolution(_) \ + _(GetRecommendedLayerResolutionMETA, META_recommended_layer_resolution) \ + + +/// For every function defined by XR_META_passthrough_color_lut in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_passthrough_color_lut(_) \ + _(CreatePassthroughColorLutMETA, META_passthrough_color_lut) \ + _(DestroyPassthroughColorLutMETA, META_passthrough_color_lut) \ + _(UpdatePassthroughColorLutMETA, META_passthrough_color_lut) \ + + +/// For every function defined by XR_META_spatial_entity_mesh in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_META_spatial_entity_mesh(_) \ + _(GetSpaceTriangleMeshMETA, META_spatial_entity_mesh) \ + + +/// For every function defined by XR_FB_face_tracking2 in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_FB_face_tracking2(_) \ + _(CreateFaceTracker2FB, FB_face_tracking2) \ + _(DestroyFaceTracker2FB, FB_face_tracking2) \ + _(GetFaceExpressionWeights2FB, FB_face_tracking2) \ + + +/// For every function defined by XR_QCOM_tracking_optimization_settings in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_QCOM_tracking_optimization_settings(_) \ + _(SetTrackingOptimizationSettingsHintQCOM, QCOM_tracking_optimization_settings) \ + + +/// For every function defined by XR_HTC_passthrough in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_HTC_passthrough(_) \ + _(CreatePassthroughHTC, HTC_passthrough) \ + _(DestroyPassthroughHTC, HTC_passthrough) \ + + +/// For every function defined by XR_HTC_foveation in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_HTC_foveation(_) \ + _(ApplyFoveationHTC, HTC_foveation) \ + + +/// For every function defined by XR_HTC_anchor in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_HTC_anchor(_) \ + _(CreateSpatialAnchorHTC, HTC_anchor) \ + _(GetSpatialAnchorNameHTC, HTC_anchor) \ + + +/// For every function defined by XR_MNDX_force_feedback_curl in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_MNDX_force_feedback_curl(_) \ + _(ApplyForceFeedbackCurlMNDX, MNDX_force_feedback_curl) \ + + +/// For every function defined by XR_EXT_plane_detection in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_EXT_plane_detection(_) \ + _(CreatePlaneDetectorEXT, EXT_plane_detection) \ + _(DestroyPlaneDetectorEXT, EXT_plane_detection) \ + _(BeginPlaneDetectionEXT, EXT_plane_detection) \ + _(GetPlaneDetectionStateEXT, EXT_plane_detection) \ + _(GetPlaneDetectionsEXT, EXT_plane_detection) \ + _(GetPlanePolygonBufferEXT, EXT_plane_detection) \ + + +/// For every function defined by XR_ML_user_calibration in this version of the spec, +/// calls your macro with the function name and extension name. +/// Trims the leading `xr` from the function name and the leading `XR_` from the feature name, +/// because it is easy to add back but impossible to remove with the preprocessor. +#define XR_LIST_FUNCTIONS_XR_ML_user_calibration(_) \ + _(EnableUserCalibrationEventsML, ML_user_calibration) \ + + + + #endif diff --git a/thirdparty/openxr/include/openxr/openxr_reflection_structs.h b/thirdparty/openxr/include/openxr/openxr_reflection_structs.h index bcc1333e29..f973539cbb 100644 --- a/thirdparty/openxr/include/openxr/openxr_reflection_structs.h +++ b/thirdparty/openxr/include/openxr/openxr_reflection_structs.h @@ -308,11 +308,19 @@ This file contains expansion macros (X Macros) for OpenXR structures. _avail(XrEventDataSpaceListSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB) \ _avail(XrSpaceUserCreateInfoFB, XR_TYPE_SPACE_USER_CREATE_INFO_FB) \ _avail(XrSystemHeadsetIdPropertiesMETA, XR_TYPE_SYSTEM_HEADSET_ID_PROPERTIES_META) \ + _avail(XrRecommendedLayerResolutionMETA, XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_META) \ + _avail(XrRecommendedLayerResolutionGetInfoMETA, XR_TYPE_RECOMMENDED_LAYER_RESOLUTION_GET_INFO_META) \ _avail(XrPassthroughColorLutCreateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_CREATE_INFO_META) \ _avail(XrPassthroughColorLutUpdateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_UPDATE_INFO_META) \ _avail(XrPassthroughColorMapLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_LUT_META) \ _avail(XrPassthroughColorMapInterpolatedLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_INTERPOLATED_LUT_META) \ _avail(XrSystemPassthroughColorLutPropertiesMETA, XR_TYPE_SYSTEM_PASSTHROUGH_COLOR_LUT_PROPERTIES_META) \ + _avail(XrSpaceTriangleMeshGetInfoMETA, XR_TYPE_SPACE_TRIANGLE_MESH_GET_INFO_META) \ + _avail(XrSpaceTriangleMeshMETA, XR_TYPE_SPACE_TRIANGLE_MESH_META) \ + _avail(XrSystemFaceTrackingProperties2FB, XR_TYPE_SYSTEM_FACE_TRACKING_PROPERTIES2_FB) \ + _avail(XrFaceTrackerCreateInfo2FB, XR_TYPE_FACE_TRACKER_CREATE_INFO2_FB) \ + _avail(XrFaceExpressionInfo2FB, XR_TYPE_FACE_EXPRESSION_INFO2_FB) \ + _avail(XrFaceExpressionWeights2FB, XR_TYPE_FACE_EXPRESSION_WEIGHTS2_FB) \ _avail(XrPassthroughCreateInfoHTC, XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC) \ _avail(XrPassthroughColorHTC, XR_TYPE_PASSTHROUGH_COLOR_HTC) \ _avail(XrPassthroughMeshTransformInfoHTC, XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC) \ @@ -334,6 +342,8 @@ This file contains expansion macros (X Macros) for OpenXR structures. _avail(XrPlaneDetectorLocationEXT, XR_TYPE_PLANE_DETECTOR_LOCATION_EXT) \ _avail(XrPlaneDetectorLocationsEXT, XR_TYPE_PLANE_DETECTOR_LOCATIONS_EXT) \ _avail(XrPlaneDetectorPolygonBufferEXT, XR_TYPE_PLANE_DETECTOR_POLYGON_BUFFER_EXT) \ + _avail(XrEventDataUserPresenceChangedEXT, XR_TYPE_EVENT_DATA_USER_PRESENCE_CHANGED_EXT) \ + _avail(XrSystemUserPresencePropertiesEXT, XR_TYPE_SYSTEM_USER_PRESENCE_PROPERTIES_EXT) \ _avail(XrEventDataHeadsetFitChangedML, XR_TYPE_EVENT_DATA_HEADSET_FIT_CHANGED_ML) \ _avail(XrEventDataEyeCalibrationChangedML, XR_TYPE_EVENT_DATA_EYE_CALIBRATION_CHANGED_ML) \ _avail(XrUserCalibrationEnableEventsInfoML, XR_TYPE_USER_CALIBRATION_ENABLE_EVENTS_INFO_ML) \ diff --git a/thirdparty/openxr/src/common/platform_utils.hpp b/thirdparty/openxr/src/common/platform_utils.hpp index c4d75bf259..35369a1477 100644 --- a/thirdparty/openxr/src/common/platform_utils.hpp +++ b/thirdparty/openxr/src/common/platform_utils.hpp @@ -323,6 +323,8 @@ static inline std::string PlatformUtilsGetSecureEnv(const char* name) { const std::string envValue = PlatformUtilsGetEnv(name); // Do not allow high integrity processes to act on data that can be controlled by medium integrity processes. + // Specifically, medium integrity processes can set environment variables which could then + // be read by high integrity processes. if (IsHighIntegrityLevel()) { if (!envValue.empty()) { LogPlatformUtilsError(std::string("!!! WARNING !!! Environment variable ") + name + diff --git a/thirdparty/openxr/src/loader/api_layer_interface.cpp b/thirdparty/openxr/src/loader/api_layer_interface.cpp index fb509de270..a93d45da37 100644 --- a/thirdparty/openxr/src/loader/api_layer_interface.cpp +++ b/thirdparty/openxr/src/loader/api_layer_interface.cpp @@ -72,10 +72,10 @@ XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_comm } // Find any implicit layers which we may need to report information for. - XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files); + XrResult result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files); if (XR_SUCCEEDED(result)) { // Find any explicit layers which we may need to report information for. - result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files); + result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files); } if (XR_FAILED(result)) { LoaderLogger::LogErrorMessage(openxr_command, @@ -126,10 +126,10 @@ XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& op // If a layer name is supplied, only use the information out of that one layer if (nullptr != layer_name && 0 != strlen(layer_name)) { - XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files); + XrResult result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files); if (XR_SUCCEEDED(result)) { // Find any explicit layers which we may need to report information for. - result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files); + result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files); if (XR_FAILED(result)) { LoaderLogger::LogErrorMessage( openxr_command, @@ -155,7 +155,7 @@ XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& op } // Otherwise, we want to add only implicit API layers and explicit API layers enabled using the environment variables } else { - XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files); + XrResult result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files); if (XR_SUCCEEDED(result)) { // Find any environmentally enabled explicit layers. If they're present, treat them like implicit layers // since we know that they're going to be enabled. @@ -163,7 +163,8 @@ XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& op AddEnvironmentApiLayers(env_enabled_layers); if (!env_enabled_layers.empty()) { std::vector<std::unique_ptr<ApiLayerManifestFile>> exp_layer_man_files = {}; - result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, exp_layer_man_files); + result = + ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_EXPLICIT_API_LAYER, exp_layer_man_files); if (XR_SUCCEEDED(result)) { for (auto& exp_layer_man_file : exp_layer_man_files) { for (std::string& enabled_layer : env_enabled_layers) { @@ -197,8 +198,8 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin std::vector<std::unique_ptr<ApiLayerManifestFile>> enabled_layer_manifest_files_in_init_order = {}; // Find any implicit layers. - XrResult result = - ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, enabled_layer_manifest_files_in_init_order); + XrResult result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_IMPLICIT_API_LAYER, + enabled_layer_manifest_files_in_init_order); for (const auto& enabled_layer_manifest_file : enabled_layer_manifest_files_in_init_order) { layers_already_found.insert(enabled_layer_manifest_file->LayerName()); @@ -208,7 +209,8 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin std::vector<std::unique_ptr<ApiLayerManifestFile>> explicit_layer_manifest_files = {}; if (XR_SUCCEEDED(result)) { - result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, explicit_layer_manifest_files); + result = ApiLayerManifestFile::FindManifestFiles(openxr_command, MANIFEST_TYPE_EXPLICIT_API_LAYER, + explicit_layer_manifest_files); } bool found_all_layers = true; diff --git a/thirdparty/openxr/src/loader/loader_init_data.cpp b/thirdparty/openxr/src/loader/loader_init_data.cpp index 11d3c4e77b..3ba6d26713 100644 --- a/thirdparty/openxr/src/loader/loader_init_data.cpp +++ b/thirdparty/openxr/src/loader/loader_init_data.cpp @@ -11,9 +11,9 @@ #ifdef XR_KHR_LOADER_INIT_SUPPORT -#ifdef XR_USE_PLATFORM_ANDROID // Check and copy the Android-specific init data. XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) { +#if defined(XR_USE_PLATFORM_ANDROID) if (info->type != XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR) { return XR_ERROR_VALIDATION_FAILURE; } @@ -40,11 +40,13 @@ XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) { const auto applicationContext = context.call<jni::Object>("getApplicationContext()Landroid/content/Context;"); const auto applicationInfo = context.call<jni::Object>("getApplicationInfo()Landroid/content/pm/ApplicationInfo;"); _native_library_path = applicationInfo.get<std::string>("nativeLibraryDir"); +#else +#error "Platform specific XR_KHR_loader_init structure is not defined for this platform." +#endif // XR_USE_PLATFORM_ANDROID _initialized = true; return XR_SUCCESS; } -#endif // XR_USE_PLATFORM_ANDROID XrResult InitializeLoaderInitData(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo) { return LoaderInitData::instance().initialize(loaderInitInfo); diff --git a/thirdparty/openxr/src/loader/loader_init_data.hpp b/thirdparty/openxr/src/loader/loader_init_data.hpp index fe6bc134d3..e3a27fc403 100644 --- a/thirdparty/openxr/src/loader/loader_init_data.hpp +++ b/thirdparty/openxr/src/loader/loader_init_data.hpp @@ -33,7 +33,7 @@ class LoaderInitData { return obj; } -#ifdef XR_USE_PLATFORM_ANDROID +#if defined(XR_USE_PLATFORM_ANDROID) /*! * Type alias for the platform-specific structure type. */ diff --git a/thirdparty/openxr/src/loader/manifest_file.cpp b/thirdparty/openxr/src/loader/manifest_file.cpp index f9699ece40..4e3e5b4947 100644 --- a/thirdparty/openxr/src/loader/manifest_file.cpp +++ b/thirdparty/openxr/src/loader/manifest_file.cpp @@ -600,14 +600,8 @@ void RuntimeManifestFile::CreateIfValid(const Json::Value &root_node, const std: // If the library_path variable has no directory symbol, it's just a file name and should be accessible on the // global library path. if (lib_path.find('\\') != std::string::npos || lib_path.find('/') != std::string::npos) { - // If the library_path is an absolute path, just use that if it exists - if (FileSysUtilsIsAbsolutePath(lib_path)) { - if (!FileSysUtilsPathExists(lib_path)) { - error_ss << filename << " library " << lib_path << " does not appear to exist"; - LoaderLogger::LogErrorMessage("", error_ss.str()); - return; - } - } else { + // If the library_path is an absolute path, just use that as-is. + if (!FileSysUtilsIsAbsolutePath(lib_path)) { // Otherwise, treat the library path as a relative path based on the JSON file. std::string canonical_path; std::string combined_path; @@ -618,8 +612,8 @@ void RuntimeManifestFile::CreateIfValid(const Json::Value &root_node, const std: canonical_path = filename; } if (!FileSysUtilsGetParentPath(canonical_path, file_parent) || - !FileSysUtilsCombinePaths(file_parent, lib_path, combined_path) || !FileSysUtilsPathExists(combined_path)) { - error_ss << filename << " library " << combined_path << " does not appear to exist"; + !FileSysUtilsCombinePaths(file_parent, lib_path, combined_path)) { + error_ss << filename << " filesystem operations failed for path " << canonical_path; LoaderLogger::LogErrorMessage("", error_ss.str()); return; } @@ -636,53 +630,58 @@ void RuntimeManifestFile::CreateIfValid(const Json::Value &root_node, const std: } // Find all manifest files in the appropriate search paths/registries for the given type. -XrResult RuntimeManifestFile::FindManifestFiles(std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files) { +XrResult RuntimeManifestFile::FindManifestFiles(const std::string &openxr_command, + std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files) { XrResult result = XR_SUCCESS; std::string filename = PlatformUtilsGetSecureEnv(OPENXR_RUNTIME_JSON_ENV_VAR); if (!filename.empty()) { LoaderLogger::LogInfoMessage( - "", "RuntimeManifestFile::FindManifestFiles - using environment variable override runtime file " + filename); + openxr_command, + "RuntimeManifestFile::FindManifestFiles - using environment variable override runtime file " + filename); } else { #ifdef XR_OS_WINDOWS std::vector<std::string> filenames; ReadRuntimeDataFilesInRegistry("", "ActiveRuntime", filenames); if (filenames.size() == 0) { LoaderLogger::LogErrorMessage( - "", "RuntimeManifestFile::FindManifestFiles - failed to find active runtime file in registry"); + openxr_command, "RuntimeManifestFile::FindManifestFiles - failed to find active runtime file in registry"); return XR_ERROR_RUNTIME_UNAVAILABLE; } if (filenames.size() > 1) { LoaderLogger::LogWarningMessage( - "", "RuntimeManifestFile::FindManifestFiles - found too many default runtime files in registry"); + openxr_command, "RuntimeManifestFile::FindManifestFiles - found too many default runtime files in registry"); } filename = filenames[0]; - LoaderLogger::LogInfoMessage("", + LoaderLogger::LogInfoMessage(openxr_command, "RuntimeManifestFile::FindManifestFiles - using registry-specified runtime file " + filename); #elif defined(XR_OS_LINUX) if (!FindXDGConfigFile("openxr/", XR_VERSION_MAJOR(XR_CURRENT_API_VERSION), filename)) { LoaderLogger::LogErrorMessage( - "", "RuntimeManifestFile::FindManifestFiles - failed to determine active runtime file path for this environment"); + openxr_command, + "RuntimeManifestFile::FindManifestFiles - failed to determine active runtime file path for this environment"); return XR_ERROR_RUNTIME_UNAVAILABLE; } -#else +#else // !defined(XR_OS_WINDOWS) && !defined(XR_OS_LINUX) -#if defined(XR_USE_PLATFORM_ANDROID) +#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID) Json::Value virtualManifest; result = GetPlatformRuntimeVirtualManifest(virtualManifest); if (XR_SUCCESS == result) { RuntimeManifestFile::CreateIfValid(virtualManifest, "", manifest_files); return result; } -#endif // defined(XR_USE_PLATFORM_ANDROID) +#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT) if (!PlatformGetGlobalRuntimeFileName(XR_VERSION_MAJOR(XR_CURRENT_API_VERSION), filename)) { LoaderLogger::LogErrorMessage( - "", "RuntimeManifestFile::FindManifestFiles - failed to determine active runtime file path for this environment"); + openxr_command, + "RuntimeManifestFile::FindManifestFiles - failed to determine active runtime file path for this environment"); return XR_ERROR_RUNTIME_UNAVAILABLE; } result = XR_SUCCESS; - LoaderLogger::LogInfoMessage("", "RuntimeManifestFile::FindManifestFiles - using global runtime file " + filename); -#endif + LoaderLogger::LogInfoMessage(openxr_command, + "RuntimeManifestFile::FindManifestFiles - using global runtime file " + filename); +#endif // !defined(XR_OS_WINDOWS) && !defined(XR_OS_LINUX) } RuntimeManifestFile::CreateIfValid(filename, manifest_files); @@ -698,9 +697,17 @@ ApiLayerManifestFile::ApiLayerManifestFile(ManifestFileType type, const std::str _description(description), _implementation_version(implementation_version) {} -#ifdef XR_USE_PLATFORM_ANDROID -void ApiLayerManifestFile::AddManifestFilesAndroid(ManifestFileType type, +#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID) +void ApiLayerManifestFile::AddManifestFilesAndroid(const std::string &openxr_command, ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) { + if (!LoaderInitData::instance().initialized()) { + // This will happen for applications that do not call xrInitializeLoaderKHR + LoaderLogger::LogWarningMessage( + openxr_command, + "ApiLayerManifestFile::AddManifestFilesAndroid unable to add manifest files LoaderInitData not initialized."); + return; + } + AAssetManager *assetManager = (AAssetManager *)Android_Get_Asset_Manager(); std::vector<std::string> filenames; { @@ -736,7 +743,7 @@ void ApiLayerManifestFile::AddManifestFilesAndroid(ManifestFileType type, UniqueAsset asset{AAssetManager_open(assetManager, filename.c_str(), AASSET_MODE_BUFFER)}; if (!asset) { LoaderLogger::LogWarningMessage( - "", "ApiLayerManifestFile::AddManifestFilesAndroid unable to open asset " + filename + ", skipping"); + openxr_command, "ApiLayerManifestFile::AddManifestFilesAndroid unable to open asset " + filename + ", skipping"); continue; } @@ -744,7 +751,7 @@ void ApiLayerManifestFile::AddManifestFilesAndroid(ManifestFileType type, const char *buf = reinterpret_cast<const char *>(AAsset_getBuffer(asset.get())); if (!buf) { LoaderLogger::LogWarningMessage( - "", "ApiLayerManifestFile::AddManifestFilesAndroid unable to access asset" + filename + ", skipping"); + openxr_command, "ApiLayerManifestFile::AddManifestFilesAndroid unable to access asset" + filename + ", skipping"); continue; } @@ -754,7 +761,7 @@ void ApiLayerManifestFile::AddManifestFilesAndroid(ManifestFileType type, &ApiLayerManifestFile::LocateLibraryInAssets, manifest_files); } } -#endif // XR_USE_PLATFORM_ANDROID +#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT) void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename, std::istream &json_stream, LibraryLocator locate_library, @@ -898,7 +905,7 @@ bool ApiLayerManifestFile::LocateLibraryRelativeToJson( return true; } -#ifdef XR_USE_PLATFORM_ANDROID +#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID) bool ApiLayerManifestFile::LocateLibraryInAssets(const std::string & /* json_filename */, const std::string &library_path, std::string &out_combined_path) { std::string combined_path; @@ -910,7 +917,7 @@ bool ApiLayerManifestFile::LocateLibraryInAssets(const std::string & /* json_fil out_combined_path = combined_path; return true; } -#endif +#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT) void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &props) const { props.layerVersion = _implementation_version; @@ -926,7 +933,7 @@ void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &prop } // Find all layer manifest files in the appropriate search paths/registries for the given type. -XrResult ApiLayerManifestFile::FindManifestFiles(ManifestFileType type, +XrResult ApiLayerManifestFile::FindManifestFiles(const std::string &openxr_command, ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) { std::string relative_path; std::string override_env_var; @@ -953,7 +960,8 @@ XrResult ApiLayerManifestFile::FindManifestFiles(ManifestFileType type, #endif break; default: - LoaderLogger::LogErrorMessage("", "ApiLayerManifestFile::FindManifestFiles - unknown manifest file requested"); + LoaderLogger::LogErrorMessage(openxr_command, + "ApiLayerManifestFile::FindManifestFiles - unknown manifest file requested"); return XR_ERROR_FILE_ACCESS_ERROR; } @@ -972,9 +980,9 @@ XrResult ApiLayerManifestFile::FindManifestFiles(ManifestFileType type, ApiLayerManifestFile::CreateIfValid(type, cur_file, manifest_files); } -#ifdef XR_USE_PLATFORM_ANDROID - ApiLayerManifestFile::AddManifestFilesAndroid(type, manifest_files); -#endif // XR_USE_PLATFORM_ANDROID +#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID) + ApiLayerManifestFile::AddManifestFilesAndroid(openxr_command, type, manifest_files); +#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT) return XR_SUCCESS; } diff --git a/thirdparty/openxr/src/loader/manifest_file.hpp b/thirdparty/openxr/src/loader/manifest_file.hpp index 52fe3134b0..801614ad1e 100644 --- a/thirdparty/openxr/src/loader/manifest_file.hpp +++ b/thirdparty/openxr/src/loader/manifest_file.hpp @@ -71,7 +71,8 @@ class ManifestFile { class RuntimeManifestFile : public ManifestFile { public: // Factory method - static XrResult FindManifestFiles(std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files); + static XrResult FindManifestFiles(const std::string &openxr_command, + std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files); private: RuntimeManifestFile(const std::string &filename, const std::string &library_path); @@ -87,7 +88,8 @@ using LibraryLocator = bool (*)(const std::string &json_filename, const std::str class ApiLayerManifestFile : public ManifestFile { public: // Factory method - static XrResult FindManifestFiles(ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files); + static XrResult FindManifestFiles(const std::string &openxr_command, ManifestFileType type, + std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files); const std::string &LayerName() const { return _layer_name; } void PopulateApiLayerProperties(XrApiLayerProperties &props) const; @@ -104,11 +106,13 @@ class ApiLayerManifestFile : public ManifestFile { /// @return false if we could not find the library. static bool LocateLibraryRelativeToJson(const std::string &json_filename, const std::string &library_path, std::string &out_combined_path); -#ifdef XR_USE_PLATFORM_ANDROID + +#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID) static bool LocateLibraryInAssets(const std::string &json_filename, const std::string &library_path, std::string &out_combined_path); - static void AddManifestFilesAndroid(ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files); -#endif + static void AddManifestFilesAndroid(const std::string &openxr_command, ManifestFileType type, + std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files); +#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT) JsonVersion _api_version; std::string _layer_name; diff --git a/thirdparty/openxr/src/loader/runtime_interface.cpp b/thirdparty/openxr/src/loader/runtime_interface.cpp index 7812aca987..a0296c738c 100644 --- a/thirdparty/openxr/src/loader/runtime_interface.cpp +++ b/thirdparty/openxr/src/loader/runtime_interface.cpp @@ -34,7 +34,7 @@ #include <openxr/openxr_platform.h> #endif // XR_USE_PLATFORM_ANDROID -#ifdef XR_USE_PLATFORM_ANDROID +#if defined(XR_KHR_LOADER_INIT_SUPPORT) && defined(XR_USE_PLATFORM_ANDROID) XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest) { using wrap::android::content::Context; auto& initData = LoaderInitData::instance(); @@ -52,7 +52,7 @@ XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest) { out_manifest = virtualManifest; return XR_SUCCESS; } -#endif // XR_USE_PLATFORM_ANDROID +#endif // defined(XR_USE_PLATFORM_ANDROID) && defined(XR_KHR_LOADER_INIT_SUPPORT) XrResult RuntimeInterface::TryLoadingSingleRuntime(const std::string& openxr_command, std::unique_ptr<RuntimeManifestFile>& manifest_file) { @@ -227,7 +227,6 @@ XrResult RuntimeInterface::LoadRuntime(const std::string& openxr_command) { return XR_SUCCESS; } #ifdef XR_KHR_LOADER_INIT_SUPPORT - if (!LoaderInitData::instance().initialized()) { LoaderLogger::LogErrorMessage( openxr_command, "RuntimeInterface::LoadRuntime cannot run because xrInitializeLoaderKHR was not successfully called."); @@ -238,7 +237,7 @@ XrResult RuntimeInterface::LoadRuntime(const std::string& openxr_command) { std::vector<std::unique_ptr<RuntimeManifestFile>> runtime_manifest_files = {}; // Find the available runtimes which we may need to report information for. - XrResult last_error = RuntimeManifestFile::FindManifestFiles(runtime_manifest_files); + XrResult last_error = RuntimeManifestFile::FindManifestFiles(openxr_command, runtime_manifest_files); if (XR_FAILED(last_error)) { LoaderLogger::LogErrorMessage(openxr_command, "RuntimeInterface::LoadRuntimes - unknown error"); } else { |