summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/android_builds.yml7
-rw-r--r--.github/workflows/linux_builds.yml29
-rw-r--r--.github/workflows/static_checks.yml16
-rw-r--r--core/config/project_settings.cpp23
-rw-r--r--core/config/project_settings.h8
-rw-r--r--core/extension/gdextension_interface.h1
-rw-r--r--core/input/input.cpp9
-rw-r--r--core/input/input_event.cpp2
-rw-r--r--core/input/input_event.h2
-rw-r--r--core/math/basis.cpp7
-rw-r--r--core/math/quick_hull.cpp10
-rw-r--r--core/math/transform_2d.cpp8
-rw-r--r--core/object/script_language.cpp4
-rw-r--r--core/object/script_language.h1
-rw-r--r--core/object/worker_thread_pool.h4
-rw-r--r--core/string/node_path.cpp5
-rw-r--r--core/string/node_path.h1
-rw-r--r--core/string/string_name.cpp59
-rw-r--r--core/variant/array.cpp7
-rw-r--r--core/variant/array.h4
-rw-r--r--core/variant/container_type_validate.h36
-rw-r--r--core/variant/variant.cpp9
-rw-r--r--doc/classes/AnimationNode.xml17
-rw-r--r--doc/classes/AnimationTree.xml7
-rw-r--r--doc/classes/Array.xml26
-rw-r--r--doc/classes/Callable.xml4
-rw-r--r--doc/classes/CanvasGroup.xml1
-rw-r--r--doc/classes/Control.xml6
-rw-r--r--doc/classes/Decal.xml1
-rw-r--r--doc/classes/DisplayServer.xml8
-rw-r--r--doc/classes/EditorImportPlugin.xml10
-rw-r--r--doc/classes/FontFile.xml17
-rw-r--r--doc/classes/FontVariation.xml10
-rw-r--r--doc/classes/Node.xml4
-rw-r--r--doc/classes/OS.xml4
-rw-r--r--doc/classes/Object.xml2
-rw-r--r--doc/classes/OmniLight3D.xml1
-rw-r--r--doc/classes/PrimitiveMesh.xml3
-rw-r--r--doc/classes/ProjectSettings.xml26
-rw-r--r--doc/classes/ReflectionProbe.xml1
-rw-r--r--doc/classes/RenderingServer.xml8
-rw-r--r--doc/classes/RichTextLabel.xml55
-rw-r--r--doc/classes/Signal.xml5
-rw-r--r--doc/classes/SpotLight3D.xml1
-rw-r--r--doc/classes/String.xml2
-rw-r--r--doc/classes/TileMap.xml6
-rw-r--r--doc/classes/Variant.xml35
-rw-r--r--doc/classes/Viewport.xml4
-rw-r--r--doc/classes/XRInterface.xml37
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp10
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp3
-rw-r--r--drivers/gles3/shaders/canvas.glsl12
-rw-r--r--drivers/gles3/storage/light_storage.cpp7
-rw-r--r--drivers/gles3/storage/light_storage.h8
-rw-r--r--drivers/gles3/storage/mesh_storage.cpp10
-rw-r--r--drivers/gles3/storage/texture_storage.h1
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp8
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h2
-rw-r--r--drivers/vulkan/vulkan_context.cpp9
-rw-r--r--editor/animation_track_editor.cpp2
-rw-r--r--editor/animation_track_editor_plugins.cpp4
-rw-r--r--editor/connections_dialog.cpp36
-rw-r--r--editor/connections_dialog.h2
-rw-r--r--editor/editor_file_dialog.cpp7
-rw-r--r--editor/editor_file_system.cpp80
-rw-r--r--editor/editor_file_system.h3
-rw-r--r--editor/editor_layouts_dialog.cpp27
-rw-r--r--editor/editor_layouts_dialog.h2
-rw-r--r--editor/editor_node.cpp50
-rw-r--r--editor/editor_node.h3
-rw-r--r--editor/editor_properties.cpp2
-rw-r--r--editor/editor_properties_array_dict.cpp2
-rw-r--r--editor/editor_themes.cpp2
-rw-r--r--editor/filesystem_dock.cpp45
-rw-r--r--editor/filesystem_dock.h11
-rw-r--r--editor/icons/GizmoLightmapGI.svg (renamed from editor/icons/GizmoBakedLightmap.svg)0
-rw-r--r--editor/import/editor_import_plugin.cpp16
-rw-r--r--editor/import/editor_import_plugin.h3
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp14
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp5
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp31
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp91
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h8
-rw-r--r--editor/project_converter_3_to_4.cpp9
-rw-r--r--editor/project_converter_3_to_4.h3
-rw-r--r--editor/project_manager.cpp5
-rw-r--r--main/main.cpp6
-rw-r--r--misc/ci/sources.list4
-rwxr-xr-xmisc/scripts/codespell.sh6
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml16
-rw-r--r--modules/gdscript/gdscript.cpp14
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp241
-rw-r--r--modules/gdscript/gdscript_analyzer.h4
-rw-r--r--modules/gdscript/gdscript_editor.cpp69
-rw-r--r--modules/gdscript/gdscript_function.cpp9
-rw-r--r--modules/gdscript/gdscript_function.h1
-rw-r--r--modules/gdscript/gdscript_parser.cpp84
-rw-r--r--modules/gdscript/gdscript_parser.h13
-rw-r--r--modules/gdscript/gdscript_vm.cpp29
-rw-r--r--modules/gdscript/gdscript_warning.cpp31
-rw-r--r--modules/gdscript/gdscript_warning.h49
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.gd18
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.out5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.gd13
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.out5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd15
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd15
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd17
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out22
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.gd7
-rw-r--r--modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.gd8
-rw-r--r--modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.out6
-rw-r--r--modules/gltf/editor/editor_import_blend_runner.cpp13
-rw-r--r--modules/gltf/gltf_document.cpp63
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotPlugins/PluginLoadContext.cs20
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs907
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs31
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs34
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs18
-rw-r--r--modules/mono/glue/runtime_interop.cpp99
-rw-r--r--modules/navigation/godot_navigation_server.cpp34
-rw-r--r--modules/navigation/godot_navigation_server.h4
-rw-r--r--modules/navigation/nav_agent.cpp (renamed from modules/navigation/rvo_agent.cpp)14
-rw-r--r--modules/navigation/nav_agent.h (renamed from modules/navigation/rvo_agent.h)10
-rw-r--r--modules/navigation/nav_map.cpp18
-rw-r--r--modules/navigation/nav_map.h20
-rw-r--r--modules/openxr/SCsub1
-rw-r--r--modules/openxr/extensions/openxr_ml2_controller_extension.cpp71
-rw-r--r--modules/openxr/extensions/openxr_ml2_controller_extension.h48
-rw-r--r--modules/openxr/openxr_api.cpp62
-rw-r--r--modules/openxr/openxr_api.h11
-rw-r--r--modules/openxr/openxr_interface.cpp54
-rw-r--r--modules/openxr/openxr_interface.h4
-rw-r--r--modules/openxr/openxr_util.cpp271
-rw-r--r--modules/openxr/openxr_util.h1
-rw-r--r--modules/openxr/register_types.cpp2
-rw-r--r--modules/text_server_adv/text_server_adv.cpp50
-rw-r--r--modules/text_server_adv/text_server_adv.h3
-rw-r--r--platform/android/export/export_plugin.cpp132
-rw-r--r--platform/android/export/export_plugin.h10
-rw-r--r--platform/android/export/gradle_export_util.cpp38
-rw-r--r--platform/android/export/gradle_export_util.h6
-rw-r--r--platform/android/java/app/AndroidManifest.xml21
-rw-r--r--platform/android/java/app/build.gradle8
-rw-r--r--platform/android/java/app/gradle.properties4
-rw-r--r--platform/android/java/app/settings.gradle2
-rw-r--r--platform/android/java/app/src/com/godot/game/GodotApp.java2
-rw-r--r--platform/android/java/build.gradle14
-rw-r--r--platform/android/java/gradle.properties2
-rw-r--r--platform/android/java/lib/res/values/strings.xml1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java2
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.java37
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp6
-rw-r--r--platform/linuxbsd/x11/display_server_x11.cpp4
-rw-r--r--platform/macos/display_server_macos.mm1
-rw-r--r--platform/windows/display_server_windows.cpp21
-rw-r--r--scene/2d/camera_2d.cpp6
-rw-r--r--scene/2d/navigation_agent_2d.cpp144
-rw-r--r--scene/2d/navigation_agent_2d.h1
-rw-r--r--scene/2d/navigation_obstacle_2d.cpp19
-rw-r--r--scene/3d/navigation_agent_3d.cpp140
-rw-r--r--scene/3d/navigation_agent_3d.h13
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp19
-rw-r--r--scene/animation/animation_blend_space_1d.cpp20
-rw-r--r--scene/animation/animation_blend_space_1d.h7
-rw-r--r--scene/animation/animation_blend_space_2d.cpp26
-rw-r--r--scene/animation/animation_blend_space_2d.h7
-rw-r--r--scene/animation/animation_blend_tree.cpp85
-rw-r--r--scene/animation/animation_blend_tree.h10
-rw-r--r--scene/animation/animation_node_state_machine.cpp20
-rw-r--r--scene/animation/animation_node_state_machine.h5
-rw-r--r--scene/animation/animation_player.cpp15
-rw-r--r--scene/animation/animation_tree.cpp76
-rw-r--r--scene/animation/animation_tree.h10
-rw-r--r--scene/gui/control.cpp10
-rw-r--r--scene/gui/control.h4
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/option_button.cpp8
-rw-r--r--scene/gui/rich_text_label.cpp46
-rw-r--r--scene/gui/rich_text_label.h5
-rw-r--r--scene/gui/split_container.cpp2
-rw-r--r--scene/main/canvas_item.cpp27
-rw-r--r--scene/main/canvas_item.h5
-rw-r--r--scene/main/node.cpp6
-rw-r--r--scene/main/viewport.cpp81
-rw-r--r--scene/main/viewport.h10
-rw-r--r--scene/main/window.cpp11
-rw-r--r--scene/main/window.h1
-rw-r--r--scene/resources/font.cpp32
-rw-r--r--scene/resources/navigation_mesh.cpp4
-rw-r--r--scene/resources/primitive_meshes.cpp2
-rw-r--r--scene/resources/resource_format_text.cpp6
-rw-r--r--scene/resources/visual_shader.cpp5
-rw-r--r--scene/resources/visual_shader.h13
-rw-r--r--servers/rendering/dummy/storage/light_storage.h1
-rw-r--r--servers/rendering/dummy/storage/texture_storage.h1
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp2
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp6
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.cpp7
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.h8
-rw-r--r--servers/rendering/renderer_rd/storage_rd/material_storage.h10
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp8
-rw-r--r--servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp65
-rw-r--r--servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h34
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.cpp9
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.h1
-rw-r--r--servers/rendering/renderer_scene_cull.cpp3
-rw-r--r--servers/rendering/renderer_scene_cull.h7
-rw-r--r--servers/rendering/rendering_device.h2
-rw-r--r--servers/rendering/shader_language.cpp32
-rw-r--r--servers/rendering/shader_language.h2
-rw-r--r--servers/rendering/storage/light_storage.h1
-rw-r--r--servers/rendering/storage/texture_storage.h1
-rw-r--r--servers/rendering_server.cpp1
-rw-r--r--servers/xr/xr_interface.cpp14
-rw-r--r--servers/xr/xr_interface.h11
-rw-r--r--tests/scene/test_text_edit.h14
251 files changed, 3921 insertions, 1325 deletions
diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml
index ed4ef01012..666b10d016 100644
--- a/.github/workflows/android_builds.yml
+++ b/.github/workflows/android_builds.yml
@@ -19,13 +19,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- # Azure repositories are not reliable, we need to prevent azure giving us packages.
- - name: Make apt sources.list use the default Ubuntu repositories
- run: |
- sudo rm -f /etc/apt/sources.list.d/*
- sudo cp -f misc/ci/sources.list /etc/apt/sources.list
- sudo apt-get update
-
- name: Set up Java 11
uses: actions/setup-java@v3
with:
diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml
index bfda7c72f8..46a9228616 100644
--- a/.github/workflows/linux_builds.yml
+++ b/.github/workflows/linux_builds.yml
@@ -74,16 +74,13 @@ jobs:
steps:
- uses: actions/checkout@v3
- - name: Linux dependencies
- shell: bash
+ # Need newer mesa for lavapipe to work properly.
+ - name: Linux dependencies for tests
+ if: ${{ matrix.proj-test }}
run: |
- # Azure repositories are not reliable, we need to prevent azure giving us packages.
- sudo rm -f /etc/apt/sources.list.d/*
- sudo cp -f misc/ci/sources.list /etc/apt/sources.list
+ sudo add-apt-repository ppa:kisak/kisak-mesa
sudo apt-get update
- # The actual dependencies
- sudo apt-get install build-essential pkg-config libgl1-mesa-dev libglu-dev \
- xvfb wget unzip llvm
+ sudo apt-get install -qq mesa-vulkan-drivers
- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
@@ -138,16 +135,6 @@ jobs:
${{ matrix.bin }} --doctool --headless 2>&1 > /dev/null || true
git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$'
- # Download, unzip and setup SwiftShader library
- # See https://github.com/godotengine/regression-test-project/releases/tag/_ci-deps for details
- - name: Download SwiftShader
- if: ${{ matrix.tests }}
- run: |
- wget https://github.com/godotengine/regression-test-project/releases/download/_ci-deps/swiftshader-ubuntu20.04-20211002.zip
- unzip swiftshader-ubuntu20.04-20211002.zip
- curr="$(pwd)/libvk_swiftshader.so"
- sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json
-
# Test 3.x -> 4.x project converter
- name: Test project converter
if: ${{ matrix.proj-conv }}
@@ -155,7 +142,7 @@ jobs:
mkdir converter_test
cd converter_test
touch project.godot
- ../${{ matrix.bin }} --headless --audio-driver Dummy --validate-conversion-3to4
+ ../${{ matrix.bin }} --headless --validate-conversion-3to4
cd ..
rm converter_test -rf
@@ -171,7 +158,7 @@ jobs:
- name: Open and close editor (Vulkan)
if: ${{ matrix.proj-test }}
run: |
- VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true
+ xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true
misc/scripts/check_ci_log.py sanitizers_log.txt
- name: Open and close editor (GLES3)
@@ -184,7 +171,7 @@ jobs:
- name: Run project
if: ${{ matrix.proj-test }}
run: |
- VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true
+ xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true
misc/scripts/check_ci_log.py sanitizers_log.txt
# Checkout godot-cpp
diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml
index d10156c04e..a3722e19ce 100644
--- a/.github/workflows/static_checks.yml
+++ b/.github/workflows/static_checks.yml
@@ -13,17 +13,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- # Azure repositories are not reliable, we need to prevent Azure giving us packages.
- - name: Make apt sources.list use the default Ubuntu repositories
+ - name: Install dependencies
run: |
- sudo rm -f /etc/apt/sources.list.d/*
- sudo cp -f misc/ci/sources.list /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"
sudo apt-get update
-
- - name: Install dependencies
- run: |
sudo apt-get install -qq dos2unix clang-format-15 libxml2-utils python3-pip moreutils
sudo update-alternatives --remove-all clang-format || true
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100
@@ -71,3 +65,11 @@ jobs:
- name: Style checks via dotnet format (dotnet_format.sh)
run: |
bash ./misc/scripts/dotnet_format.sh
+
+ - name: Spell checks via codespell
+ uses: codespell-project/actions-codespell@v1
+ with:
+ skip: ./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json
+ check_hidden: false
+ ignore_words_list: curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te
+ only_warn: true
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 6a1d802453..f0de22f2ef 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -40,6 +40,7 @@
#include "core/io/file_access_pack.h"
#include "core/io/marshalls.h"
#include "core/os/keyboard.h"
+#include "core/variant/typed_array.h"
#include "core/variant/variant_parser.h"
#include "core/version.h"
@@ -301,13 +302,13 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
for (int i = 1; i < s.size(); i++) {
String feature = s[i].strip_edges();
- Pair<StringName, StringName> fo(feature, p_name);
+ Pair<StringName, StringName> feature_override(feature, p_name);
if (!feature_overrides.has(s[0])) {
feature_overrides[s[0]] = LocalVector<Pair<StringName, StringName>>();
}
- feature_overrides[s[0]].push_back(fo);
+ feature_overrides[s[0]].push_back(feature_override);
}
}
}
@@ -1136,20 +1137,27 @@ Variant ProjectSettings::get_setting(const String &p_setting, const Variant &p_d
}
}
-Array ProjectSettings::get_global_class_list() {
- Array script_classes;
+TypedArray<Dictionary> ProjectSettings::get_global_class_list() {
+ if (is_global_class_list_loaded) {
+ return global_class_list;
+ }
Ref<ConfigFile> cf;
cf.instantiate();
if (cf->load(get_global_class_list_path()) == OK) {
- script_classes = cf->get_value("", "list", Array());
+ global_class_list = cf->get_value("", "list", Array());
} else {
#ifndef TOOLS_ENABLED
// Script classes can't be recreated in exported project, so print an error.
ERR_PRINT("Could not load global script cache.");
#endif
}
- return script_classes;
+
+ // File read succeeded or failed. If it failed, assume everything is still okay.
+ // We will later receive updated class data in store_global_class_list().
+ is_global_class_list_loaded = true;
+
+ return global_class_list;
}
String ProjectSettings::get_global_class_list_path() const {
@@ -1161,6 +1169,8 @@ void ProjectSettings::store_global_class_list(const Array &p_classes) {
cf.instantiate();
cf->set_value("", "list", p_classes);
cf->save(get_global_class_list_path());
+
+ global_class_list = p_classes;
}
bool ProjectSettings::has_custom_feature(const String &p_feature) const {
@@ -1195,6 +1205,7 @@ void ProjectSettings::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &ProjectSettings::set_setting);
ClassDB::bind_method(D_METHOD("get_setting", "name", "default_value"), &ProjectSettings::get_setting, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("get_setting_with_override", "name"), &ProjectSettings::get_setting_with_override);
+ ClassDB::bind_method(D_METHOD("get_global_class_list"), &ProjectSettings::get_global_class_list);
ClassDB::bind_method(D_METHOD("set_order", "name", "position"), &ProjectSettings::set_order);
ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order);
ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value);
diff --git a/core/config/project_settings.h b/core/config/project_settings.h
index 70f697741f..50cb274831 100644
--- a/core/config/project_settings.h
+++ b/core/config/project_settings.h
@@ -37,6 +37,9 @@
#include "core/templates/local_vector.h"
#include "core/templates/rb_set.h"
+template <typename T>
+class TypedArray;
+
class ProjectSettings : public Object {
GDCLASS(ProjectSettings, Object);
_THREAD_SAFE_CLASS_
@@ -99,6 +102,9 @@ protected:
HashMap<StringName, AutoloadInfo> autoloads;
+ Array global_class_list;
+ bool is_global_class_list_loaded = false;
+
String project_data_dir_name;
bool _set(const StringName &p_name, const Variant &p_value);
@@ -141,7 +147,7 @@ public:
void set_setting(const String &p_setting, const Variant &p_value);
Variant get_setting(const String &p_setting, const Variant &p_default_value = Variant()) const;
- Array get_global_class_list();
+ TypedArray<Dictionary> get_global_class_list();
void store_global_class_list(const Array &p_classes);
String get_global_class_list_path() const;
diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h
index 876a09beff..9593afc2fb 100644
--- a/core/extension/gdextension_interface.h
+++ b/core/extension/gdextension_interface.h
@@ -37,7 +37,6 @@
#include <stddef.h>
#include <stdint.h>
-#include <stdio.h>
#ifndef __cplusplus
typedef uint32_t char32_t;
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 2e886f9093..071d9ba648 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -533,6 +533,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
touch_event->set_pressed(mb->is_pressed());
touch_event->set_position(mb->get_position());
touch_event->set_double_tap(mb->is_double_click());
+ touch_event->set_device(InputEvent::DEVICE_ID_EMULATION);
event_dispatch_function(touch_event);
}
}
@@ -557,6 +558,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
drag_event->set_pen_inverted(mm->get_pen_inverted());
drag_event->set_pressure(mm->get_pressure());
drag_event->set_velocity(get_last_mouse_velocity());
+ drag_event->set_device(InputEvent::DEVICE_ID_EMULATION);
event_dispatch_function(drag_event);
}
@@ -592,7 +594,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventMouseButton> button_event;
button_event.instantiate();
- button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
+ button_event->set_device(InputEvent::DEVICE_ID_EMULATION);
button_event->set_position(st->get_position());
button_event->set_global_position(st->get_position());
button_event->set_pressed(st->is_pressed());
@@ -623,7 +625,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventMouseMotion> motion_event;
motion_event.instantiate();
- motion_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
+ motion_event->set_device(InputEvent::DEVICE_ID_EMULATION);
motion_event->set_tilt(sd->get_tilt());
motion_event->set_pen_inverted(sd->get_pen_inverted());
motion_event->set_pressure(sd->get_pressure());
@@ -832,7 +834,7 @@ void Input::ensure_touch_mouse_raised() {
Ref<InputEventMouseButton> button_event;
button_event.instantiate();
- button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
+ button_event->set_device(InputEvent::DEVICE_ID_EMULATION);
button_event->set_position(mouse_pos);
button_event->set_global_position(mouse_pos);
button_event->set_pressed(false);
@@ -869,6 +871,7 @@ void Input::set_default_cursor_shape(CursorShape p_shape) {
mm.instantiate();
mm->set_position(mouse_pos);
mm->set_global_position(mouse_pos);
+ mm->set_device(InputEvent::DEVICE_ID_INTERNAL);
parse_input_event(mm);
}
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 5a9ec74184..7c4642a8a5 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -34,7 +34,7 @@
#include "core/input/shortcut.h"
#include "core/os/keyboard.h"
-const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1;
+const int InputEvent::DEVICE_ID_EMULATION = -1;
const int InputEvent::DEVICE_ID_INTERNAL = -2;
void InputEvent::set_device(int p_device) {
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 797761b208..eff8d479db 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -59,7 +59,7 @@ protected:
static void _bind_methods();
public:
- static const int DEVICE_ID_TOUCH_MOUSE;
+ static const int DEVICE_ID_EMULATION;
static const int DEVICE_ID_INTERNAL;
void set_device(int p_device);
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index 234a4ddb79..95a4187062 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -239,13 +239,18 @@ void Basis::scale_orthogonal(const Vector3 &p_scale) {
Basis Basis::scaled_orthogonal(const Vector3 &p_scale) const {
Basis m = *this;
Vector3 s = Vector3(-1, -1, -1) + p_scale;
+ bool sign = signbit(s.x + s.y + s.z);
+ Basis b = m.orthonormalized();
+ s = b.xform_inv(s);
Vector3 dots;
- Basis b;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
dots[j] += s[i] * abs(m.get_column(i).normalized().dot(b.get_column(j)));
}
}
+ if (sign != signbit(dots.x + dots.y + dots.z)) {
+ dots = -dots;
+ }
m.scale_local(Vector3(1, 1, 1) + dots);
return m;
}
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 9488c6bcff..4483f61bc4 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -383,15 +383,15 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_
if (O->get().plane.is_equal_approx(f.plane)) {
//merge and delete edge and contiguous face, while repointing edges (uuugh!)
- int ois = O->get().indices.size();
+ int o_index_size = O->get().indices.size();
- for (int j = 0; j < ois; j++) {
+ for (int j = 0; j < o_index_size; j++) {
//search a
if (O->get().indices[j] == a) {
//append the rest
- for (int k = 0; k < ois; k++) {
- int idx = O->get().indices[(k + j) % ois];
- int idxn = O->get().indices[(k + j + 1) % ois];
+ for (int k = 0; k < o_index_size; k++) {
+ int idx = O->get().indices[(k + j) % o_index_size];
+ int idxn = O->get().indices[(k + j + 1) % o_index_size];
if (idx == b && idxn == a) { //already have b!
break;
}
diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp
index 96010b4096..868665cb5c 100644
--- a/core/math/transform_2d.cpp
+++ b/core/math/transform_2d.cpp
@@ -151,7 +151,7 @@ void Transform2D::orthonormalize() {
Vector2 y = columns[1];
x.normalize();
- y = (y - x * (x.dot(y)));
+ y = y - x * x.dot(y);
y.normalize();
columns[0] = x;
@@ -159,9 +159,9 @@ void Transform2D::orthonormalize() {
}
Transform2D Transform2D::orthonormalized() const {
- Transform2D on = *this;
- on.orthonormalize();
- return on;
+ Transform2D ortho = *this;
+ ortho.orthonormalize();
+ return ortho;
}
bool Transform2D::is_equal_approx(const Transform2D &p_transform) const {
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index 61f5cfc22a..1d53cf66d4 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -369,10 +369,6 @@ void ScriptServer::save_global_classes() {
ProjectSettings::get_singleton()->store_global_class_list(gcarr);
}
-bool ScriptServer::has_global_classes() {
- return !global_classes.is_empty();
-}
-
String ScriptServer::get_global_class_cache_file_path() {
return ProjectSettings::get_singleton()->get_global_class_list_path();
}
diff --git a/core/object/script_language.h b/core/object/script_language.h
index b1393c7196..14cc30e029 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -91,7 +91,6 @@ public:
static void get_global_class_list(List<StringName> *r_global_classes);
static void get_inheriters_list(const StringName &p_base_type, List<StringName> *r_classes);
static void save_global_classes();
- static bool has_global_classes();
static String get_global_class_cache_file_path();
static void init_languages();
diff --git a/core/object/worker_thread_pool.h b/core/object/worker_thread_pool.h
index cf3f7f0885..c62e05fc28 100644
--- a/core/object/worker_thread_pool.h
+++ b/core/object/worker_thread_pool.h
@@ -173,8 +173,8 @@ public:
template <class C, class M, class U>
GroupID add_template_group_task(C *p_instance, M p_method, U p_userdata, int p_elements, int p_tasks = -1, bool p_high_priority = false, const String &p_description = String()) {
- typedef GroupUserData<C, M, U> GUD;
- GUD *ud = memnew(GUD);
+ typedef GroupUserData<C, M, U> GroupUD;
+ GroupUD *ud = memnew(GroupUD);
ud->instance = p_instance;
ud->method = p_method;
ud->userdata = p_userdata;
diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp
index 9ce1c2d4bb..af7c18741d 100644
--- a/core/string/node_path.cpp
+++ b/core/string/node_path.cpp
@@ -339,7 +339,6 @@ NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) {
data->refcount.init();
data->absolute = p_absolute;
data->path = p_path;
- data->has_slashes = true;
data->hash_cache_valid = false;
}
@@ -353,7 +352,6 @@ NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p
data->absolute = p_absolute;
data->path = p_path;
data->subpath = p_subpath;
- data->has_slashes = true;
data->hash_cache_valid = false;
}
@@ -373,7 +371,6 @@ NodePath::NodePath(const String &p_path) {
bool absolute = (path[0] == '/');
bool last_is_slash = true;
- bool has_slashes = false;
int slices = 0;
int subpath_pos = path.find(":");
@@ -402,7 +399,6 @@ NodePath::NodePath(const String &p_path) {
for (int i = (int)absolute; i < path.length(); i++) {
if (path[i] == '/') {
last_is_slash = true;
- has_slashes = true;
} else {
if (last_is_slash) {
slices++;
@@ -419,7 +415,6 @@ NodePath::NodePath(const String &p_path) {
data = memnew(Data);
data->refcount.init();
data->absolute = absolute;
- data->has_slashes = has_slashes;
data->subpath = subpath;
data->hash_cache_valid = false;
diff --git a/core/string/node_path.h b/core/string/node_path.h
index 7053798cb2..876d69924e 100644
--- a/core/string/node_path.h
+++ b/core/string/node_path.h
@@ -42,7 +42,6 @@ class NodePath {
StringName concatenated_path;
StringName concatenated_subpath;
bool absolute;
- bool has_slashes;
mutable bool hash_cache_valid;
mutable uint32_t hash_cache;
};
diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp
index 95812fc311..df9b6b3f1a 100644
--- a/core/string/string_name.cpp
+++ b/core/string/string_name.cpp
@@ -226,19 +226,16 @@ StringName::StringName(const char *p_name, bool p_static) {
_data = _data->next;
}
- if (_data) {
- if (_data->refcount.ref()) {
- // exists
- if (p_static) {
- _data->static_count.increment();
- }
+ if (_data && _data->refcount.ref()) {
+ // exists
+ if (p_static) {
+ _data->static_count.increment();
+ }
#ifdef DEBUG_ENABLED
- if (unlikely(debug_stringname)) {
- _data->debug_references++;
- }
-#endif
+ if (unlikely(debug_stringname)) {
+ _data->debug_references++;
}
-
+#endif
return;
}
@@ -288,19 +285,17 @@ StringName::StringName(const StaticCString &p_static_string, bool p_static) {
_data = _data->next;
}
- if (_data) {
- if (_data->refcount.ref()) {
- // exists
- if (p_static) {
- _data->static_count.increment();
- }
+ if (_data && _data->refcount.ref()) {
+ // exists
+ if (p_static) {
+ _data->static_count.increment();
+ }
#ifdef DEBUG_ENABLED
- if (unlikely(debug_stringname)) {
- _data->debug_references++;
- }
-#endif
- return;
+ if (unlikely(debug_stringname)) {
+ _data->debug_references++;
}
+#endif
+ return;
}
_data = memnew(_Data);
@@ -348,19 +343,17 @@ StringName::StringName(const String &p_name, bool p_static) {
_data = _data->next;
}
- if (_data) {
- if (_data->refcount.ref()) {
- // exists
- if (p_static) {
- _data->static_count.increment();
- }
+ if (_data && _data->refcount.ref()) {
+ // exists
+ if (p_static) {
+ _data->static_count.increment();
+ }
#ifdef DEBUG_ENABLED
- if (unlikely(debug_stringname)) {
- _data->debug_references++;
- }
-#endif
- return;
+ if (unlikely(debug_stringname)) {
+ _data->debug_references++;
}
+#endif
+ return;
}
_data = memnew(_Data);
diff --git a/core/variant/array.cpp b/core/variant/array.cpp
index 2d7dff0b27..d156c35343 100644
--- a/core/variant/array.cpp
+++ b/core/variant/array.cpp
@@ -225,6 +225,9 @@ void Array::assign(const Array &p_array) {
_p->array = p_array._p->array;
return;
}
+ if (typed.type == Variant::OBJECT || source_typed.type == Variant::OBJECT) {
+ ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", Variant::get_type_name(source_typed.type), Variant::get_type_name(typed.type)));
+ }
Vector<Variant> array;
array.resize(size);
@@ -629,14 +632,14 @@ void Array::shuffle() {
}
}
-int Array::bsearch(const Variant &p_value, bool p_before) {
+int Array::bsearch(const Variant &p_value, bool p_before) const {
Variant value = p_value;
ERR_FAIL_COND_V(!_p->typed.validate(value, "binary search"), -1);
SearchArray<Variant, _ArrayVariantSort> avs;
return avs.bisect(_p->array.ptrw(), _p->array.size(), value, p_before);
}
-int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) {
+int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) const {
Variant value = p_value;
ERR_FAIL_COND_V(!_p->typed.validate(value, "custom binary search"), -1);
diff --git a/core/variant/array.h b/core/variant/array.h
index 4ef8ba8ce7..8b1f8c0678 100644
--- a/core/variant/array.h
+++ b/core/variant/array.h
@@ -83,8 +83,8 @@ public:
void sort();
void sort_custom(const Callable &p_callable);
void shuffle();
- int bsearch(const Variant &p_value, bool p_before = true);
- int bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before = true);
+ int bsearch(const Variant &p_value, bool p_before = true) const;
+ int bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before = true) const;
void reverse();
int find(const Variant &p_value, int p_from = 0) const;
diff --git a/core/variant/container_type_validate.h b/core/variant/container_type_validate.h
index 796b66dc77..ad679db9d0 100644
--- a/core/variant/container_type_validate.h
+++ b/core/variant/container_type_validate.h
@@ -41,34 +41,26 @@ struct ContainerTypeValidate {
const char *where = "container";
_FORCE_INLINE_ bool can_reference(const ContainerTypeValidate &p_type) const {
- if (type == p_type.type) {
- if (type != Variant::OBJECT) {
- return true; //nothing else to check
- }
- } else {
+ if (type != p_type.type) {
return false;
+ } else if (type != Variant::OBJECT) {
+ return true;
}
- //both are object
-
- if ((class_name != StringName()) != (p_type.class_name != StringName())) {
- return false; //both need to have class or none
- }
-
- if (class_name != p_type.class_name) {
- if (!ClassDB::is_parent_class(p_type.class_name, class_name)) {
- return false;
- }
- }
-
- if (script.is_null() != p_type.script.is_null()) {
+ if (class_name == StringName()) {
+ return true;
+ } else if (p_type.class_name == StringName()) {
+ return false;
+ } else if (class_name != p_type.class_name && !ClassDB::is_parent_class(p_type.class_name, class_name)) {
return false;
}
- if (script != p_type.script) {
- if (!p_type.script->inherits_script(script)) {
- return false;
- }
+ if (script.is_null()) {
+ return true;
+ } else if (p_type.script.is_null()) {
+ return false;
+ } else if (script != p_type.script && !p_type.script->inherits_script(script)) {
+ return false;
}
return true;
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 672b030806..04e1561a0c 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -3601,15 +3601,6 @@ bool Variant::is_type_shared(Variant::Type p_type) {
case OBJECT:
case ARRAY:
case DICTIONARY:
- case PACKED_BYTE_ARRAY:
- case PACKED_INT32_ARRAY:
- case PACKED_INT64_ARRAY:
- case PACKED_FLOAT32_ARRAY:
- case PACKED_FLOAT64_ARRAY:
- case PACKED_STRING_ARRAY:
- case PACKED_VECTOR2_ARRAY:
- case PACKED_VECTOR3_ARRAY:
- case PACKED_COLOR_ARRAY:
return true;
default: {
}
diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml
index bc65e6013b..4dd83c0d9f 100644
--- a/doc/classes/AnimationNode.xml
+++ b/doc/classes/AnimationNode.xml
@@ -187,9 +187,24 @@
</member>
</members>
<signals>
+ <signal name="animation_node_removed">
+ <param index="0" name="object_id" type="int" />
+ <param index="1" name="name" type="String" />
+ <description>
+ Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes removes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
+ </description>
+ </signal>
+ <signal name="animation_node_renamed">
+ <param index="0" name="object_id" type="int" />
+ <param index="1" name="old_name" type="String" />
+ <param index="2" name="new_name" type="String" />
+ <description>
+ Emitted by nodes that inherit from this class and that have an internal tree when one of their node names changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
+ </description>
+ </signal>
<signal name="tree_changed">
<description>
- Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
+ Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], [AnimationNodeBlendTree] and [AnimationNodeTransition].
</description>
</signal>
</signals>
diff --git a/doc/classes/AnimationTree.xml b/doc/classes/AnimationTree.xml
index 86562c340d..98256f0a38 100644
--- a/doc/classes/AnimationTree.xml
+++ b/doc/classes/AnimationTree.xml
@@ -92,13 +92,6 @@
[/codeblocks]
</description>
</method>
- <method name="rename_parameter">
- <return type="void" />
- <param index="0" name="old_name" type="String" />
- <param index="1" name="new_name" type="String" />
- <description>
- </description>
- </method>
</methods>
<members>
<member name="active" type="bool" setter="set_active" getter="is_active" default="false">
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml
index 213a2254af..c4fec5a729 100644
--- a/doc/classes/Array.xml
+++ b/doc/classes/Array.xml
@@ -214,7 +214,7 @@
[b]Note:[/b] Calling this function is not the same as writing [code]array[-1][/code]. If the array is empty, accessing by index will pause project execution when running from the editor.
</description>
</method>
- <method name="bsearch">
+ <method name="bsearch" qualifiers="const">
<return type="int" />
<param index="0" name="value" type="Variant" />
<param index="1" name="before" type="bool" default="true" />
@@ -223,7 +223,7 @@
[b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior.
</description>
</method>
- <method name="bsearch_custom">
+ <method name="bsearch_custom" qualifiers="const">
<return type="int" />
<param index="0" name="value" type="Variant" />
<param index="1" name="func" type="Callable" />
@@ -276,7 +276,7 @@
array.fill(0) # Initialize the 10 elements to 0.
[/gdscript]
[csharp]
- var array = new Godot.Collections.Array{};
+ var array = new Godot.Collections.Array();
array.Resize(10);
array.Fill(0); // Initialize the 10 elements to 0.
[/csharp]
@@ -347,7 +347,7 @@
print(["inside", 7].has("7")) # False
[/gdscript]
[csharp]
- var arr = new Godot.Collections.Array{"inside", 7};
+ var arr = new Godot.Collections.Array { "inside", 7 };
// has is renamed to Contains
GD.Print(arr.Contains("inside")); // True
GD.Print(arr.Contains("outside")); // False
@@ -364,7 +364,7 @@
[/gdscript]
[csharp]
// As there is no "in" keyword in C#, you have to use Contains
- var array = new Godot.Collections.Array{2, 4, 6, 8};
+ var array = new Godot.Collections.Array { 2, 4, 6, 8 };
if (array.Contains(2))
{
GD.Print("Contains!");
@@ -454,10 +454,16 @@
<return type="Variant" />
<description>
Returns a random value from the target array.
- [codeblock]
+ [codeblocks]
+ [gdscript]
var array: Array[int] = [1, 2, 3, 4]
print(array.pick_random()) # Prints either of the four numbers.
- [/codeblock]
+ [/gdscript]
+ [csharp]
+ var array = new Godot.Collections.Array { 1, 2, 3, 4 };
+ GD.Print(array.PickRandom()); // Prints either of the four numbers.
+ [/csharp]
+ [/codeblocks]
</description>
</method>
<method name="pop_at">
@@ -566,7 +572,7 @@
Returns the slice of the [Array], from [param begin] (inclusive) to [param end] (exclusive), as a new [Array].
The absolute value of [param begin] and [param end] will be clamped to the array size, so the default value for [param end] makes it slice to the size of the array by default (i.e. [code]arr.slice(1)[/code] is a shorthand for [code]arr.slice(1, arr.size())[/code]).
If either [param begin] or [param end] are negative, they will be relative to the end of the array (i.e. [code]arr.slice(0, -2)[/code] is a shorthand for [code]arr.slice(0, arr.size() - 2)[/code]).
- If specified, [param step] is the relative index between source elements. It can be negative, then [param begin] must be higher than [param end]. For example, [code][0, 1, 2, 3, 4, 5].slice(5, 1, -2)[/code] returns [code][5, 3][/code]).
+ If specified, [param step] is the relative index between source elements. It can be negative, then [param begin] must be higher than [param end]. For example, [code][0, 1, 2, 3, 4, 5].slice(5, 1, -2)[/code] returns [code][5, 3][/code].
If [param deep] is true, each element will be copied by value rather than by reference.
</description>
</method>
@@ -583,7 +589,9 @@
print(strings) # Prints [string1, string10, string11, string2]
[/gdscript]
[csharp]
- // There is no sort support for Godot.Collections.Array
+ var strings = new Godot.Collections.Array { "string1", "string2", "string10", "string11" };
+ strings.Sort();
+ GD.Print(strings); // Prints [string1, string10, string11, string2]
[/csharp]
[/codeblocks]
To perform natural order sorting, you can use [method sort_custom] with [method String.naturalnocasecmp_to] as follows:
diff --git a/doc/classes/Callable.xml b/doc/classes/Callable.xml
index 8fc44d7536..50be9b86bf 100644
--- a/doc/classes/Callable.xml
+++ b/doc/classes/Callable.xml
@@ -173,14 +173,14 @@
<method name="rpc" qualifiers="vararg const">
<return type="void" />
<description>
- Perform an RPC (Remote Procedure Call). This is used for multiplayer and is normally not available, unless the function being called has been marked as [i]RPC[/i]. Calling this method on unsupported functions will result in an error.
+ Perform an RPC (Remote Procedure Call). This is used for multiplayer and is normally not available, unless the function being called has been marked as [i]RPC[/i]. Calling this method on unsupported functions will result in an error. See [method Node.rpc].
</description>
</method>
<method name="rpc_id" qualifiers="vararg const">
<return type="void" />
<param index="0" name="peer_id" type="int" />
<description>
- Perform an RPC (Remote Procedure Call) on a specific peer ID (see multiplayer documentation for reference). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling this method on unsupported functions will result in an error.
+ Perform an RPC (Remote Procedure Call) on a specific peer ID (see multiplayer documentation for reference). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling this method on unsupported functions will result in an error. See [method Node.rpc_id].
</description>
</method>
<method name="unbind" qualifiers="const">
diff --git a/doc/classes/CanvasGroup.xml b/doc/classes/CanvasGroup.xml
index 6eeff8fef3..45f77ba484 100644
--- a/doc/classes/CanvasGroup.xml
+++ b/doc/classes/CanvasGroup.xml
@@ -8,6 +8,7 @@
[b]Note:[/b] The [CanvasGroup] uses a custom shader to read from the backbuffer to draw its children. Assigning a [Material] to the [CanvasGroup] overrides the builtin shader. To duplicate the behavior of the builtin shader in a custom [Shader] use the following:
[codeblock]
shader_type canvas_item;
+ render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index d74ddba369..7d7925d61e 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -144,11 +144,11 @@
</method>
<method name="_has_point" qualifiers="virtual const">
<return type="bool" />
- <param index="0" name="position" type="Vector2" />
+ <param index="0" name="point" type="Vector2" />
<description>
- Virtual method to be implemented by the user. Returns whether the given [param position] is inside this control.
+ Virtual method to be implemented by the user. Returns whether the given [param point] is inside this control.
If not overridden, default behavior is checking if the point is within control's Rect.
- [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code].
+ [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]Rect2(Vector2.ZERO, size).has_point(point)[/code].
</description>
</method>
<method name="_make_custom_tooltip" qualifiers="virtual const">
diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml
index fb8bc18c1a..b63f6e7252 100644
--- a/doc/classes/Decal.xml
+++ b/doc/classes/Decal.xml
@@ -8,6 +8,7 @@
They are made of an [AABB] and a group of [Texture2D]s specifying [Color], normal, ORM (ambient occlusion, roughness, metallic), and emission. Decals are projected within their [AABB] so altering the orientation of the Decal affects the direction in which they are projected. By default, Decals are projected down (i.e. from positive Y to negative Y).
The [Texture2D]s associated with the Decal are automatically stored in a texture atlas which is used for drawing the decals so all decals can be drawn at once. Godot uses clustered decals, meaning they are stored in cluster data and drawn when the mesh is drawn, they are not drawn as a post-processing effect after.
[b]Note:[/b] Decals cannot affect an underlying material's transparency, regardless of its transparency mode (alpha blend, alpha scissor, alpha hash, opaque pre-pass). This means translucent or transparent areas of a material will remain translucent or transparent even if an opaque decal is applied on them.
+ [b]Note:[/b] When using the Mobile rendering method, decals will only correctly affect meshes whose visibility AABB intersects with the decal's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, [member GeometryInstance3D.extra_cull_margin] must be increased on the mesh. Otherwise, the decal may not be visible on the mesh.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml
index 6f4a7fc13d..55ba1f4f0c 100644
--- a/doc/classes/DisplayServer.xml
+++ b/doc/classes/DisplayServer.xml
@@ -1325,6 +1325,7 @@
<param index="1" name="window_id" type="int" default="0" />
<description>
Sets the maximum size of the window specified by [param window_id] in pixels. Normally, the user will not be able to drag the window to make it smaller than the specified size. See also [method window_get_max_size].
+ [b]Note:[/b] It's recommended to change this value using [member Window.max_size] instead.
[b]Note:[/b] Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit.
</description>
</method>
@@ -1334,6 +1335,7 @@
<param index="1" name="window_id" type="int" default="0" />
<description>
Sets the minimum size for the given window to [param min_size] (in pixels). Normally, the user will not be able to drag the window to make it larger than the specified size. See also [method window_get_min_size].
+ [b]Note:[/b] It's recommended to change this value using [member Window.min_size] instead.
[b]Note:[/b] By default, the main window has a minimum size of [code]Vector2i(64, 64)[/code]. This prevents issues that can arise when the window is resized to a near-zero size.
[b]Note:[/b] Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit.
</description>
@@ -1403,6 +1405,7 @@
+-------------+ +-------+
[/codeblock]
See also [method window_get_position] and [method window_set_size].
+ [b]Note:[/b] It's recommended to change this value using [member Window.position] instead.
</description>
</method>
<method name="window_set_rect_changed_callback">
@@ -1419,6 +1422,7 @@
<param index="1" name="window_id" type="int" default="0" />
<description>
Sets the size of the given window to [param size] (in pixels). See also [method window_get_size] and [method window_get_position].
+ [b]Note:[/b] It's recommended to change this value using [member Window.size] instead.
</description>
</method>
<method name="window_set_title">
@@ -1427,6 +1431,7 @@
<param index="1" name="window_id" type="int" default="0" />
<description>
Sets the title of the given window to [param title].
+ [b]Note:[/b] It's recommended to change this value using [member Window.title] instead.
[b]Note:[/b] Avoid changing the window title every frame, as this can cause performance issues on certain window managers. Try to change the window title only a few times per second at most.
</description>
</method>
@@ -1436,7 +1441,8 @@
<param index="1" name="parent_window_id" type="int" />
<description>
Sets window transient parent. Transient window is will be destroyed with its transient parent and will return focus to their parent when closed. The transient window is displayed on top of a non-exclusive full-screen parent window. Transient windows can't enter full-screen mode.
- Note that behavior might be different depending on the platform.
+ [b]Note:[/b] It's recommended to change this value using [member Window.transient] instead.
+ [b]Note:[/b] The behavior might be different depending on the platform.
</description>
</method>
<method name="window_set_vsync_mode">
diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml
index 6a976d218f..66b61f187e 100644
--- a/doc/classes/EditorImportPlugin.xml
+++ b/doc/classes/EditorImportPlugin.xml
@@ -227,5 +227,15 @@
This method must be overridden to do the actual importing work. See this class' description for an example of overriding this method.
</description>
</method>
+ <method name="append_import_external_resource">
+ <return type="int" enum="Error" />
+ <param index="0" name="path" type="String" />
+ <param index="1" name="custom_options" type="Dictionary" default="{}" />
+ <param index="2" name="custom_importer" type="String" default="&quot;&quot;" />
+ <param index="3" name="generator_parameters" type="Variant" default="null" />
+ <description>
+ This function can only be called during the [method _import] callback and it allows manually importing resources from it. This is useful when the imported file generates external resources that require importing (as example, images). Custom parameters for the ".import" file can be passed via the [param custom_options]. Additionally, in cases where multiple importers can handle a file, the [param custom_importer] ca be specified to force a specific one. This function performs a resource import and returns immediately with a success or error code. [param generator_parameters] defines optional extra metadata which will be stored as [code]generator_parameters[/code] in the [code]remap[/code] section of the [code].import[/code] file, for example to store a md5 hash of the source data.
+ </description>
+ </method>
</methods>
</class>
diff --git a/doc/classes/FontFile.xml b/doc/classes/FontFile.xml
index 69a7627774..a349c2b7b7 100644
--- a/doc/classes/FontFile.xml
+++ b/doc/classes/FontFile.xml
@@ -17,13 +17,13 @@
[codeblocks]
[gdscript]
var f = load("res://BarlowCondensed-Bold.ttf")
- $"Label".set("custom_fonts/font", f)
- $"Label".set("custom_fonts/font_size", 64)
+ $Label.add_theme_font_override("font", f)
+ $Label.add_theme_font_size_override("font_size", 64)
[/gdscript]
[csharp]
var f = ResourceLoader.Load&lt;FontFile&gt;("res://BarlowCondensed-Bold.ttf");
- GetNode("Label").Set("custom_fonts/font", f);
- GetNode("Label").Set("custom_font_sizes/font_size", 64);
+ GetNode("Label").AddThemeFontOverride("font", f);
+ GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
[/csharp]
[/codeblocks]
</description>
@@ -88,6 +88,7 @@
<param index="0" name="cache_index" type="int" />
<param index="1" name="size" type="int" />
<description>
+ Returns the font descent (number of pixels below the baseline).
</description>
</method>
<method name="get_cache_scale" qualifiers="const">
@@ -95,6 +96,7 @@
<param index="0" name="cache_index" type="int" />
<param index="1" name="size" type="int" />
<description>
+ Returns scaling factor of the color bitmap font.
</description>
</method>
<method name="get_cache_underline_position" qualifiers="const">
@@ -102,6 +104,7 @@
<param index="0" name="cache_index" type="int" />
<param index="1" name="size" type="int" />
<description>
+ Returns pixel offset of the underline below the baseline.
</description>
</method>
<method name="get_cache_underline_thickness" qualifiers="const">
@@ -109,6 +112,7 @@
<param index="0" name="cache_index" type="int" />
<param index="1" name="size" type="int" />
<description>
+ Returns thickness of the underline in pixels.
</description>
</method>
<method name="get_embolden" qualifiers="const">
@@ -377,6 +381,7 @@
<param index="1" name="size" type="int" />
<param index="2" name="ascent" type="float" />
<description>
+ Sets the font ascent (number of pixels above the baseline).
</description>
</method>
<method name="set_cache_descent">
@@ -385,6 +390,7 @@
<param index="1" name="size" type="int" />
<param index="2" name="descent" type="float" />
<description>
+ Sets the font descent (number of pixels below the baseline).
</description>
</method>
<method name="set_cache_scale">
@@ -393,6 +399,7 @@
<param index="1" name="size" type="int" />
<param index="2" name="scale" type="float" />
<description>
+ Sets scaling factor of the color bitmap font.
</description>
</method>
<method name="set_cache_underline_position">
@@ -401,6 +408,7 @@
<param index="1" name="size" type="int" />
<param index="2" name="underline_position" type="float" />
<description>
+ Sets pixel offset of the underline below the baseline.
</description>
</method>
<method name="set_cache_underline_thickness">
@@ -409,6 +417,7 @@
<param index="1" name="size" type="int" />
<param index="2" name="underline_thickness" type="float" />
<description>
+ Sets thickness of the underline in pixels.
</description>
</method>
<method name="set_embolden">
diff --git a/doc/classes/FontVariation.xml b/doc/classes/FontVariation.xml
index e0fad126b9..5bc2606adb 100644
--- a/doc/classes/FontVariation.xml
+++ b/doc/classes/FontVariation.xml
@@ -10,16 +10,16 @@
[gdscript]
var fv = FontVariation.new()
fv.set_base_font(load("res://BarlowCondensed-Regular.ttf"))
- fv.set_variation_embolden(1.2);
- $"Label".set("custom_fonts/font", fv)
- $"Label".set("custom_fonts/font_size", 64)
+ fv.set_variation_embolden(1.2)
+ $Label.add_theme_font_override("font", fv)
+ $Label.add_theme_font_size_override("font_size", 64)
[/gdscript]
[csharp]
var fv = new FontVariation();
fv.SetBaseFont(ResourceLoader.Load&lt;FontFile&gt;("res://BarlowCondensed-Regular.ttf"));
fv.SetVariationEmbolden(1.2);
- GetNode("Label").Set("custom_fonts/font", fv);
- GetNode("Label").Set("custom_font_sizes/font_size", 64);
+ GetNode("Label").AddThemeFontOverride("font", fv);
+ GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
[/csharp]
[/codeblocks]
</description>
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 7c40c189c0..bc43f228a7 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -648,7 +648,7 @@
<return type="int" enum="Error" />
<param index="0" name="method" type="StringName" />
<description>
- Sends a remote procedure call request for the given [param method] to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same [NodePath], including the exact same node name. Behavior depends on the RPC configuration for the given method, see [method rpc_config]. Methods are not exposed to RPCs by default. Returns [code]null[/code].
+ Sends a remote procedure call request for the given [param method] to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same [NodePath], including the exact same node name. Behavior depends on the RPC configuration for the given method, see [method rpc_config] and [annotation @GDScript.@rpc]. Methods are not exposed to RPCs by default. Returns [code]null[/code].
[b]Note:[/b] You can only safely use RPCs on clients after you received the [code]connected_to_server[/code] signal from the [MultiplayerAPI]. You also need to keep track of the connection state, either by the [MultiplayerAPI] signals like [code]server_disconnected[/code] or by checking [code]get_multiplayer().peer.get_connection_status() == CONNECTION_CONNECTED[/code].
</description>
</method>
@@ -666,7 +666,7 @@
channel = 0,
}
[/codeblock]
- See [enum MultiplayerAPI.RPCMode] and [enum MultiplayerPeer.TransferMode]. An alternative is annotating methods and properties with the corresponding annotation ([code]@rpc("any")[/code], [code]@rpc("authority")[/code]). By default, methods are not exposed to networking (and RPCs).
+ See [enum MultiplayerAPI.RPCMode] and [enum MultiplayerPeer.TransferMode]. An alternative is annotating methods and properties with the corresponding [annotation @GDScript.@rpc] annotation ([code]@rpc("any_peer")[/code], [code]@rpc("authority")[/code]). By default, methods are not exposed to networking (and RPCs).
</description>
</method>
<method name="rpc_id" qualifiers="vararg">
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 04895c28a8..ca090d596e 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -553,11 +553,11 @@
[b]Note:[/b] If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
[codeblocks]
[gdscript]
- var file_to_remove = "user://slot1.sav"
+ var file_to_remove = "user://slot1.save"
OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
[/gdscript]
[csharp]
- var fileToRemove = "user://slot1.sav";
+ var fileToRemove = "user://slot1.save";
OS.MoveToTrash(ProjectSettings.GlobalizePath(fileToRemove));
[/csharp]
[/codeblocks]
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index e30ff6be19..ab7ae82875 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -639,7 +639,7 @@
<description>
Returns an [Array] of connections for the given [param signal] name. Each connection is represented as a [Dictionary] that contains three entries:
- [code]signal[/code] is a reference to the [Signal];
- - [code]callable[/code] is a reference to the [Callable];
+ - [code]callable[/code] is a reference to the connected [Callable];
- [code]flags[/code] is a combination of [enum ConnectFlags].
</description>
</method>
diff --git a/doc/classes/OmniLight3D.xml b/doc/classes/OmniLight3D.xml
index f71c81e713..c0e10574c8 100644
--- a/doc/classes/OmniLight3D.xml
+++ b/doc/classes/OmniLight3D.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
An Omnidirectional light is a type of [Light3D] that emits light in all directions. The light is attenuated by distance and this attenuation can be configured by changing its energy, radius, and attenuation parameters.
+ [b]Note:[/b] When using the Mobile or Compatibility rendering methods, omni lights will only correctly affect meshes whose visibility AABB intersects with the light's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, [member GeometryInstance3D.extra_cull_margin] must be increased on the mesh. Otherwise, the light may not be visible on the mesh.
</description>
<tutorials>
<link title="3D lights and shadows">$DOCS_URL/tutorials/3d/lights_and_shadows.html</link>
diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml
index b1c8907d8e..b98590d10c 100644
--- a/doc/classes/PrimitiveMesh.xml
+++ b/doc/classes/PrimitiveMesh.xml
@@ -48,7 +48,8 @@
The current [Material] of the primitive mesh.
</member>
<member name="uv2_padding" type="float" setter="set_uv2_padding" getter="get_uv2_padding" default="2.0">
- If [member add_uv2] is set, specifies the padding in pixels applied along seams of the mesh. If at generation the size of the lightmap texture can't be determined, the UVs are calculated assuming a texture size of 1024x1024.
+ If [member add_uv2] is set, specifies the padding in pixels applied along seams of the mesh. Lower padding values allow making better use of the lightmap texture (resulting in higher texel density), but may introduce visible lightmap bleeding along edges.
+ If the size of the lightmap texture can't be determined when generating the mesh, UV2 is calculated assuming a texture size of 1024x1024.
</member>
</members>
</class>
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index e429759e93..c30747eac1 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -60,6 +60,18 @@
Clears the whole configuration (not recommended, may break things).
</description>
</method>
+ <method name="get_global_class_list">
+ <return type="Dictionary[]" />
+ <description>
+ Returns an [Array] of registered global classes. Each global class is represented as a [Dictionary] that contains the following entries:
+ - [code]base[/code] is a name of the base class;
+ - [code]class[/code] is a name of the registered global class;
+ - [code]icon[/code] is a path to a custom icon of the global class, if it has any;
+ - [code]language[/code] is a name of a programming language in which the global class is written;
+ - [code]path[/code] is a path to a file containing the global class.
+ [b]Note:[/b] Both the script and the icon paths are local to the project filesystem, i.e. they start with [code]res://[/code].
+ </description>
+ </method>
<method name="get_order" qualifiers="const">
<return type="int" />
<param index="0" name="name" type="String" />
@@ -405,9 +417,15 @@
<member name="debug/gdscript/warnings/function_used_as_property" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when using a function as if it is a property.
</member>
+ <member name="debug/gdscript/warnings/get_node_default_without_onready" type="int" setter="" getter="" default="2">
+ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when [method Node.get_node] (or the shorthand [code]$[/code]) is used as default value of a class variable without the [code]@onready[/code] annotation.
+ </member>
<member name="debug/gdscript/warnings/incompatible_ternary" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a ternary operator may emit values with incompatible types.
</member>
+ <member name="debug/gdscript/warnings/inference_on_variant" type="int" setter="" getter="" default="2">
+ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a static inferred type uses a [Variant] as initial value, which makes the static type to also be Variant.
+ </member>
<member name="debug/gdscript/warnings/int_as_enum_without_cast" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when trying to use an integer as an enum without an explicit cast.
</member>
@@ -420,6 +438,12 @@
<member name="debug/gdscript/warnings/narrowing_conversion" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when passing a floating-point value to a function that expects an integer (it will be converted and lose precision).
</member>
+ <member name="debug/gdscript/warnings/native_method_override" type="int" setter="" getter="" default="2">
+ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a method in the script overrides a native method, because it may not behave as expected.
+ </member>
+ <member name="debug/gdscript/warnings/onready_with_export" type="int" setter="" getter="" default="2">
+ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when the [code]@onready[/code] annotation is used together with the [code]@export[/code] annotation, since it may not behave as expected.
+ </member>
<member name="debug/gdscript/warnings/property_used_as_function" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when using a property as if it is a function.
</member>
@@ -477,7 +501,7 @@
<member name="debug/gdscript/warnings/unsafe_property_access" type="int" setter="" getter="" default="0">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when accessing a property whose presence is not guaranteed at compile-time in the class.
</member>
- <member name="debug/gdscript/warnings/unsafe_void_return" type="int" setter="" getter="" default="0">
+ <member name="debug/gdscript/warnings/unsafe_void_return" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when returning a call from a [code]void[/code] function when such call cannot be guaranteed to be also [code]void[/code].
</member>
<member name="debug/gdscript/warnings/unused_local_constant" type="int" setter="" getter="" default="1">
diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml
index fa0b1ab00b..e912925cd2 100644
--- a/doc/classes/ReflectionProbe.xml
+++ b/doc/classes/ReflectionProbe.xml
@@ -7,6 +7,7 @@
Captures its surroundings as a cubemap, and stores versions of it with increasing levels of blur to simulate different material roughnesses.
The [ReflectionProbe] is used to create high-quality reflections at a low performance cost (when [member update_mode] is [constant UPDATE_ONCE]). [ReflectionProbe]s can be blended together and with the rest of the scene smoothly. [ReflectionProbe]s can also be combined with [VoxelGI], SDFGI ([member Environment.sdfgi_enabled]) and screen-space reflections ([member Environment.ssr_enabled]) to get more accurate reflections in specific areas. [ReflectionProbe]s render all objects within their [member cull_mask], so updating them can be quite expensive. It is best to update them once with the important static objects and then leave them as-is.
[b]Note:[/b] Unlike [VoxelGI] and SDFGI, [ReflectionProbe]s only source their environment from a [WorldEnvironment] node. If you specify an [Environment] resource within a [Camera3D] node, it will be ignored by the [ReflectionProbe]. This can lead to incorrect lighting within the [ReflectionProbe].
+ [b]Note:[/b] When using the Mobile rendering method, reflection probes will only correctly affect meshes whose visibility AABB intersects with the reflection probe's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, [member GeometryInstance3D.extra_cull_margin] must be increased on the mesh. Otherwise, the reflection probe may not be visible on the mesh.
</description>
<tutorials>
<link title="Reflection probes">$DOCS_URL/tutorials/3d/reflection_probes.html</link>
diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml
index 4e3a1bc0ef..e5ab3271dc 100644
--- a/doc/classes/RenderingServer.xml
+++ b/doc/classes/RenderingServer.xml
@@ -630,6 +630,14 @@
Sets a light occluder's [Transform2D].
</description>
</method>
+ <method name="canvas_light_set_blend_mode">
+ <return type="void" />
+ <param index="0" name="light" type="RID" />
+ <param index="1" name="mode" type="int" enum="RenderingServer.CanvasLightBlendMode" />
+ <description>
+ Sets the blend mode for the given canvas light. See [enum CanvasLightBlendMode] for options. Equivalent to [member Light2D.blend_mode].
+ </description>
+ </method>
<method name="canvas_light_set_color">
<return type="void" />
<param index="0" name="light" type="RID" />
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 1ecc8a1d4e..49bb65b64d 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -106,6 +106,45 @@
<return type="PopupMenu" />
<description>
Returns the [PopupMenu] of this [RichTextLabel]. By default, this menu is displayed when right-clicking on the [RichTextLabel].
+ You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see [enum MenuItems]). For example:
+ [codeblocks]
+ [gdscript]
+ func _ready():
+ var menu = get_menu()
+ # Remove "Select All" item.
+ menu.remove_item(MENU_SELECT_ALL)
+ # Add custom items.
+ menu.add_separator()
+ menu.add_item("Duplicate Text", MENU_MAX + 1)
+ # Connect callback.
+ menu.id_pressed.connect(_on_item_pressed)
+
+ func _on_item_pressed(id):
+ if id == MENU_MAX + 1:
+ add_text("\n" + get_parsed_text())
+ [/gdscript]
+ [csharp]
+ public override void _Ready()
+ {
+ var menu = GetMenu();
+ // Remove "Select All" item.
+ menu.RemoveItem(RichTextLabel.MenuItems.SelectAll);
+ // Add custom items.
+ menu.AddSeparator();
+ menu.AddItem("Duplicate Text", RichTextLabel.MenuItems.Max + 1);
+ // Add event handler.
+ menu.IdPressed += OnItemPressed;
+ }
+
+ public void OnItemPressed(int id)
+ {
+ if (id == TextEdit.MenuItems.Max + 1)
+ {
+ AddText("\n" + GetParsedText());
+ }
+ }
+ [/csharp]
+ [/codeblocks]
[b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member Window.visible] property.
</description>
</method>
@@ -193,6 +232,13 @@
If [member threaded] is enabled, returns [code]true[/code] if the background thread has finished text processing, otherwise always return [code]true[/code].
</description>
</method>
+ <method name="menu_option">
+ <return type="void" />
+ <param index="0" name="option" type="int" />
+ <description>
+ Executes a given action as defined in the [enum MenuItems] enum.
+ </description>
+ </method>
<method name="newline">
<return type="void" />
<description>
@@ -633,6 +679,15 @@
</constant>
<constant name="ITEM_CUSTOMFX" value="26" enum="ItemType">
</constant>
+ <constant name="MENU_COPY" value="0" enum="MenuItems">
+ Copies the selected text.
+ </constant>
+ <constant name="MENU_SELECT_ALL" value="1" enum="MenuItems">
+ Selects the whole [RichTextLabel] text.
+ </constant>
+ <constant name="MENU_MAX" value="2" enum="MenuItems">
+ Represents the size of the [enum MenuItems] enum.
+ </constant>
</constants>
<theme_items>
<theme_item name="default_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml
index 71905e8b2e..cdbeba0220 100644
--- a/doc/classes/Signal.xml
+++ b/doc/classes/Signal.xml
@@ -85,7 +85,10 @@
<method name="get_connections" qualifiers="const">
<return type="Array" />
<description>
- Returns the list of [Callable]s connected to this signal.
+ Returns an [Array] of connections for this signal. Each connection is represented as a [Dictionary] that contains three entries:
+ - [code]signal[/code] is a reference to this signal;
+ - [code]callable[/code] is a reference to the connected [Callable];
+ - [code]flags[/code] is a combination of [enum Object.ConnectFlags].
</description>
</method>
<method name="get_name" qualifiers="const">
diff --git a/doc/classes/SpotLight3D.xml b/doc/classes/SpotLight3D.xml
index 59d36aefab..9dff742748 100644
--- a/doc/classes/SpotLight3D.xml
+++ b/doc/classes/SpotLight3D.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
A Spotlight is a type of [Light3D] node that emits lights in a specific direction, in the shape of a cone. The light is attenuated through the distance. This attenuation can be configured by changing the energy, radius and attenuation parameters of [Light3D].
+ [b]Note:[/b] When using the Mobile or Compatibility rendering methods, spot lights will only correctly affect meshes whose visibility AABB intersects with the light's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, [member GeometryInstance3D.extra_cull_margin] must be increased on the mesh. Otherwise, the light may not be visible on the mesh.
</description>
<tutorials>
<link title="3D lights and shadows">$DOCS_URL/tutorials/3d/lights_and_shadows.html</link>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 143e1f23e9..792cd38741 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -529,7 +529,7 @@
<return type="bool" />
<param index="0" name="expr" type="String" />
<description>
- Does a simple expression match, where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except a period ([code].[/code]). An empty string or empty expression always evaluates to [code]false[/code].
+ Does a simple expression match (also called "glob" or "globbing"), where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except a period ([code].[/code]). An empty string or empty expression always evaluates to [code]false[/code].
</description>
</method>
<method name="matchn" qualifiers="const">
diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml
index c387bd435b..5dedea50d0 100644
--- a/doc/classes/TileMap.xml
+++ b/doc/classes/TileMap.xml
@@ -205,7 +205,7 @@
<param index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<param index="3" name="alternative_tile" type="int" default="-1" />
<description>
- Returns a [Vector2i] array with the positions of all cells containing a tile in the given layer. Tiles may be filtered according to their source ([param source_id]), their atlas coordinates ([param atlas_coords]) or alternative id ([param source_id]).
+ Returns a [Vector2i] array with the positions of all cells containing a tile in the given layer. Tiles may be filtered according to their source ([param source_id]), their atlas coordinates ([param atlas_coords]) or alternative id ([param alternative_tile]).
If a parameter has it's value set to the default one, this parameter is not used to filter a cell. Thus, if all parameters have their respective default value, this method returns the same result as [method get_used_cells].
A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers is [code]Vector2(-1, -1)[/code] and its alternative identifier is -1.
</description>
@@ -279,8 +279,8 @@
<description>
Sets the tile indentifiers for the cell on layer [param layer] at coordinates [param coords]. Each tile of the [TileSet] is identified using three parts:
- The source identifier [param source_id] identifies a [TileSetSource] identifier. See [method TileSet.set_source_id],
- - The atlas coordinates identifier [param atlas_coords] identifies a tile coordinates in the atlas (if the source is a [TileSetAtlasSource]. For [TileSetScenesCollectionSource] it should always be [code]Vector2i(0, 0)[/code]),
- - The alternative tile identifier [param alternative_tile] identifies a tile alternative the source is a [TileSetAtlasSource], and the scene for a [TileSetScenesCollectionSource].
+ - The atlas coordinates identifier [param atlas_coords] identifies a tile coordinates in the atlas (if the source is a [TileSetAtlasSource]). For [TileSetScenesCollectionSource] it should always be [code]Vector2i(0, 0)[/code]),
+ - The alternative tile identifier [param alternative_tile] identifies a tile alternative in the atlas (if the source is a [TileSetAtlasSource]), and the scene for a [TileSetScenesCollectionSource].
If [param source_id] is set to [code]-1[/code], [param atlas_coords] to [code]Vector2i(-1, -1)[/code] or [param alternative_tile] to [code]-1[/code], the cell will be erased. An erased cell gets [b]all[/b] its identifiers automatically set to their respective invalid values, namely [code]-1[/code], [code]Vector2i(-1, -1)[/code] and [code]-1[/code].
</description>
</method>
diff --git a/doc/classes/Variant.xml b/doc/classes/Variant.xml
index 5416468ab6..390722b7e5 100644
--- a/doc/classes/Variant.xml
+++ b/doc/classes/Variant.xml
@@ -14,16 +14,21 @@
# bar = "Uh oh! I can't make static variables become a different type!"
[/gdscript]
[csharp]
- // ... but C# is statically typed. Once a variable has a type it cannot be changed. However you can use the var keyword in methods to let the compiler decide the type automatically.
- var foo = 2; // Foo is a 32-bit integer (int). Be cautious, integers in GDScript are 64-bit and the direct C# equivalent is "long".
+ // C# is statically typed. Once a variable has a type it cannot be changed. You can use the `var` keyword to let the compiler infer the type automatically.
+ var foo = 2; // Foo is a 32-bit integer (int). Be cautious, integers in GDScript are 64-bit and the direct C# equivalent is `long`.
// foo = "foo was and will always be an integer. It cannot be turned into a string!";
var boo = "Boo is a string!";
- var ref = new Reference(); // var is especially useful when used together with a constructor.
+ var ref = new RefCounted(); // var is especially useful when used together with a constructor.
+
+ // Godot also provides a Variant type that works like an union of all the Variant-compatible types.
+ Variant fooVar = 2; // fooVar is dynamically an integer (stored as a `long` in the Variant type).
+ fooVar = "Now fooVar is a string!";
+ fooVar = new RefCounted(); // fooVar is a GodotObject.
[/csharp]
[/codeblocks]
Godot tracks all scripting API variables within Variants. Without even realizing it, you use Variants all the time. When a particular language enforces its own rules for keeping data typed, then that language is applying its own custom logic over the base Variant scripting API.
- GDScript automatically wrap values in them. It keeps all data in plain Variants by default and then optionally enforces custom static typing rules on variable types.
- - C# is statically typed, but uses the Mono [code]object[/code] type in place of Godot's Variant class when it needs to represent a dynamic value. [code]object[/code] is the Mono runtime's equivalent of the same concept.
+ - C# is statically typed, but uses its own implementation of the [code]Variant[/code] type in place of Godot's Variant class when it needs to represent a dynamic value. A [code]Variant[/code] can be assigned any compatible type implicitly but converting requires an explicit cast.
The global [method @GlobalScope.typeof] function returns the enumerated value of the Variant type stored in the current variable (see [enum Variant.Type]).
[codeblocks]
[gdscript]
@@ -38,18 +43,24 @@
# To get the name of the underlying Object type, you need the `get_class()` method.
print("foo is a(n) %s" % foo.get_class()) # inject the class name into a formatted string.
# Note also that there is not yet any way to get a script's `class_name` string easily.
- # To fetch that value, you can parse the [code]res://.godot/global_script_class_cache.cfg[/code] file with the [ConfigFile] API.
+ # To fetch that value, you can use [member ProjectSettings.get_global_class_list].
# Open your project.godot file to see it up close.
[/gdscript]
[csharp]
- int foo = 2;
- if (foo == null)
+ Variant foo = 2;
+ switch (foo.VariantType)
{
- GD.Print("foo is null");
- }
- if (foo is int)
- {
- GD.Print("foo is an integer");
+ case Variant.Type.Nil:
+ GD.Print("foo is null");
+ break;
+ case Variant.Type.Int:
+ GD.Print("foo is an integer");
+ break;
+ case Variant.Type.Object:
+ // Note that Objects are their own special category.
+ // You can convert a Variant to a GodotObject and use reflection to get its name.
+ GD.Print($"foo is a(n) {foo.AsGodotObject().GetType().Name}");
+ break;
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml
index ab2de14638..e76f805e3c 100644
--- a/doc/classes/Viewport.xml
+++ b/doc/classes/Viewport.xml
@@ -277,6 +277,10 @@
<member name="physics_object_picking" type="bool" setter="set_physics_object_picking" getter="get_physics_object_picking" default="false">
If [code]true[/code], the objects rendered by viewport become subjects of mouse picking process.
</member>
+ <member name="physics_object_picking_sort" type="bool" setter="set_physics_object_picking_sort" getter="get_physics_object_picking_sort" default="false">
+ If [code]true[/code], objects receive mouse picking events sorted primarily by their [member CanvasItem.z_index] and secondarily by their position in the scene tree. If [code]false[/code], the order is undetermined.
+ [b]Note:[/b] This setting is disabled by default because of its potential expensive computational cost.
+ </member>
<member name="positional_shadow_atlas_16_bits" type="bool" setter="set_positional_shadow_atlas_16_bits" getter="get_positional_shadow_atlas_16_bits" default="true">
</member>
<member name="positional_shadow_atlas_quad_0" type="int" setter="set_positional_shadow_atlas_quadrant_subdiv" getter="get_positional_shadow_atlas_quadrant_subdiv" enum="Viewport.PositionalShadowAtlasQuadrantSubdiv" default="2">
diff --git a/doc/classes/XRInterface.xml b/doc/classes/XRInterface.xml
index 05d5eb6673..db65ce62f2 100644
--- a/doc/classes/XRInterface.xml
+++ b/doc/classes/XRInterface.xml
@@ -51,6 +51,12 @@
Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
</description>
</method>
+ <method name="get_supported_environment_blend_modes">
+ <return type="Array" />
+ <description>
+ Returns the an array of supported environment blend modes, see [enum XRInterface.EnvironmentBlendMode].
+ </description>
+ </method>
<method name="get_tracking_status" qualifiers="const">
<return type="int" enum="XRInterface.TrackingStatus" />
<description>
@@ -101,6 +107,28 @@
Is [code]true[/code] if this interface supports passthrough.
</description>
</method>
+ <method name="set_environment_blend_mode">
+ <return type="bool" />
+ <param index="0" name="mode" type="int" enum="XRInterface.EnvironmentBlendMode" />
+ <description>
+ Sets the active environment blend mode.
+ [param mode] is the [enum XRInterface.EnvironmentBlendMode] starting with the next frame.
+ [b]Note:[/b] Not all runtimes support all environment blend modes, so it is important to check this at startup. For example:
+ [codeblock]
+ func _ready():
+ var xr_interface : XRInterface = XRServer.find_interface("OpenXR")
+ if xr_interface and xr_interface.is_initialized():
+ var vp : Viewport = get_viewport()
+ vp.use_xr = true
+ var acceptable_modes = [ XRInterface.XR_ENV_BLEND_MODE_OPAQUE, XRInterface.XR_ENV_BLEND_MODE_ADDITIVE ]
+ var modes = xr_interface.get_supported_environment_blend_modes()
+ for mode in acceptable_modes:
+ if mode in modes:
+ xr_interface.set_environment_blend_mode(mode)
+ break
+ [/codeblock]
+ </description>
+ </method>
<method name="set_play_area_mode">
<return type="bool" />
<param index="0" name="mode" type="int" enum="XRInterface.PlayAreaMode" />
@@ -220,5 +248,14 @@
<constant name="XR_PLAY_AREA_STAGE" value="4" enum="PlayAreaMode">
Same as roomscale but origin point is fixed to the center of the physical space, XRServer.center_on_hmd disabled.
</constant>
+ <constant name="XR_ENV_BLEND_MODE_OPAQUE" value="0" enum="EnvironmentBlendMode">
+ Opaque blend mode. This is typically used for VR devices.
+ </constant>
+ <constant name="XR_ENV_BLEND_MODE_ADDITIVE" value="1" enum="EnvironmentBlendMode">
+ Additive blend mode. This is typically used for AR devices or VR devices with passthrough.
+ </constant>
+ <constant name="XR_ENV_BLEND_MODE_ALPHA_BLEND" value="2" enum="EnvironmentBlendMode">
+ Alpha blend mode. This is typically used for AR or VR devices with passthrough capabilities. The alpha channel controls how much of the passthrough is visible. Alpha of 0.0 means the passthrough is visible and this pixel works in ADDITIVE mode. Alpha of 1.0 means that the passthrough is not visible and this pixel works in OPAQUE mode.
+ </constant>
</constants>
</class>
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 7f381b3f3e..7f67651e62 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -920,7 +920,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
}
if (rect->flags & CANVAS_RECT_TRANSPOSE) {
- dst_rect.size.x *= -1; // Encoding in the dst_rect.z uniform
+ state.instance_data_array[r_index].flags |= FLAGS_TRANSPOSE_RECT;
}
if (rect->flags & CANVAS_RECT_CLIP_UV) {
@@ -1128,6 +1128,12 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
state.canvas_instance_batches[state.current_batch_index].tex = mm->texture;
state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED;
+ if (GLES3::MeshStorage::get_singleton()->multimesh_uses_colors(mm->multimesh)) {
+ state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS;
+ }
+ if (GLES3::MeshStorage::get_singleton()->multimesh_uses_custom_data(mm->multimesh)) {
+ state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_CUSTOM_DATA;
+ }
} else if (c->type == Item::Command::TYPE_PARTICLES) {
GLES3::ParticlesStorage *particles_storage = GLES3::ParticlesStorage::get_singleton();
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
@@ -2684,6 +2690,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
// Default CanvasGroup shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
@@ -2711,6 +2718,7 @@ void fragment() {
// Default clip children shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index 672dcacd88..2e3e6263ed 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -179,7 +179,8 @@ typedef void (*DEBUGPROCARB)(GLenum source,
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
void RasterizerGLES3::initialize() {
- print_line("OpenGL Renderer: " + RS::get_singleton()->get_video_adapter_name());
+ // NVIDIA suffixes all GPU model names with "/PCIe/SSE2" in OpenGL (but not Vulkan). This isn't necessary to display nowadays, so it can be trimmed.
+ print_line(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name().trim_suffix("/PCIe/SSE2")));
}
void RasterizerGLES3::finalize() {
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 1631c65385..ea0a0b660d 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -162,9 +162,13 @@ void main() {
vec2 uv = uv_attrib;
#ifdef USE_INSTANCING
- vec4 instance_color = vec4(unpackHalf2x16(instance_color_custom_data.x), unpackHalf2x16(instance_color_custom_data.y));
- color *= instance_color;
- instance_custom = vec4(unpackHalf2x16(instance_color_custom_data.z), unpackHalf2x16(instance_color_custom_data.w));
+ if (bool(read_draw_data_flags & FLAGS_INSTANCING_HAS_COLORS)) {
+ vec4 instance_color = vec4(unpackHalf2x16(instance_color_custom_data.x), unpackHalf2x16(instance_color_custom_data.y));
+ color *= instance_color;
+ }
+ if (bool(read_draw_data_flags & FLAGS_INSTANCING_HAS_CUSTOM_DATA)) {
+ instance_custom = vec4(unpackHalf2x16(instance_color_custom_data.z), unpackHalf2x16(instance_color_custom_data.w));
+ }
#endif
#else
@@ -645,7 +649,7 @@ void main() {
#ifdef MODE_LIGHT_ONLY
color = vec4(0.0);
-#else
+#elif !defined(MODE_UNSHADED)
color *= canvas_modulation;
#endif
diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp
index 138498220d..026f7467a8 100644
--- a/drivers/gles3/storage/light_storage.cpp
+++ b/drivers/gles3/storage/light_storage.cpp
@@ -311,6 +311,13 @@ uint64_t LightStorage::light_get_version(RID p_light) const {
return light->version;
}
+uint32_t LightStorage::light_get_cull_mask(RID p_light) const {
+ const Light *light = light_owner.get_or_null(p_light);
+ ERR_FAIL_COND_V(!light, 0);
+
+ return light->cull_mask;
+}
+
AABB LightStorage::light_get_aabb(RID p_light) const {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, AABB());
diff --git a/drivers/gles3/storage/light_storage.h b/drivers/gles3/storage/light_storage.h
index f6f7628a90..8e6480869b 100644
--- a/drivers/gles3/storage/light_storage.h
+++ b/drivers/gles3/storage/light_storage.h
@@ -239,13 +239,6 @@ public:
return light->color;
}
- _FORCE_INLINE_ uint32_t light_get_cull_mask(RID p_light) {
- const Light *light = light_owner.get_or_null(p_light);
- ERR_FAIL_COND_V(!light, 0);
-
- return light->cull_mask;
- }
-
_FORCE_INLINE_ bool light_is_distance_fade_enabled(RID p_light) {
const Light *light = light_owner.get_or_null(p_light);
return light->distance_fade;
@@ -297,6 +290,7 @@ public:
virtual RS::LightBakeMode light_get_bake_mode(RID p_light) override;
virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override { return 0; }
virtual uint64_t light_get_version(RID p_light) const override;
+ virtual uint32_t light_get_cull_mask(RID p_light) const override;
/* LIGHT INSTANCE API */
diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp
index 5ba0c5a09c..36b34dd8a2 100644
--- a/drivers/gles3/storage/mesh_storage.cpp
+++ b/drivers/gles3/storage/mesh_storage.cpp
@@ -491,6 +491,8 @@ void MeshStorage::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
mesh->custom_aabb = p_aabb;
+
+ mesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
}
AABB MeshStorage::mesh_get_custom_aabb(RID p_mesh) const {
@@ -1833,8 +1835,12 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible
}
if (multimesh->data_cache.size()) {
- //there is a data cache..
+ // There is a data cache, but we may need to update some sections.
_multimesh_mark_all_dirty(multimesh, false, true);
+ int start = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
+ for (int i = start; i < p_visible; i++) {
+ _multimesh_mark_dirty(multimesh, i, true);
+ }
}
multimesh->visible_instances = p_visible;
@@ -1866,7 +1872,7 @@ void MeshStorage::_update_dirty_multimeshes() {
if (multimesh->data_cache_used_dirty_regions > 32 || multimesh->data_cache_used_dirty_regions > visible_region_count / 2) {
// If there too many dirty regions, or represent the majority of regions, just copy all, else transfer cost piles up too much
glBindBuffer(GL_ARRAY_BUFFER, multimesh->buffer);
- glBufferData(GL_ARRAY_BUFFER, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data, GL_STATIC_DRAW);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data);
glBindBuffer(GL_ARRAY_BUFFER, 0);
} else {
// Not that many regions? update them all
diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h
index 017e74fc4d..fedda6b260 100644
--- a/drivers/gles3/storage/texture_storage.h
+++ b/drivers/gles3/storage/texture_storage.h
@@ -585,6 +585,7 @@ public:
virtual void decal_set_normal_fade(RID p_decal, float p_fade) override;
virtual AABB decal_get_aabb(RID p_decal) const override;
+ virtual uint32_t decal_get_cull_mask(RID p_decal) const override { return 0; }
virtual void texture_add_to_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override {}
virtual void texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override {}
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 42146cd7ec..58569dc69e 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -2294,7 +2294,7 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat
return id;
}
-RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps, TextureSliceType p_slice_type) {
+RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps, TextureSliceType p_slice_type, uint32_t p_layers) {
_THREAD_SAFE_METHOD_
Texture *src_texture = texture_owner.get_or_null(p_with_texture);
@@ -2322,7 +2322,11 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p
ERR_FAIL_UNSIGNED_INDEX_V(p_layer, src_texture->layers, RID());
int slice_layers = 1;
- if (p_slice_type == TEXTURE_SLICE_2D_ARRAY) {
+ if (p_layers != 0) {
+ ERR_FAIL_COND_V_MSG(p_layers > 1 && p_slice_type != TEXTURE_SLICE_2D_ARRAY, RID(), "layer slicing only supported for 2D arrays");
+ ERR_FAIL_COND_V_MSG(p_layer + p_layers > src_texture->layers, RID(), "layer slice is out of bounds");
+ slice_layers = p_layers;
+ } else if (p_slice_type == TEXTURE_SLICE_2D_ARRAY) {
ERR_FAIL_COND_V_MSG(p_layer != 0, RID(), "layer must be 0 when obtaining a 2D array mipmap slice");
slice_layers = src_texture->layers;
} else if (p_slice_type == TEXTURE_SLICE_CUBEMAP) {
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index b2c2a03a87..63c6b97515 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -1047,7 +1047,7 @@ public:
virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture);
virtual RID texture_create_from_extension(TextureType p_type, DataFormat p_format, TextureSamples p_samples, uint64_t p_flags, uint64_t p_image, uint64_t p_width, uint64_t p_height, uint64_t p_depth, uint64_t p_layers);
- virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
+ virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D, uint32_t p_layers = 0);
virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS);
virtual Vector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer);
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index d1391cb53e..864ad5931a 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -1299,8 +1299,15 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) {
// Get device version
device_api_version = gpu_props.apiVersion;
+ String rendering_method;
+ if (OS::get_singleton()->get_current_rendering_method() == "mobile") {
+ rendering_method = "Forward Mobile";
+ } else {
+ rendering_method = "Forward+";
+ }
+
// Output our device version
- print_line("Vulkan API " + get_device_api_version() + " - " + "Using Vulkan Device #" + itos(device_index) + ": " + device_vendor + " - " + device_name);
+ print_line(vformat("Vulkan API %s - %s - Using Vulkan Device #%d: %s - %s", get_device_api_version(), rendering_method, device_index, device_vendor, device_name));
{
Error _err = _initialize_device_extensions();
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index ee4163bc14..8426dfd1ac 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1108,7 +1108,7 @@ void AnimationMultiTrackKeyEdit::_get_property_list(List<PropertyInfo> *p_list)
p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
} break;
case Animation::TYPE_ROTATION_3D: {
- p_list->push_back(PropertyInfo(Variant::QUATERNION, "scale"));
+ p_list->push_back(PropertyInfo(Variant::QUATERNION, "rotation"));
} break;
case Animation::TYPE_SCALE_3D: {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index ba73a63245..2895aa9710 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -389,7 +389,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
size = texture->get_size();
- if (bool(object->call("is_region"))) {
+ if (bool(object->call("is_region_enabled"))) {
size = Rect2(object->call("get_region_rect")).size;
}
@@ -479,7 +479,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.size = texture->get_size();
- if (bool(object->call("is_region"))) {
+ if (bool(object->call("is_region_enabled"))) {
region = Rect2(object->call("get_region_rect"));
}
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index aaa07e98c8..20a9e633a8 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -170,6 +170,10 @@ void ConnectDialog::_tree_node_selected() {
_update_ok_enabled();
}
+void ConnectDialog::_focus_currently_connected() {
+ tree->set_selected(source);
+}
+
void ConnectDialog::_unbind_count_changed(double p_count) {
for (Control *control : bind_controls) {
BaseButton *b = Object::cast_to<BaseButton>(control);
@@ -577,6 +581,8 @@ void ConnectDialog::init(const ConnectionData &p_cd, const PackedStringArray &p_
void ConnectDialog::popup_dialog(const String p_for_signal) {
from_signal->set_text(p_for_signal);
error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ filter_nodes->clear();
+
if (!advanced->is_pressed()) {
error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root()));
}
@@ -591,14 +597,12 @@ void ConnectDialog::popup_dialog(const String p_for_signal) {
void ConnectDialog::_advanced_pressed() {
if (advanced->is_pressed()) {
- set_min_size(Size2(900, 500) * EDSCALE);
connect_to_label->set_text(TTR("Connect to Node:"));
tree->set_connect_to_script_mode(false);
vbc_right->show();
error_label->hide();
} else {
- set_min_size(Size2(600, 500) * EDSCALE);
reset_size();
connect_to_label->set_text(TTR("Connect to Script:"));
tree->set_connect_to_script_mode(true);
@@ -613,18 +617,15 @@ void ConnectDialog::_advanced_pressed() {
}
ConnectDialog::ConnectDialog() {
- set_min_size(Size2(600, 500) * EDSCALE);
-
- VBoxContainer *vbc = memnew(VBoxContainer);
- add_child(vbc);
+ set_min_size(Size2(0, 500) * EDSCALE);
HBoxContainer *main_hb = memnew(HBoxContainer);
- vbc->add_child(main_hb);
- main_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ add_child(main_hb);
VBoxContainer *vbc_left = memnew(VBoxContainer);
main_hb->add_child(vbc_left);
vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ vbc_left->set_custom_minimum_size(Vector2(400 * EDSCALE, 0));
from_signal = memnew(LineEdit);
vbc_left->add_margin_child(TTR("From Signal:"), from_signal);
@@ -633,12 +634,28 @@ ConnectDialog::ConnectDialog() {
tree = memnew(SceneTreeEditor(false));
tree->set_connecting_signal(true);
tree->set_show_enabled_subscene(true);
+ tree->set_v_size_flags(Control::SIZE_FILL | Control::SIZE_EXPAND);
tree->get_scene_tree()->connect("item_activated", callable_mp(this, &ConnectDialog::_item_activated));
tree->connect("node_selected", callable_mp(this, &ConnectDialog::_tree_node_selected));
tree->set_connect_to_script_mode(true);
- Node *mc = vbc_left->add_margin_child(TTR("Connect to Script:"), tree, true);
+ HBoxContainer *hbc_filter = memnew(HBoxContainer);
+
+ filter_nodes = memnew(LineEdit);
+ hbc_filter->add_child(filter_nodes);
+ filter_nodes->set_h_size_flags(Control::SIZE_FILL | Control::SIZE_EXPAND);
+ filter_nodes->set_placeholder(TTR("Filter Nodes"));
+ filter_nodes->set_clear_button_enabled(true);
+ filter_nodes->connect("text_changed", callable_mp(tree, &SceneTreeEditor::set_filter));
+
+ Button *focus_current = memnew(Button);
+ hbc_filter->add_child(focus_current);
+ focus_current->set_text(TTR("Go to Source"));
+ focus_current->connect("pressed", callable_mp(this, &ConnectDialog::_focus_currently_connected));
+
+ Node *mc = vbc_left->add_margin_child(TTR("Connect to Script:"), hbc_filter, false);
connect_to_label = Object::cast_to<Label>(vbc_left->get_child(mc->get_index() - 1));
+ vbc_left->add_child(tree);
error_label = memnew(Label);
error_label->set_text(TTR("Scene does not contain any script."));
@@ -685,6 +702,7 @@ ConnectDialog::ConnectDialog() {
vbc_right = memnew(VBoxContainer);
main_hb->add_child(vbc_right);
vbc_right->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ vbc_right->set_custom_minimum_size(Vector2(150 * EDSCALE, 0));
vbc_right->hide();
HBoxContainer *add_bind_hb = memnew(HBoxContainer);
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index 277ea03cf7..e5375a3fc8 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -106,6 +106,7 @@ public:
private:
Label *connect_to_label = nullptr;
LineEdit *from_signal = nullptr;
+ LineEdit *filter_nodes = nullptr;
Node *source = nullptr;
ConnectionData source_connection_data;
StringName signal;
@@ -142,6 +143,7 @@ private:
void _item_activated();
void _text_submitted(const String &p_text);
void _tree_node_selected();
+ void _focus_currently_connected();
void _method_selected();
void _create_method_tree_items(const List<MethodInfo> &p_methods, TreeItem *p_parent_item);
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index bbd0a6bd70..4a1f0b4c09 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -620,12 +620,16 @@ void EditorFileDialog::_item_list_item_rmb_clicked(int p_item, const Vector2 &p_
if (allow_delete) {
item_menu->add_icon_item(theme_cache.action_delete, TTR("Delete"), ITEM_MENU_DELETE, Key::KEY_DELETE);
}
+
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
+ // Opening the system file manager is not supported on the Android and web editors.
if (single_item_selected) {
item_menu->add_separator();
Dictionary item_meta = item_list->get_item_metadata(p_item);
String item_text = item_meta["dir"] ? TTR("Open in File Manager") : TTR("Show in File Manager");
item_menu->add_icon_item(theme_cache.filesystem, item_text, ITEM_MENU_SHOW_IN_EXPLORER);
}
+#endif
if (item_menu->get_item_count() > 0) {
item_menu->set_position(item_list->get_screen_position() + p_pos);
@@ -655,8 +659,11 @@ void EditorFileDialog::_item_list_empty_clicked(const Vector2 &p_pos, MouseButto
item_menu->add_icon_item(theme_cache.folder, TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KeyModifierMask::CMD_OR_CTRL | Key::N);
}
item_menu->add_icon_item(theme_cache.reload, TTR("Refresh"), ITEM_MENU_REFRESH, Key::F5);
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
+ // Opening the system file manager is not supported on the Android and web editors.
item_menu->add_separator();
item_menu->add_icon_item(theme_cache.filesystem, TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER);
+#endif
item_menu->set_position(item_list->get_screen_position() + p_pos);
item_menu->reset_size();
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 644c32e8a4..ec1ef8a6bc 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1900,49 +1900,56 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
return err;
}
-void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<StringName, Variant> *p_custom_options, const String &p_custom_importer) {
+Error EditorFileSystem::_reimport_file(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant *p_generator_parameters) {
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
bool found = _find_file(p_file, &fs, cpos);
- ERR_FAIL_COND_MSG(!found, "Can't find file '" + p_file + "'.");
+ ERR_FAIL_COND_V_MSG(!found, ERR_FILE_NOT_FOUND, "Can't find file '" + p_file + "'.");
//try to obtain existing params
- HashMap<StringName, Variant> params;
+ HashMap<StringName, Variant> params = p_custom_options;
String importer_name; //empty by default though
if (!p_custom_importer.is_empty()) {
importer_name = p_custom_importer;
}
- if (p_custom_options != nullptr) {
- params = *p_custom_options;
- }
ResourceUID::ID uid = ResourceUID::INVALID_ID;
+ Variant generator_parameters;
+ if (p_generator_parameters) {
+ generator_parameters = *p_generator_parameters;
+ }
if (FileAccess::exists(p_file + ".import")) {
//use existing
- if (p_custom_options == nullptr) {
- Ref<ConfigFile> cf;
- cf.instantiate();
- Error err = cf->load(p_file + ".import");
- if (err == OK) {
- if (cf->has_section("params")) {
- List<String> sk;
- cf->get_section_keys("params", &sk);
- for (const String &E : sk) {
+ Ref<ConfigFile> cf;
+ cf.instantiate();
+ Error err = cf->load(p_file + ".import");
+ if (err == OK) {
+ if (cf->has_section("params")) {
+ List<String> sk;
+ cf->get_section_keys("params", &sk);
+ for (const String &E : sk) {
+ if (!params.has(E)) {
params[E] = cf->get_value("params", E);
}
}
+ }
+
+ if (cf->has_section("remap")) {
+ if (p_custom_importer.is_empty()) {
+ importer_name = cf->get_value("remap", "importer");
+ }
- if (cf->has_section("remap")) {
- if (p_custom_importer.is_empty()) {
- importer_name = cf->get_value("remap", "importer");
- }
+ if (cf->has_section_key("remap", "uid")) {
+ String uidt = cf->get_value("remap", "uid");
+ uid = ResourceUID::get_singleton()->text_to_id(uidt);
+ }
- if (cf->has_section_key("remap", "uid")) {
- String uidt = cf->get_value("remap", "uid");
- uid = ResourceUID::get_singleton()->text_to_id(uidt);
+ if (!p_generator_parameters) {
+ if (cf->has_section_key("remap", "generator_parameters")) {
+ generator_parameters = cf->get_value("remap", "generator_parameters");
}
}
}
@@ -1957,7 +1964,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
fs->files[cpos]->type = "";
fs->files[cpos]->import_valid = false;
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
- return;
+ return OK;
}
Ref<ResourceImporter> importer;
bool load_default = false;
@@ -1971,8 +1978,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
importer = ResourceFormatImporter::get_singleton()->get_importer_by_extension(p_file.get_extension());
load_default = true;
if (importer.is_null()) {
- ERR_PRINT("BUG: File queued for import, but can't be imported, importer for type '" + importer_name + "' not found.");
- ERR_FAIL();
+ ERR_FAIL_V_MSG(ERR_FILE_CANT_OPEN, "BUG: File queued for import, but can't be imported, importer for type '" + importer_name + "' not found.");
}
}
@@ -2005,16 +2011,14 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
Variant meta;
Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &meta);
- if (err != OK) {
- ERR_PRINT("Error importing '" + p_file + "'.");
- }
+ ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_UNRECOGNIZED, "Error importing '" + p_file + "'.");
//as import is complete, save the .import file
Vector<String> dest_paths;
{
Ref<FileAccess> f = FileAccess::open(p_file + ".import", FileAccess::WRITE);
- ERR_FAIL_COND_MSG(f.is_null(), "Cannot open file from path '" + p_file + ".import'.");
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_FILE_CANT_OPEN, "Cannot open file from path '" + p_file + ".import'.");
//write manually, as order matters ([remap] has to go first for performance).
f->store_line("[remap]");
@@ -2059,6 +2063,10 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
f->store_line("metadata=" + meta.get_construct_string());
}
+ if (generator_parameters != Variant()) {
+ f->store_line("generator_parameters=" + generator_parameters.get_construct_string());
+ }
+
f->store_line("");
f->store_line("[deps]\n");
@@ -2102,7 +2110,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
// Store the md5's of the various files. These are stored separately so that the .import files can be version controlled.
{
Ref<FileAccess> md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
- ERR_FAIL_COND_MSG(md5s.is_null(), "Cannot open MD5 file '" + base_path + ".md5'.");
+ ERR_FAIL_COND_V_MSG(md5s.is_null(), ERR_FILE_CANT_OPEN, "Cannot open MD5 file '" + base_path + ".md5'.");
md5s->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\"");
if (dest_paths.size()) {
@@ -2136,6 +2144,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
}
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
+
+ return OK;
}
void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap<String, Vector<String>> &group_files, HashSet<String> &groups_to_reimport) {
@@ -2156,7 +2166,7 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap
}
void EditorFileSystem::reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params) {
- _reimport_file(p_file, &p_custom_params, p_importer);
+ _reimport_file(p_file, p_custom_params, p_importer);
}
void EditorFileSystem::_reimport_thread(uint32_t p_index, ImportThreadData *p_import_data) {
@@ -2166,10 +2176,11 @@ void EditorFileSystem::_reimport_thread(uint32_t p_index, ImportThreadData *p_im
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
importing = true;
- EditorProgress pr("reimport", TTR("(Re)Importing Assets"), p_files.size());
Vector<String> reloads;
+ EditorProgress pr("reimport", TTR("(Re)Importing Assets"), p_files.size());
+
Vector<ImportFile> reimport_files;
HashSet<String> groups_to_reimport;
@@ -2292,6 +2303,11 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
emit_signal(SNAME("resources_reimported"), reloads);
}
+Error EditorFileSystem::reimport_append(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters) {
+ ERR_FAIL_COND_V_MSG(!importing, ERR_INVALID_PARAMETER, "Can only append files to import during a current reimport process.");
+ return _reimport_file(p_file, p_custom_options, p_custom_importer, &p_generator_parameters);
+}
+
Error EditorFileSystem::_resource_import(const String &p_path) {
Vector<String> files;
files.push_back(p_path);
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 2490bd31b3..0d558c84c5 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -242,7 +242,7 @@ class EditorFileSystem : public Node {
void _update_extensions();
- void _reimport_file(const String &p_file, const HashMap<StringName, Variant> *p_custom_options = nullptr, const String &p_custom_importer = String());
+ Error _reimport_file(const String &p_file, const HashMap<StringName, Variant> &p_custom_options = HashMap<StringName, Variant>(), const String &p_custom_importer = String(), Variant *generator_parameters = nullptr);
Error _reimport_group(const String &p_group_file, const Vector<String> &p_files);
bool _test_for_reimport(const String &p_path, bool p_only_imported_files);
@@ -315,6 +315,7 @@ public:
EditorFileSystemDirectory *find_file(const String &p_file, int *r_index) const;
void reimport_files(const Vector<String> &p_files);
+ Error reimport_append(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters);
void reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params);
diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp
index 3f788627f4..57a0a88810 100644
--- a/editor/editor_layouts_dialog.cpp
+++ b/editor/editor_layouts_dialog.cpp
@@ -65,6 +65,20 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) {
}
}
+void EditorLayoutsDialog::_update_ok_disable_state() {
+ if (layout_names->is_anything_selected()) {
+ get_ok_button()->set_disabled(false);
+ } else {
+ get_ok_button()->set_disabled(!name->is_visible() || name->get_text().is_empty());
+ }
+}
+
+void EditorLayoutsDialog::_deselect_layout_names() {
+ // The deselect method does not emit any signal, therefore we need update the disable state as well.
+ layout_names->deselect_all();
+ _update_ok_disable_state();
+}
+
void EditorLayoutsDialog::_bind_methods() {
ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name")));
}
@@ -82,8 +96,8 @@ void EditorLayoutsDialog::ok_pressed() {
void EditorLayoutsDialog::_post_popup() {
ConfirmationDialog::_post_popup();
- name->clear();
layout_names->clear();
+ name->clear();
Ref<ConfigFile> config;
config.instantiate();
@@ -112,9 +126,9 @@ EditorLayoutsDialog::EditorLayoutsDialog() {
makevb->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5);
layout_names = memnew(ItemList);
- layout_names->set_auto_height(true);
makevb->add_margin_child(TTR("Select existing layout:"), layout_names);
- layout_names->set_custom_minimum_size(Size2(300 * EDSCALE, 1));
+ layout_names->set_auto_height(true);
+ layout_names->set_custom_minimum_size(Size2(300 * EDSCALE, 50 * EDSCALE));
layout_names->set_visible(true);
layout_names->set_offset(SIDE_TOP, 5);
layout_names->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5);
@@ -122,16 +136,17 @@ EditorLayoutsDialog::EditorLayoutsDialog() {
layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL);
layout_names->set_select_mode(ItemList::SELECT_MULTI);
layout_names->set_allow_rmb_select(true);
+ layout_names->connect("multi_selected", callable_mp(this, &EditorLayoutsDialog::_update_ok_disable_state).unbind(2));
name = memnew(LineEdit);
- name->set_placeholder("Or enter new layout name");
makevb->add_child(name);
+ name->set_placeholder("Or enter new layout name");
name->set_offset(SIDE_TOP, 5);
- name->set_custom_minimum_size(Size2(300 * EDSCALE, 1));
name->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5);
name->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5);
name->connect("gui_input", callable_mp(this, &EditorLayoutsDialog::_line_gui_input));
- name->connect("focus_entered", callable_mp(layout_names, &ItemList::deselect_all));
+ name->connect("focus_entered", callable_mp(this, &EditorLayoutsDialog::_deselect_layout_names));
+ name->connect("text_changed", callable_mp(this, &EditorLayoutsDialog::_update_ok_disable_state).unbind(1));
}
void EditorLayoutsDialog::set_name_line_enabled(bool p_enabled) {
diff --git a/editor/editor_layouts_dialog.h b/editor/editor_layouts_dialog.h
index 80a7ed0b53..e3557fbe71 100644
--- a/editor/editor_layouts_dialog.h
+++ b/editor/editor_layouts_dialog.h
@@ -44,6 +44,8 @@ class EditorLayoutsDialog : public ConfirmationDialog {
VBoxContainer *makevb = nullptr;
void _line_gui_input(const Ref<InputEvent> &p_event);
+ void _update_ok_disable_state();
+ void _deselect_layout_names();
protected:
static void _bind_methods();
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f317c23b83..3adebb2f8e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -852,6 +852,18 @@ void EditorNode::_remove_plugin_from_enabled(const String &p_name) {
ps->set("editor_plugins/enabled", enabled_plugins);
}
+void EditorNode::_plugin_over_edit(EditorPlugin *p_plugin, Object *p_object) {
+ if (p_object) {
+ editor_plugins_over->add_plugin(p_plugin);
+ p_plugin->make_visible(true);
+ p_plugin->edit(p_object);
+ } else {
+ editor_plugins_over->remove_plugin(p_plugin);
+ p_plugin->make_visible(false);
+ p_plugin->edit(nullptr);
+ }
+}
+
void EditorNode::_resources_changed(const Vector<String> &p_resources) {
List<Ref<Resource>> changed;
@@ -2102,8 +2114,7 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) {
if (!item_plugins.has(plugin)) {
// Remove plugins no longer used by this editing owner.
to_remove.push_back(plugin);
- plugin->make_visible(false);
- plugin->edit(nullptr);
+ _plugin_over_edit(plugin, nullptr);
}
}
@@ -2113,6 +2124,7 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) {
for (EditorPlugin *plugin : item_plugins) {
if (active_plugins[owner_id].has(plugin)) {
+ plugin->edit(p_object);
continue;
}
@@ -2127,9 +2139,7 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) {
}
}
active_plugins[owner_id].insert(plugin);
- editor_plugins_over->add_plugin(plugin);
- plugin->edit(p_object);
- plugin->make_visible(true);
+ _plugin_over_edit(plugin, p_object);
}
} else {
hide_unused_editors(p_editing_owner);
@@ -2181,9 +2191,7 @@ void EditorNode::hide_unused_editors(const Object *p_editing_owner) {
if (p_editing_owner) {
const ObjectID id = p_editing_owner->get_instance_id();
for (EditorPlugin *plugin : active_plugins[id]) {
- plugin->make_visible(false);
- plugin->edit(nullptr);
- editor_plugins_over->remove_plugin(plugin);
+ _plugin_over_edit(plugin, nullptr);
}
active_plugins.erase(id);
} else {
@@ -2194,9 +2202,7 @@ void EditorNode::hide_unused_editors(const Object *p_editing_owner) {
if (!ObjectDB::get_instance(kv.key)) {
to_remove.push_back(kv.key);
for (EditorPlugin *plugin : kv.value) {
- plugin->make_visible(false);
- plugin->edit(nullptr);
- editor_plugins_over->remove_plugin(plugin);
+ _plugin_over_edit(plugin, nullptr);
}
}
}
@@ -2947,7 +2953,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} else if (export_template_manager->can_install_android_template()) {
install_android_build_template->popup_centered();
} else {
- custom_build_manage_templates->popup_centered();
+ gradle_build_manage_templates->popup_centered();
}
}
} break;
@@ -3037,7 +3043,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
#endif
} break;
case SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE: {
- custom_build_manage_templates->hide();
+ gradle_build_manage_templates->hide();
file_android_build_source->popup_centered_ratio();
} break;
case SETTINGS_MANAGE_FEATURE_PROFILES: {
@@ -5618,8 +5624,9 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
return;
}
- bottom_panel_updating = true;
if (p_enable) {
+ bottom_panel_updating = true;
+
for (int i = 0; i < bottom_panel_items.size(); i++) {
bottom_panel_items[i].button->set_pressed(i == p_idx);
bottom_panel_items[i].control->set_visible(i == p_idx);
@@ -5636,7 +5643,6 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
top_split->hide();
}
bottom_panel_raise->show();
-
} else {
bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles")));
bottom_panel_items[p_idx].button->set_pressed(false);
@@ -7700,12 +7706,12 @@ EditorNode::EditorNode() {
save_confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
save_confirmation->connect("custom_action", callable_mp(this, &EditorNode::_discard_changes));
- custom_build_manage_templates = memnew(ConfirmationDialog);
- custom_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates."));
- custom_build_manage_templates->set_ok_button_text(TTR("Manage Templates"));
- custom_build_manage_templates->add_button(TTR("Install from file"))->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE));
- custom_build_manage_templates->connect("confirmed", callable_mp(this, &EditorNode::_menu_option).bind(SETTINGS_MANAGE_EXPORT_TEMPLATES));
- gui_base->add_child(custom_build_manage_templates);
+ gradle_build_manage_templates = memnew(ConfirmationDialog);
+ gradle_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates."));
+ gradle_build_manage_templates->set_ok_button_text(TTR("Manage Templates"));
+ gradle_build_manage_templates->add_button(TTR("Install from file"))->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE));
+ gradle_build_manage_templates->connect("confirmed", callable_mp(this, &EditorNode::_menu_option).bind(SETTINGS_MANAGE_EXPORT_TEMPLATES));
+ gui_base->add_child(gradle_build_manage_templates);
file_android_build_source = memnew(EditorFileDialog);
file_android_build_source->set_title(TTR("Select Android sources file"));
@@ -7716,7 +7722,7 @@ EditorNode::EditorNode() {
gui_base->add_child(file_android_build_source);
install_android_build_template = memnew(ConfirmationDialog);
- install_android_build_template->set_text(TTR("This will set up your project for custom Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make custom builds instead of using pre-built APKs, the \"Use Custom Build\" option should be enabled in the Android export preset."));
+ install_android_build_template->set_text(TTR("This will set up your project for gradle Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make gradle builds instead of using pre-built APKs, the \"Use Gradle Build\" option should be enabled in the Android export preset."));
install_android_build_template->set_ok_button_text(TTR("Install"));
install_android_build_template->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
gui_base->add_child(install_android_build_template);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 914dab0254..eefe45ca1f 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -398,7 +398,7 @@ private:
PopupMenu *editor_layouts = nullptr;
EditorLayoutsDialog *layout_dialog = nullptr;
- ConfirmationDialog *custom_build_manage_templates = nullptr;
+ ConfirmationDialog *gradle_build_manage_templates = nullptr;
ConfirmationDialog *install_android_build_template = nullptr;
ConfirmationDialog *remove_android_build_template = nullptr;
@@ -565,6 +565,7 @@ private:
void _update_file_menu_closed();
void _remove_plugin_from_enabled(const String &p_name);
+ void _plugin_over_edit(EditorPlugin *p_plugin, Object *p_object);
void _fs_changed();
void _resources_reimported(const Vector<String> &p_resources);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index c9eae77b53..33bba90c70 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -4593,7 +4593,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} break;
case Variant::PACKED_STRING_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
- editor->setup(Variant::PACKED_STRING_ARRAY);
+ editor->setup(Variant::PACKED_STRING_ARRAY, p_hint_text);
return editor;
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index b96ac9dbcb..24cfa7ad7b 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -574,7 +574,7 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint
// The format of p_hint_string is:
// subType/subTypeHint:nextSubtype ... etc.
- if (array_type == Variant::ARRAY && !p_hint_string.is_empty()) {
+ if (!p_hint_string.is_empty()) {
int hint_subtype_separator = p_hint_string.find(":");
if (hint_subtype_separator >= 0) {
String subtype_string = p_hint_string.substr(0, hint_subtype_separator);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index d2c82ad013..6410821dcf 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1423,9 +1423,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("grabber", "VSplitContainer", theme->get_icon(SNAME("GuiVsplitter"), SNAME("EditorIcons")));
theme->set_icon("grabber", "HSplitContainer", theme->get_icon(SNAME("GuiHsplitter"), SNAME("EditorIcons")));
+ theme->set_constant("separation", "SplitContainer", default_margin_size * 2 * EDSCALE);
theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE);
theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE);
+ theme->set_constant("minimum_grab_thickness", "SplitContainer", 6 * EDSCALE);
theme->set_constant("minimum_grab_thickness", "HSplitContainer", 6 * EDSCALE);
theme->set_constant("minimum_grab_thickness", "VSplitContainer", 6 * EDSCALE);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 378e06b4c9..e1924c7994 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -241,8 +241,8 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
}
for (int i = 0; i < favorite_paths.size(); i++) {
- String fave = favorite_paths[i];
- if (!fave.begins_with("res://")) {
+ String favorite = favorite_paths[i];
+ if (!favorite.begins_with("res://")) {
continue;
}
@@ -252,18 +252,18 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
String text;
Ref<Texture2D> icon;
Color color;
- if (fave == "res://") {
+ if (favorite == "res://") {
text = "/";
icon = folder_icon;
color = folder_color;
- } else if (fave.ends_with("/")) {
- text = fave.substr(0, fave.length() - 1).get_file();
+ } else if (favorite.ends_with("/")) {
+ text = favorite.substr(0, favorite.length() - 1).get_file();
icon = folder_icon;
color = folder_color;
} else {
- text = fave.get_file();
+ text = favorite.get_file();
int index;
- EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->find_file(fave, &index);
+ EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->find_file(favorite, &index);
if (dir) {
icon = _get_tree_item_icon(dir->get_file_import_is_valid(index), dir->get_file_type(index));
} else {
@@ -277,18 +277,18 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
ti->set_text(0, text);
ti->set_icon(0, icon);
ti->set_icon_modulate(0, color);
- ti->set_tooltip_text(0, fave);
+ ti->set_tooltip_text(0, favorite);
ti->set_selectable(0, true);
- ti->set_metadata(0, fave);
- if (p_select_in_favorites && fave == path) {
+ ti->set_metadata(0, favorite);
+ if (p_select_in_favorites && favorite == path) {
ti->select(0);
ti->set_as_cursor(0);
}
- if (!fave.ends_with("/")) {
+ if (!favorite.ends_with("/")) {
Array udata;
udata.push_back(tree_update_id);
udata.push_back(ti);
- EditorResourcePreview::get_singleton()->queue_resource_preview(fave, this, "_tree_thumbnail_done", udata);
+ EditorResourcePreview::get_singleton()->queue_resource_preview(favorite, this, "_tree_thumbnail_done", udata);
}
}
}
@@ -2636,24 +2636,31 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
new_menu->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option));
p_popup->add_child(new_menu);
- p_popup->add_submenu_item(TTR("New"), "New");
+ p_popup->add_submenu_item(TTR("New"), "New", FILE_NEW);
new_menu->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("Folder..."), FILE_NEW_FOLDER);
new_menu->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("Scene..."), FILE_NEW_SCENE);
new_menu->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("Script..."), FILE_NEW_SCRIPT);
new_menu->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("Resource..."), FILE_NEW_RESOURCE);
new_menu->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("TextFile..."), FILE_NEW_TEXTFILE);
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
p_popup->add_separator();
+#endif
}
- String fpath = p_paths[0];
- bool is_directory = fpath.ends_with("/");
- String item_text = is_directory ? TTR("Open in File Manager") : TTR("Show in File Manager");
+ const String fpath = p_paths[0];
+
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
+ // Opening the system file manager is not supported on the Android and web editors.
+ const bool is_directory = fpath.ends_with("/");
+ const String item_text = is_directory ? TTR("Open in File Manager") : TTR("Show in File Manager");
p_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER);
p_popup->set_item_text(p_popup->get_item_index(FILE_SHOW_IN_EXPLORER), item_text);
if (!is_directory) {
p_popup->add_icon_shortcut(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/open_in_external_program"), FILE_OPEN_EXTERNAL);
}
+#endif
+
path = fpath;
}
}
@@ -2697,8 +2704,11 @@ void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_butto
tree_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT);
tree_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE);
tree_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE);
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
+ // Opening the system file manager is not supported on the Android and web editors.
tree_popup->add_separator();
tree_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER);
+#endif
tree_popup->set_position(tree->get_screen_position() + p_pos);
tree_popup->reset_size();
@@ -3120,8 +3130,11 @@ FileSystemDock::FileSystemDock() {
ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), Key::KEY_DELETE);
ED_SHORTCUT("filesystem_dock/rename", TTR("Rename..."), Key::F2);
ED_SHORTCUT_OVERRIDE("filesystem_dock/rename", "macos", Key::ENTER);
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
+ // Opening the system file manager or opening in an external program is not supported on the Android and web editors.
ED_SHORTCUT("filesystem_dock/show_in_explorer", TTR("Open in File Manager"));
ED_SHORTCUT("filesystem_dock/open_in_external_program", TTR("Open in External Program"));
+#endif
VBoxContainer *top_vbc = memnew(VBoxContainer);
add_child(top_vbc);
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index ede6869eea..9060f5c0a4 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -90,17 +90,18 @@ private:
FILE_DUPLICATE,
FILE_REIMPORT,
FILE_INFO,
- FILE_NEW_FOLDER,
- FILE_NEW_SCRIPT,
- FILE_NEW_SCENE,
+ FILE_NEW,
FILE_SHOW_IN_EXPLORER,
FILE_OPEN_EXTERNAL,
FILE_COPY_PATH,
FILE_COPY_UID,
- FILE_NEW_RESOURCE,
- FILE_NEW_TEXTFILE,
FOLDER_EXPAND_ALL,
FOLDER_COLLAPSE_ALL,
+ FILE_NEW_RESOURCE,
+ FILE_NEW_TEXTFILE,
+ FILE_NEW_FOLDER,
+ FILE_NEW_SCRIPT,
+ FILE_NEW_SCENE,
};
FileSortOption file_sort = FILE_SORT_NAME;
diff --git a/editor/icons/GizmoBakedLightmap.svg b/editor/icons/GizmoLightmapGI.svg
index a7828615fd..a7828615fd 100644
--- a/editor/icons/GizmoBakedLightmap.svg
+++ b/editor/icons/GizmoLightmapGI.svg
diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp
index ef3d3d1276..7afce116b8 100644
--- a/editor/import/editor_import_plugin.cpp
+++ b/editor/import/editor_import_plugin.cpp
@@ -31,6 +31,7 @@
#include "editor_import_plugin.h"
#include "core/object/script_language.h"
+#include "editor/editor_file_system.h"
EditorImportPlugin::EditorImportPlugin() {
}
@@ -185,6 +186,20 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa
ERR_FAIL_V_MSG(ERR_METHOD_NOT_FOUND, "Unimplemented _import in add-on.");
}
+Error EditorImportPlugin::_append_import_external_resource(const String &p_file, const Dictionary &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters) {
+ HashMap<StringName, Variant> options;
+ List<Variant> keys;
+ p_custom_options.get_key_list(&keys);
+ for (const Variant &K : keys) {
+ options.insert(K, p_custom_options[K]);
+ }
+ return append_import_external_resource(p_file, options, p_custom_importer, p_generator_parameters);
+}
+
+Error EditorImportPlugin::append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer, Variant p_generator_parameters) {
+ return EditorFileSystem::get_singleton()->reimport_append(p_file, p_custom_options, p_custom_importer, p_generator_parameters);
+}
+
void EditorImportPlugin::_bind_methods() {
GDVIRTUAL_BIND(_get_importer_name)
GDVIRTUAL_BIND(_get_visible_name)
@@ -198,4 +213,5 @@ void EditorImportPlugin::_bind_methods() {
GDVIRTUAL_BIND(_get_import_order)
GDVIRTUAL_BIND(_get_option_visibility, "path", "option_name", "options")
GDVIRTUAL_BIND(_import, "source_file", "save_path", "options", "platform_variants", "gen_files");
+ ClassDB::bind_method(D_METHOD("append_import_external_resource", "path", "custom_options", "custom_importer", "generator_parameters"), &EditorImportPlugin::_append_import_external_resource, DEFVAL(Dictionary()), DEFVAL(String()), DEFVAL(Variant()));
}
diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h
index bf912058a2..fb164c7f15 100644
--- a/editor/import/editor_import_plugin.h
+++ b/editor/import/editor_import_plugin.h
@@ -53,6 +53,8 @@ protected:
GDVIRTUAL3RC(bool, _get_option_visibility, String, StringName, Dictionary)
GDVIRTUAL5RC(Error, _import, String, String, Dictionary, TypedArray<String>, TypedArray<String>)
+ Error _append_import_external_resource(const String &p_file, const Dictionary &p_custom_options = Dictionary(), const String &p_custom_importer = String(), Variant p_generator_parameters = Variant());
+
public:
EditorImportPlugin();
virtual String get_importer_name() const override;
@@ -67,6 +69,7 @@ public:
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const override;
virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override;
+ Error append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options = HashMap<StringName, Variant>(), const String &p_custom_importer = String(), Variant p_generator_parameters = Variant());
};
#endif // EDITOR_IMPORT_PLUGIN_H
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index f5f9ec11b3..77785b15ca 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -985,8 +985,6 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
undo_redo->create_action(TTR("Node Renamed"));
undo_redo->add_do_method(blend_tree.ptr(), "rename_node", prev_name, name);
undo_redo->add_undo_method(blend_tree.ptr(), "rename_node", name, prev_name);
- undo_redo->add_do_method(tree, "rename_parameter", base_path + prev_name, base_path + name);
- undo_redo->add_undo_method(tree, "rename_parameter", base_path + name, base_path + prev_name);
undo_redo->add_do_method(this, "update_graph");
undo_redo->add_undo_method(this, "update_graph");
undo_redo->commit_action();
@@ -1111,7 +1109,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
add_options.push_back(AddOption("Add3", "AnimationNodeAdd3", 3));
add_options.push_back(AddOption("Blend2", "AnimationNodeBlend2", 2));
add_options.push_back(AddOption("Blend3", "AnimationNodeBlend3", 3));
- add_options.push_back(AddOption("Seek", "AnimationNodeTimeSeek", 1));
+ add_options.push_back(AddOption("TimeSeek", "AnimationNodeTimeSeek", 1));
add_options.push_back(AddOption("TimeScale", "AnimationNodeTimeScale", 1));
add_options.push_back(AddOption("Transition", "AnimationNodeTransition"));
add_options.push_back(AddOption("BlendTree", "AnimationNodeBlendTree"));
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index e48a5bb95d..bcb94b0f32 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -4876,6 +4876,10 @@ NavigationRegion3DGizmoPlugin::NavigationRegion3DGizmoPlugin() {
create_material("face_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_disabled_color(), false, false, true);
create_material("edge_material", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_color());
create_material("edge_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_disabled_color());
+
+ Color baking_aabb_material_color = Color(0.8, 0.5, 0.7);
+ baking_aabb_material_color.a = 0.1;
+ create_material("baking_aabb_material", baking_aabb_material_color);
}
bool NavigationRegion3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
@@ -4899,6 +4903,16 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
return;
}
+ AABB baking_aabb = navigationmesh->get_filter_baking_aabb();
+ if (baking_aabb.has_volume()) {
+ Vector3 baking_aabb_offset = navigationmesh->get_filter_baking_aabb_offset();
+
+ if (p_gizmo->is_selected()) {
+ Ref<Material> material = get_material("baking_aabb_material", p_gizmo);
+ p_gizmo->add_solid_box(material, baking_aabb.get_size(), baking_aabb.get_center() + baking_aabb_offset);
+ }
+ }
+
Vector<Vector3> vertices = navigationmesh->get_vertices();
const Vector3 *vr = vertices.ptr();
List<Face3> faces;
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 36d1e54246..b001b4f766 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -1415,9 +1415,6 @@ Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const
// Recalculate orthogonalized scale without moving origin.
if (p_orthogonal) {
s.basis = p_original.basis.scaled_orthogonal(p_motion + Vector3(1, 1, 1));
- // The scaled_orthogonal() does not require orthogonal Basis,
- // but it may make a bit skew by precision problems.
- s.basis.orthogonalize();
}
}
@@ -4634,7 +4631,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) {
if (se->gizmo.is_valid()) {
for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
Transform3D xform = GE.value;
- Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo.
+ Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords, _edit.plane != TRANSFORM_VIEW); // Force orthogonal with subgizmo.
if (!local_coords) {
new_xform = se->original.affine_inverse() * new_xform;
}
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 782e365138..7f43de3240 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -1301,7 +1301,7 @@ void Skeleton3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gi
Transform3D original_to_local;
int parent_idx = skeleton->get_bone_parent(p_id);
if (parent_idx >= 0) {
- original_to_local = original_to_local * skeleton->get_bone_global_pose(parent_idx);
+ original_to_local = skeleton->get_bone_global_pose(parent_idx);
}
Basis to_local = original_to_local.get_basis().inverse();
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 14b5f7cefb..c41bf4b8cc 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1171,32 +1171,29 @@ void SpriteFramesEditor::edit(Ref<SpriteFrames> p_frames) {
if (!p_frames.is_valid()) {
frames.unref();
+ hide();
return;
}
frames = p_frames;
read_only = EditorNode::get_singleton()->is_resource_read_only(p_frames);
- if (p_frames.is_valid()) {
- if (!p_frames->has_animation(edited_anim)) {
- List<StringName> anim_names;
- frames->get_animation_list(&anim_names);
- anim_names.sort_custom<StringName::AlphCompare>();
- if (anim_names.size()) {
- edited_anim = anim_names.front()->get();
- } else {
- edited_anim = StringName();
- }
+ if (!p_frames->has_animation(edited_anim)) {
+ List<StringName> anim_names;
+ frames->get_animation_list(&anim_names);
+ anim_names.sort_custom<StringName::AlphCompare>();
+ if (anim_names.size()) {
+ edited_anim = anim_names.front()->get();
+ } else {
+ edited_anim = StringName();
}
-
- _update_library();
- // Clear zoom and split sheet texture
- split_sheet_preview->set_texture(Ref<Texture2D>());
- _zoom_reset();
- } else {
- hide();
}
+ _update_library();
+ // Clear zoom and split sheet texture
+ split_sheet_preview->set_texture(Ref<Texture2D>());
+ _zoom_reset();
+
add_anim->set_disabled(read_only);
delete_anim->set_disabled(read_only);
anim_speed->set_editable(!read_only);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 59b5795ae3..af761a2cea 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -128,7 +128,7 @@ void VisualShaderGraphPlugin::set_connections(const List<VisualShader::Connectio
connections = p_connections;
}
-void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id) {
+void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id, bool p_is_valid) {
if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].output_ports.has(p_port_id)) {
Link &link = links[p_node_id];
@@ -162,7 +162,7 @@ void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p
vbox->add_child(offset);
VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
- port_preview->setup(visual_shader, visual_shader->get_shader_type(), p_node_id, p_port_id);
+ port_preview->setup(visual_shader, visual_shader->get_shader_type(), p_node_id, p_port_id, p_is_valid);
port_preview->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
vbox->add_child(port_preview);
link.preview_visible = true;
@@ -351,6 +351,29 @@ void VisualShaderGraphPlugin::update_theme() {
vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), SNAME("Editor")); // alpha
}
+bool VisualShaderGraphPlugin::is_node_has_parameter_instances_relatively(VisualShader::Type p_type, int p_node) const {
+ bool result = false;
+
+ Ref<VisualShaderNodeParameter> parameter_node = Object::cast_to<VisualShaderNodeParameter>(visual_shader->get_node_unchecked(p_type, p_node).ptr());
+ if (parameter_node.is_valid()) {
+ if (parameter_node->get_qualifier() == VisualShaderNodeParameter::QUAL_INSTANCE) {
+ return true;
+ }
+ }
+
+ LocalVector<int> prev_connected_nodes;
+ visual_shader->get_prev_connected_nodes(p_type, p_node, prev_connected_nodes);
+
+ for (const int &E : prev_connected_nodes) {
+ result = is_node_has_parameter_instances_relatively(p_type, E);
+ if (result) {
+ break;
+ }
+ }
+
+ return result;
+}
+
void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool p_just_update) {
if (!visual_shader.is_valid() || p_type != visual_shader->get_shader_type()) {
return;
@@ -969,8 +992,10 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
}
}
+ bool has_relative_parameter_instances = false;
if (vsnode->get_output_port_for_preview() >= 0) {
- show_port_preview(p_type, p_id, vsnode->get_output_port_for_preview());
+ has_relative_parameter_instances = is_node_has_parameter_instances_relatively(p_type, p_id);
+ show_port_preview(p_type, p_id, vsnode->get_output_port_for_preview(), !has_relative_parameter_instances);
} else {
offset = memnew(Control);
offset->set_custom_minimum_size(Size2(0, 4 * EDSCALE));
@@ -978,6 +1003,9 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
}
String error = vsnode->get_warning(mode, p_type);
+ if (has_relative_parameter_instances) {
+ error += "\n" + TTR("The 2D preview cannot correctly show the result retrieved from instance parameter.");
+ }
if (!error.is_empty()) {
Label *error_label = memnew(Label);
error_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("error_color"), SNAME("Editor")));
@@ -4970,6 +4998,29 @@ void VisualShaderEditor::_update_preview() {
}
}
+void VisualShaderEditor::_update_next_previews(int p_node_id) {
+ VisualShader::Type type = get_current_shader_type();
+
+ LocalVector<int> nodes;
+ _get_next_nodes_recursively(type, p_node_id, nodes);
+
+ for (int node_id : nodes) {
+ if (graph_plugin->is_preview_visible(node_id)) {
+ graph_plugin->update_node_deferred(type, node_id);
+ }
+ }
+}
+
+void VisualShaderEditor::_get_next_nodes_recursively(VisualShader::Type p_type, int p_node_id, LocalVector<int> &r_nodes) const {
+ LocalVector<int> next_connections;
+ visual_shader->get_next_connected_nodes(p_type, p_node_id, next_connections);
+
+ for (int node_id : next_connections) {
+ r_nodes.push_back(node_id);
+ _get_next_nodes_recursively(p_type, node_id, r_nodes);
+ }
+}
+
void VisualShaderEditor::_visibility_changed() {
if (!is_visible()) {
if (preview_window->is_visible()) {
@@ -5002,6 +5053,7 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_update_options_menu_deferred", &VisualShaderEditor::_update_options_menu_deferred);
ClassDB::bind_method("_rebuild_shader_deferred", &VisualShaderEditor::_rebuild_shader_deferred);
ClassDB::bind_method("_resources_removed", &VisualShaderEditor::_resources_removed);
+ ClassDB::bind_method("_update_next_previews", &VisualShaderEditor::_update_next_previews);
ClassDB::bind_method("_is_available", &VisualShaderEditor::_is_available);
}
@@ -6292,6 +6344,8 @@ public:
if (p_property != "constant") {
VisualShaderGraphPlugin *graph_plugin = editor->get_graph_plugin();
if (graph_plugin) {
+ undo_redo->add_do_method(editor, "_update_next_previews", node_id);
+ undo_redo->add_undo_method(editor, "_update_next_previews", node_id);
undo_redo->add_do_method(graph_plugin, "update_node_deferred", shader_type, node_id);
undo_redo->add_undo_method(graph_plugin, "update_node_deferred", shader_type, node_id);
}
@@ -6586,7 +6640,7 @@ bool EditorInspectorVisualShaderModePlugin::parse_property(Object *p_object, con
//////////////////////////////////
void VisualShaderNodePortPreview::_shader_changed() {
- if (shader.is_null()) {
+ if (!is_valid || shader.is_null()) {
return;
}
@@ -6633,12 +6687,13 @@ void VisualShaderNodePortPreview::_shader_changed() {
set_material(mat);
}
-void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) {
+void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port, bool p_is_valid) {
shader = p_shader;
- shader->connect("changed", callable_mp(this, &VisualShaderNodePortPreview::_shader_changed));
+ shader->connect("changed", callable_mp(this, &VisualShaderNodePortPreview::_shader_changed), CONNECT_DEFERRED);
type = p_type;
port = p_port;
node = p_node;
+ is_valid = p_is_valid;
queue_redraw();
_shader_changed();
}
@@ -6665,14 +6720,24 @@ void VisualShaderNodePortPreview::_notification(int p_what) {
Vector2(0, 1)
};
- Vector<Color> colors = {
- Color(1, 1, 1, 1),
- Color(1, 1, 1, 1),
- Color(1, 1, 1, 1),
- Color(1, 1, 1, 1)
- };
+ if (is_valid) {
+ Vector<Color> colors = {
+ Color(1, 1, 1, 1),
+ Color(1, 1, 1, 1),
+ Color(1, 1, 1, 1),
+ Color(1, 1, 1, 1)
+ };
+ draw_primitive(points, colors, uvs);
+ } else {
+ Vector<Color> colors = {
+ Color(0, 0, 0, 1),
+ Color(0, 0, 0, 1),
+ Color(0, 0, 0, 1),
+ Color(0, 0, 0, 1)
+ };
+ draw_primitive(points, colors, uvs);
+ }
- draw_primitive(points, colors, uvs);
} break;
}
}
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 142c8167a8..21139fbddd 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -120,7 +120,7 @@ public:
void remove_node(VisualShader::Type p_type, int p_id, bool p_just_update);
void connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
- void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id);
+ 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);
@@ -133,6 +133,7 @@ public:
Ref<Script> get_node_script(int p_node_id) const;
void update_node_size(int p_node_id);
void update_theme();
+ bool is_node_has_parameter_instances_relatively(VisualShader::Type p_type, int p_node) const;
VisualShader::Type get_shader_type() const;
VisualShaderGraphPlugin();
@@ -354,6 +355,8 @@ class VisualShaderEditor : public VBoxContainer {
void _preview_close_requested();
void _preview_size_changed();
void _update_preview();
+ void _update_next_previews(int p_node_id);
+ void _get_next_nodes_recursively(VisualShader::Type p_type, int p_node_id, LocalVector<int> &r_nodes) const;
String _get_description(int p_idx);
struct DragOp {
@@ -570,6 +573,7 @@ class VisualShaderNodePortPreview : public Control {
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
int node = 0;
int port = 0;
+ bool is_valid = false;
void _shader_changed(); //must regen
protected:
void _notification(int p_what);
@@ -577,7 +581,7 @@ protected:
public:
virtual Size2 get_minimum_size() const override;
- void setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port);
+ void setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port, bool p_is_valid);
};
class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {
diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp
index d3e16211f7..706466a974 100644
--- a/editor/project_converter_3_to_4.cpp
+++ b/editor/project_converter_3_to_4.cpp
@@ -30,13 +30,14 @@
#include "project_converter_3_to_4.h"
-#include "modules/modules_enabled.gen.h"
-
#ifndef DISABLE_DEPRECATED
-#ifdef MODULE_REGEX_ENABLED
const int ERROR_CODE = 77;
+#include "modules/modules_enabled.gen.h" // For regex.
+
+#ifdef MODULE_REGEX_ENABLED
+
#include "modules/regex/regex.h"
#include "core/io/dir_access.h"
@@ -2404,7 +2405,7 @@ Vector<String> ProjectConverter3To4::check_for_files() {
directories_to_check.append(current_dir.path_join(file_name) + "/");
} else {
bool proper_extension = false;
- if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj"))
+ if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj"))
proper_extension = true;
if (proper_extension) {
diff --git a/editor/project_converter_3_to_4.h b/editor/project_converter_3_to_4.h
index 6ec2dd188d..641bc467ac 100644
--- a/editor/project_converter_3_to_4.h
+++ b/editor/project_converter_3_to_4.h
@@ -29,9 +29,10 @@
/**************************************************************************/
#ifndef PROJECT_CONVERTER_3_TO_4_H
-#ifndef DISABLE_DEPRECATED
#define PROJECT_CONVERTER_3_TO_4_H
+#ifndef DISABLE_DEPRECATED
+
#include "core/io/file_access.h"
#include "core/object/ref_counted.h"
#include "core/string/ustring.h"
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index c4f5eb777e..105e3a5d47 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1503,8 +1503,13 @@ void ProjectList::create_project_item_control(int p_index) {
path_hb->add_child(show);
if (!item.missing) {
+#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
show->connect("pressed", callable_mp(this, &ProjectList::_show_project).bind(item.path));
show->set_tooltip_text(TTR("Show in File Manager"));
+#else
+ // Opening the system file manager is not supported on the Android and web editors.
+ show->hide();
+#endif
} else {
show->set_tooltip_text(TTR("Error: Project is missing on the filesystem."));
}
diff --git a/main/main.cpp b/main/main.cpp
index c5a9f94417..3aa9a44a21 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2366,8 +2366,10 @@ bool Main::start() {
String _export_preset;
bool export_debug = false;
bool export_pack_only = false;
+#ifndef DISABLE_DEPRECATED
bool converting_project = false;
bool validating_converting_project = false;
+#endif // DISABLE_DEPRECATED
#endif
main_timer_sync.init(OS::get_singleton()->get_ticks_usec());
@@ -2383,10 +2385,12 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
} else if (args[i] == "--no-docbase") {
doc_base = false;
+#ifndef DISABLE_DEPRECATED
} else if (args[i] == "--convert-3to4") {
converting_project = true;
} else if (args[i] == "--validate-conversion-3to4") {
validating_converting_project = true;
+#endif // DISABLE_DEPRECATED
} else if (args[i] == "-e" || args[i] == "--editor") {
editor = true;
} else if (args[i] == "-p" || args[i] == "--project-manager") {
@@ -2547,6 +2551,7 @@ bool Main::start() {
return false;
}
+#ifndef DISABLE_DEPRECATED
if (converting_project) {
int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).convert();
OS::get_singleton()->set_exit_code(exit_code);
@@ -2557,6 +2562,7 @@ bool Main::start() {
OS::get_singleton()->set_exit_code(exit_code);
return false;
}
+#endif // DISABLE_DEPRECATED
#endif
diff --git a/misc/ci/sources.list b/misc/ci/sources.list
deleted file mode 100644
index 4d8f94f35c..0000000000
--- a/misc/ci/sources.list
+++ /dev/null
@@ -1,4 +0,0 @@
-deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
diff --git a/misc/scripts/codespell.sh b/misc/scripts/codespell.sh
index 0551492420..1268350180 100755
--- a/misc/scripts/codespell.sh
+++ b/misc/scripts/codespell.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-SKIP_LIST="./.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,"
-SKIP_LIST+="./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,"
+SKIP_LIST="./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,"
+SKIP_LIST+="./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,"
SKIP_LIST+="./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json,"
-IGNORE_LIST="alo,ba,complies,curvelinear,doubleclick,expct,fave,findn,gird,gud,inout,lod,nd,numer,ois,readded,ro,sav,statics,te,varius,varn,wan"
+IGNORE_LIST="curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te"
codespell -w -q 3 -S "${SKIP_LIST}" -L "${IGNORE_LIST}" --builtin "clear,rare,en-GB_to_en-US"
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 32acad76aa..e05b17168d 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -565,14 +565,22 @@
</annotation>
<annotation name="@rpc" qualifiers="vararg">
<return type="void" />
- <param index="0" name="mode" type="String" default="&quot;&quot;" />
- <param index="1" name="sync" type="String" default="&quot;&quot;" />
- <param index="2" name="transfer_mode" type="String" default="&quot;&quot;" />
+ <param index="0" name="mode" type="String" default="&quot;authority&quot;" />
+ <param index="1" name="sync" type="String" default="&quot;call_remote&quot;" />
+ <param index="2" name="transfer_mode" type="String" default="&quot;unreliable&quot;" />
<param index="3" name="transfer_channel" type="int" default="0" />
<description>
Mark the following method for remote procedure calls. See [url=$DOCS_URL/tutorials/networking/high_level_multiplayer.html]High-level multiplayer[/url].
+ The order of [code]mode[/code], [code]sync[/code] and [code]transfer_mode[/code] does not matter and all arguments can be omitted, but [code]transfer_channel[/code] always has to be the last argument. The accepted values for [code]mode[/code] are [code]"any_peer"[/code] or [code]"authority"[/code], for [code]sync[/code] are [code]"call_remote"[/code] or [code]"call_local"[/code] and for [code]transfer_mode[/code] are [code]"unreliable"[/code], [code]"unreliable_ordered"[/code] or [code]"reliable"[/code].
[codeblock]
- @rpc()
+ @rpc
+ func fn(): pass
+
+ @rpc("any_peer", "unreliable_ordered")
+ func fn_update_pos(): pass
+
+ @rpc("authority", "call_remote", "unreliable", 0) # Equivalent to @rpc
+ func fn_default(): pass
[/codeblock]
</description>
</annotation>
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 8324cb0fe0..a876229276 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1496,7 +1496,12 @@ GDScript::~GDScript() {
// Order matters since clearing the stack may already cause
// the GDScriptFunctionState to be destroyed and thus removed from the list.
pending_func_states.remove(E);
- E->self()->_clear_stack();
+ GDScriptFunctionState *state = E->self();
+ ObjectID state_id = state->get_instance_id();
+ state->_clear_connections();
+ if (ObjectDB::get_instance(state_id)) {
+ state->_clear_stack();
+ }
}
}
@@ -1920,7 +1925,12 @@ GDScriptInstance::~GDScriptInstance() {
// Order matters since clearing the stack may already cause
// the GDSCriptFunctionState to be destroyed and thus removed from the list.
pending_func_states.remove(E);
- E->self()->_clear_stack();
+ GDScriptFunctionState *state = E->self();
+ ObjectID state_id = state->get_instance_id();
+ state->_clear_connections();
+ if (ObjectDB::get_instance(state_id)) {
+ state->_clear_stack();
+ }
}
if (script.is_valid() && owner) {
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 1c2b743909..cd1dcf9a78 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -138,13 +138,25 @@ static GDScriptParser::DataType make_enum_type(const StringName &p_enum_name, co
}
static GDScriptParser::DataType make_native_enum_type(const StringName &p_enum_name, const StringName &p_native_class, const bool p_meta = true) {
- GDScriptParser::DataType type = make_enum_type(p_enum_name, p_native_class, p_meta);
+ // Find out which base class declared the enum, so the name is always the same even when coming from other contexts.
+ StringName native_base = p_native_class;
+ while (true && native_base != StringName()) {
+ if (ClassDB::has_enum(native_base, p_enum_name, true)) {
+ break;
+ }
+ native_base = ClassDB::get_parent_class_nocheck(native_base);
+ }
+
+ GDScriptParser::DataType type = make_enum_type(p_enum_name, native_base, p_meta);
+ if (p_meta) {
+ type.builtin_type = Variant::NIL; // Native enum types are not Dictionaries
+ }
List<StringName> enum_values;
- ClassDB::get_enum_constants(p_native_class, p_enum_name, &enum_values);
+ ClassDB::get_enum_constants(native_base, p_enum_name, &enum_values, true);
for (const StringName &E : enum_values) {
- type.enum_values[E] = ClassDB::get_integer_constant(p_native_class, E);
+ type.enum_values[E] = ClassDB::get_integer_constant(native_base, E);
}
return type;
@@ -782,6 +794,22 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
resolving_datatype.kind = GDScriptParser::DataType::RESOLVING;
{
+#ifdef DEBUG_ENABLED
+ HashSet<GDScriptWarning::Code> previously_ignored_warnings = parser->ignored_warnings;
+ GDScriptParser::Node *member_node = member.get_source_node();
+ if (member_node && member_node->type != GDScriptParser::Node::ANNOTATION) {
+ // Apply @warning_ignore annotations before resolving member.
+ for (GDScriptParser::AnnotationNode *&E : member_node->annotations) {
+ if (E->name == SNAME("@warning_ignore")) {
+ resolve_annotation(E);
+ E->apply(parser, member.variable);
+ }
+ }
+ for (GDScriptWarning::Code ignored_warning : member_node->ignored_warnings) {
+ parser->ignored_warnings.insert(ignored_warning);
+ }
+ }
+#endif
switch (member.type) {
case GDScriptParser::ClassNode::Member::VARIABLE: {
check_class_member_name_conflict(p_class, member.variable->identifier->name, member.variable);
@@ -790,9 +818,48 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
// Apply annotations.
for (GDScriptParser::AnnotationNode *&E : member.variable->annotations) {
- resolve_annotation(E);
- E->apply(parser, member.variable);
+ if (E->name != SNAME("@warning_ignore")) {
+ resolve_annotation(E);
+ E->apply(parser, member.variable);
+ }
+ }
+#ifdef DEBUG_ENABLED
+ if (member.variable->exported && member.variable->onready) {
+ parser->push_warning(member.variable, GDScriptWarning::ONREADY_WITH_EXPORT);
+ }
+ if (member.variable->initializer) {
+ // Check if it is call to get_node() on self (using shorthand $ or not), so we can check if @onready is needed.
+ // This could be improved by traversing the expression fully and checking the presence of get_node at any level.
+ if (!member.variable->onready && member.variable->initializer && (member.variable->initializer->type == GDScriptParser::Node::GET_NODE || member.variable->initializer->type == GDScriptParser::Node::CALL || member.variable->initializer->type == GDScriptParser::Node::CAST)) {
+ GDScriptParser::Node *expr = member.variable->initializer;
+ if (expr->type == GDScriptParser::Node::CAST) {
+ expr = static_cast<GDScriptParser::CastNode *>(expr)->operand;
+ }
+ bool is_get_node = expr->type == GDScriptParser::Node::GET_NODE;
+ bool is_using_shorthand = is_get_node;
+ if (!is_get_node && expr->type == GDScriptParser::Node::CALL) {
+ is_using_shorthand = false;
+ GDScriptParser::CallNode *call = static_cast<GDScriptParser::CallNode *>(expr);
+ if (call->function_name == SNAME("get_node")) {
+ switch (call->get_callee_type()) {
+ case GDScriptParser::Node::IDENTIFIER: {
+ is_get_node = true;
+ } break;
+ case GDScriptParser::Node::SUBSCRIPT: {
+ GDScriptParser::SubscriptNode *subscript = static_cast<GDScriptParser::SubscriptNode *>(call->callee);
+ is_get_node = subscript->is_attribute && subscript->base->type == GDScriptParser::Node::SELF;
+ } break;
+ default:
+ break;
+ }
+ }
+ }
+ if (is_get_node) {
+ parser->push_warning(member.variable, GDScriptWarning::GET_NODE_DEFAULT_WITHOUT_ONREADY, is_using_shorthand ? "$" : "get_node()");
+ }
+ }
}
+#endif
} break;
case GDScriptParser::ClassNode::Member::CONSTANT: {
check_class_member_name_conflict(p_class, member.constant->identifier->name, member.constant);
@@ -878,6 +945,10 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
}
} break;
case GDScriptParser::ClassNode::Member::FUNCTION:
+ for (GDScriptParser::AnnotationNode *&E : member.function->annotations) {
+ resolve_annotation(E);
+ E->apply(parser, member.function);
+ }
resolve_function_signature(member.function, p_source);
break;
case GDScriptParser::ClassNode::Member::ENUM_VALUE: {
@@ -931,6 +1002,9 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
ERR_PRINT("Trying to resolve undefined member.");
break;
}
+#ifdef DEBUG_ENABLED
+ parser->ignored_warnings = previously_ignored_warnings;
+#endif
}
parser->current_class = previous_class;
@@ -1059,19 +1133,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
resolve_annotation(E);
E->apply(parser, member.function);
}
-
-#ifdef DEBUG_ENABLED
- HashSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
- for (uint32_t ignored_warning : member.function->ignored_warnings) {
- parser->ignored_warning_codes.insert(ignored_warning);
- }
-#endif // DEBUG_ENABLED
-
resolve_function_body(member.function);
-
-#ifdef DEBUG_ENABLED
- parser->ignored_warning_codes = previously_ignored;
-#endif // DEBUG_ENABLED
} else if (member.type == GDScriptParser::ClassNode::Member::VARIABLE && member.variable->property != GDScriptParser::VariableNode::PROP_NONE) {
if (member.variable->property == GDScriptParser::VariableNode::PROP_INLINE) {
if (member.variable->getter != nullptr) {
@@ -1102,9 +1164,9 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
GDScriptParser::ClassNode::Member member = p_class->members[i];
if (member.type == GDScriptParser::ClassNode::Member::VARIABLE) {
#ifdef DEBUG_ENABLED
- HashSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
- for (uint32_t ignored_warning : member.function->ignored_warnings) {
- parser->ignored_warning_codes.insert(ignored_warning);
+ HashSet<GDScriptWarning::Code> previously_ignored_warnings = parser->ignored_warnings;
+ for (GDScriptWarning::Code ignored_warning : member.variable->ignored_warnings) {
+ parser->ignored_warnings.insert(ignored_warning);
}
if (member.variable->usages == 0 && String(member.variable->identifier->name).begins_with("_")) {
parser->push_warning(member.variable->identifier, GDScriptWarning::UNUSED_PRIVATE_CLASS_VARIABLE, member.variable->identifier->name);
@@ -1179,7 +1241,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
}
}
#ifdef DEBUG_ENABLED
- parser->ignored_warning_codes = previously_ignored;
+ parser->ignored_warnings = previously_ignored_warnings;
#endif // DEBUG_ENABLED
}
}
@@ -1289,6 +1351,11 @@ void GDScriptAnalyzer::resolve_node(GDScriptParser::Node *p_node, bool p_is_root
void GDScriptAnalyzer::resolve_annotation(GDScriptParser::AnnotationNode *p_annotation) {
ERR_FAIL_COND_MSG(!parser->valid_annotations.has(p_annotation->name), vformat(R"(Annotation "%s" not found to validate.)", p_annotation->name));
+ if (p_annotation->is_resolved) {
+ return;
+ }
+ p_annotation->is_resolved = true;
+
const MethodInfo &annotation_info = parser->valid_annotations[p_annotation->name].info;
const List<PropertyInfo>::Element *E = annotation_info.arguments.front();
@@ -1355,6 +1422,13 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
}
p_function->resolved_signature = true;
+#ifdef DEBUG_ENABLED
+ HashSet<GDScriptWarning::Code> previously_ignored_warnings = parser->ignored_warnings;
+ for (GDScriptWarning::Code ignored_warning : p_function->ignored_warnings) {
+ parser->ignored_warnings.insert(ignored_warning);
+ }
+#endif
+
GDScriptParser::FunctionNode *previous_function = parser->current_function;
parser->current_function = p_function;
@@ -1421,7 +1495,8 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
int default_par_count = 0;
bool is_static = false;
bool is_vararg = false;
- if (!p_is_lambda && get_function_signature(p_function, false, base_type, function_name, parent_return_type, parameters_types, default_par_count, is_static, is_vararg)) {
+ StringName native_base;
+ if (!p_is_lambda && get_function_signature(p_function, false, base_type, function_name, parent_return_type, parameters_types, default_par_count, is_static, is_vararg, &native_base)) {
bool valid = p_function->is_static == is_static;
valid = valid && parent_return_type == p_function->get_datatype();
@@ -1447,8 +1522,8 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
parameter = "Variant";
}
parent_signature += parameter;
- if (j == parameters_types.size() - default_par_count) {
- parent_signature += " = default";
+ if (j >= parameters_types.size() - default_par_count) {
+ parent_signature += " = <default>";
}
j++;
@@ -1464,6 +1539,11 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
push_error(vformat(R"(The function signature doesn't match the parent. Parent signature is "%s".)", parent_signature), p_function);
}
+#ifdef DEBUG_ENABLED
+ if (native_base != StringName()) {
+ parser->push_warning(p_function, GDScriptWarning::NATIVE_METHOD_OVERRIDE, function_name, native_base);
+ }
+#endif
}
#endif // TOOLS_ENABLED
}
@@ -1472,6 +1552,9 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
p_function->set_datatype(prev_datatype);
}
+#ifdef DEBUG_ENABLED
+ parser->ignored_warnings = previously_ignored_warnings;
+#endif
parser->current_function = previous_function;
}
@@ -1481,6 +1564,13 @@ void GDScriptAnalyzer::resolve_function_body(GDScriptParser::FunctionNode *p_fun
}
p_function->resolved_body = true;
+#ifdef DEBUG_ENABLED
+ HashSet<GDScriptWarning::Code> previously_ignored_warnings = parser->ignored_warnings;
+ for (GDScriptWarning::Code ignored_warning : p_function->ignored_warnings) {
+ parser->ignored_warnings.insert(ignored_warning);
+ }
+#endif
+
GDScriptParser::FunctionNode *previous_function = parser->current_function;
parser->current_function = p_function;
@@ -1498,6 +1588,9 @@ void GDScriptAnalyzer::resolve_function_body(GDScriptParser::FunctionNode *p_fun
}
}
+#ifdef DEBUG_ENABLED
+ parser->ignored_warnings = previously_ignored_warnings;
+#endif
parser->current_function = previous_function;
}
@@ -1538,16 +1631,16 @@ void GDScriptAnalyzer::resolve_suite(GDScriptParser::SuiteNode *p_suite) {
}
#ifdef DEBUG_ENABLED
- HashSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
- for (uint32_t ignored_warning : stmt->ignored_warnings) {
- parser->ignored_warning_codes.insert(ignored_warning);
+ HashSet<GDScriptWarning::Code> previously_ignored_warnings = parser->ignored_warnings;
+ for (GDScriptWarning::Code ignored_warning : stmt->ignored_warnings) {
+ parser->ignored_warnings.insert(ignored_warning);
}
#endif // DEBUG_ENABLED
resolve_node(stmt);
#ifdef DEBUG_ENABLED
- parser->ignored_warning_codes = previously_ignored;
+ parser->ignored_warnings = previously_ignored_warnings;
#endif // DEBUG_ENABLED
decide_suite_type(p_suite, stmt);
@@ -1599,6 +1692,11 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
} else if (initializer_type.kind == GDScriptParser::DataType::BUILTIN && initializer_type.builtin_type == Variant::NIL && !is_constant) {
push_error(vformat(R"(Cannot infer the type of "%s" %s because the value is "null".)", p_assignable->identifier->name, p_kind), p_assignable->initializer);
}
+#ifdef DEBUG_ENABLED
+ if (initializer_type.is_hard_type() && initializer_type.is_variant()) {
+ parser->push_warning(p_assignable, GDScriptWarning::INFERENCE_ON_VARIANT, p_kind);
+ }
+#endif
} else {
if (!initializer_type.is_set()) {
push_error(vformat(R"(Could not resolve type for %s "%s".)", p_kind, p_assignable->identifier->name), p_assignable->initializer);
@@ -2240,6 +2338,28 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
if (assignee_type.is_constant || (p_assignment->assignee->type == GDScriptParser::Node::SUBSCRIPT && static_cast<GDScriptParser::SubscriptNode *>(p_assignment->assignee)->base->is_constant)) {
push_error("Cannot assign a new value to a constant.", p_assignment->assignee);
+ return;
+ } else if (assignee_type.is_read_only) {
+ push_error("Cannot assign a new value to a read-only property.", p_assignment->assignee);
+ return;
+ } else if (p_assignment->assignee->type == GDScriptParser::Node::SUBSCRIPT) {
+ GDScriptParser::SubscriptNode *sub = static_cast<GDScriptParser::SubscriptNode *>(p_assignment->assignee);
+ while (sub) {
+ const GDScriptParser::DataType &base_type = sub->base->datatype;
+ if (base_type.is_hard_type() && base_type.is_read_only) {
+ if (base_type.kind == GDScriptParser::DataType::BUILTIN && !Variant::is_type_shared(base_type.builtin_type)) {
+ push_error("Cannot assign a new value to a read-only property.", p_assignment->assignee);
+ return;
+ }
+ } else {
+ break;
+ }
+ if (sub->base->type == GDScriptParser::Node::SUBSCRIPT) {
+ sub = static_cast<GDScriptParser::SubscriptNode *>(sub->base);
+ } else {
+ sub = nullptr;
+ }
+ }
}
// Check if assigned value is an array literal, so we can make it a typed array too if appropriate.
@@ -2351,30 +2471,27 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
return;
}
- GDScriptParser::DataType awaiting_type;
-
if (p_await->to_await->type == GDScriptParser::Node::CALL) {
reduce_call(static_cast<GDScriptParser::CallNode *>(p_await->to_await), true);
- awaiting_type = p_await->to_await->get_datatype();
} else {
reduce_expression(p_await->to_await);
}
- if (p_await->to_await->is_constant) {
+ GDScriptParser::DataType await_type = p_await->to_await->get_datatype();
+ // We cannot infer the type of the result of waiting for a signal.
+ if (await_type.is_hard_type() && await_type.kind == GDScriptParser::DataType::BUILTIN && await_type.builtin_type == Variant::SIGNAL) {
+ await_type.kind = GDScriptParser::DataType::VARIANT;
+ await_type.type_source = GDScriptParser::DataType::UNDETECTED;
+ } else if (p_await->to_await->is_constant) {
p_await->is_constant = p_await->to_await->is_constant;
p_await->reduced_value = p_await->to_await->reduced_value;
-
- awaiting_type = p_await->to_await->get_datatype();
- } else {
- awaiting_type.kind = GDScriptParser::DataType::VARIANT;
- awaiting_type.type_source = GDScriptParser::DataType::UNDETECTED;
}
-
- p_await->set_datatype(awaiting_type);
+ await_type.is_coroutine = false;
+ p_await->set_datatype(await_type);
#ifdef DEBUG_ENABLED
- awaiting_type = p_await->to_await->get_datatype();
- if (!(awaiting_type.has_no_type() || awaiting_type.is_coroutine || awaiting_type.builtin_type == Variant::SIGNAL)) {
+ GDScriptParser::DataType to_await_type = p_await->to_await->get_datatype();
+ if (!(to_await_type.has_no_type() || to_await_type.is_coroutine || to_await_type.builtin_type == Variant::SIGNAL)) {
parser->push_warning(p_await, GDScriptWarning::REDUNDANT_AWAIT);
}
#endif
@@ -2931,7 +3048,11 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
// Enums do not have functions other than the built-in dictionary ones.
if (base_type.kind == GDScriptParser::DataType::ENUM && base_type.is_meta_type) {
- push_error(vformat(R"*(Enums only have Dictionary built-in methods. Function "%s()" does not exist for enum "%s".)*", p_call->function_name, base_type.enum_type), p_call->callee);
+ if (base_type.builtin_type == Variant::DICTIONARY) {
+ push_error(vformat(R"*(Enums only have Dictionary built-in methods. Function "%s()" does not exist for enum "%s".)*", p_call->function_name, base_type.enum_type), p_call->callee);
+ } else {
+ push_error(vformat(R"*(The native enum "%s" does not behave like Dictionary and does not have methods of its own.)*", base_type.enum_type), p_call->callee);
+ }
} else if (!p_call->is_super && callee_type != GDScriptParser::Node::NONE) { // Check if the name exists as something else.
GDScriptParser::IdentifierNode *callee_id;
if (callee_type == GDScriptParser::Node::IDENTIFIER) {
@@ -3329,7 +3450,8 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
StringName getter_name = ClassDB::get_property_getter(native, name);
MethodBind *getter = ClassDB::get_method(native, getter_name);
if (getter != nullptr) {
- p_identifier->set_datatype(type_from_property(getter->get_return_info()));
+ bool has_setter = ClassDB::get_property_setter(native, name) != StringName();
+ p_identifier->set_datatype(type_from_property(getter->get_return_info(), false, !has_setter));
p_identifier->source = GDScriptParser::IdentifierNode::INHERITED_VARIABLE;
}
return;
@@ -3988,7 +4110,6 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
if (!is_type_compatible(true_type, false_type)) {
result = false_type;
if (!is_type_compatible(false_type, true_type)) {
- result.type_source = GDScriptParser::DataType::UNDETECTED;
result.kind = GDScriptParser::DataType::VARIANT;
#ifdef DEBUG_ENABLED
parser->push_warning(p_ternary_op, GDScriptWarning::INCOMPATIBLE_TERNARY);
@@ -3996,6 +4117,7 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
}
}
}
+ result.type_source = true_type.is_hard_type() && false_type.is_hard_type() ? GDScriptParser::DataType::ANNOTATED_INFERRED : GDScriptParser::DataType::INFERRED;
p_ternary_op->set_datatype(result);
}
@@ -4037,6 +4159,10 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op)
Variant GDScriptAnalyzer::make_expression_reduced_value(GDScriptParser::ExpressionNode *p_expression, bool &is_reduced) {
Variant value;
+ if (p_expression == nullptr) {
+ return value;
+ }
+
if (p_expression->is_constant) {
is_reduced = true;
value = p_expression->reduced_value;
@@ -4101,6 +4227,10 @@ Variant GDScriptAnalyzer::make_dictionary_reduced_value(GDScriptParser::Dictiona
}
Variant GDScriptAnalyzer::make_subscript_reduced_value(GDScriptParser::SubscriptNode *p_subscript, bool &is_reduced) {
+ if (p_subscript->base == nullptr || p_subscript->index == nullptr) {
+ return Variant();
+ }
+
bool is_base_value_reduced = false;
Variant base_value = make_expression_reduced_value(p_subscript->base, is_base_value_reduced);
if (!is_base_value_reduced) {
@@ -4260,8 +4390,9 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_metatype(const GDScriptPars
return result;
}
-GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo &p_property, bool p_is_arg) const {
+GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo &p_property, bool p_is_arg, bool p_is_readonly) const {
GDScriptParser::DataType result;
+ result.is_read_only = p_is_readonly;
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
if (p_property.type == Variant::NIL && (p_is_arg || (p_property.usage & PROPERTY_USAGE_NIL_IS_VARIANT))) {
// Variant
@@ -4302,15 +4433,27 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
}
elem_type.is_constant = false;
result.set_container_element_type(elem_type);
+ } else if (p_property.type == Variant::INT) {
+ // Check if it's enum.
+ if (p_property.class_name != StringName()) {
+ Vector<String> names = String(p_property.class_name).split(".");
+ if (names.size() == 2) {
+ result = make_native_enum_type(names[1], names[0], false);
+ result.is_constant = false;
+ }
+ }
}
}
return result;
}
-bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, bool p_is_constructor, GDScriptParser::DataType p_base_type, const StringName &p_function, GDScriptParser::DataType &r_return_type, List<GDScriptParser::DataType> &r_par_types, int &r_default_arg_count, bool &r_static, bool &r_vararg) {
+bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, bool p_is_constructor, GDScriptParser::DataType p_base_type, const StringName &p_function, GDScriptParser::DataType &r_return_type, List<GDScriptParser::DataType> &r_par_types, int &r_default_arg_count, bool &r_static, bool &r_vararg, StringName *r_native_class) {
r_static = false;
r_vararg = false;
r_default_arg_count = 0;
+ if (r_native_class) {
+ *r_native_class = StringName();
+ }
StringName function_name = p_function;
bool was_enum = false;
@@ -4445,6 +4588,12 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, bo
if (valid && Engine::get_singleton()->has_singleton(base_native)) {
r_static = true;
}
+#ifdef DEBUG_ENABLED
+ MethodBind *native_method = ClassDB::get_method(base_native, function_name);
+ if (native_method && r_native_class) {
+ *r_native_class = native_method->get_instance_class();
+ }
+#endif
return valid;
}
diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h
index b51564fb0a..a4c84db6b9 100644
--- a/modules/gdscript/gdscript_analyzer.h
+++ b/modules/gdscript/gdscript_analyzer.h
@@ -115,9 +115,9 @@ class GDScriptAnalyzer {
Array make_array_from_element_datatype(const GDScriptParser::DataType &p_element_datatype, const GDScriptParser::Node *p_source_node = nullptr);
GDScriptParser::DataType type_from_variant(const Variant &p_value, const GDScriptParser::Node *p_source);
static GDScriptParser::DataType type_from_metatype(const GDScriptParser::DataType &p_meta_type);
- GDScriptParser::DataType type_from_property(const PropertyInfo &p_property, bool p_is_arg = false) const;
+ GDScriptParser::DataType type_from_property(const PropertyInfo &p_property, bool p_is_arg = false, bool p_is_readonly = false) const;
GDScriptParser::DataType make_global_class_meta_type(const StringName &p_class_name, const GDScriptParser::Node *p_source);
- bool get_function_signature(GDScriptParser::Node *p_source, bool p_is_constructor, GDScriptParser::DataType base_type, const StringName &p_function, GDScriptParser::DataType &r_return_type, List<GDScriptParser::DataType> &r_par_types, int &r_default_arg_count, bool &r_static, bool &r_vararg);
+ bool get_function_signature(GDScriptParser::Node *p_source, bool p_is_constructor, GDScriptParser::DataType base_type, const StringName &p_function, GDScriptParser::DataType &r_return_type, List<GDScriptParser::DataType> &r_par_types, int &r_default_arg_count, bool &r_static, bool &r_vararg, StringName *r_native_class = nullptr);
bool function_signature_from_info(const MethodInfo &p_info, GDScriptParser::DataType &r_return_type, List<GDScriptParser::DataType> &r_par_types, int &r_default_arg_count, bool &r_static, bool &r_vararg);
void validate_call_arg(const List<GDScriptParser::DataType> &p_par_types, int p_default_args_count, bool p_is_vararg, const GDScriptParser::CallNode *p_call);
void validate_call_arg(const MethodInfo &p_method, const GDScriptParser::CallNode *p_call);
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index f88ac581ca..8cfd48b52b 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -800,6 +800,15 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
warning.insert_text = warning.display.quote(p_quote_style);
r_result.insert(warning.display, warning);
}
+ } else if (p_annotation->name == SNAME("@rpc")) {
+ if (p_argument == 0 || p_argument == 1 || p_argument == 2) {
+ static const char *options[7] = { "call_local", "call_remote", "any_peer", "authority", "reliable", "unreliable", "unreliable_ordered" };
+ for (int i = 0; i < 7; i++) {
+ ScriptLanguage::CodeCompletionOption option(options[i], ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
+ option.insert_text = option.display.quote(p_quote_style);
+ r_result.insert(option.display, option);
+ }
+ }
}
}
@@ -968,7 +977,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
}
break;
case GDScriptParser::ClassNode::Member::SIGNAL:
- if (p_only_functions || outer) {
+ if (p_only_functions || outer || p_static) {
continue;
}
option = ScriptLanguage::CodeCompletionOption(member.signal->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
@@ -1024,6 +1033,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location);
r_result.insert(option.display, option);
}
+
+ List<MethodInfo> signals;
+ scr->get_script_signal_list(&signals);
+ for (const MethodInfo &E : signals) {
+ int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
+ r_result.insert(option.display, option);
+ }
}
HashMap<StringName, Variant> constants;
scr->get_constants(&constants);
@@ -1032,14 +1049,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
ScriptLanguage::CodeCompletionOption option(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location);
r_result.insert(option.display, option);
}
-
- List<MethodInfo> signals;
- scr->get_script_signal_list(&signals);
- for (const MethodInfo &E : signals) {
- int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name);
- ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
- r_result.insert(option.display, option);
- }
}
List<MethodInfo> methods;
@@ -1084,14 +1093,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
r_result.insert(option.display, option);
}
- List<MethodInfo> signals;
- ClassDB::get_signal_list(type, &signals);
- for (const MethodInfo &E : signals) {
- int location = p_recursion_depth + _get_signal_location(type, StringName(E.name));
- ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
- r_result.insert(option.display, option);
- }
-
if (!base_type.is_meta_type || Engine::get_singleton()->has_singleton(type)) {
List<PropertyInfo> pinfo;
ClassDB::get_property_list(type, &pinfo);
@@ -1106,6 +1107,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location);
r_result.insert(option.display, option);
}
+
+ List<MethodInfo> signals;
+ ClassDB::get_signal_list(type, &signals);
+ for (const MethodInfo &E : signals) {
+ int location = p_recursion_depth + _get_signal_location(type, StringName(E.name));
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
+ r_result.insert(option.display, option);
+ }
}
}
@@ -1953,17 +1962,19 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context,
case GDScriptParser::DataType::CLASS:
if (base_type.class_type->has_function(p_context.current_function->identifier->name)) {
GDScriptParser::FunctionNode *parent_function = base_type.class_type->get_member(p_context.current_function->identifier->name).function;
- const GDScriptParser::ParameterNode *parameter = parent_function->parameters[parent_function->parameters_indices[p_identifier]];
- if ((!id_type.is_set() || id_type.is_variant()) && parameter->get_datatype().is_hard_type()) {
- id_type = parameter->get_datatype();
- }
- if (parameter->initializer) {
- GDScriptParser::CompletionContext c = p_context;
- c.current_function = parent_function;
- c.current_class = base_type.class_type;
- c.base = nullptr;
- if (_guess_expression_type(c, parameter->initializer, r_type)) {
- return true;
+ if (parent_function->parameters_indices.has(p_identifier)) {
+ const GDScriptParser::ParameterNode *parameter = parent_function->parameters[parent_function->parameters_indices[p_identifier]];
+ if ((!id_type.is_set() || id_type.is_variant()) && parameter->get_datatype().is_hard_type()) {
+ id_type = parameter->get_datatype();
+ }
+ if (parameter->initializer) {
+ GDScriptParser::CompletionContext c = p_context;
+ c.current_function = parent_function;
+ c.current_class = base_type.class_type;
+ c.base = nullptr;
+ if (_guess_expression_type(c, parameter->initializer, r_type)) {
+ return true;
+ }
}
}
}
@@ -2020,6 +2031,7 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context,
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
r_type.type.script_path = script;
r_type.type.class_type = parser->get_parser()->get_tree();
+ r_type.type.is_meta_type = true;
r_type.type.is_constant = false;
r_type.type.kind = GDScriptParser::DataType::CLASS;
r_type.value = Variant();
@@ -2131,6 +2143,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
r_type.type.kind = GDScriptParser::DataType::CLASS;
r_type.type.class_type = member.m_class;
+ r_type.type.is_meta_type = true;
return true;
case GDScriptParser::ClassNode::Member::GROUP:
return false; // No-op, but silences warnings.
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 71831a3a97..a6b4dc7981 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -296,6 +296,15 @@ void GDScriptFunctionState::_clear_stack() {
}
}
+void GDScriptFunctionState::_clear_connections() {
+ List<Object::Connection> conns;
+ get_signals_connected_to_this(&conns);
+
+ for (Object::Connection &c : conns) {
+ c.signal.disconnect(c.callable);
+ }
+}
+
void GDScriptFunctionState::_bind_methods() {
ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false));
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 37416a734d..f45c1f9577 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -628,6 +628,7 @@ public:
Variant resume(const Variant &p_arg = Variant());
void _clear_stack();
+ void _clear_connections();
GDScriptFunctionState();
~GDScriptFunctionState();
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 713ad3ed17..0a1a64cb59 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -109,7 +109,7 @@ GDScriptParser::GDScriptParser() {
// Warning annotations.
register_annotation(MethodInfo("@warning_ignore", PropertyInfo(Variant::STRING, "warning")), AnnotationInfo::CLASS | AnnotationInfo::VARIABLE | AnnotationInfo::SIGNAL | AnnotationInfo::CONSTANT | AnnotationInfo::FUNCTION | AnnotationInfo::STATEMENT, &GDScriptParser::warning_annotations, varray(), true);
// Networking.
- register_annotation(MethodInfo("@rpc", PropertyInfo(Variant::STRING, "mode"), PropertyInfo(Variant::STRING, "sync"), PropertyInfo(Variant::STRING, "transfer_mode"), PropertyInfo(Variant::INT, "transfer_channel")), AnnotationInfo::FUNCTION, &GDScriptParser::rpc_annotation, varray("", "", "", 0), true);
+ register_annotation(MethodInfo("@rpc", PropertyInfo(Variant::STRING, "mode"), PropertyInfo(Variant::STRING, "sync"), PropertyInfo(Variant::STRING, "transfer_mode"), PropertyInfo(Variant::INT, "transfer_channel")), AnnotationInfo::FUNCTION, &GDScriptParser::rpc_annotation, varray("authority", "call_remote", "unreliable", 0), true);
#ifdef DEBUG_ENABLED
is_ignoring_warnings = !(bool)GLOBAL_GET("debug/gdscript/warnings/enable");
@@ -158,14 +158,10 @@ void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_
return;
}
- if (ignored_warning_codes.has(p_code)) {
+ if (ignored_warnings.has(p_code)) {
return;
}
- String warn_name = GDScriptWarning::get_name_from_code((GDScriptWarning::Code)p_code).to_lower();
- if (ignored_warnings.has(warn_name)) {
- return;
- }
int warn_level = (int)GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(p_code));
if (!warn_level) {
return;
@@ -180,7 +176,7 @@ void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_
warning.rightmost_column = p_source->rightmost_column;
if (warn_level == GDScriptWarning::WarnLevel::ERROR || bool(GLOBAL_GET("debug/gdscript/warnings/treat_warnings_as_errors"))) {
- push_error(warning.get_message(), p_source);
+ push_error(warning.get_message() + String(" (Warning treated as error.)"), p_source);
return;
}
@@ -1837,10 +1833,18 @@ GDScriptParser::IfNode *GDScriptParser::parse_if(const String &p_token) {
if (match(GDScriptTokenizer::Token::ELIF)) {
SuiteNode *else_block = alloc_node<SuiteNode>();
+ else_block->parent_function = current_function;
+ else_block->parent_block = current_suite;
+
+ SuiteNode *previous_suite = current_suite;
+ current_suite = else_block;
+
IfNode *elif = parse_if("elif");
else_block->statements.push_back(elif);
complete_extents(else_block);
n_if->false_block = else_block;
+
+ current_suite = previous_suite;
} else if (match(GDScriptTokenizer::Token::ELSE)) {
consume(GDScriptTokenizer::Token::COLON, R"(Expected ":" after "else".)");
n_if->false_block = parse_suite(R"("else" block)");
@@ -3548,7 +3552,11 @@ const GDScriptParser::SuiteNode::Local &GDScriptParser::SuiteNode::get_local(con
return empty;
}
-bool GDScriptParser::AnnotationNode::apply(GDScriptParser *p_this, Node *p_target) const {
+bool GDScriptParser::AnnotationNode::apply(GDScriptParser *p_this, Node *p_target) {
+ if (is_applied) {
+ return true;
+ }
+ is_applied = true;
return (p_this->*(p_this->valid_annotations[name].apply))(this, p_target);
}
@@ -3602,6 +3610,7 @@ bool GDScriptParser::tool_annotation(const AnnotationNode *p_annotation, Node *p
bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p_node) {
ERR_FAIL_COND_V_MSG(p_node->type != Node::CLASS, false, R"("@icon" annotation can only be applied to classes.)");
+ ERR_FAIL_COND_V(p_annotation->resolved_arguments.is_empty(), false);
ClassNode *p_class = static_cast<ClassNode *>(p_node);
p_class->icon_path = p_annotation->resolved_arguments[0];
return true;
@@ -3610,6 +3619,10 @@ bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p
bool GDScriptParser::onready_annotation(const AnnotationNode *p_annotation, Node *p_node) {
ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, R"("@onready" annotation can only be applied to class variables.)");
+ if (current_class && !ClassDB::is_parent_class(current_class->get_datatype().native_type, SNAME("Node"))) {
+ push_error(R"("@onready" can only be used in classes that inherit "Node".)", p_annotation);
+ }
+
VariableNode *variable = static_cast<VariableNode *>(p_node);
if (variable->onready) {
push_error(R"("@onready" annotation can only be used once per variable.)");
@@ -3684,6 +3697,13 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
variable->export_info.type = Variant::DICTIONARY;
return true;
+ } else if (export_type.builtin_type == Variant::PACKED_STRING_ARRAY) {
+ String hint_prefix = itos(Variant::STRING) + "/" + itos(variable->export_info.hint);
+ variable->export_info.hint = PROPERTY_HINT_TYPE_STRING;
+ variable->export_info.hint_string = hint_prefix + ":" + variable->export_info.hint_string;
+ variable->export_info.type = Variant::PACKED_STRING_ARRAY;
+
+ return true;
}
}
@@ -3830,6 +3850,10 @@ template <PropertyUsageFlags t_usage>
bool GDScriptParser::export_group_annotations(const AnnotationNode *p_annotation, Node *p_node) {
AnnotationNode *annotation = const_cast<AnnotationNode *>(p_annotation);
+ if (annotation->resolved_arguments.is_empty()) {
+ return false;
+ }
+
annotation->export_info.name = annotation->resolved_arguments[0];
switch (t_usage) {
@@ -3887,7 +3911,7 @@ bool GDScriptParser::rpc_annotation(const AnnotationNode *p_annotation, Node *p_
Dictionary rpc_config;
rpc_config["rpc_mode"] = MultiplayerAPI::RPC_MODE_AUTHORITY;
- if (p_annotation->resolved_arguments.size()) {
+ if (!p_annotation->resolved_arguments.is_empty()) {
int last = p_annotation->resolved_arguments.size() - 1;
if (p_annotation->resolved_arguments[last].get_type() == Variant::INT) {
rpc_config["channel"] = p_annotation->resolved_arguments[last].operator int();
@@ -3897,26 +3921,46 @@ bool GDScriptParser::rpc_annotation(const AnnotationNode *p_annotation, Node *p_
push_error(R"(Invalid RPC arguments. At most 4 arguments are allowed, where only the last argument can be an integer to specify the channel.')", p_annotation);
return false;
}
+
+ unsigned char locality_args = 0;
+ unsigned char permission_args = 0;
+ unsigned char transfer_mode_args = 0;
+
for (int i = last; i >= 0; i--) {
- String mode = p_annotation->resolved_arguments[i].operator String();
- if (mode == "any_peer") {
- rpc_config["rpc_mode"] = MultiplayerAPI::RPC_MODE_ANY_PEER;
- } else if (mode == "authority") {
- rpc_config["rpc_mode"] = MultiplayerAPI::RPC_MODE_AUTHORITY;
- } else if (mode == "call_local") {
+ String arg = p_annotation->resolved_arguments[i].operator String();
+ if (arg == "call_local") {
+ locality_args++;
rpc_config["call_local"] = true;
- } else if (mode == "call_remote") {
+ } else if (arg == "call_remote") {
+ locality_args++;
rpc_config["call_local"] = false;
- } else if (mode == "reliable") {
+ } else if (arg == "any_peer") {
+ permission_args++;
+ rpc_config["rpc_mode"] = MultiplayerAPI::RPC_MODE_ANY_PEER;
+ } else if (arg == "authority") {
+ permission_args++;
+ rpc_config["rpc_mode"] = MultiplayerAPI::RPC_MODE_AUTHORITY;
+ } else if (arg == "reliable") {
+ transfer_mode_args++;
rpc_config["transfer_mode"] = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
- } else if (mode == "unreliable") {
+ } else if (arg == "unreliable") {
+ transfer_mode_args++;
rpc_config["transfer_mode"] = MultiplayerPeer::TRANSFER_MODE_UNRELIABLE;
- } else if (mode == "unreliable_ordered") {
+ } else if (arg == "unreliable_ordered") {
+ transfer_mode_args++;
rpc_config["transfer_mode"] = MultiplayerPeer::TRANSFER_MODE_UNRELIABLE_ORDERED;
} else {
- push_error(R"(Invalid RPC argument. Must be one of: 'call_local'/'call_remote' (local calls), 'any_peer'/'authority' (permission), 'reliable'/'unreliable'/'unreliable_ordered' (transfer mode).)", p_annotation);
+ push_error(R"(Invalid RPC argument. Must be one of: "call_local"/"call_remote" (local calls), "any_peer"/"authority" (permission), "reliable"/"unreliable"/"unreliable_ordered" (transfer mode).)", p_annotation);
}
}
+
+ if (locality_args > 1) {
+ push_error(R"(Invalid RPC config. The locality ("call_local"/"call_remote") must be specified no more than once.)", p_annotation);
+ } else if (permission_args > 1) {
+ push_error(R"(Invalid RPC config. The permission ("any_peer"/"authority") must be specified no more than once.)", p_annotation);
+ } else if (transfer_mode_args > 1) {
+ push_error(R"(Invalid RPC config. The transfer mode ("reliable"/"unreliable"/"unreliable_ordered") must be specified no more than once.)", p_annotation);
+ }
}
function->rpc_config = rpc_config;
return true;
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 07dac25ec5..0ba0d5b6da 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -122,6 +122,7 @@ public:
TypeSource type_source = UNDETECTED;
bool is_constant = false;
+ bool is_read_only = false;
bool is_meta_type = false;
bool is_coroutine = false; // For function calls.
@@ -206,6 +207,7 @@ public:
void operator=(const DataType &p_other) {
kind = p_other.kind;
type_source = p_other.type_source;
+ is_read_only = p_other.is_read_only;
is_constant = p_other.is_constant;
is_meta_type = p_other.is_meta_type;
is_coroutine = p_other.is_coroutine;
@@ -297,7 +299,9 @@ public:
int leftmost_column = 0, rightmost_column = 0;
Node *next = nullptr;
List<AnnotationNode *> annotations;
- Vector<uint32_t> ignored_warnings;
+#ifdef DEBUG_ENABLED
+ Vector<GDScriptWarning::Code> ignored_warnings;
+#endif
DataType datatype;
@@ -329,8 +333,10 @@ public:
AnnotationInfo *info = nullptr;
PropertyInfo export_info;
+ bool is_resolved = false;
+ bool is_applied = false;
- bool apply(GDScriptParser *p_this, Node *p_target) const;
+ bool apply(GDScriptParser *p_this, Node *p_target);
bool applies_to(uint32_t p_target_kinds) const;
AnnotationNode() {
@@ -1263,8 +1269,7 @@ private:
#ifdef DEBUG_ENABLED
bool is_ignoring_warnings = false;
List<GDScriptWarning> warnings;
- HashSet<String> ignored_warnings;
- HashSet<uint32_t> ignored_warning_codes;
+ HashSet<GDScriptWarning::Code> ignored_warnings;
HashSet<int> unsafe_lines;
#endif
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index e18a4a6190..b99f5d2685 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -811,13 +811,22 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (!valid) {
+ Object *obj = dst->get_validated_object();
String v = index->operator String();
- if (!v.is_empty()) {
- v = "'" + v + "'";
+ bool read_only_property = false;
+ if (obj) {
+ read_only_property = ClassDB::has_property(obj->get_class_name(), v) && (ClassDB::get_property_setter(obj->get_class_name(), v) == StringName());
+ }
+ if (read_only_property) {
+ err_text = vformat(R"(Cannot set value into property "%s" (on base "%s") because it is read-only.)", v, _get_var_type(dst));
} else {
- v = "of type '" + _get_var_type(index) + "'";
+ if (!v.is_empty()) {
+ v = "'" + v + "'";
+ } else {
+ v = "of type '" + _get_var_type(index) + "'";
+ }
+ err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'";
}
- err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'";
OPCODE_BREAK;
}
#endif
@@ -1003,8 +1012,16 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (!valid) {
- String err_type;
- err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'.";
+ Object *obj = dst->get_validated_object();
+ bool read_only_property = false;
+ if (obj) {
+ read_only_property = ClassDB::has_property(obj->get_class_name(), *index) && (ClassDB::get_property_setter(obj->get_class_name(), *index) == StringName());
+ }
+ if (read_only_property) {
+ err_text = vformat(R"(Cannot set value into property "%s" (on base "%s") because it is read-only.)", String(*index), _get_var_type(dst));
+ } else {
+ err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'.";
+ }
OPCODE_BREAK;
}
#endif
diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp
index 9436146bed..ef59a07f1a 100644
--- a/modules/gdscript/gdscript_warning.cpp
+++ b/modules/gdscript/gdscript_warning.cpp
@@ -170,6 +170,21 @@ String GDScriptWarning::get_message() const {
case RENAMED_IN_GD4_HINT: {
break; // Renamed identifier hint is taken care of by the GDScriptAnalyzer. No message needed here.
}
+ case INFERENCE_ON_VARIANT: {
+ CHECK_SYMBOLS(1);
+ return vformat("The %s type is being inferred from a Variant value, so it will be typed as Variant.", symbols[0]);
+ }
+ case NATIVE_METHOD_OVERRIDE: {
+ CHECK_SYMBOLS(2);
+ return vformat(R"(The method "%s" overrides a method from native class "%s". This won't be called by the engine and may not work as expected.)", symbols[0], symbols[1]);
+ }
+ case GET_NODE_DEFAULT_WITHOUT_ONREADY: {
+ CHECK_SYMBOLS(1);
+ return vformat(R"*(The default value is using "%s" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.)*", symbols[0]);
+ }
+ case ONREADY_WITH_EXPORT: {
+ return R"(The "@onready" annotation will make the default value to be set after the "@export" takes effect and will override it.)";
+ }
case WARNING_MAX:
break; // Can't happen, but silences warning
}
@@ -179,14 +194,8 @@ String GDScriptWarning::get_message() const {
}
int GDScriptWarning::get_default_value(Code p_code) {
- if (get_name_from_code(p_code).to_lower().begins_with("unsafe_")) {
- return WarnLevel::IGNORE;
- }
- // Too spammy by default on common cases (connect, Tween, etc.).
- if (p_code == RETURN_VALUE_DISCARDED) {
- return WarnLevel::IGNORE;
- }
- return WarnLevel::WARN;
+ ERR_FAIL_INDEX_V_MSG(p_code, WARNING_MAX, WarnLevel::IGNORE, "Getting default value of invalid warning code.");
+ return default_warning_levels[p_code];
}
PropertyInfo GDScriptWarning::get_property_info(Code p_code) {
@@ -240,7 +249,11 @@ String GDScriptWarning::get_name_from_code(Code p_code) {
"INT_AS_ENUM_WITHOUT_MATCH",
"STATIC_CALLED_ON_INSTANCE",
"CONFUSABLE_IDENTIFIER",
- "RENAMED_IN_GODOT_4_HINT"
+ "RENAMED_IN_GODOT_4_HINT",
+ "INFERENCE_ON_VARIANT",
+ "NATIVE_METHOD_OVERRIDE",
+ "GET_NODE_DEFAULT_WITHOUT_ONREADY",
+ "ONREADY_WITH_EXPORT",
};
static_assert((sizeof(names) / sizeof(*names)) == WARNING_MAX, "Amount of warning types don't match the amount of warning names.");
diff --git a/modules/gdscript/gdscript_warning.h b/modules/gdscript/gdscript_warning.h
index fa2907cdae..f0123c518c 100644
--- a/modules/gdscript/gdscript_warning.h
+++ b/modules/gdscript/gdscript_warning.h
@@ -82,9 +82,58 @@ public:
STATIC_CALLED_ON_INSTANCE, // A static method was called on an instance of a class instead of on the class itself.
CONFUSABLE_IDENTIFIER, // The identifier contains misleading characters that can be confused. E.g. "usеr" (has Cyrillic "е" instead of Latin "e").
RENAMED_IN_GD4_HINT, // A variable or function that could not be found has been renamed in Godot 4
+ INFERENCE_ON_VARIANT, // The declaration uses type inference but the value is typed as Variant.
+ NATIVE_METHOD_OVERRIDE, // The script method overrides a native one, this may not work as intended.
+ GET_NODE_DEFAULT_WITHOUT_ONREADY, // A class variable uses `get_node()` (or the `$` notation) as its default value, but does not use the @onready annotation.
+ ONREADY_WITH_EXPORT, // The `@onready` annotation will set the value after `@export` which is likely not intended.
WARNING_MAX,
};
+ constexpr static WarnLevel default_warning_levels[] = {
+ WARN, // UNASSIGNED_VARIABLE
+ WARN, // UNASSIGNED_VARIABLE_OP_ASSIGN
+ WARN, // UNUSED_VARIABLE
+ WARN, // UNUSED_LOCAL_CONSTANT
+ WARN, // SHADOWED_VARIABLE
+ WARN, // SHADOWED_VARIABLE_BASE_CLASS
+ WARN, // UNUSED_PRIVATE_CLASS_VARIABLE
+ WARN, // UNUSED_PARAMETER
+ WARN, // UNREACHABLE_CODE
+ WARN, // UNREACHABLE_PATTERN
+ WARN, // STANDALONE_EXPRESSION
+ WARN, // NARROWING_CONVERSION
+ WARN, // INCOMPATIBLE_TERNARY
+ WARN, // UNUSED_SIGNAL
+ IGNORE, // RETURN_VALUE_DISCARDED // Too spammy by default on common cases (connect, Tween, etc.).
+ WARN, // PROPERTY_USED_AS_FUNCTION
+ WARN, // CONSTANT_USED_AS_FUNCTION
+ WARN, // FUNCTION_USED_AS_PROPERTY
+ WARN, // INTEGER_DIVISION
+ IGNORE, // UNSAFE_PROPERTY_ACCESS // Too common in untyped scenarios.
+ IGNORE, // UNSAFE_METHOD_ACCESS // Too common in untyped scenarios.
+ IGNORE, // UNSAFE_CAST // Too common in untyped scenarios.
+ IGNORE, // UNSAFE_CALL_ARGUMENT // Too common in untyped scenarios.
+ WARN, // UNSAFE_VOID_RETURN
+ WARN, // DEPRECATED_KEYWORD
+ WARN, // STANDALONE_TERNARY
+ WARN, // ASSERT_ALWAYS_TRUE
+ WARN, // ASSERT_ALWAYS_FALSE
+ WARN, // REDUNDANT_AWAIT
+ WARN, // EMPTY_FILE
+ WARN, // SHADOWED_GLOBAL_IDENTIFIER
+ WARN, // INT_AS_ENUM_WITHOUT_CAST
+ WARN, // INT_AS_ENUM_WITHOUT_MATCH
+ WARN, // STATIC_CALLED_ON_INSTANCE
+ WARN, // CONFUSABLE_IDENTIFIER
+ WARN, // RENAMED_IN_GD4_HINT
+ ERROR, // INFERENCE_ON_VARIANT // Most likely done by accident, usually inference is trying for a particular type.
+ ERROR, // NATIVE_METHOD_OVERRIDE // May not work as expected.
+ ERROR, // GET_NODE_DEFAULT_WITHOUT_ONREADY // May not work as expected.
+ ERROR, // ONREADY_WITH_EXPORT // May not work as expected.
+ };
+
+ static_assert((sizeof(default_warning_levels) / sizeof(default_warning_levels[0])) == WARNING_MAX, "Amount of default levels does not match the amount of warnings.");
+
Code code = WARNING_MAX;
int start_line = -1, end_line = -1;
int leftmost_column = -1, rightmost_column = -1;
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index 5b8af0ff34..57405aa1ce 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -146,11 +146,11 @@ GDScriptTestRunner::GDScriptTestRunner(const String &p_source_dir, bool p_init_l
init_language(p_source_dir);
}
#ifdef DEBUG_ENABLED
- // Enable all warnings for GDScript, so we can test them.
+ // Set all warning levels to "Warn" in order to test them properly, even the ones that default to error.
ProjectSettings::get_singleton()->set_setting("debug/gdscript/warnings/enable", true);
for (int i = 0; i < (int)GDScriptWarning::WARNING_MAX; i++) {
- String warning = GDScriptWarning::get_name_from_code((GDScriptWarning::Code)i).to_lower();
- ProjectSettings::get_singleton()->set_setting("debug/gdscript/warnings/" + warning, true);
+ String warning_setting = GDScriptWarning::get_settings_path_from_code((GDScriptWarning::Code)i);
+ ProjectSettings::get_singleton()->set_setting(warning_setting, (int)GDScriptWarning::WARN);
}
#endif
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd
new file mode 100644
index 0000000000..2b1c4c9594
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd
@@ -0,0 +1,4 @@
+func test():
+ var tree := SceneTree.new()
+ tree.root = Window.new()
+ tree.free()
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out
new file mode 100644
index 0000000000..b236d70ec8
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot assign a new value to a read-only property.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd
new file mode 100644
index 0000000000..c97ee0ea69
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd
@@ -0,0 +1,4 @@
+func test():
+ var state := PhysicsDirectBodyState3DExtension.new()
+ state.center_of_mass.x += 1.0
+ state.free()
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out
new file mode 100644
index 0000000000..b236d70ec8
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot assign a new value to a read-only property.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd
new file mode 100644
index 0000000000..c787d9e50e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd
@@ -0,0 +1,4 @@
+signal my_signal()
+
+func test():
+ var _a := await my_signal
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out
new file mode 100644
index 0000000000..8f8744ad7e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot infer the type of "_a" variable because the value doesn't have a set type.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out
index c70a1df10d..508e46742f 100644
--- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
-The function signature doesn't match the parent. Parent signature is "my_function(int = default) -> int".
+The function signature doesn't match the parent. Parent signature is "my_function(int = <default>) -> int".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd
new file mode 100644
index 0000000000..91f5071fa9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd
@@ -0,0 +1,5 @@
+extends RefCounted
+
+func test():
+ var nope := $Node
+ print("Cannot use $ without a Node base")
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out
new file mode 100644
index 0000000000..33365908bf
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot use shorthand "get_node()" notation ("$") on a class that isn't a node.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.gd b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.gd
new file mode 100644
index 0000000000..e781315266
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.gd
@@ -0,0 +1,6 @@
+extends RefCounted
+
+@onready var nope := 0
+
+func test():
+ print("Cannot use @onready without a Node base")
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.out b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.out
new file mode 100644
index 0000000000..8088d28329
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+"@onready" can only be used in classes that inherit "Node".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd
new file mode 100644
index 0000000000..1639bbbd52
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd
@@ -0,0 +1,7 @@
+extends Node
+
+class Inner extends RefCounted:
+ @onready var nope = 0
+
+func test():
+ print("Cannot use @onready without a Node base")
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out
new file mode 100644
index 0000000000..8088d28329
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+"@onready" can only be used in classes that inherit "Node".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd
new file mode 100644
index 0000000000..fac0e8756c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.gd
@@ -0,0 +1,6 @@
+func test():
+ var left_hard_int := 1
+ var right_weak_int = 2
+ var result_hm_int := left_hard_int if true else right_weak_int
+
+ print('not ok')
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out
new file mode 100644
index 0000000000..71d1e2f8ae
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/ternary_weak_infer.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot infer the type of "result_hm_int" variable because the value doesn't have a set type.
diff --git a/modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.gd b/modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.gd
new file mode 100644
index 0000000000..a9004a346b
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.gd
@@ -0,0 +1,18 @@
+extends Node
+
+@onready var shorthand = $Node
+@onready var call = get_node(^"Node")
+@onready var shorthand_with_cast = $Node as Node
+@onready var call_with_cast = get_node(^"Node") as Node
+
+func _init():
+ var node := Node.new()
+ node.name = "Node"
+ add_child(node)
+
+func test():
+ # Those are expected to be `null` since `_ready()` is never called on tests.
+ prints("shorthand", shorthand)
+ prints("call", call)
+ prints("shorthand_with_cast", shorthand_with_cast)
+ prints("call_with_cast", call_with_cast)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.out b/modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.out
new file mode 100644
index 0000000000..eddc2deec0
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+shorthand <null>
+call <null>
+shorthand_with_cast <null>
+call_with_cast <null>
diff --git a/modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.gd b/modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.gd
new file mode 100644
index 0000000000..02120db868
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.gd
@@ -0,0 +1,13 @@
+# https://github.com/godotengine/godot/issues/72501
+extends Node
+
+func test():
+ prints("before", process_mode)
+ process_mode = PROCESS_MODE_PAUSABLE
+ prints("after", process_mode)
+
+ var node := Node.new()
+ add_child(node)
+ prints("before", node.process_mode)
+ node.process_mode = PROCESS_MODE_PAUSABLE
+ prints("after", node.process_mode)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.out b/modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.out
new file mode 100644
index 0000000000..1eb045a4e4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+before 0
+after 1
+before 0
+after 1
diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd
new file mode 100644
index 0000000000..9d8cfc7f99
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd
@@ -0,0 +1,15 @@
+func coroutine() -> int:
+ @warning_ignore("redundant_await")
+ await 0
+ return 1
+
+func not_coroutine() -> int:
+ return 2
+
+func test():
+ var a := await coroutine()
+ @warning_ignore("redundant_await")
+ var b := await not_coroutine()
+ @warning_ignore("redundant_await")
+ var c := await 3
+ prints(a, b, c)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out
new file mode 100644
index 0000000000..2920e2ce9c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+1 2 3
diff --git a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
index 48a804ff54..b447180ea8 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
@@ -2,16 +2,18 @@ func variant() -> Variant: return null
var member_weak = variant()
var member_typed: Variant = variant()
+@warning_ignore("inference_on_variant")
var member_inferred := variant()
func param_weak(param = variant()) -> void: print(param)
func param_typed(param: Variant = variant()) -> void: print(param)
+@warning_ignore("inference_on_variant")
func param_inferred(param := variant()) -> void: print(param)
func return_untyped(): return variant()
func return_typed() -> Variant: return variant()
-@warning_ignore("unused_variable")
+@warning_ignore("unused_variable", "inference_on_variant")
func test() -> void:
var weak = variant()
var typed: Variant = variant()
diff --git a/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd
new file mode 100644
index 0000000000..1ac03c2181
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd
@@ -0,0 +1,7 @@
+extends RefCounted
+
+func test():
+ print("ok")
+
+class Inner extends Node:
+ @onready var okay = 0
diff --git a/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out
new file mode 100644
index 0000000000..1b47ed10dc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+ok
diff --git a/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd
new file mode 100644
index 0000000000..44ca5f4dd0
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.gd
@@ -0,0 +1,15 @@
+func test():
+ var left_hard_int := 1
+ var right_hard_int := 2
+ var result_hard_int := left_hard_int if true else right_hard_int
+ assert(result_hard_int == 1)
+
+ @warning_ignore("inference_on_variant")
+ var left_hard_variant := 1 as Variant
+ @warning_ignore("inference_on_variant")
+ var right_hard_variant := 2.0 as Variant
+ @warning_ignore("inference_on_variant")
+ var result_hard_variant := left_hard_variant if true else right_hard_variant
+ assert(result_hard_variant == 1)
+
+ print('ok')
diff --git a/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out
new file mode 100644
index 0000000000..1b47ed10dc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/ternary_hard_infer.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+ok
diff --git a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd
index e1e6134fd4..092ae49d00 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd
@@ -201,4 +201,10 @@ func test():
assert(typed_enums.get_typed_builtin() == TYPE_INT)
+ var a := A.new()
+ var typed_natives: Array[RefCounted] = [a]
+ var typed_scripts = Array(typed_natives, TYPE_OBJECT, "RefCounted", A)
+ assert(typed_scripts[0] == a)
+
+
print('ok')
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
new file mode 100644
index 0000000000..849df0921e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
@@ -0,0 +1,17 @@
+extends Node
+
+var add_node = do_add_node() # Hack to have one node on init and not fail at runtime.
+
+var shorthand = $Node
+var with_self = self.get_node(^"Node")
+var without_self = get_node(^"Node")
+var with_cast = get_node(^"Node") as Node
+var shorthand_with_cast = $Node as Node
+
+func test():
+ print("warn")
+
+func do_add_node():
+ var node = Node.new()
+ node.name = "Node"
+ add_child(node)
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out
new file mode 100644
index 0000000000..62b3ae291f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out
@@ -0,0 +1,22 @@
+GDTEST_OK
+>> WARNING
+>> Line: 5
+>> GET_NODE_DEFAULT_WITHOUT_ONREADY
+>> The default value is using "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
+>> WARNING
+>> Line: 6
+>> GET_NODE_DEFAULT_WITHOUT_ONREADY
+>> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
+>> WARNING
+>> Line: 7
+>> GET_NODE_DEFAULT_WITHOUT_ONREADY
+>> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
+>> WARNING
+>> Line: 8
+>> GET_NODE_DEFAULT_WITHOUT_ONREADY
+>> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
+>> WARNING
+>> Line: 9
+>> GET_NODE_DEFAULT_WITHOUT_ONREADY
+>> The default value is using "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
+warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd b/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd
new file mode 100644
index 0000000000..024e91b7c6
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd
@@ -0,0 +1,6 @@
+func test():
+ var inferred_with_variant := return_variant()
+ print(inferred_with_variant)
+
+func return_variant() -> Variant:
+ return "warn"
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out b/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out
new file mode 100644
index 0000000000..1d4078d2f7
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out
@@ -0,0 +1,6 @@
+GDTEST_OK
+>> WARNING
+>> Line: 2
+>> INFERENCE_ON_VARIANT
+>> The variable type is being inferred from a Variant value, so it will be typed as Variant.
+warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd b/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd
new file mode 100644
index 0000000000..0b358ca5f2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd
@@ -0,0 +1,6 @@
+extends Node
+
+@onready @export var conflict = ""
+
+func test():
+ print("warn")
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out b/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out
new file mode 100644
index 0000000000..ff184f9f04
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out
@@ -0,0 +1,6 @@
+GDTEST_OK
+>> WARNING
+>> Line: 3
+>> ONREADY_WITH_EXPORT
+>> The "@onready" annotation will make the default value to be set after the "@export" takes effect and will override it.
+warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd
new file mode 100644
index 0000000000..19d40f8ec8
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd
@@ -0,0 +1,5 @@
+func test():
+ print("warn")
+
+func get(_property: StringName) -> Variant:
+ return null
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
new file mode 100644
index 0000000000..793faa05d4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
@@ -0,0 +1,6 @@
+GDTEST_OK
+>> WARNING
+>> Line: 4
+>> NATIVE_METHOD_OVERRIDE
+>> The method "get" overrides a method from native class "Object". This won't be called by the engine and may not work as expected.
+warn
diff --git a/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.gd b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.gd
new file mode 100644
index 0000000000..19c4186622
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.gd
@@ -0,0 +1,7 @@
+func test():
+ var state = PhysicsDirectBodyState3DExtension.new()
+ assign(state)
+ state.free()
+
+func assign(state):
+ state.center_of_mass.x -= 1.0
diff --git a/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.out b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.out
new file mode 100644
index 0000000000..c181c5dd02
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: assign()
+>> runtime/assign_to_read_only_property.gd
+>> 7
+>> Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only.
diff --git a/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.gd b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.gd
new file mode 100644
index 0000000000..f15f580272
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.gd
@@ -0,0 +1,8 @@
+func test():
+ var state = PhysicsDirectBodyState3DExtension.new()
+ var prop = &"center_of_mass"
+ assign(state, prop)
+ state.free()
+
+func assign(state, prop):
+ state[prop].x = 1.0
diff --git a/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.out b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.out
new file mode 100644
index 0000000000..2cdc81aacc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/assign_to_read_only_property_with_variable_index.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: assign()
+>> runtime/assign_to_read_only_property_with_variable_index.gd
+>> 8
+>> Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only.
diff --git a/modules/gltf/editor/editor_import_blend_runner.cpp b/modules/gltf/editor/editor_import_blend_runner.cpp
index c203a91834..659a60e6a1 100644
--- a/modules/gltf/editor/editor_import_blend_runner.cpp
+++ b/modules/gltf/editor/editor_import_blend_runner.cpp
@@ -181,7 +181,18 @@ Error EditorImportBlendRunner::start_blender(const String &p_python_script, bool
Error EditorImportBlendRunner::do_import(const Dictionary &p_options) {
if (is_using_rpc()) {
- return do_import_rpc(p_options);
+ Error err = do_import_rpc(p_options);
+ if (err != OK) {
+ // Retry without using RPC (slow, but better than the import failing completely).
+ if (err == ERR_CONNECTION_ERROR) {
+ // Disable RPC if the connection could not be established.
+ print_error(vformat("Failed to connect to Blender via RPC, switching to direct imports of .blend files. Check your proxy and firewall settings, then RPC can be re-enabled by changing the editor setting `filesystem/import/blender/rpc_port` to %d.", rpc_port));
+ EditorSettings::get_singleton()->set_manually("filesystem/import/blender/rpc_port", 0);
+ rpc_port = 0;
+ }
+ err = do_import_direct(p_options);
+ }
+ return err;
} else {
return do_import_direct(p_options);
}
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 1a09b5bdcc..bd3ee1881f 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -54,6 +54,9 @@
#include "modules/modules_enabled.gen.h" // For csg, gridmap.
+#ifdef TOOLS_ENABLED
+#include "editor/editor_file_system.h"
+#endif
#ifdef MODULE_CSG_ENABLED
#include "modules/csg/csg_shape.h"
#endif // MODULE_CSG_ENABLED
@@ -3232,54 +3235,38 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
p_state->source_images.push_back(Ref<Image>());
} else {
Error err = OK;
- bool must_import = false;
+ bool must_import = true;
+ Vector<uint8_t> img_data = img->get_data();
+ Dictionary generator_parameters;
String file_path = p_state->get_base_path() + "/" + p_state->filename.get_basename() + "_" + img->get_name() + ".png";
- if (!FileAccess::exists(file_path + ".import")) {
+ if (FileAccess::exists(file_path + ".import")) {
Ref<ConfigFile> config;
config.instantiate();
- config->set_value("remap", "importer", "texture");
- config->set_value("remap", "type", "Texture2D");
- // Currently, it will likely use project defaults of Detect 3D, so textures will be reimported again.
- if (!config->has_section_key("params", "mipmaps/generate")) {
- config->set_value("params", "mipmaps/generate", true);
+ config->load(file_path + ".import");
+ if (config->has_section_key("remap", "generator_parameters")) {
+ generator_parameters = (Dictionary)config->get_value("remap", "generator_parameters");
}
-
- if (ProjectSettings::get_singleton()->has_setting("importer_defaults/texture")) {
- //use defaults if exist
- Dictionary importer_defaults = GLOBAL_GET("importer_defaults/texture");
- List<Variant> importer_def_keys;
- importer_defaults.get_key_list(&importer_def_keys);
- for (const Variant &key : importer_def_keys) {
- if (!config->has_section_key("params", (String)key)) {
- config->set_value("params", (String)key, importer_defaults[key]);
- }
- }
+ if (!generator_parameters.has("md5")) {
+ must_import = false; // Didn't come form a gltf document; don't overwrite.
}
- err = config->save(file_path + ".import");
- ERR_FAIL_COND_V(err != OK, err);
- must_import = true;
- }
- Vector<uint8_t> png_buffer = img->save_png_to_buffer();
- if (ResourceLoader::exists(file_path)) {
- Ref<FileAccess> file = FileAccess::open(file_path, FileAccess::READ, &err);
- if (err == OK && file.is_valid()) {
- Vector<uint8_t> orig_png_buffer = file->get_buffer(file->get_length());
- if (png_buffer != orig_png_buffer) {
- must_import = true;
- }
+ String existing_md5 = generator_parameters["md5"];
+ unsigned char md5_hash[16];
+ CryptoCore::md5(img_data.ptr(), img_data.size(), md5_hash);
+ String new_md5 = String::hex_encode_buffer(md5_hash, 16);
+ generator_parameters["md5"] = new_md5;
+ if (new_md5 == existing_md5) {
+ must_import = false;
}
- } else {
- must_import = true;
}
if (must_import) {
- Ref<FileAccess> file = FileAccess::open(file_path, FileAccess::WRITE, &err);
+ err = img->save_png(file_path);
ERR_FAIL_COND_V(err != OK, err);
- ERR_FAIL_COND_V(file.is_null(), FAILED);
- file->store_buffer(png_buffer);
- file->flush();
- file.unref();
// ResourceLoader::import will crash if not is_editor_hint(), so this case is protected above and will fall through to uncompressed.
- ResourceLoader::import(file_path);
+ HashMap<StringName, Variant> custom_options;
+ custom_options[SNAME("mipmaps/generate")] = true;
+ // Will only use project settings defaults if custom_importer is empty.
+ EditorFileSystem::get_singleton()->update_file(file_path);
+ EditorFileSystem::get_singleton()->reimport_append(file_path, custom_options, String(), generator_parameters);
}
Ref<Texture2D> saved_image = ResourceLoader::load(file_path, "Texture2D");
if (saved_image.is_valid()) {
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs
index 813bdf1e9f..47a4516948 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs
@@ -48,7 +48,7 @@ namespace GodotPlugins.Game
}
catch (Exception e)
{
- Console.Error.WriteLine(e);
+ global::System.Console.Error.WriteLine(e);
return false.ToGodotBool();
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
index 019504ad66..70b48b0e3a 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
@@ -185,7 +185,9 @@ namespace GodotTools.Export
foreach (string file in Directory.GetFiles(publishOutputTempDir, "*", SearchOption.AllDirectories))
{
- AddSharedObject(file, tags: null, projectDataDirName);
+ AddSharedObject(file, tags: null,
+ Path.Join(projectDataDirName,
+ Path.GetRelativePath(publishOutputTempDir, Path.GetDirectoryName(file))));
}
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotPlugins/PluginLoadContext.cs b/modules/mono/glue/GodotSharp/GodotPlugins/PluginLoadContext.cs
index 344b76a202..93baf4e51c 100644
--- a/modules/mono/glue/GodotSharp/GodotPlugins/PluginLoadContext.cs
+++ b/modules/mono/glue/GodotSharp/GodotPlugins/PluginLoadContext.cs
@@ -21,6 +21,26 @@ namespace GodotPlugins
_resolver = new AssemblyDependencyResolver(pluginPath);
_sharedAssemblies = sharedAssemblies;
_mainLoadContext = mainLoadContext;
+
+ if (string.IsNullOrEmpty(AppContext.BaseDirectory))
+ {
+ // See https://github.com/dotnet/runtime/blob/v6.0.0/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs#L17-L35
+ // but Assembly.Location is unavailable, because we load assemblies from memory.
+ string? baseDirectory = Path.GetDirectoryName(pluginPath);
+ if (baseDirectory != null)
+ {
+ if (!Path.EndsInDirectorySeparator(baseDirectory))
+ baseDirectory += Path.DirectorySeparatorChar;
+ // This SetData call effectively sets AppContext.BaseDirectory
+ // See https://github.com/dotnet/runtime/blob/v6.0.0/src/libraries/System.Private.CoreLib/src/System/AppContext.cs#L21-L25
+ AppDomain.CurrentDomain.SetData("APP_CONTEXT_BASE_DIRECTORY", baseDirectory);
+ }
+ else
+ {
+ // TODO: How to log from GodotPlugins? (delegate pointer?)
+ Console.Error.WriteLine("Failed to set AppContext.BaseDirectory. Dynamic loading of libraries may fail.");
+ }
+ }
}
protected override Assembly? Load(AssemblyName assemblyName)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
index a61c5403b9..8598c32760 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Runtime.CompilerServices;
using Godot.NativeInterop;
@@ -174,7 +175,15 @@ namespace Godot.Collections
}
/// <summary>
- /// Duplicates this <see cref="Array"/>.
+ /// Returns a copy of the <see cref="Array"/>.
+ /// If <paramref name="deep"/> is <see langword="true"/>, a deep copy if performed:
+ /// all nested arrays and dictionaries are duplicated and will not be shared with
+ /// the original array. If <see langword="false"/>, a shallow copy is made and
+ /// references to the original nested arrays and dictionaries are kept, so that
+ /// modifying a sub-array or dictionary in the copy will also impact those
+ /// referenced in the source array. Note that any <see cref="GodotObject"/> derived
+ /// elements will be shallow copied regardless of the <paramref name="deep"/>
+ /// setting.
/// </summary>
/// <param name="deep">If <see langword="true"/>, performs a deep copy.</param>
/// <returns>A new Godot Array.</returns>
@@ -187,7 +196,102 @@ namespace Godot.Collections
}
/// <summary>
- /// Resizes this <see cref="Array"/> to the given size.
+ /// Assigns the given value to all elements in the array. This can typically be
+ /// used together with <see cref="Resize(int)"/> to create an array with a given
+ /// size and initialized elements.
+ /// Note: If <paramref name="value"/> is of a reference type (<see cref="GodotObject"/>
+ /// derived, <see cref="Array"/> or <see cref="Dictionary"/>, etc.) then the array
+ /// is filled with the references to the same object, i.e. no duplicates are
+ /// created.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var array = new Godot.Collections.Array();
+ /// array.Resize(10);
+ /// array.Fill(0); // Initialize the 10 elements to 0.
+ /// </code>
+ /// </example>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ /// <param name="value">The value to fill the array with.</param>
+ public void Fill(Variant value)
+ {
+ ThrowIfReadOnly();
+
+ godot_variant variantValue = (godot_variant)value.NativeVar;
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_fill(ref self, variantValue);
+ }
+
+ /// <summary>
+ /// Returns the maximum value contained in the array if all elements are of
+ /// comparable types. If the elements can't be compared, <see langword="null"/>
+ /// is returned.
+ /// </summary>
+ /// <returns>The maximum value contained in the array.</returns>
+ public Variant Max()
+ {
+ godot_variant resVariant;
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_max(ref self, out resVariant);
+ return Variant.CreateTakingOwnershipOfDisposableValue(resVariant);
+ }
+
+ /// <summary>
+ /// Returns the minimum value contained in the array if all elements are of
+ /// comparable types. If the elements can't be compared, <see langword="null"/>
+ /// is returned.
+ /// </summary>
+ /// <returns>The minimum value contained in the array.</returns>
+ public Variant Min()
+ {
+ godot_variant resVariant;
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_min(ref self, out resVariant);
+ return Variant.CreateTakingOwnershipOfDisposableValue(resVariant);
+ }
+
+ /// <summary>
+ /// Returns a random value from the target array.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var array = new Godot.Collections.Array { 1, 2, 3, 4 };
+ /// GD.Print(array.PickRandom()); // Prints either of the four numbers.
+ /// </code>
+ /// </example>
+ /// <returns>A random element from the array.</returns>
+ public Variant PickRandom()
+ {
+ godot_variant resVariant;
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_pick_random(ref self, out resVariant);
+ return Variant.CreateTakingOwnershipOfDisposableValue(resVariant);
+ }
+
+ /// <summary>
+ /// Compares this <see cref="Array"/> against the <paramref name="other"/>
+ /// <see cref="Array"/> recursively. Returns <see langword="true"/> if the
+ /// sizes and contents of the arrays are equal, <see langword="false"/>
+ /// otherwise.
+ /// </summary>
+ /// <param name="other">The other array to compare against.</param>
+ /// <returns>
+ /// <see langword="true"/> if the sizes and contents of the arrays are equal,
+ /// <see langword="false"/> otherwise.
+ /// </returns>
+ public bool RecursiveEqual(Array other)
+ {
+ var self = (godot_array)NativeValue;
+ var otherVariant = (godot_array)other.NativeValue;
+ return NativeFuncs.godotsharp_array_recursive_equal(ref self, otherVariant).ToBool();
+ }
+
+ /// <summary>
+ /// Resizes the array to contain a different number of elements. If the array
+ /// size is smaller, elements are cleared, if bigger, new elements are
+ /// <see langword="null"/>.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
@@ -203,7 +307,25 @@ namespace Godot.Collections
}
/// <summary>
- /// Shuffles the contents of this <see cref="Array"/> into a random order.
+ /// Reverses the order of the elements in the array.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ public void Reverse()
+ {
+ ThrowIfReadOnly();
+
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_reverse(ref self);
+ }
+
+ /// <summary>
+ /// Shuffles the array such that the items will have a random order.
+ /// This method uses the global random number generator common to methods
+ /// such as <see cref="GD.Randi"/>. Call <see cref="GD.Randomize"/> to
+ /// ensure that a new seed will be used each time if you want
+ /// non-reproducible shuffling.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
@@ -217,7 +339,104 @@ namespace Godot.Collections
}
/// <summary>
- /// Concatenates these two <see cref="Array"/>s.
+ /// Creates a shallow copy of a range of elements in the source <see cref="Array"/>.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="start"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="start">The zero-based index at which the range starts.</param>
+ /// <returns>A new array that contains the elements inside the slice range.</returns>
+ public Array Slice(int start)
+ {
+ if (start < 0 || start > Count)
+ throw new ArgumentOutOfRangeException(nameof(start));
+
+ return GetSliceRange(start, Count, step: 1, deep: false);
+ }
+
+ /// <summary>
+ /// Creates a shallow copy of a range of elements in the source <see cref="Array"/>.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="start"/> is less than 0 or greater than the array's size.
+ /// -or-
+ /// <paramref name="length"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="start">The zero-based index at which the range starts.</param>
+ /// <param name="length">The length of the range.</param>
+ /// <returns>A new array that contains the elements inside the slice range.</returns>
+ // The Slice method must have this signature to get implicit Range support.
+ public Array Slice(int start, int length)
+ {
+ if (start < 0 || start > Count)
+ throw new ArgumentOutOfRangeException(nameof(start));
+
+ if (length < 0 || length > Count)
+ throw new ArgumentOutOfRangeException(nameof(start));
+
+ return GetSliceRange(start, start + length, step: 1, deep: false);
+ }
+
+ /// <summary>
+ /// Returns the slice of the <see cref="Array"/>, from <paramref name="start"/>
+ /// (inclusive) to <paramref name="end"/> (exclusive), as a new <see cref="Array"/>.
+ /// The absolute value of <paramref name="start"/> and <paramref name="end"/>
+ /// will be clamped to the array size.
+ /// If either <paramref name="start"/> or <paramref name="end"/> are negative, they
+ /// will be relative to the end of the array (i.e. <c>arr.GetSliceRange(0, -2)</c>
+ /// is a shorthand for <c>arr.GetSliceRange(0, arr.Count - 2)</c>).
+ /// If specified, <paramref name="step"/> is the relative index between source
+ /// elements. It can be negative, then <paramref name="start"/> must be higher than
+ /// <paramref name="end"/>. For example, <c>[0, 1, 2, 3, 4, 5].GetSliceRange(5, 1, -2)</c>
+ /// returns <c>[5, 3]</c>.
+ /// If <paramref name="deep"/> is true, each element will be copied by value
+ /// rather than by reference.
+ /// </summary>
+ /// <param name="start">The zero-based index at which the range starts.</param>
+ /// <param name="end">The zero-based index at which the range ends.</param>
+ /// <param name="step">The relative index between source elements to take.</param>
+ /// <param name="deep">If <see langword="true"/>, performs a deep copy.</param>
+ /// <returns>A new array that contains the elements inside the slice range.</returns>
+ public Array GetSliceRange(int start, int end, int step = 1, bool deep = false)
+ {
+ godot_array newArray;
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_slice(ref self, start, end, step, deep.ToGodotBool(), out newArray);
+ return CreateTakingOwnershipOfDisposableValue(newArray);
+ }
+
+ /// <summary>
+ /// Sorts the array.
+ /// Note: The sorting algorithm used is not stable. This means that values
+ /// considered equal may have their order changed when using <see cref="Sort"/>.
+ /// Note: Strings are sorted in alphabetical order (as opposed to natural order).
+ /// This may lead to unexpected behavior when sorting an array of strings ending
+ /// with a sequence of numbers.
+ /// To sort with a custom predicate use
+ /// <see cref="Enumerable.OrderBy{TSource, TKey}(IEnumerable{TSource}, Func{TSource, TKey})"/>.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var strings = new Godot.Collections.Array { "string1", "string2", "string10", "string11" };
+ /// strings.Sort();
+ /// GD.Print(strings); // Prints [string1, string10, string11, string2]
+ /// </code>
+ /// </example>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ public void Sort()
+ {
+ ThrowIfReadOnly();
+
+ var self = (godot_array)NativeValue;
+ NativeFuncs.godotsharp_array_sort(ref self);
+ }
+
+ /// <summary>
+ /// Concatenates two <see cref="Array"/>s together, with the <paramref name="right"/>
+ /// being added to the end of the <see cref="Array"/> specified in <paramref name="left"/>.
+ /// For example, <c>[1, 2] + [3, 4]</c> results in <c>[1, 2, 3, 4]</c>.
/// </summary>
/// <param name="left">The first array.</param>
/// <param name="right">The second array.</param>
@@ -253,6 +472,9 @@ namespace Godot.Collections
/// <exception cref="InvalidOperationException">
/// The property is assigned and the array is read-only.
/// </exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <value>The <see cref="Variant"/> item at the given <paramref name="index"/>.</value>
public unsafe Variant this[int index]
{
@@ -294,14 +516,146 @@ namespace Godot.Collections
}
/// <summary>
- /// Checks if this <see cref="Array"/> contains the given item.
+ /// Adds the elements of the specified collection to the end of this <see cref="Array"/>.
/// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ /// <exception cref="ArgumentNullException">
+ /// The <paramref name="collection"/> is <see langword="null"/>.
+ /// </exception>
+ /// <param name="collection">Collection of <see cref="Variant"/> items to add.</param>
+ public void AddRange<[MustBeVariant] T>(IEnumerable<T> collection)
+ {
+ ThrowIfReadOnly();
+
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection), "Value cannot be null.");
+
+ // If the collection is another Godot Array, we can add the items
+ // with a single interop call.
+ if (collection is Array array)
+ {
+ var self = (godot_array)NativeValue;
+ var collectionNative = (godot_array)array.NativeValue;
+ _ = NativeFuncs.godotsharp_array_add_range(ref self, collectionNative);
+ return;
+ }
+ if (collection is Array<T> typedArray)
+ {
+ var self = (godot_array)NativeValue;
+ var collectionNative = (godot_array)typedArray.NativeValue;
+ _ = NativeFuncs.godotsharp_array_add_range(ref self, collectionNative);
+ return;
+ }
+
+ // If we can retrieve the count of the collection without enumerating it
+ // (e.g.: the collections is a List<T>), use it to resize the array once
+ // instead of growing it as we add items.
+ if (collection.TryGetNonEnumeratedCount(out int count))
+ {
+ Resize(Count + count);
+
+ using var enumerator = collection.GetEnumerator();
+
+ for (int i = 0; i < count; i++)
+ {
+ enumerator.MoveNext();
+ this[count + i] = Variant.From(enumerator.Current);
+ }
+
+ return;
+ }
+
+ foreach (var item in collection)
+ {
+ Add(Variant.From(item));
+ }
+ }
+
+ /// <summary>
+ /// Finds the index of an existing value using binary search.
+ /// If the value is not present in the array, it returns the bitwise
+ /// complement of the insertion index that maintains sorting order.
+ /// Note: Calling <see cref="BinarySearch(int, int, Variant)"/> on an
+ /// unsorted array results in unexpected behavior.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0.
+ /// -or-
+ /// <paramref name="count"/> is less than 0.
+ /// </exception>
+ /// <exception cref="ArgumentException">
+ /// <paramref name="index"/> and <paramref name="count"/> do not denote
+ /// a valid range in the <see cref="Array"/>.
+ /// </exception>
+ /// <param name="index">The starting index of the range to search.</param>
+ /// <param name="count">The length of the range to search.</param>
+ /// <param name="item">The object to locate.</param>
+ /// <returns>
+ /// The index of the item in the array, if <paramref name="item"/> is found;
+ /// otherwise, a negative number that is the bitwise complement of the index
+ /// of the next element that is larger than <paramref name="item"/> or, if
+ /// there is no larger element, the bitwise complement of <see cref="Count"/>.
+ /// </returns>
+ public int BinarySearch(int index, int count, Variant item)
+ {
+ if (index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index), "index cannot be negative.");
+ if (count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count), "count cannot be negative.");
+ if (Count - index < count)
+ throw new ArgumentException("length is out of bounds or count is greater than the number of elements.");
+
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = (godot_variant)item.NativeVar;
+ var self = (godot_array)NativeValue;
+ return NativeFuncs.godotsharp_array_binary_search(ref self, index, count, variantValue);
+ }
+
+ /// <summary>
+ /// Finds the index of an existing value using binary search.
+ /// If the value is not present in the array, it returns the bitwise
+ /// complement of the insertion index that maintains sorting order.
+ /// Note: Calling <see cref="BinarySearch(Variant)"/> on an unsorted
+ /// array results in unexpected behavior.
+ /// </summary>
+ /// <param name="item">The object to locate.</param>
+ /// <returns>
+ /// The index of the item in the array, if <paramref name="item"/> is found;
+ /// otherwise, a negative number that is the bitwise complement of the index
+ /// of the next element that is larger than <paramref name="item"/> or, if
+ /// there is no larger element, the bitwise complement of <see cref="Count"/>.
+ /// </returns>
+ public int BinarySearch(Variant item)
+ {
+ return BinarySearch(0, Count, item);
+ }
+
+ /// <summary>
+ /// Returns <see langword="true"/> if the array contains the given value.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var arr = new Godot.Collections.Array { "inside", 7 };
+ /// GD.Print(arr.Contains("inside")); // True
+ /// GD.Print(arr.Contains("outside")); // False
+ /// GD.Print(arr.Contains(7)); // True
+ /// GD.Print(arr.Contains("7")); // False
+ /// </code>
+ /// </example>
/// <param name="item">The <see cref="Variant"/> item to look for.</param>
/// <returns>Whether or not this array contains the given item.</returns>
public bool Contains(Variant item) => IndexOf(item) != -1;
/// <summary>
- /// Erases all items from this <see cref="Array"/>.
+ /// Clears the array. This is the equivalent to using <see cref="Resize(int)"/>
+ /// with a size of <c>0</c>
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
@@ -309,27 +663,104 @@ namespace Godot.Collections
public void Clear() => Resize(0);
/// <summary>
- /// Searches this <see cref="Array"/> for an item
- /// and returns its index or -1 if not found.
+ /// Searches the array for a value and returns its index or <c>-1</c> if not found.
/// </summary>
/// <param name="item">The <see cref="Variant"/> item to search for.</param>
/// <returns>The index of the item, or -1 if not found.</returns>
public int IndexOf(Variant item)
{
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
godot_variant variantValue = (godot_variant)item.NativeVar;
var self = (godot_array)NativeValue;
return NativeFuncs.godotsharp_array_index_of(ref self, variantValue);
}
/// <summary>
- /// Inserts a new item at a given position in the array.
- /// The position must be a valid position of an existing item,
- /// or the position at the end of the array.
+ /// Searches the array for a value and returns its index or <c>-1</c> if not found.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
+ /// <param name="index">The initial search index to start from.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
+ public int IndexOf(Variant item, int index)
+ {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException(nameof(index));
+
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = (godot_variant)item.NativeVar;
+ var self = (godot_array)NativeValue;
+ return NativeFuncs.godotsharp_array_index_of(ref self, variantValue, index);
+ }
+
+ /// <summary>
+ /// Searches the array for a value in reverse order and returns its index
+ /// or <c>-1</c> if not found.
+ /// </summary>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
+ public int LastIndexOf(Variant item)
+ {
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = (godot_variant)item.NativeVar;
+ var self = (godot_array)NativeValue;
+ return NativeFuncs.godotsharp_array_last_index_of(ref self, variantValue, Count - 1);
+ }
+
+ /// <summary>
+ /// Searches the array for a value in reverse order and returns its index
+ /// or <c>-1</c> if not found.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
+ /// <param name="index">The initial search index to start from.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
+ public int LastIndexOf(Variant item, int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException(nameof(index));
+
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = (godot_variant)item.NativeVar;
+ var self = (godot_array)NativeValue;
+ return NativeFuncs.godotsharp_array_last_index_of(ref self, variantValue, index);
+ }
+
+ /// <summary>
+ /// Inserts a new element at a given position in the array. The position
+ /// must be valid, or at the end of the array (<c>pos == Count - 1</c>).
/// Existing items will be moved to the right.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
/// </exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <param name="index">The index to insert at.</param>
/// <param name="item">The <see cref="Variant"/> item to insert.</param>
public void Insert(int index, Variant item)
@@ -367,11 +798,16 @@ namespace Godot.Collections
}
/// <summary>
- /// Removes an element from this <see cref="Array"/> by index.
+ /// Removes an element from the array by index.
+ /// To remove an element by searching for its value, use
+ /// <see cref="Remove(Variant)"/> instead.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
/// </exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <param name="index">The index of the element to remove.</param>
public void RemoveAt(int index)
{
@@ -424,6 +860,9 @@ namespace Godot.Collections
/// Copies the elements of this <see cref="Array"/> to the given
/// <see cref="Variant"/> C# array, starting at the given index.
/// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="arrayIndex"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <param name="array">The array to copy to.</param>
/// <param name="arrayIndex">The index to start at.</param>
public void CopyTo(Variant[] array, int arrayIndex)
@@ -518,6 +957,9 @@ namespace Godot.Collections
/// <summary>
/// The variant returned via the <paramref name="elem"/> parameter is owned by the Array and must not be disposed.
/// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
internal void GetVariantBorrowElementAt(int index, out godot_variant elem)
{
if (index < 0 || index >= Count)
@@ -658,6 +1100,97 @@ namespace Godot.Collections
}
/// <summary>
+ /// Assigns the given value to all elements in the array. This can typically be
+ /// used together with <see cref="Resize(int)"/> to create an array with a given
+ /// size and initialized elements.
+ /// Note: If <paramref name="value"/> is of a reference type (<see cref="GodotObject"/>
+ /// derived, <see cref="Array"/> or <see cref="Dictionary"/>, etc.) then the array
+ /// is filled with the references to the same object, i.e. no duplicates are
+ /// created.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var array = new Godot.Collections.Array&lt;int&gt;();
+ /// array.Resize(10);
+ /// array.Fill(0); // Initialize the 10 elements to 0.
+ /// </code>
+ /// </example>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ /// <param name="value">The value to fill the array with.</param>
+ public void Fill(T value)
+ {
+ ThrowIfReadOnly();
+
+ godot_variant variantValue = VariantUtils.CreateFrom(value);
+ var self = (godot_array)_underlyingArray.NativeValue;
+ NativeFuncs.godotsharp_array_fill(ref self, variantValue);
+ }
+
+ /// <summary>
+ /// Returns the maximum value contained in the array if all elements are of
+ /// comparable types. If the elements can't be compared, <see langword="default"/>
+ /// is returned.
+ /// </summary>
+ /// <returns>The maximum value contained in the array.</returns>
+ public T Max()
+ {
+ godot_variant resVariant;
+ var self = (godot_array)_underlyingArray.NativeValue;
+ NativeFuncs.godotsharp_array_max(ref self, out resVariant);
+ return VariantUtils.ConvertTo<T>(resVariant);
+ }
+
+ /// <summary>
+ /// Returns the minimum value contained in the array if all elements are of
+ /// comparable types. If the elements can't be compared, <see langword="default"/>
+ /// is returned.
+ /// </summary>
+ /// <returns>The minimum value contained in the array.</returns>
+ public T Min()
+ {
+ godot_variant resVariant;
+ var self = (godot_array)_underlyingArray.NativeValue;
+ NativeFuncs.godotsharp_array_min(ref self, out resVariant);
+ return VariantUtils.ConvertTo<T>(resVariant);
+ }
+
+ /// <summary>
+ /// Returns a random value from the target array.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var array = new Godot.Collections.Array&lt;int&gt; { 1, 2, 3, 4 };
+ /// GD.Print(array.PickRandom()); // Prints either of the four numbers.
+ /// </code>
+ /// </example>
+ /// <returns>A random element from the array.</returns>
+ public T PickRandom()
+ {
+ godot_variant resVariant;
+ var self = (godot_array)_underlyingArray.NativeValue;
+ NativeFuncs.godotsharp_array_pick_random(ref self, out resVariant);
+ return VariantUtils.ConvertTo<T>(resVariant);
+ }
+
+ /// <summary>
+ /// Compares this <see cref="Array{T}"/> against the <paramref name="other"/>
+ /// <see cref="Array{T}"/> recursively. Returns <see langword="true"/> if the
+ /// sizes and contents of the arrays are equal, <see langword="false"/>
+ /// otherwise.
+ /// </summary>
+ /// <param name="other">The other array to compare against.</param>
+ /// <returns>
+ /// <see langword="true"/> if the sizes and contents of the arrays are equal,
+ /// <see langword="false"/> otherwise.
+ /// </returns>
+ public bool RecursiveEqual(Array<T> other)
+ {
+ return _underlyingArray.RecursiveEqual(other._underlyingArray);
+ }
+
+ /// <summary>
/// Resizes this <see cref="Array{T}"/> to the given size.
/// </summary>
/// <exception cref="InvalidOperationException">
@@ -671,7 +1204,22 @@ namespace Godot.Collections
}
/// <summary>
- /// Shuffles the contents of this <see cref="Array{T}"/> into a random order.
+ /// Reverses the order of the elements in the array.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ public void Reverse()
+ {
+ _underlyingArray.Reverse();
+ }
+
+ /// <summary>
+ /// Shuffles the array such that the items will have a random order.
+ /// This method uses the global random number generator common to methods
+ /// such as <see cref="GD.Randi"/>. Call <see cref="GD.Randomize"/> to
+ /// ensure that a new seed will be used each time if you want
+ /// non-reproducible shuffling.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
@@ -682,7 +1230,89 @@ namespace Godot.Collections
}
/// <summary>
- /// Concatenates these two <see cref="Array{T}"/>s.
+ /// Creates a shallow copy of a range of elements in the source <see cref="Array{T}"/>.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="start"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="start">The zero-based index at which the range starts.</param>
+ /// <returns>A new array that contains the elements inside the slice range.</returns>
+ public Array<T> Slice(int start)
+ {
+ return GetSliceRange(start, Count, step: 1, deep: false);
+ }
+
+ /// <summary>
+ /// Creates a shallow copy of a range of elements in the source <see cref="Array{T}"/>.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="start"/> is less than 0 or greater than the array's size.
+ /// -or-
+ /// <paramref name="length"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="start">The zero-based index at which the range starts.</param>
+ /// <param name="length">The length of the range.</param>
+ /// <returns>A new array that contains the elements inside the slice range.</returns>
+ // The Slice method must have this signature to get implicit Range support.
+ public Array<T> Slice(int start, int length)
+ {
+ return GetSliceRange(start, start + length, step: 1, deep: false);
+ }
+
+ /// <summary>
+ /// Returns the slice of the <see cref="Array{T}"/>, from <paramref name="start"/>
+ /// (inclusive) to <paramref name="end"/> (exclusive), as a new <see cref="Array{T}"/>.
+ /// The absolute value of <paramref name="start"/> and <paramref name="end"/>
+ /// will be clamped to the array size.
+ /// If either <paramref name="start"/> or <paramref name="end"/> are negative, they
+ /// will be relative to the end of the array (i.e. <c>arr.GetSliceRange(0, -2)</c>
+ /// is a shorthand for <c>arr.GetSliceRange(0, arr.Count - 2)</c>).
+ /// If specified, <paramref name="step"/> is the relative index between source
+ /// elements. It can be negative, then <paramref name="start"/> must be higher than
+ /// <paramref name="end"/>. For example, <c>[0, 1, 2, 3, 4, 5].GetSliceRange(5, 1, -2)</c>
+ /// returns <c>[5, 3]</c>.
+ /// If <paramref name="deep"/> is true, each element will be copied by value
+ /// rather than by reference.
+ /// </summary>
+ /// <param name="start">The zero-based index at which the range starts.</param>
+ /// <param name="end">The zero-based index at which the range ends.</param>
+ /// <param name="step">The relative index between source elements to take.</param>
+ /// <param name="deep">If <see langword="true"/>, performs a deep copy.</param>
+ /// <returns>A new array that contains the elements inside the slice range.</returns>
+ public Array<T> GetSliceRange(int start, int end, int step = 1, bool deep = false)
+ {
+ return new Array<T>(_underlyingArray.GetSliceRange(start, end, step, deep));
+ }
+
+ /// <summary>
+ /// Sorts the array.
+ /// Note: The sorting algorithm used is not stable. This means that values
+ /// considered equal may have their order changed when using <see cref="Sort"/>.
+ /// Note: Strings are sorted in alphabetical order (as opposed to natural order).
+ /// This may lead to unexpected behavior when sorting an array of strings ending
+ /// with a sequence of numbers.
+ /// To sort with a custom predicate use
+ /// <see cref="Enumerable.OrderBy{TSource, TKey}(IEnumerable{TSource}, Func{TSource, TKey})"/>.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var strings = new Godot.Collections.Array&lt;string&gt; { "string1", "string2", "string10", "string11" };
+ /// strings.Sort();
+ /// GD.Print(strings); // Prints [string1, string10, string11, string2]
+ /// </code>
+ /// </example>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ public void Sort()
+ {
+ _underlyingArray.Sort();
+ }
+
+ /// <summary>
+ /// Concatenates two <see cref="Array{T}"/>s together, with the <paramref name="right"/>
+ /// being added to the end of the <see cref="Array{T}"/> specified in <paramref name="left"/>.
+ /// For example, <c>[1, 2] + [3, 4]</c> results in <c>[1, 2, 3, 4]</c>.
/// </summary>
/// <param name="left">The first array.</param>
/// <param name="right">The second array.</param>
@@ -706,12 +1336,15 @@ namespace Godot.Collections
// IList<T>
/// <summary>
- /// Returns the value at the given <paramref name="index"/>.
+ /// Returns the item at the given <paramref name="index"/>.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The property is assigned and the array is read-only.
/// </exception>
- /// <value>The value at the given <paramref name="index"/>.</value>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <value>The <see cref="Variant"/> item at the given <paramref name="index"/>.</value>
public unsafe T this[int index]
{
get
@@ -735,29 +1368,106 @@ namespace Godot.Collections
}
/// <summary>
- /// Searches this <see cref="Array{T}"/> for an item
- /// and returns its index or -1 if not found.
+ /// Searches the array for a value and returns its index or <c>-1</c> if not found.
/// </summary>
- /// <param name="item">The item to search for.</param>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
/// <returns>The index of the item, or -1 if not found.</returns>
public int IndexOf(T item)
{
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
using var variantValue = VariantUtils.CreateFrom(item);
var self = (godot_array)_underlyingArray.NativeValue;
return NativeFuncs.godotsharp_array_index_of(ref self, variantValue);
}
/// <summary>
- /// Inserts a new item at a given position in the <see cref="Array{T}"/>.
- /// The position must be a valid position of an existing item,
- /// or the position at the end of the array.
+ /// Searches the array for a value and returns its index or <c>-1</c> if not found.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
+ /// <param name="index">The initial search index to start from.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
+ public int IndexOf(T item, int index)
+ {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException(nameof(index));
+
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = VariantUtils.CreateFrom(item);
+ var self = (godot_array)_underlyingArray.NativeValue;
+ return NativeFuncs.godotsharp_array_index_of(ref self, variantValue, index);
+ }
+
+ /// <summary>
+ /// Searches the array for a value in reverse order and returns its index
+ /// or <c>-1</c> if not found.
+ /// </summary>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
+ public int LastIndexOf(Variant item)
+ {
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = VariantUtils.CreateFrom(item);
+ var self = (godot_array)_underlyingArray.NativeValue;
+ return NativeFuncs.godotsharp_array_last_index_of(ref self, variantValue, Count - 1);
+ }
+
+ /// <summary>
+ /// Searches the array for a value in reverse order and returns its index
+ /// or <c>-1</c> if not found.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
+ /// <param name="item">The <see cref="Variant"/> item to search for.</param>
+ /// <param name="index">The initial search index to start from.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
+ public int LastIndexOf(Variant item, int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException(nameof(index));
+
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ godot_variant variantValue = VariantUtils.CreateFrom(item);
+ var self = (godot_array)_underlyingArray.NativeValue;
+ return NativeFuncs.godotsharp_array_last_index_of(ref self, variantValue, index);
+ }
+
+ /// <summary>
+ /// Inserts a new element at a given position in the array. The position
+ /// must be valid, or at the end of the array (<c>pos == Count - 1</c>).
/// Existing items will be moved to the right.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
/// </exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <param name="index">The index to insert at.</param>
- /// <param name="item">The item to insert.</param>
+ /// <param name="item">The <see cref="Variant"/> item to insert.</param>
public void Insert(int index, T item)
{
ThrowIfReadOnly();
@@ -771,11 +1481,16 @@ namespace Godot.Collections
}
/// <summary>
- /// Removes an element from this <see cref="Array{T}"/> by index.
+ /// Removes an element from the array by index.
+ /// To remove an element by searching for its value, use
+ /// <see cref="Remove(T)"/> instead.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
/// </exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <param name="index">The index of the element to remove.</param>
public void RemoveAt(int index)
{
@@ -814,8 +1529,7 @@ namespace Godot.Collections
/// <exception cref="InvalidOperationException">
/// The array is read-only.
/// </exception>
- /// <param name="item">The item to add.</param>
- /// <returns>The new size after adding the item.</returns>
+ /// <param name="item">The <see cref="Variant"/> item to add.</param>
public void Add(T item)
{
ThrowIfReadOnly();
@@ -826,7 +1540,130 @@ namespace Godot.Collections
}
/// <summary>
- /// Erases all items from this <see cref="Array{T}"/>.
+ /// Adds the elements of the specified collection to the end of this <see cref="Array{T}"/>.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// The array is read-only.
+ /// </exception>
+ /// <exception cref="ArgumentNullException">
+ /// The <paramref name="collection"/> is <see langword="null"/>.
+ /// </exception>
+ /// <param name="collection">Collection of <see cref="Variant"/> items to add.</param>
+ public void AddRange(IEnumerable<T> collection)
+ {
+ ThrowIfReadOnly();
+
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection), "Value cannot be null.");
+
+ // If the collection is another Godot Array, we can add the items
+ // with a single interop call.
+ if (collection is Array array)
+ {
+ var self = (godot_array)_underlyingArray.NativeValue;
+ var collectionNative = (godot_array)array.NativeValue;
+ _ = NativeFuncs.godotsharp_array_add_range(ref self, collectionNative);
+ return;
+ }
+ if (collection is Array<T> typedArray)
+ {
+ var self = (godot_array)_underlyingArray.NativeValue;
+ var collectionNative = (godot_array)typedArray._underlyingArray.NativeValue;
+ _ = NativeFuncs.godotsharp_array_add_range(ref self, collectionNative);
+ return;
+ }
+
+ // If we can retrieve the count of the collection without enumerating it
+ // (e.g.: the collections is a List<T>), use it to resize the array once
+ // instead of growing it as we add items.
+ if (collection.TryGetNonEnumeratedCount(out int count))
+ {
+ Resize(Count + count);
+
+ using var enumerator = collection.GetEnumerator();
+
+ for (int i = 0; i < count; i++)
+ {
+ enumerator.MoveNext();
+ this[count + i] = enumerator.Current;
+ }
+
+ return;
+ }
+
+ foreach (var item in collection)
+ {
+ Add(item);
+ }
+ }
+
+ /// <summary>
+ /// Finds the index of an existing value using binary search.
+ /// If the value is not present in the array, it returns the bitwise
+ /// complement of the insertion index that maintains sorting order.
+ /// Note: Calling <see cref="BinarySearch(int, int, T)"/> on an unsorted
+ /// array results in unexpected behavior.
+ /// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="index"/> is less than 0.
+ /// -or-
+ /// <paramref name="count"/> is less than 0.
+ /// </exception>
+ /// <exception cref="ArgumentException">
+ /// <paramref name="index"/> and <paramref name="count"/> do not denote
+ /// a valid range in the <see cref="Array{T}"/>.
+ /// </exception>
+ /// <param name="index">The starting index of the range to search.</param>
+ /// <param name="count">The length of the range to search.</param>
+ /// <param name="item">The object to locate.</param>
+ /// <returns>
+ /// The index of the item in the array, if <paramref name="item"/> is found;
+ /// otherwise, a negative number that is the bitwise complement of the index
+ /// of the next element that is larger than <paramref name="item"/> or, if
+ /// there is no larger element, the bitwise complement of <see cref="Count"/>.
+ /// </returns>
+ public int BinarySearch(int index, int count, T item)
+ {
+ if (index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index), "index cannot be negative.");
+ if (count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count), "count cannot be negative.");
+ if (Count - index < count)
+ throw new ArgumentException("length is out of bounds or count is greater than the number of elements.");
+
+ if (Count == 0)
+ {
+ // Special case for empty array to avoid an interop call.
+ return -1;
+ }
+
+ using var variantValue = VariantUtils.CreateFrom(item);
+ var self = (godot_array)_underlyingArray.NativeValue;
+ return NativeFuncs.godotsharp_array_binary_search(ref self, index, count, variantValue);
+ }
+
+ /// <summary>
+ /// Finds the index of an existing value using binary search.
+ /// If the value is not present in the array, it returns the bitwise
+ /// complement of the insertion index that maintains sorting order.
+ /// Note: Calling <see cref="BinarySearch(T)"/> on an unsorted
+ /// array results in unexpected behavior.
+ /// </summary>
+ /// <param name="item">The object to locate.</param>
+ /// <returns>
+ /// The index of the item in the array, if <paramref name="item"/> is found;
+ /// otherwise, a negative number that is the bitwise complement of the index
+ /// of the next element that is larger than <paramref name="item"/> or, if
+ /// there is no larger element, the bitwise complement of <see cref="Count"/>.
+ /// </returns>
+ public int BinarySearch(T item)
+ {
+ return BinarySearch(0, Count, item);
+ }
+
+ /// <summary>
+ /// Clears the array. This is the equivalent to using <see cref="Resize(int)"/>
+ /// with a size of <c>0</c>
/// </summary>
/// <exception cref="InvalidOperationException">
/// The array is read-only.
@@ -837,8 +1674,17 @@ namespace Godot.Collections
}
/// <summary>
- /// Checks if this <see cref="Array{T}"/> contains the given item.
+ /// Returns <see langword="true"/> if the array contains the given value.
/// </summary>
+ /// <example>
+ /// <code>
+ /// var arr = new Godot.Collections.Array&lt;string&gt; { "inside", "7" };
+ /// GD.Print(arr.Contains("inside")); // True
+ /// GD.Print(arr.Contains("outside")); // False
+ /// GD.Print(arr.Contains(7)); // False
+ /// GD.Print(arr.Contains("7")); // True
+ /// </code>
+ /// </example>
/// <param name="item">The item to look for.</param>
/// <returns>Whether or not this array contains the given item.</returns>
public bool Contains(T item) => IndexOf(item) != -1;
@@ -847,6 +1693,9 @@ namespace Godot.Collections
/// Copies the elements of this <see cref="Array{T}"/> to the given
/// C# array, starting at the given index.
/// </summary>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="arrayIndex"/> is less than 0 or greater than the array's size.
+ /// </exception>
/// <param name="array">The C# array to copy to.</param>
/// <param name="arrayIndex">The index to start at.</param>
public void CopyTo(T[] array, int arrayIndex)
@@ -876,7 +1725,7 @@ namespace Godot.Collections
}
/// <summary>
- /// Removes the first occurrence of the specified value
+ /// Removes the first occurrence of the specified <paramref name="item"/>
/// from this <see cref="Array{T}"/>.
/// </summary>
/// <exception cref="InvalidOperationException">
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
index 1e23689c95..3d72ee0036 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
@@ -365,21 +365,44 @@ namespace Godot.NativeInterop
public static partial int godotsharp_array_add(ref godot_array p_self, in godot_variant p_item);
+ public static partial int godotsharp_array_add_range(ref godot_array p_self, in godot_array p_collection);
+
+ public static partial int godotsharp_array_binary_search(ref godot_array p_self, int p_index, int p_count, in godot_variant p_value);
+
public static partial void
godotsharp_array_duplicate(ref godot_array p_self, godot_bool p_deep, out godot_array r_dest);
- public static partial int godotsharp_array_index_of(ref godot_array p_self, in godot_variant p_item);
+ public static partial void godotsharp_array_fill(ref godot_array p_self, in godot_variant p_value);
+
+ public static partial int godotsharp_array_index_of(ref godot_array p_self, in godot_variant p_item, int p_index = 0);
public static partial void godotsharp_array_insert(ref godot_array p_self, int p_index, in godot_variant p_item);
+ public static partial int godotsharp_array_last_index_of(ref godot_array p_self, in godot_variant p_item, int p_index);
+
+ public static partial void godotsharp_array_make_read_only(ref godot_array p_self);
+
+ public static partial void godotsharp_array_max(ref godot_array p_self, out godot_variant r_value);
+
+ public static partial void godotsharp_array_min(ref godot_array p_self, out godot_variant r_value);
+
+ public static partial void godotsharp_array_pick_random(ref godot_array p_self, out godot_variant r_value);
+
+ public static partial godot_bool godotsharp_array_recursive_equal(ref godot_array p_self, in godot_array p_other);
+
public static partial void godotsharp_array_remove_at(ref godot_array p_self, int p_index);
public static partial Error godotsharp_array_resize(ref godot_array p_self, int p_new_size);
- public static partial void godotsharp_array_make_read_only(ref godot_array p_self);
+ public static partial void godotsharp_array_reverse(ref godot_array p_self);
public static partial void godotsharp_array_shuffle(ref godot_array p_self);
+ public static partial void godotsharp_array_slice(ref godot_array p_self, int p_start, int p_end,
+ int p_step, godot_bool p_deep, out godot_array r_dest);
+
+ public static partial void godotsharp_array_sort(ref godot_array p_self);
+
public static partial void godotsharp_array_to_string(ref godot_array p_self, out godot_string r_str);
// Dictionary
@@ -459,6 +482,10 @@ namespace Godot.NativeInterop
public static partial godot_bool godotsharp_node_path_is_absolute(in godot_node_path p_self);
+ public static partial godot_bool godotsharp_node_path_equals(in godot_node_path p_self, in godot_node_path p_other);
+
+ public static partial int godotsharp_node_path_hash(in godot_node_path p_self);
+
// GD, etc
internal static partial void godotsharp_bytes_to_var(in godot_packed_byte_array p_bytes,
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs
index b02bd167a1..f216fb7ea3 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs
@@ -39,7 +39,7 @@ namespace Godot
/// new NodePath("/root/MyAutoload"); // If you have an autoloaded node or scene.
/// </code>
/// </example>
- public sealed class NodePath : IDisposable
+ public sealed class NodePath : IDisposable, IEquatable<NodePath>
{
internal godot_node_path.movable NativeValue;
@@ -288,5 +288,37 @@ namespace Godot
/// </summary>
/// <returns>If the <see cref="NodePath"/> is empty.</returns>
public bool IsEmpty => NativeValue.DangerousSelfRef.IsEmpty;
+
+ public static bool operator ==(NodePath left, NodePath right)
+ {
+ if (left is null)
+ return right is null;
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(NodePath left, NodePath right)
+ {
+ return !(left == right);
+ }
+
+ public bool Equals(NodePath other)
+ {
+ if (other is null)
+ return false;
+ var self = (godot_node_path)NativeValue;
+ var otherNative = (godot_node_path)other.NativeValue;
+ return NativeFuncs.godotsharp_node_path_equals(self, otherNative).ToBool();
+ }
+
+ public override bool Equals(object obj)
+ {
+ return ReferenceEquals(this, obj) || (obj is NodePath other && Equals(other));
+ }
+
+ public override int GetHashCode()
+ {
+ var self = (godot_node_path)NativeValue;
+ return NativeFuncs.godotsharp_node_path_hash(self);
+ }
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs
index b9ee0bc278..97d28f9ee9 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs
@@ -10,7 +10,7 @@ namespace Godot
/// Comparing them is much faster than with regular strings, because only the pointers are compared,
/// not the whole strings.
/// </summary>
- public sealed class StringName : IDisposable
+ public sealed class StringName : IDisposable, IEquatable<StringName>
{
internal godot_string_name.movable NativeValue;
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
index 5283dc7ec6..d7392dbda8 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
@@ -247,19 +247,19 @@ namespace Godot
/// <returns>The orthonormalized transform.</returns>
public readonly Transform2D Orthonormalized()
{
- Transform2D on = this;
+ Transform2D ortho = this;
- Vector2 onX = on.X;
- Vector2 onY = on.Y;
+ Vector2 orthoX = ortho.X;
+ Vector2 orthoY = ortho.Y;
- onX.Normalize();
- onY = onY - (onX * onX.Dot(onY));
- onY.Normalize();
+ orthoX.Normalize();
+ orthoY = orthoY - orthoX * orthoX.Dot(orthoY);
+ orthoY.Normalize();
- on.X = onX;
- on.Y = onY;
+ ortho.X = orthoX;
+ ortho.Y = orthoY;
- return on;
+ return ortho;
}
/// <summary>
diff --git a/modules/mono/glue/runtime_interop.cpp b/modules/mono/glue/runtime_interop.cpp
index d17fe3e75f..306ac333eb 100644
--- a/modules/mono/glue/runtime_interop.cpp
+++ b/modules/mono/glue/runtime_interop.cpp
@@ -992,18 +992,78 @@ int32_t godotsharp_array_add(Array *p_self, const Variant *p_item) {
return p_self->size();
}
+int32_t godotsharp_array_add_range(Array *p_self, const Array *p_collection) {
+ p_self->append_array(*p_collection);
+ return p_self->size();
+}
+
+int32_t godotsharp_array_binary_search(const Array *p_self, int32_t p_index, int32_t p_length, const Variant *p_value) {
+ ERR_FAIL_COND_V(p_index < 0, -1);
+ ERR_FAIL_COND_V(p_length < 0, -1);
+ ERR_FAIL_COND_V(p_self->size() - p_index < p_length, -1);
+
+ const Variant &value = *p_value;
+ const Array &array = *p_self;
+
+ int lo = p_index;
+ int hi = p_index + p_length - 1;
+ while (lo <= hi) {
+ int mid = lo + ((hi - lo) >> 1);
+ const Variant &mid_item = array[mid];
+
+ if (mid_item == value) {
+ return mid;
+ }
+ if (mid_item < value) {
+ lo = mid + 1;
+ } else {
+ hi = mid - 1;
+ }
+ }
+
+ return ~lo;
+}
+
void godotsharp_array_duplicate(const Array *p_self, bool p_deep, Array *r_dest) {
memnew_placement(r_dest, Array(p_self->duplicate(p_deep)));
}
-int32_t godotsharp_array_index_of(const Array *p_self, const Variant *p_item) {
- return p_self->find(*p_item);
+void godotsharp_array_fill(Array *p_self, const Variant *p_value) {
+ p_self->fill(*p_value);
+}
+
+int32_t godotsharp_array_index_of(const Array *p_self, const Variant *p_item, int32_t p_index = 0) {
+ return p_self->find(*p_item, p_index);
}
void godotsharp_array_insert(Array *p_self, int32_t p_index, const Variant *p_item) {
p_self->insert(p_index, *p_item);
}
+int32_t godotsharp_array_last_index_of(const Array *p_self, const Variant *p_item, int32_t p_index) {
+ return p_self->rfind(*p_item, p_index);
+}
+
+void godotsharp_array_make_read_only(Array *p_self) {
+ p_self->make_read_only();
+}
+
+void godotsharp_array_max(const Array *p_self, Variant *r_value) {
+ *r_value = p_self->max();
+}
+
+void godotsharp_array_min(const Array *p_self, Variant *r_value) {
+ *r_value = p_self->min();
+}
+
+void godotsharp_array_pick_random(const Array *p_self, Variant *r_value) {
+ *r_value = p_self->pick_random();
+}
+
+bool godotsharp_array_recursive_equal(const Array *p_self, const Array *p_other) {
+ return p_self->recursive_equal(*p_other, 0);
+}
+
void godotsharp_array_remove_at(Array *p_self, int32_t p_index) {
p_self->remove_at(p_index);
}
@@ -1012,14 +1072,22 @@ int32_t godotsharp_array_resize(Array *p_self, int32_t p_new_size) {
return (int32_t)p_self->resize(p_new_size);
}
-void godotsharp_array_make_read_only(Array *p_self) {
- p_self->make_read_only();
+void godotsharp_array_reverse(Array *p_self) {
+ p_self->reverse();
}
void godotsharp_array_shuffle(Array *p_self) {
p_self->shuffle();
}
+void godotsharp_array_slice(Array *p_self, int32_t p_start, int32_t p_end, int32_t p_step, bool p_deep, Array *r_dest) {
+ memnew_placement(r_dest, Array(p_self->slice(p_start, p_end, p_step, p_deep)));
+}
+
+void godotsharp_array_sort(Array *p_self) {
+ p_self->sort();
+}
+
void godotsharp_array_to_string(const Array *p_self, String *r_str) {
*r_str = Variant(*p_self).operator String();
}
@@ -1141,6 +1209,14 @@ bool godotsharp_node_path_is_absolute(const NodePath *p_self) {
return p_self->is_absolute();
}
+bool godotsharp_node_path_equals(const NodePath *p_self, const NodePath *p_other) {
+ return *p_self == *p_other;
+}
+
+int godotsharp_node_path_hash(const NodePath *p_self) {
+ return p_self->hash();
+}
+
void godotsharp_randomize() {
Math::randomize();
}
@@ -1442,13 +1518,24 @@ static const void *unmanaged_callbacks[]{
(void *)godotsharp_array_destroy,
(void *)godotsharp_dictionary_destroy,
(void *)godotsharp_array_add,
+ (void *)godotsharp_array_add_range,
+ (void *)godotsharp_array_binary_search,
(void *)godotsharp_array_duplicate,
+ (void *)godotsharp_array_fill,
(void *)godotsharp_array_index_of,
(void *)godotsharp_array_insert,
+ (void *)godotsharp_array_last_index_of,
+ (void *)godotsharp_array_make_read_only,
+ (void *)godotsharp_array_max,
+ (void *)godotsharp_array_min,
+ (void *)godotsharp_array_pick_random,
+ (void *)godotsharp_array_recursive_equal,
(void *)godotsharp_array_remove_at,
(void *)godotsharp_array_resize,
- (void *)godotsharp_array_make_read_only,
+ (void *)godotsharp_array_reverse,
(void *)godotsharp_array_shuffle,
+ (void *)godotsharp_array_slice,
+ (void *)godotsharp_array_sort,
(void *)godotsharp_array_to_string,
(void *)godotsharp_dictionary_try_get_value,
(void *)godotsharp_dictionary_set_value,
@@ -1477,6 +1564,8 @@ static const void *unmanaged_callbacks[]{
(void *)godotsharp_node_path_get_subname,
(void *)godotsharp_node_path_get_subname_count,
(void *)godotsharp_node_path_is_absolute,
+ (void *)godotsharp_node_path_equals,
+ (void *)godotsharp_node_path_hash,
(void *)godotsharp_bytes_to_var,
(void *)godotsharp_convert,
(void *)godotsharp_hash,
diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp
index d546c5d3ba..c3cb1c5f13 100644
--- a/modules/navigation/godot_navigation_server.cpp
+++ b/modules/navigation/godot_navigation_server.cpp
@@ -262,7 +262,7 @@ TypedArray<RID> GodotNavigationServer::map_get_agents(RID p_map) const {
const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, agents_rids);
- const LocalVector<RvoAgent *> agents = map->get_agents();
+ const LocalVector<NavAgent *> agents = map->get_agents();
agents_rids.resize(agents.size());
for (uint32_t i = 0; i < agents.size(); i++) {
@@ -282,7 +282,7 @@ RID GodotNavigationServer::region_get_map(RID p_region) const {
}
RID GodotNavigationServer::agent_get_map(RID p_agent) const {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND_V(agent == nullptr, RID());
if (agent->get_map()) {
@@ -579,13 +579,13 @@ RID GodotNavigationServer::agent_create() {
MutexLock lock(operations_mutex);
RID rid = agent_owner.make_rid();
- RvoAgent *agent = agent_owner.get_or_null(rid);
+ NavAgent *agent = agent_owner.get_or_null(rid);
agent->set_self(rid);
return rid;
}
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
if (agent->get_map()) {
@@ -612,77 +612,77 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
}
COMMAND_2(agent_set_neighbor_distance, RID, p_agent, real_t, p_distance) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->neighborDist_ = p_distance;
}
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxNeighbors_ = p_count;
}
COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->timeHorizon_ = p_time;
}
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->radius_ = p_radius;
}
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxSpeed_ = p_max_speed;
}
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
}
COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->ignore_y_ = p_ignore;
}
bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND_V(agent == nullptr, false);
return agent->is_map_changed();
}
COMMAND_2(agent_set_callback, RID, p_agent, Callable, p_callback) {
- RvoAgent *agent = agent_owner.get_or_null(p_agent);
+ NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->set_callback(p_callback);
@@ -713,7 +713,7 @@ COMMAND_1(free, RID, p_object) {
}
// Remove any assigned agent
- for (RvoAgent *agent : map->get_agents()) {
+ for (NavAgent *agent : map->get_agents()) {
map->remove_agent(agent);
agent->set_map(nullptr);
}
@@ -746,7 +746,7 @@ COMMAND_1(free, RID, p_object) {
link_owner.free(p_object);
} else if (agent_owner.owns(p_object)) {
- RvoAgent *agent = agent_owner.get_or_null(p_object);
+ NavAgent *agent = agent_owner.get_or_null(p_object);
// Removes this agent from the map if assigned
if (agent->get_map() != nullptr) {
diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h
index eea5713c40..0b113b77d4 100644
--- a/modules/navigation/godot_navigation_server.h
+++ b/modules/navigation/godot_navigation_server.h
@@ -36,10 +36,10 @@
#include "core/templates/rid_owner.h"
#include "servers/navigation_server_3d.h"
+#include "nav_agent.h"
#include "nav_link.h"
#include "nav_map.h"
#include "nav_region.h"
-#include "rvo_agent.h"
/// The commands are functions executed during the `sync` phase.
@@ -71,7 +71,7 @@ class GodotNavigationServer : public NavigationServer3D {
mutable RID_Owner<NavLink> link_owner;
mutable RID_Owner<NavMap> map_owner;
mutable RID_Owner<NavRegion> region_owner;
- mutable RID_Owner<RvoAgent> agent_owner;
+ mutable RID_Owner<NavAgent> agent_owner;
bool active = true;
LocalVector<NavMap *> active_maps;
diff --git a/modules/navigation/rvo_agent.cpp b/modules/navigation/nav_agent.cpp
index 40f1e925be..293544c0a5 100644
--- a/modules/navigation/rvo_agent.cpp
+++ b/modules/navigation/nav_agent.cpp
@@ -1,5 +1,5 @@
/**************************************************************************/
-/* rvo_agent.cpp */
+/* nav_agent.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#include "rvo_agent.h"
+#include "nav_agent.h"
#include "nav_map.h"
-void RvoAgent::set_map(NavMap *p_map) {
+void NavAgent::set_map(NavMap *p_map) {
map = p_map;
}
-bool RvoAgent::is_map_changed() {
+bool NavAgent::is_map_changed() {
if (map) {
bool is_changed = map->get_map_update_id() != map_update_id;
map_update_id = map->get_map_update_id();
@@ -46,15 +46,15 @@ bool RvoAgent::is_map_changed() {
}
}
-void RvoAgent::set_callback(Callable p_callback) {
+void NavAgent::set_callback(Callable p_callback) {
callback = p_callback;
}
-bool RvoAgent::has_callback() const {
+bool NavAgent::has_callback() const {
return callback.is_valid();
}
-void RvoAgent::dispatch_callback() {
+void NavAgent::dispatch_callback() {
if (!callback.is_valid()) {
return;
}
diff --git a/modules/navigation/rvo_agent.h b/modules/navigation/nav_agent.h
index 5f377b6079..f154ce14d9 100644
--- a/modules/navigation/rvo_agent.h
+++ b/modules/navigation/nav_agent.h
@@ -1,5 +1,5 @@
/**************************************************************************/
-/* rvo_agent.h */
+/* nav_agent.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#ifndef RVO_AGENT_H
-#define RVO_AGENT_H
+#ifndef NAV_AGENT_H
+#define NAV_AGENT_H
#include "core/object/class_db.h"
#include "nav_rid.h"
@@ -38,7 +38,7 @@
class NavMap;
-class RvoAgent : public NavRid {
+class NavAgent : public NavRid {
NavMap *map = nullptr;
RVO::Agent agent;
Callable callback = Callable();
@@ -62,4 +62,4 @@ public:
void dispatch_callback();
};
-#endif // RVO_AGENT_H
+#endif // NAV_AGENT_H
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index d763b1d3bc..b1674c8fc5 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -31,9 +31,9 @@
#include "nav_map.h"
#include "core/object/worker_thread_pool.h"
+#include "nav_agent.h"
#include "nav_link.h"
#include "nav_region.h"
-#include "rvo_agent.h"
#include <algorithm>
#define THREE_POINTS_CROSS_PRODUCT(m_a, m_b, m_c) (((m_c) - (m_a)).cross((m_b) - (m_a)))
@@ -568,18 +568,18 @@ void NavMap::remove_link(NavLink *p_link) {
}
}
-bool NavMap::has_agent(RvoAgent *agent) const {
+bool NavMap::has_agent(NavAgent *agent) const {
return (agents.find(agent) != -1);
}
-void NavMap::add_agent(RvoAgent *agent) {
+void NavMap::add_agent(NavAgent *agent) {
if (!has_agent(agent)) {
agents.push_back(agent);
agents_dirty = true;
}
}
-void NavMap::remove_agent(RvoAgent *agent) {
+void NavMap::remove_agent(NavAgent *agent) {
remove_agent_as_controlled(agent);
int64_t agent_index = agents.find(agent);
if (agent_index != -1) {
@@ -588,7 +588,7 @@ void NavMap::remove_agent(RvoAgent *agent) {
}
}
-void NavMap::set_agent_as_controlled(RvoAgent *agent) {
+void NavMap::set_agent_as_controlled(NavAgent *agent) {
const bool exist = (controlled_agents.find(agent) != -1);
if (!exist) {
ERR_FAIL_COND(!has_agent(agent));
@@ -596,7 +596,7 @@ void NavMap::set_agent_as_controlled(RvoAgent *agent) {
}
}
-void NavMap::remove_agent_as_controlled(RvoAgent *agent) {
+void NavMap::remove_agent_as_controlled(NavAgent *agent) {
int64_t active_avoidance_agent_index = controlled_agents.find(agent);
if (active_avoidance_agent_index != -1) {
controlled_agents.remove_at_unordered(active_avoidance_agent_index);
@@ -895,7 +895,7 @@ void NavMap::sync() {
// cannot use LocalVector here as RVO library expects std::vector to build KdTree
std::vector<RVO::Agent *> raw_agents;
raw_agents.reserve(agents.size());
- for (RvoAgent *agent : agents) {
+ for (NavAgent *agent : agents) {
raw_agents.push_back(agent->get_agent());
}
rvo.buildAgentTree(raw_agents);
@@ -916,7 +916,7 @@ void NavMap::sync() {
pm_edge_free_count = _new_pm_edge_free_count;
}
-void NavMap::compute_single_step(uint32_t index, RvoAgent **agent) {
+void NavMap::compute_single_step(uint32_t index, NavAgent **agent) {
(*(agent + index))->get_agent()->computeNeighbors(&rvo);
(*(agent + index))->get_agent()->computeNewVelocity(deltatime);
}
@@ -930,7 +930,7 @@ void NavMap::step(real_t p_deltatime) {
}
void NavMap::dispatch_callbacks() {
- for (RvoAgent *agent : controlled_agents) {
+ for (NavAgent *agent : controlled_agents) {
agent->dispatch_callback();
}
}
diff --git a/modules/navigation/nav_map.h b/modules/navigation/nav_map.h
index fce7aff3ba..ab6a48dd70 100644
--- a/modules/navigation/nav_map.h
+++ b/modules/navigation/nav_map.h
@@ -42,7 +42,7 @@
class NavLink;
class NavRegion;
-class RvoAgent;
+class NavAgent;
class NavMap : public NavRid {
/// Map Up
@@ -78,10 +78,10 @@ class NavMap : public NavRid {
bool agents_dirty = false;
/// All the Agents (even the controlled one)
- LocalVector<RvoAgent *> agents;
+ LocalVector<NavAgent *> agents;
/// Controlled agents
- LocalVector<RvoAgent *> controlled_agents;
+ LocalVector<NavAgent *> controlled_agents;
/// Physics delta time
real_t deltatime = 0.0;
@@ -144,15 +144,15 @@ public:
return links;
}
- bool has_agent(RvoAgent *agent) const;
- void add_agent(RvoAgent *agent);
- void remove_agent(RvoAgent *agent);
- const LocalVector<RvoAgent *> &get_agents() const {
+ bool has_agent(NavAgent *agent) const;
+ void add_agent(NavAgent *agent);
+ void remove_agent(NavAgent *agent);
+ const LocalVector<NavAgent *> &get_agents() const {
return agents;
}
- void set_agent_as_controlled(RvoAgent *agent);
- void remove_agent_as_controlled(RvoAgent *agent);
+ void set_agent_as_controlled(NavAgent *agent);
+ void remove_agent_as_controlled(NavAgent *agent);
uint32_t get_map_update_id() const {
return map_update_id;
@@ -173,7 +173,7 @@ public:
int get_pm_edge_free_count() const { return pm_edge_free_count; }
private:
- void compute_single_step(uint32_t index, RvoAgent **agent);
+ void compute_single_step(uint32_t index, NavAgent **agent);
void clip_path(const LocalVector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly, Vector<int32_t> *r_path_types, TypedArray<RID> *r_path_rids, Vector<int64_t> *r_path_owners) const;
};
diff --git a/modules/openxr/SCsub b/modules/openxr/SCsub
index 3b39967ba4..0dd41675b6 100644
--- a/modules/openxr/SCsub
+++ b/modules/openxr/SCsub
@@ -103,6 +103,7 @@ env_openxr.add_source_files(module_obj, "extensions/openxr_fb_passthrough_extens
env_openxr.add_source_files(module_obj, "extensions/openxr_fb_display_refresh_rate_extension.cpp")
env_openxr.add_source_files(module_obj, "extensions/openxr_pico_controller_extension.cpp")
env_openxr.add_source_files(module_obj, "extensions/openxr_wmr_controller_extension.cpp")
+env_openxr.add_source_files(module_obj, "extensions/openxr_ml2_controller_extension.cpp")
env.modules_sources += module_obj
diff --git a/modules/openxr/extensions/openxr_ml2_controller_extension.cpp b/modules/openxr/extensions/openxr_ml2_controller_extension.cpp
new file mode 100644
index 0000000000..ae372f69b3
--- /dev/null
+++ b/modules/openxr/extensions/openxr_ml2_controller_extension.cpp
@@ -0,0 +1,71 @@
+/**************************************************************************/
+/* openxr_ml2_controller_extension.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "openxr_ml2_controller_extension.h"
+#include "../action_map/openxr_interaction_profile_meta_data.h"
+
+HashMap<String, bool *> OpenXRML2ControllerExtension::get_requested_extensions() {
+ HashMap<String, bool *> request_extensions;
+
+ request_extensions[XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME] = &available;
+
+ return request_extensions;
+}
+
+bool OpenXRML2ControllerExtension::is_available() {
+ return available;
+}
+
+void OpenXRML2ControllerExtension::on_register_metadata() {
+ OpenXRInteractionProfileMetaData *metadata = OpenXRInteractionProfileMetaData::get_singleton();
+ ERR_FAIL_NULL(metadata);
+
+ // Magic Leap 2 Controller
+ const String profile_path = "/interaction_profiles/ml/ml2_controller";
+ metadata->register_interaction_profile("Magic Leap 2 controller", "/interaction_profiles/ml/ml2_controller", XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME);
+ for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
+ metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
+ metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
+
+ metadata->register_io_path(profile_path, "Menu click", user_path, user_path + "/input/menu/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
+ metadata->register_io_path(profile_path, "Trigger", user_path, user_path + "/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
+ metadata->register_io_path(profile_path, "Trigger click", user_path, user_path + "/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
+
+ metadata->register_io_path(profile_path, "Shoulder click", user_path, user_path + "/input/shoulder/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
+
+ metadata->register_io_path(profile_path, "Trackpad click", user_path, user_path + "/input/trackpad/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
+ metadata->register_io_path(profile_path, "Trackpad force", user_path, user_path + "/input/trackpad/force", "", OpenXRAction::OPENXR_ACTION_FLOAT);
+ metadata->register_io_path(profile_path, "Trackpad X", user_path, user_path + "/input/trackpad/x", "", OpenXRAction::OPENXR_ACTION_FLOAT);
+ metadata->register_io_path(profile_path, "Trackpad Y", user_path, user_path + "/input/trackpad/y", "", OpenXRAction::OPENXR_ACTION_FLOAT);
+ metadata->register_io_path(profile_path, "Trackpad touch", user_path, user_path + "/input/trackpad/touch", "", OpenXRAction::OPENXR_ACTION_VECTOR2);
+
+ metadata->register_io_path(profile_path, "Haptic output", user_path, user_path + "/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
+ }
+}
diff --git a/modules/openxr/extensions/openxr_ml2_controller_extension.h b/modules/openxr/extensions/openxr_ml2_controller_extension.h
new file mode 100644
index 0000000000..216cd55a2f
--- /dev/null
+++ b/modules/openxr/extensions/openxr_ml2_controller_extension.h
@@ -0,0 +1,48 @@
+/**************************************************************************/
+/* openxr_ml2_controller_extension.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef OPENXR_ML2_CONTROLLER_EXTENSION_H
+#define OPENXR_ML2_CONTROLLER_EXTENSION_H
+
+#include "openxr_extension_wrapper.h"
+
+class OpenXRML2ControllerExtension : public OpenXRExtensionWrapper {
+public:
+ virtual HashMap<String, bool *> get_requested_extensions() override;
+
+ bool is_available();
+
+ virtual void on_register_metadata() override;
+
+private:
+ bool available = false;
+};
+
+#endif // OPENXR_ML2_CONTROLLER_EXTENSION_H
diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp
index 0a25cd68b7..ddb3114b59 100644
--- a/modules/openxr/openxr_api.cpp
+++ b/modules/openxr/openxr_api.cpp
@@ -483,6 +483,37 @@ bool OpenXRAPI::load_supported_view_configuration_types() {
return true;
}
+bool OpenXRAPI::load_supported_environmental_blend_modes() {
+ // This queries the supported environmental blend modes.
+
+ ERR_FAIL_COND_V(instance == XR_NULL_HANDLE, false);
+
+ if (supported_environment_blend_modes != nullptr) {
+ // free previous results
+ memfree(supported_environment_blend_modes);
+ supported_environment_blend_modes = nullptr;
+ num_supported_environment_blend_modes = 0;
+ }
+
+ XrResult result = xrEnumerateEnvironmentBlendModes(instance, system_id, view_configuration, 0, &num_supported_environment_blend_modes, nullptr);
+ if (XR_FAILED(result)) {
+ print_line("OpenXR: Failed to get supported environmental blend mode count [", get_error_string(result), "]");
+ return false;
+ }
+
+ supported_environment_blend_modes = (XrEnvironmentBlendMode *)memalloc(sizeof(XrEnvironmentBlendMode) * num_supported_environment_blend_modes);
+ ERR_FAIL_NULL_V(supported_environment_blend_modes, false);
+
+ result = xrEnumerateEnvironmentBlendModes(instance, system_id, view_configuration, num_supported_environment_blend_modes, &num_supported_environment_blend_modes, supported_environment_blend_modes);
+ ERR_FAIL_COND_V_MSG(XR_FAILED(result), false, "OpenXR: Failed to enumerate environmental blend modes");
+
+ for (uint32_t i = 0; i < num_supported_environment_blend_modes; i++) {
+ print_verbose(String("OpenXR: Found environmental blend mode ") + OpenXRUtil::get_environment_blend_mode_name(supported_environment_blend_modes[i]));
+ }
+
+ return true;
+}
+
bool OpenXRAPI::is_view_configuration_supported(XrViewConfigurationType p_configuration_type) const {
ERR_FAIL_NULL_V(supported_view_configuration_types, false);
@@ -551,6 +582,12 @@ void OpenXRAPI::destroy_instance() {
supported_view_configuration_types = nullptr;
}
+ if (supported_environment_blend_modes != nullptr) {
+ memfree(supported_environment_blend_modes);
+ supported_environment_blend_modes = nullptr;
+ num_supported_environment_blend_modes = 0;
+ }
+
if (instance != XR_NULL_HANDLE) {
for (OpenXRExtensionWrapper *wrapper : registered_extension_wrappers) {
wrapper->on_instance_destroyed();
@@ -1205,6 +1242,7 @@ bool OpenXRAPI::resolve_instance_openxr_symbols() {
OPENXR_API_INIT_XR_FUNC_V(xrDestroySwapchain);
OPENXR_API_INIT_XR_FUNC_V(xrEndFrame);
OPENXR_API_INIT_XR_FUNC_V(xrEndSession);
+ OPENXR_API_INIT_XR_FUNC_V(xrEnumerateEnvironmentBlendModes);
OPENXR_API_INIT_XR_FUNC_V(xrEnumerateReferenceSpaces);
OPENXR_API_INIT_XR_FUNC_V(xrEnumerateSwapchainFormats);
OPENXR_API_INIT_XR_FUNC_V(xrEnumerateViewConfigurations);
@@ -1312,6 +1350,11 @@ bool OpenXRAPI::initialize(const String &p_rendering_driver) {
return false;
}
+ if (!load_supported_environmental_blend_modes()) {
+ destroy_instance();
+ return false;
+ }
+
return true;
}
@@ -1822,7 +1865,7 @@ void OpenXRAPI::end_frame() {
XR_TYPE_FRAME_END_INFO, // type
nullptr, // next
frame_state.predictedDisplayTime, // displayTime
- XR_ENVIRONMENT_BLEND_MODE_OPAQUE, // environmentBlendMode
+ environment_blend_mode, // environmentBlendMode
0, // layerCount
nullptr // layers
};
@@ -1874,7 +1917,7 @@ void OpenXRAPI::end_frame() {
XR_TYPE_FRAME_END_INFO, // type
nullptr, // next
frame_state.predictedDisplayTime, // displayTime
- XR_ENVIRONMENT_BLEND_MODE_OPAQUE, // environmentBlendMode
+ environment_blend_mode, // environmentBlendMode
static_cast<uint32_t>(layers_list.size()), // layerCount
layers_list.ptr() // layers
};
@@ -2777,3 +2820,18 @@ void OpenXRAPI::register_composition_layer_provider(OpenXRCompositionLayerProvid
void OpenXRAPI::unregister_composition_layer_provider(OpenXRCompositionLayerProvider *provider) {
composition_layer_providers.erase(provider);
}
+
+const XrEnvironmentBlendMode *OpenXRAPI::get_supported_environment_blend_modes(uint32_t &count) {
+ count = num_supported_environment_blend_modes;
+ return supported_environment_blend_modes;
+}
+
+bool OpenXRAPI::set_environment_blend_mode(XrEnvironmentBlendMode mode) {
+ for (uint32_t i = 0; i < num_supported_environment_blend_modes; i++) {
+ if (supported_environment_blend_modes[i] == mode) {
+ environment_blend_mode = mode;
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h
index e1787c6da0..8c642c4ff4 100644
--- a/modules/openxr/openxr_api.h
+++ b/modules/openxr/openxr_api.h
@@ -99,9 +99,13 @@ private:
XrFormFactor form_factor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
XrViewConfigurationType view_configuration = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
XrReferenceSpaceType reference_space = XR_REFERENCE_SPACE_TYPE_STAGE;
- // XrEnvironmentBlendMode environment_blend_mode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
bool submit_depth_buffer = false; // if set to true we submit depth buffers to OpenXR if a suitable extension is enabled.
+ // blend mode
+ XrEnvironmentBlendMode environment_blend_mode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
+ uint32_t num_supported_environment_blend_modes = 0;
+ XrEnvironmentBlendMode *supported_environment_blend_modes = nullptr;
+
// state
XrInstance instance = XR_NULL_HANDLE;
XrSystemId system_id = 0;
@@ -182,6 +186,7 @@ private:
EXT_PROTO_XRRESULT_FUNC2(xrEndFrame, (XrSession), session, (const XrFrameEndInfo *), frameEndInfo)
EXT_PROTO_XRRESULT_FUNC1(xrEndSession, (XrSession), session)
EXT_PROTO_XRRESULT_FUNC3(xrEnumerateApiLayerProperties, (uint32_t), propertyCapacityInput, (uint32_t *), propertyCountOutput, (XrApiLayerProperties *), properties)
+ EXT_PROTO_XRRESULT_FUNC6(xrEnumerateEnvironmentBlendModes, (XrInstance), instance, (XrSystemId), systemId, (XrViewConfigurationType), viewConfigurationType, (uint32_t), environmentBlendModeCapacityInput, (uint32_t *), environmentBlendModeCountOutput, (XrEnvironmentBlendMode *), environmentBlendModes)
EXT_PROTO_XRRESULT_FUNC4(xrEnumerateInstanceExtensionProperties, (const char *), layerName, (uint32_t), propertyCapacityInput, (uint32_t *), propertyCountOutput, (XrExtensionProperties *), properties)
EXT_PROTO_XRRESULT_FUNC4(xrEnumerateReferenceSpaces, (XrSession), session, (uint32_t), spaceCapacityInput, (uint32_t *), spaceCountOutput, (XrReferenceSpaceType *), spaces)
EXT_PROTO_XRRESULT_FUNC4(xrEnumerateSwapchainFormats, (XrSession), session, (uint32_t), formatCapacityInput, (uint32_t *), formatCountOutput, (int64_t *), formats)
@@ -210,6 +215,7 @@ private:
bool create_instance();
bool get_system_info();
bool load_supported_view_configuration_types();
+ bool load_supported_environmental_blend_modes();
bool is_view_configuration_supported(XrViewConfigurationType p_configuration_type) const;
bool load_supported_view_configuration_views(XrViewConfigurationType p_configuration_type);
void destroy_instance();
@@ -390,6 +396,9 @@ public:
void register_composition_layer_provider(OpenXRCompositionLayerProvider *provider);
void unregister_composition_layer_provider(OpenXRCompositionLayerProvider *provider);
+ const XrEnvironmentBlendMode *get_supported_environment_blend_modes(uint32_t &count);
+ bool set_environment_blend_mode(XrEnvironmentBlendMode mode);
+
OpenXRAPI();
~OpenXRAPI();
};
diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp
index 702e56b410..51de9b913a 100644
--- a/modules/openxr/openxr_interface.cpp
+++ b/modules/openxr/openxr_interface.cpp
@@ -870,6 +870,60 @@ void OpenXRInterface::stop_passthrough() {
}
}
+Array OpenXRInterface::get_supported_environment_blend_modes() {
+ Array modes;
+
+ if (!openxr_api) {
+ return modes;
+ }
+
+ uint32_t count = 0;
+ const XrEnvironmentBlendMode *env_blend_modes = openxr_api->get_supported_environment_blend_modes(count);
+
+ if (!env_blend_modes) {
+ return modes;
+ }
+
+ for (uint32_t i = 0; i < count; i++) {
+ switch (env_blend_modes[i]) {
+ case XR_ENVIRONMENT_BLEND_MODE_OPAQUE:
+ modes.push_back(XR_ENV_BLEND_MODE_OPAQUE);
+ break;
+ case XR_ENVIRONMENT_BLEND_MODE_ADDITIVE:
+ modes.push_back(XR_ENV_BLEND_MODE_ADDITIVE);
+ break;
+ case XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND:
+ modes.push_back(XR_ENV_BLEND_MODE_ALPHA_BLEND);
+ break;
+ default:
+ WARN_PRINT("Unsupported blend mode found: " + String::num_int64(int64_t(env_blend_modes[i])));
+ }
+ }
+ return modes;
+}
+
+bool OpenXRInterface::set_environment_blend_mode(XRInterface::EnvironmentBlendMode mode) {
+ if (openxr_api) {
+ XrEnvironmentBlendMode oxr_blend_mode;
+ switch (mode) {
+ case XR_ENV_BLEND_MODE_OPAQUE:
+ oxr_blend_mode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
+ break;
+ case XR_ENV_BLEND_MODE_ADDITIVE:
+ oxr_blend_mode = XR_ENVIRONMENT_BLEND_MODE_ADDITIVE;
+ break;
+ case XR_ENV_BLEND_MODE_ALPHA_BLEND:
+ oxr_blend_mode = XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND;
+ break;
+ default:
+ WARN_PRINT("Unknown blend mode requested: " + String::num_int64(int64_t(mode)));
+ oxr_blend_mode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
+ }
+ return openxr_api->set_environment_blend_mode(oxr_blend_mode);
+ }
+ return false;
+}
+
void OpenXRInterface::on_state_ready() {
emit_signal(SNAME("session_begun"));
}
diff --git a/modules/openxr/openxr_interface.h b/modules/openxr/openxr_interface.h
index cce329d8e6..40ee95f02f 100644
--- a/modules/openxr/openxr_interface.h
+++ b/modules/openxr/openxr_interface.h
@@ -147,6 +147,10 @@ public:
virtual bool start_passthrough() override;
virtual void stop_passthrough() override;
+ /** environment blend mode. */
+ virtual Array get_supported_environment_blend_modes() override;
+ virtual bool set_environment_blend_mode(XRInterface::EnvironmentBlendMode mode) override;
+
void on_state_ready();
void on_state_visible();
void on_state_focused();
diff --git a/modules/openxr/openxr_util.cpp b/modules/openxr/openxr_util.cpp
index 50ebf468b9..926e918390 100644
--- a/modules/openxr/openxr_util.cpp
+++ b/modules/openxr/openxr_util.cpp
@@ -29,267 +29,38 @@
/**************************************************************************/
#include "openxr_util.h"
+#include <openxr/openxr_reflection.h>
-#define ENUM_TO_STRING_CASE(e) \
- case e: { \
- return String(#e); \
- } break;
+#define XR_ENUM_CASE_STR(name, val) \
+ case name: \
+ return #name;
+#define XR_ENUM_SWITCH(enumType, var) \
+ switch (var) { \
+ XR_LIST_ENUM_##enumType(XR_ENUM_CASE_STR) default : return "Unknown " #enumType ": " + String::num_int64(int64_t(var)); \
+ }
-// TODO see if we can generate this code further using the xml file with meta data supplied by OpenXR
+String OpenXRUtil::get_view_configuration_name(XrViewConfigurationType p_view_configuration){
+ XR_ENUM_SWITCH(XrViewConfigurationType, p_view_configuration)
+}
-String OpenXRUtil::get_view_configuration_name(XrViewConfigurationType p_view_configuration) {
- switch (p_view_configuration) {
- ENUM_TO_STRING_CASE(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO)
- ENUM_TO_STRING_CASE(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO)
- ENUM_TO_STRING_CASE(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_QUAD_VARJO)
- ENUM_TO_STRING_CASE(XR_VIEW_CONFIGURATION_TYPE_SECONDARY_MONO_FIRST_PERSON_OBSERVER_MSFT)
- ENUM_TO_STRING_CASE(XR_VIEW_CONFIGURATION_TYPE_MAX_ENUM)
- default: {
- return String("View Configuration ") + String::num_int64(int64_t(p_view_configuration));
- } break;
- }
+String OpenXRUtil::get_reference_space_name(XrReferenceSpaceType p_reference_space){
+ XR_ENUM_SWITCH(XrReferenceSpaceType, p_reference_space)
}
-String OpenXRUtil::get_reference_space_name(XrReferenceSpaceType p_reference_space) {
- switch (p_reference_space) {
- ENUM_TO_STRING_CASE(XR_REFERENCE_SPACE_TYPE_VIEW)
- ENUM_TO_STRING_CASE(XR_REFERENCE_SPACE_TYPE_LOCAL)
- ENUM_TO_STRING_CASE(XR_REFERENCE_SPACE_TYPE_STAGE)
- ENUM_TO_STRING_CASE(XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT)
- ENUM_TO_STRING_CASE(XR_REFERENCE_SPACE_TYPE_COMBINED_EYE_VARJO)
- ENUM_TO_STRING_CASE(XR_REFERENCE_SPACE_TYPE_MAX_ENUM)
- default: {
- return String("Reference space ") + String::num_int64(int64_t(p_reference_space));
- } break;
- }
+String OpenXRUtil::get_structure_type_name(XrStructureType p_structure_type){
+ XR_ENUM_SWITCH(XrStructureType, p_structure_type)
}
-String OpenXRUtil::get_structure_type_name(XrStructureType p_structure_type) {
- switch (p_structure_type) {
- ENUM_TO_STRING_CASE(XR_TYPE_UNKNOWN)
- ENUM_TO_STRING_CASE(XR_TYPE_API_LAYER_PROPERTIES)
- ENUM_TO_STRING_CASE(XR_TYPE_EXTENSION_PROPERTIES)
- ENUM_TO_STRING_CASE(XR_TYPE_INSTANCE_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_GET_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_PROPERTIES)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_LOCATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW)
- ENUM_TO_STRING_CASE(XR_TYPE_SESSION_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SESSION_BEGIN_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_STATE)
- ENUM_TO_STRING_CASE(XR_TYPE_FRAME_END_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_HAPTIC_VIBRATION)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_BUFFER)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_STATE_BOOLEAN)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_STATE_FLOAT)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_STATE_VECTOR2F)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_STATE_POSE)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_SET_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_INSTANCE_PROPERTIES)
- ENUM_TO_STRING_CASE(XR_TYPE_FRAME_WAIT_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_PROJECTION)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_QUAD)
- ENUM_TO_STRING_CASE(XR_TYPE_REFERENCE_SPACE_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_SPACE_CREATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_CONFIGURATION_VIEW)
- ENUM_TO_STRING_CASE(XR_TYPE_SPACE_LOCATION)
- ENUM_TO_STRING_CASE(XR_TYPE_SPACE_VELOCITY)
- ENUM_TO_STRING_CASE(XR_TYPE_FRAME_STATE)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_CONFIGURATION_PROPERTIES)
- ENUM_TO_STRING_CASE(XR_TYPE_FRAME_BEGIN_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_EVENTS_LOST)
- ENUM_TO_STRING_CASE(XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED)
- ENUM_TO_STRING_CASE(XR_TYPE_INTERACTION_PROFILE_STATE)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTION_STATE_GET_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_HAPTIC_ACTION_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_ACTIONS_SYNC_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_BOUND_SOURCES_FOR_ACTION_ENUMERATE_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_INPUT_SOURCE_LOCALIZED_NAME_GET_INFO)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_CUBE_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_DEPTH_INFO_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_VULKAN_SWAPCHAIN_FORMAT_LIST_CREATE_INFO_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_PERF_SETTINGS_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_CYLINDER_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_EQUIRECT_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_DEBUG_UTILS_LABEL_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_OPENGL_XCB_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_D3D11_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_D3D11_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_D3D12_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_D3D12_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_REQUIREMENTS_D3D12_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_EYE_GAZE_INTERACTION_PROPERTIES_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_EYE_GAZE_SAMPLE_TIME_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_VISIBILITY_MASK_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_VISIBILITY_MASK_CHANGED_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_MAIN_SESSION_VISIBILITY_CHANGED_EXTX)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_COLOR_SCALE_BIAS_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SPATIAL_ANCHOR_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SPATIAL_ANCHOR_SPACE_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_IMAGE_LAYOUT_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_ALPHA_BLEND_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_CONFIGURATION_DEPTH_RANGE_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_GRAPHICS_BINDING_EGL_MNDX)
- ENUM_TO_STRING_CASE(XR_TYPE_SPATIAL_GRAPH_NODE_SPACE_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_HAND_TRACKING_PROPERTIES_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_TRACKER_CREATE_INFO_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_JOINTS_LOCATE_INFO_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_JOINT_LOCATIONS_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_JOINT_VELOCITIES_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_HAND_TRACKING_MESH_PROPERTIES_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_MESH_SPACE_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_MESH_UPDATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_MESH_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_POSE_TYPE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SECONDARY_VIEW_CONFIGURATION_SESSION_BEGIN_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SECONDARY_VIEW_CONFIGURATION_STATE_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SECONDARY_VIEW_CONFIGURATION_FRAME_STATE_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SECONDARY_VIEW_CONFIGURATION_FRAME_END_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SECONDARY_VIEW_CONFIGURATION_LAYER_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SECONDARY_VIEW_CONFIGURATION_SWAPCHAIN_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_CONTROLLER_MODEL_KEY_STATE_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_CONTROLLER_MODEL_NODE_PROPERTIES_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_CONTROLLER_MODEL_PROPERTIES_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_CONTROLLER_MODEL_NODE_STATE_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_CONTROLLER_MODEL_STATE_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_CONFIGURATION_VIEW_FOV_EPIC)
- ENUM_TO_STRING_CASE(XR_TYPE_HOLOGRAPHIC_WINDOW_ATTACHMENT_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_REPROJECTION_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_REPROJECTION_PLANE_OVERRIDE_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_ANDROID_SURFACE_SWAPCHAIN_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_SECURE_CONTENT_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_INTERACTION_PROFILE_ANALOG_THRESHOLD_VALVE)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_JOINTS_MOTION_RANGE_INFO_EXT)
- ENUM_TO_STRING_CASE(XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_VULKAN_INSTANCE_CREATE_INFO_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_VULKAN_DEVICE_CREATE_INFO_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_VULKAN_GRAPHICS_DEVICE_GET_INFO_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_EQUIRECT2_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_OBSERVER_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_NEW_SCENE_COMPUTE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_VISUAL_MESH_COMPUTE_LOD_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_COMPONENTS_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_COMPONENTS_GET_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_COMPONENT_LOCATIONS_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_COMPONENTS_LOCATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_OBJECTS_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_COMPONENT_PARENT_FILTER_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_OBJECT_TYPES_FILTER_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_PLANES_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_PLANE_ALIGNMENT_FILTER_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_MESHES_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_MESH_BUFFERS_GET_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_MESH_BUFFERS_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_MESH_VERTEX_BUFFER_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_MESH_INDICES_UINT32_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_MESH_INDICES_UINT16_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SERIALIZED_SCENE_FRAGMENT_DATA_GET_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SCENE_DESERIALIZE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_VIVE_TRACKER_PATHS_HTCX)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_VIVE_TRACKER_CONNECTED_HTCX)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_COLOR_SPACE_PROPERTIES_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_TRACKING_MESH_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_TRACKING_SCALE_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_TRACKING_AIM_STATE_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_HAND_TRACKING_CAPSULES_STATE_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_FOVEATION_PROFILE_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_CREATE_INFO_FOVEATION_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_STATE_FOVEATION_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_FOVEATION_LEVEL_PROFILE_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_TRIANGLE_MESH_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_PASSTHROUGH_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_PASSTHROUGH_STYLE_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_PASSTHROUGH_STATE_CHANGED_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_BINDING_MODIFICATIONS_KHR)
- ENUM_TO_STRING_CASE(XR_TYPE_VIEW_LOCATE_FOVEATED_RENDERING_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_FOVEATED_VIEW_CONFIGURATION_VIEW_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_FOVEATED_RENDERING_PROPERTIES_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_MARKER_TRACKING_PROPERTIES_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_EVENT_DATA_MARKER_TRACKING_UPDATE_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_MARKER_SPACE_CREATE_INFO_VARJO)
- ENUM_TO_STRING_CASE(XR_TYPE_SPATIAL_ANCHOR_PERSISTENCE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SPATIAL_ANCHOR_FROM_PERSISTED_ANCHOR_CREATE_INFO_MSFT)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_IMAGE_FOVEATION_VULKAN_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_STATE_ANDROID_SURFACE_DIMENSIONS_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_STATE_SAMPLER_OPENGL_ES_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB)
- ENUM_TO_STRING_CASE(XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB)
- ENUM_TO_STRING_CASE(XR_STRUCTURE_TYPE_MAX_ENUM)
- default: {
- return String("Structure type ") + String::num_int64(int64_t(p_structure_type));
- } break;
- }
+String OpenXRUtil::get_session_state_name(XrSessionState p_session_state){
+ XR_ENUM_SWITCH(XrSessionState, p_session_state)
}
-String OpenXRUtil::get_session_state_name(XrSessionState p_session_state) {
- switch (p_session_state) {
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_UNKNOWN)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_IDLE)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_READY)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_SYNCHRONIZED)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_VISIBLE)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_FOCUSED)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_STOPPING)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_LOSS_PENDING)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_EXITING)
- ENUM_TO_STRING_CASE(XR_SESSION_STATE_MAX_ENUM)
- default: {
- return String("Session state ") + String::num_int64(int64_t(p_session_state));
- } break;
- }
+String OpenXRUtil::get_action_type_name(XrActionType p_action_type){
+ XR_ENUM_SWITCH(XrActionType, p_action_type)
}
-String OpenXRUtil::get_action_type_name(XrActionType p_action_type) {
- switch (p_action_type) {
- ENUM_TO_STRING_CASE(XR_ACTION_TYPE_BOOLEAN_INPUT)
- ENUM_TO_STRING_CASE(XR_ACTION_TYPE_FLOAT_INPUT)
- ENUM_TO_STRING_CASE(XR_ACTION_TYPE_VECTOR2F_INPUT)
- ENUM_TO_STRING_CASE(XR_ACTION_TYPE_POSE_INPUT)
- ENUM_TO_STRING_CASE(XR_ACTION_TYPE_VIBRATION_OUTPUT)
- ENUM_TO_STRING_CASE(XR_ACTION_TYPE_MAX_ENUM)
- default: {
- return String("Action type ") + String::num_int64(int64_t(p_action_type));
- } break;
- }
+String OpenXRUtil::get_environment_blend_mode_name(XrEnvironmentBlendMode p_blend_mode) {
+ XR_ENUM_SWITCH(XrEnvironmentBlendMode, p_blend_mode);
}
String OpenXRUtil::make_xr_version_string(XrVersion p_version) {
diff --git a/modules/openxr/openxr_util.h b/modules/openxr/openxr_util.h
index dfda537474..7e7a6a1880 100644
--- a/modules/openxr/openxr_util.h
+++ b/modules/openxr/openxr_util.h
@@ -41,6 +41,7 @@ public:
static String get_structure_type_name(XrStructureType p_structure_type);
static String get_session_state_name(XrSessionState p_session_state);
static String get_action_type_name(XrActionType p_action_type);
+ static String get_environment_blend_mode_name(XrEnvironmentBlendMode p_blend_mode);
static String make_xr_version_string(XrVersion p_version);
};
diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp
index 306a2f1bbd..c39e49387a 100644
--- a/modules/openxr/register_types.cpp
+++ b/modules/openxr/register_types.cpp
@@ -52,6 +52,7 @@
#include "extensions/openxr_htc_controller_extension.h"
#include "extensions/openxr_htc_vive_tracker_extension.h"
#include "extensions/openxr_huawei_controller_extension.h"
+#include "extensions/openxr_ml2_controller_extension.h"
#include "extensions/openxr_palm_pose_extension.h"
#include "extensions/openxr_pico_controller_extension.h"
#include "extensions/openxr_wmr_controller_extension.h"
@@ -102,6 +103,7 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) {
OpenXRAPI::register_extension_wrapper(memnew(OpenXRFbPassthroughExtensionWrapper));
OpenXRAPI::register_extension_wrapper(memnew(OpenXRDisplayRefreshRateExtension));
OpenXRAPI::register_extension_wrapper(memnew(OpenXRWMRControllerExtension));
+ OpenXRAPI::register_extension_wrapper(memnew(OpenXRML2ControllerExtension));
}
if (OpenXRAPI::openxr_is_enabled()) {
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index 9b474bf2ce..b55188ce0c 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -6118,20 +6118,22 @@ int64_t TextServerAdvanced::_is_confusable(const String &p_string, const PackedS
Vector<UChar *> skeletons;
skeletons.resize(p_dict.size());
- USpoofChecker *sc = uspoof_open(&status);
- uspoof_setChecks(sc, USPOOF_CONFUSABLE, &status);
+ if (sc_conf == nullptr) {
+ sc_conf = uspoof_open(&status);
+ uspoof_setChecks(sc_conf, USPOOF_CONFUSABLE, &status);
+ }
for (int i = 0; i < p_dict.size(); i++) {
Char16String word = p_dict[i].utf16();
- int32_t len = uspoof_getSkeleton(sc, 0, word.get_data(), -1, NULL, 0, &status);
+ int32_t len = uspoof_getSkeleton(sc_conf, 0, word.get_data(), -1, NULL, 0, &status);
skeletons.write[i] = (UChar *)memalloc(++len * sizeof(UChar));
status = U_ZERO_ERROR;
- uspoof_getSkeleton(sc, 0, word.get_data(), -1, skeletons.write[i], len, &status);
+ uspoof_getSkeleton(sc_conf, 0, word.get_data(), -1, skeletons.write[i], len, &status);
}
- int32_t len = uspoof_getSkeleton(sc, 0, utf16.get_data(), -1, NULL, 0, &status);
+ int32_t len = uspoof_getSkeleton(sc_conf, 0, utf16.get_data(), -1, NULL, 0, &status);
UChar *skel = (UChar *)memalloc(++len * sizeof(UChar));
status = U_ZERO_ERROR;
- uspoof_getSkeleton(sc, 0, utf16.get_data(), -1, skel, len, &status);
+ uspoof_getSkeleton(sc_conf, 0, utf16.get_data(), -1, skel, len, &status);
for (int i = 0; i < skeletons.size(); i++) {
if (u_strcmp(skel, skeletons[i]) == 0) {
match_index = i;
@@ -6143,7 +6145,6 @@ int64_t TextServerAdvanced::_is_confusable(const String &p_string, const PackedS
for (int i = 0; i < skeletons.size(); i++) {
memfree(skeletons.write[i]);
}
- uspoof_close(sc);
ERR_FAIL_COND_V_MSG(U_FAILURE(status), -1, u_errorName(status));
@@ -6159,19 +6160,18 @@ bool TextServerAdvanced::_spoof_check(const String &p_string) const {
UErrorCode status = U_ZERO_ERROR;
Char16String utf16 = p_string.utf16();
- USet *allowed = uset_openEmpty();
- uset_addAll(allowed, uspoof_getRecommendedSet(&status));
- uset_addAll(allowed, uspoof_getInclusionSet(&status));
-
- USpoofChecker *sc = uspoof_open(&status);
- uspoof_setAllowedChars(sc, allowed, &status);
- uspoof_setRestrictionLevel(sc, USPOOF_MODERATELY_RESTRICTIVE);
-
- int32_t bitmask = uspoof_check(sc, utf16.get_data(), -1, NULL, &status);
-
- uspoof_close(sc);
- uset_close(allowed);
+ if (allowed == nullptr) {
+ allowed = uset_openEmpty();
+ uset_addAll(allowed, uspoof_getRecommendedSet(&status));
+ uset_addAll(allowed, uspoof_getInclusionSet(&status));
+ }
+ if (sc_spoof == nullptr) {
+ sc_spoof = uspoof_open(&status);
+ uspoof_setAllowedChars(sc_spoof, allowed, &status);
+ uspoof_setRestrictionLevel(sc_spoof, USPOOF_MODERATELY_RESTRICTIVE);
+ }
+ int32_t bitmask = uspoof_check(sc_spoof, utf16.get_data(), -1, NULL, &status);
ERR_FAIL_COND_V_MSG(U_FAILURE(status), false, u_errorName(status));
return (bitmask != 0);
@@ -6587,5 +6587,17 @@ TextServerAdvanced::~TextServerAdvanced() {
FT_Done_FreeType(ft_library);
}
#endif
+ if (sc_spoof != nullptr) {
+ uspoof_close(sc_spoof);
+ sc_spoof = nullptr;
+ }
+ if (sc_conf != nullptr) {
+ uspoof_close(sc_conf);
+ sc_conf = nullptr;
+ }
+ if (allowed != nullptr) {
+ uset_close(allowed);
+ allowed = nullptr;
+ }
u_cleanup();
}
diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h
index c7fe46d554..1acf5b21f0 100644
--- a/modules/text_server_adv/text_server_adv.h
+++ b/modules/text_server_adv/text_server_adv.h
@@ -159,6 +159,9 @@ class TextServerAdvanced : public TextServerExtension {
// ICU support data.
bool icu_data_loaded = false;
+ mutable USet *allowed = nullptr;
+ mutable USpoofChecker *sc_spoof = nullptr;
+ mutable USpoofChecker *sc_conf = nullptr;
// Font cache data.
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 0902be9595..fdd2fed836 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -252,6 +252,7 @@ static const char *APK_ASSETS_DIRECTORY = "res://android/build/assets";
static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/installTime/src/main/assets";
static const int DEFAULT_MIN_SDK_VERSION = 21; // Should match the value in 'platform/android/java/app/config.gradle#minSdk'
+static const int VULKAN_MIN_SDK_VERSION = 24;
static const int DEFAULT_TARGET_SDK_VERSION = 32; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
#ifndef ANDROID_ENABLED
@@ -799,6 +800,12 @@ bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const
return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1;
}
+bool EditorExportPlatformAndroid::_uses_vulkan() {
+ String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
+ bool uses_vulkan = (current_renderer == "forward_plus" || current_renderer == "mobile") && GLOBAL_GET("rendering/rendering_device/driver.android") == "vulkan";
+ return uses_vulkan;
+}
+
void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, Vector<String> &r_permissions) {
const char **aperms = android_perms;
while (*aperms) {
@@ -853,7 +860,7 @@ void EditorExportPlatformAndroid::_write_tmp_manifest(const Ref<EditorExportPres
}
}
- manifest_text += _get_xr_features_tag(p_preset);
+ manifest_text += _get_xr_features_tag(p_preset, _uses_vulkan());
manifest_text += _get_application_tag(p_preset, _has_read_write_storage_permission(perms));
manifest_text += "</manifest>\n";
String manifest_path = vformat("res://android/build/src/%s/AndroidManifest.xml", (p_debug ? "debug" : "release"));
@@ -899,10 +906,6 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
bool screen_support_large = p_preset->get("screen/support_large");
bool screen_support_xlarge = p_preset->get("screen/support_xlarge");
- int xr_mode_index = p_preset->get("xr_features/xr_mode");
- int hand_tracking_index = p_preset->get("xr_features/hand_tracking");
- int hand_tracking_frequency_index = p_preset->get("xr_features/hand_tracking_frequency");
-
bool backup_allowed = p_preset->get("user_data_backup/allow");
int app_category = p_preset->get("package/app_category");
bool retain_data_on_uninstall = p_preset->get("package/retain_data_on_uninstall");
@@ -1046,25 +1049,6 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
}
}
- // Hand tracking related configurations
- if (xr_mode_index == XR_MODE_OPENXR && hand_tracking_index > XR_HAND_TRACKING_NONE) {
- if (tname == "meta-data" && attrname == "name" && value == "xr_hand_tracking_metadata_name") {
- string_table.write[attr_value] = "com.oculus.handtracking.frequency";
- }
-
- if (tname == "meta-data" && attrname == "value" && value == "xr_hand_tracking_metadata_value") {
- string_table.write[attr_value] = (hand_tracking_frequency_index == XR_HAND_TRACKING_FREQUENCY_LOW ? "LOW" : "HIGH");
- }
-
- if (tname == "meta-data" && attrname == "name" && value == "xr_hand_tracking_version_name") {
- string_table.write[attr_value] = "com.oculus.handtracking.version";
- }
-
- if (tname == "meta-data" && attrname == "value" && value == "xr_hand_tracking_version_value") {
- string_table.write[attr_value] = "V2.0";
- }
- }
-
iofs += 20;
}
@@ -1079,21 +1063,11 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
Vector<bool> feature_required_list;
Vector<int> feature_versions;
- if (xr_mode_index == XR_MODE_OPENXR) {
- // Check for hand tracking
- if (hand_tracking_index > XR_HAND_TRACKING_NONE) {
- feature_names.push_back("oculus.software.handtracking");
- feature_required_list.push_back(hand_tracking_index == XR_HAND_TRACKING_REQUIRED);
- feature_versions.push_back(-1); // no version attribute should be added.
- }
-
- // Check for passthrough
- int passthrough_mode = p_preset->get("xr_features/passthrough");
- if (passthrough_mode > XR_PASSTHROUGH_NONE) {
- feature_names.push_back("com.oculus.feature.PASSTHROUGH");
- feature_required_list.push_back(passthrough_mode == XR_PASSTHROUGH_REQUIRED);
- feature_versions.push_back(-1);
- }
+ if (_uses_vulkan()) {
+ // Require vulkan hardware level 1 support
+ feature_names.push_back("android.hardware.vulkan.level");
+ feature_required_list.push_back(true);
+ feature_versions.push_back(1);
}
if (feature_names.size() > 0) {
@@ -1728,12 +1702,12 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "custom_build/use_custom_build"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "custom_build/export_format", PROPERTY_HINT_ENUM, "Export APK,Export AAB"), EXPORT_FORMAT_APK));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "gradle_build/use_gradle_build"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "gradle_build/export_format", PROPERTY_HINT_ENUM, "Export APK,Export AAB"), EXPORT_FORMAT_APK));
// Using String instead of int to default to an empty string (no override) with placeholder for instructions (see GH-62465).
// This implies doing validation that the string is a proper int.
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_build/min_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", DEFAULT_MIN_SDK_VERSION)), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_build/target_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", DEFAULT_TARGET_SDK_VERSION)), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/min_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", DEFAULT_MIN_SDK_VERSION)), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/target_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", DEFAULT_TARGET_SDK_VERSION)), ""));
Vector<PluginConfigAndroid> plugins_configs = get_plugins();
for (int i = 0; i < plugins_configs.size(); i++) {
@@ -2158,11 +2132,11 @@ String EditorExportPlatformAndroid::get_apksigner_path(int p_target_sdk, bool p_
bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
String err;
bool valid = false;
- const bool custom_build_enabled = p_preset->get("custom_build/use_custom_build");
+ const bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build");
// Look for export templates (first official, and if defined custom templates).
- if (!custom_build_enabled) {
+ if (!gradle_build_enabled) {
String template_err;
bool dvalid = false;
bool rvalid = false;
@@ -2269,7 +2243,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
valid = false;
}
- String target_sdk_version = p_preset->get("custom_build/target_sdk");
+ String target_sdk_version = p_preset->get("gradle_build/target_sdk");
if (!target_sdk_version.is_valid_int()) {
target_sdk_version = itos(DEFAULT_TARGET_SDK_VERSION);
}
@@ -2293,7 +2267,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
String err;
bool valid = true;
- const bool custom_build_enabled = p_preset->get("custom_build/use_custom_build");
+ const bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build");
// Validate the project configuration.
bool apk_expansion = p_preset->get("apk_expansion/enable");
@@ -2322,11 +2296,11 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
err += etc_error;
}
- // Ensure that `Use Custom Build` is enabled if a plugin is selected.
+ // Ensure that `Use Gradle Build` is enabled if a plugin is selected.
String enabled_plugins_names = PluginConfigAndroid::get_plugins_names(get_enabled_plugins(p_preset));
- if (!enabled_plugins_names.is_empty() && !custom_build_enabled) {
+ if (!enabled_plugins_names.is_empty() && !gradle_build_enabled) {
valid = false;
- err += TTR("\"Use Custom Build\" must be enabled to use the plugins.");
+ err += TTR("\"Use Gradle Build\" must be enabled to use the plugins.");
err += "\n";
}
@@ -2334,6 +2308,12 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
int xr_mode_index = p_preset->get("xr_features/xr_mode");
int hand_tracking = p_preset->get("xr_features/hand_tracking");
int passthrough_mode = p_preset->get("xr_features/passthrough");
+ if (xr_mode_index == XR_MODE_OPENXR && !gradle_build_enabled) {
+ valid = false;
+ err += TTR("OpenXR requires \"Use Gradle Build\" to be enabled");
+ err += "\n";
+ }
+
if (xr_mode_index != XR_MODE_OPENXR) {
if (hand_tracking > XR_HAND_TRACKING_NONE) {
valid = false;
@@ -2348,20 +2328,20 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
}
}
- if (int(p_preset->get("custom_build/export_format")) == EXPORT_FORMAT_AAB &&
- !custom_build_enabled) {
+ if (int(p_preset->get("gradle_build/export_format")) == EXPORT_FORMAT_AAB &&
+ !gradle_build_enabled) {
valid = false;
- err += TTR("\"Export AAB\" is only valid when \"Use Custom Build\" is enabled.");
+ err += TTR("\"Export AAB\" is only valid when \"Use Gradle Build\" is enabled.");
err += "\n";
}
// Check the min sdk version.
- String min_sdk_str = p_preset->get("custom_build/min_sdk");
+ String min_sdk_str = p_preset->get("gradle_build/min_sdk");
int min_sdk_int = DEFAULT_MIN_SDK_VERSION;
if (!min_sdk_str.is_empty()) { // Empty means no override, nothing to do.
- if (!custom_build_enabled) {
+ if (!gradle_build_enabled) {
valid = false;
- err += TTR("\"Min SDK\" can only be overridden when \"Use Custom Build\" is enabled.");
+ err += TTR("\"Min SDK\" can only be overridden when \"Use Gradle Build\" is enabled.");
err += "\n";
}
if (!min_sdk_str.is_valid_int()) {
@@ -2379,12 +2359,12 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
}
// Check the target sdk version.
- String target_sdk_str = p_preset->get("custom_build/target_sdk");
+ String target_sdk_str = p_preset->get("gradle_build/target_sdk");
int target_sdk_int = DEFAULT_TARGET_SDK_VERSION;
if (!target_sdk_str.is_empty()) { // Empty means no override, nothing to do.
- if (!custom_build_enabled) {
+ if (!gradle_build_enabled) {
valid = false;
- err += TTR("\"Target SDK\" can only be overridden when \"Use Custom Build\" is enabled.");
+ err += TTR("\"Target SDK\" can only be overridden when \"Use Gradle Build\" is enabled.");
err += "\n";
}
if (!target_sdk_str.is_valid_int()) {
@@ -2407,6 +2387,18 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
err += "\n";
}
+ String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
+ if (current_renderer == "forward_plus") {
+ // Warning only, so don't override `valid`.
+ err += vformat(TTR("The \"%s\" renderer is designed for Desktop devices, and is not suitable for Android devices."), current_renderer);
+ err += "\n";
+ }
+ if (_uses_vulkan() && min_sdk_int < VULKAN_MIN_SDK_VERSION) {
+ // Warning only, so don't override `valid`.
+ err += vformat(TTR("\"Min SDK\" should be greater or equal to %d for the \"%s\" renderer."), VULKAN_MIN_SDK_VERSION, current_renderer);
+ err += "\n";
+ }
+
r_error = err;
return valid;
}
@@ -2492,12 +2484,12 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Ref<EditorExportP
}
Error EditorExportPlatformAndroid::sign_apk(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &export_path, EditorProgress &ep) {
- int export_format = int(p_preset->get("custom_build/export_format"));
+ int export_format = int(p_preset->get("gradle_build/export_format"));
String export_label = export_format == EXPORT_FORMAT_AAB ? "AAB" : "APK";
String release_keystore = p_preset->get("keystore/release");
String release_username = p_preset->get("keystore/release_user");
String release_password = p_preset->get("keystore/release_password");
- String target_sdk_version = p_preset->get("custom_build/target_sdk");
+ String target_sdk_version = p_preset->get("gradle_build/target_sdk");
if (!target_sdk_version.is_valid_int()) {
target_sdk_version = itos(DEFAULT_TARGET_SDK_VERSION);
}
@@ -2674,7 +2666,7 @@ String EditorExportPlatformAndroid::join_abis(const Vector<EditorExportPlatformA
}
Error EditorExportPlatformAndroid::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- int export_format = int(p_preset->get("custom_build/export_format"));
+ int export_format = int(p_preset->get("gradle_build/export_format"));
bool should_sign = p_preset->get("package/signed");
return export_project_helper(p_preset, p_debug, p_path, export_format, should_sign, p_flags);
}
@@ -2687,7 +2679,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
EditorProgress ep("export", TTR("Exporting for Android"), 105, true);
- bool use_custom_build = bool(p_preset->get("custom_build/use_custom_build"));
+ bool use_gradle_build = bool(p_preset->get("gradle_build/use_gradle_build"));
bool p_give_internet = p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG);
bool apk_expansion = p_preset->get("apk_expansion/enable");
Vector<ABI> enabled_abis = get_enabled_abis(p_preset);
@@ -2697,7 +2689,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
print_verbose("- export path: " + p_path);
print_verbose("- export format: " + itos(export_format));
print_verbose("- sign build: " + bool_to_string(should_sign));
- print_verbose("- custom build enabled: " + bool_to_string(use_custom_build));
+ print_verbose("- gradle build enabled: " + bool_to_string(use_gradle_build));
print_verbose("- apk expansion enabled: " + bool_to_string(apk_expansion));
print_verbose("- enabled abis: " + join_abis(enabled_abis, ",", false));
print_verbose("- export filter: " + itos(p_preset->get_export_filter()));
@@ -2737,14 +2729,14 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
return ERR_UNCONFIGURED;
}
- if (use_custom_build) {
- print_verbose("Starting custom build...");
+ if (use_gradle_build) {
+ print_verbose("Starting gradle build...");
//test that installed build version is alright
{
print_verbose("Checking build version...");
Ref<FileAccess> f = FileAccess::open("res://android/.build_version", FileAccess::READ);
if (f.is_null()) {
- add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Trying to build from a custom built template, but no version info for it exists. Please reinstall from the 'Project' menu."));
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Trying to build from a gradle built template, but no version info for it exists. Please reinstall from the 'Project' menu."));
return ERR_UNCONFIGURED;
}
String version = f->get_line().strip_edges();
@@ -2814,11 +2806,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
String package_name = get_package_name(p_preset->get("package/unique_name"));
String version_code = itos(p_preset->get("version/code"));
String version_name = p_preset->get("version/name");
- String min_sdk_version = p_preset->get("custom_build/min_sdk");
+ String min_sdk_version = p_preset->get("gradle_build/min_sdk");
if (!min_sdk_version.is_valid_int()) {
min_sdk_version = itos(DEFAULT_MIN_SDK_VERSION);
}
- String target_sdk_version = p_preset->get("custom_build/target_sdk");
+ String target_sdk_version = p_preset->get("gradle_build/target_sdk");
if (!target_sdk_version.is_valid_int()) {
target_sdk_version = itos(DEFAULT_TARGET_SDK_VERSION);
}
@@ -2944,7 +2936,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
return ERR_CANT_CREATE;
}
- print_verbose("Successfully completed Android custom build.");
+ print_verbose("Successfully completed Android gradle build.");
return OK;
}
// This is the start of the Legacy build system
diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h
index bff769fcba..337a0228d0 100644
--- a/platform/android/export/export_plugin.h
+++ b/platform/android/export/export_plugin.h
@@ -74,7 +74,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
Vector<PluginConfigAndroid> plugins;
String last_plugin_names;
- uint64_t last_custom_build_time = 0;
+ uint64_t last_gradle_build_time = 0;
SafeFlag plugins_changed;
Mutex plugins_lock;
Vector<Device> devices;
@@ -172,6 +172,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
static Vector<ABI> get_enabled_abis(const Ref<EditorExportPreset> &p_preset);
+ static bool _uses_vulkan();
+
public:
typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
@@ -213,14 +215,14 @@ public:
inline bool is_clean_build_required(Vector<PluginConfigAndroid> enabled_plugins) {
String plugin_names = PluginConfigAndroid::get_plugins_names(enabled_plugins);
- bool first_build = last_custom_build_time == 0;
+ bool first_build = last_gradle_build_time == 0;
bool have_plugins_changed = false;
if (!first_build) {
have_plugins_changed = plugin_names != last_plugin_names;
if (!have_plugins_changed) {
for (int i = 0; i < enabled_plugins.size(); i++) {
- if (enabled_plugins.get(i).last_updated > last_custom_build_time) {
+ if (enabled_plugins.get(i).last_updated > last_gradle_build_time) {
have_plugins_changed = true;
break;
}
@@ -228,7 +230,7 @@ public:
}
}
- last_custom_build_time = OS::get_singleton()->get_unix_time();
+ last_gradle_build_time = OS::get_singleton()->get_unix_time();
last_plugin_names = plugin_names;
return have_plugins_changed || first_build;
diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp
index 4fdcca68e9..b889d58199 100644
--- a/platform/android/export/gradle_export_util.cpp
+++ b/platform/android/export/gradle_export_util.cpp
@@ -166,7 +166,7 @@ Error store_string_at_path(const String &p_path, const String &p_data) {
// This method will only be called as an input to export_project_files.
// It is used by the export_project_files method to save all the asset files into the gradle project.
// It's functionality mirrors that of the method save_apk_file.
-// This method will be called ONLY when custom build is enabled.
+// This method will be called ONLY when gradle build is enabled.
Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) {
CustomExportData *export_data = static_cast<CustomExportData *>(p_userdata);
String dst_path = p_path.replace_first("res://", export_data->assets_directory + "/");
@@ -254,7 +254,7 @@ String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset) {
return manifest_screen_sizes;
}
-String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) {
+String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan) {
String manifest_xr_features;
int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode"));
bool uses_xr = xr_mode_index == XR_MODE_OPENXR;
@@ -273,20 +273,46 @@ String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) {
manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"true\" />\n";
}
}
+
+ if (p_uses_vulkan) {
+ manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"android.hardware.vulkan.level\" android:required=\"true\" android:version=\"1\" />\n";
+ }
return manifest_xr_features;
}
-String _get_activity_tag(const Ref<EditorExportPreset> &p_preset) {
+String _get_activity_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_xr) {
String orientation = _get_android_orientation_label(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))));
String manifest_activity_text = vformat(
" <activity android:name=\"com.godot.game.GodotApp\" "
"tools:replace=\"android:screenOrientation,android:excludeFromRecents,android:resizeableActivity\" "
+ "tools:node=\"mergeOnlyAttributes\" "
"android:excludeFromRecents=\"%s\" "
"android:screenOrientation=\"%s\" "
"android:resizeableActivity=\"%s\">\n",
bool_to_string(p_preset->get("package/exclude_from_recents")),
orientation,
bool_to_string(bool(GLOBAL_GET("display/window/size/resizable"))));
+
+ if (p_uses_xr) {
+ manifest_activity_text += " <intent-filter>\n"
+ " <action android:name=\"android.intent.action.MAIN\" />\n"
+ " <category android:name=\"android.intent.category.LAUNCHER\" />\n"
+ "\n"
+ " <!-- Enable access to OpenXR on Oculus mobile devices, no-op on other Android\n"
+ " platforms. -->\n"
+ " <category android:name=\"com.oculus.intent.category.VR\" />\n"
+ "\n"
+ " <!-- OpenXR category tag to indicate the activity starts in an immersive OpenXR mode. \n"
+ " See https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#android-runtime-category. -->\n"
+ " <category android:name=\"org.khronos.openxr.intent.category.IMMERSIVE_HMD\" />\n"
+ " </intent-filter>\n";
+ } else {
+ manifest_activity_text += " <intent-filter>\n"
+ " <action android:name=\"android.intent.action.MAIN\" />\n"
+ " <category android:name=\"android.intent.category.LAUNCHER\" />\n"
+ " </intent-filter>\n";
+ }
+
manifest_activity_text += " </activity>\n";
return manifest_activity_text;
}
@@ -307,9 +333,7 @@ String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_
" android:hasFragileUserData=\"%s\"\n"
" android:requestLegacyExternalStorage=\"%s\"\n"
" tools:replace=\"android:allowBackup,android:appCategory,android:isGame,android:hasFragileUserData,android:requestLegacyExternalStorage\"\n"
- " tools:ignore=\"GoogleAppIndexingWarning\">\n\n"
- " <meta-data tools:node=\"remove\" android:name=\"xr_hand_tracking_version_name\" />\n"
- " <meta-data tools:node=\"remove\" android:name=\"xr_hand_tracking_metadata_name\" />\n",
+ " tools:ignore=\"GoogleAppIndexingWarning\">\n\n",
bool_to_string(p_preset->get("user_data_backup/allow")),
_get_app_category_label(app_category_index),
bool_to_string(is_game),
@@ -327,7 +351,7 @@ String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_
manifest_application_text += " <meta-data tools:node=\"replace\" android:name=\"com.oculus.handtracking.version\" android:value=\"V2.0\" />\n";
}
}
- manifest_application_text += _get_activity_tag(p_preset);
+ manifest_application_text += _get_activity_tag(p_preset, uses_xr);
manifest_application_text += " </application>\n";
return manifest_application_text;
}
diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h
index 0fa857cb75..8a885a0d12 100644
--- a/platform/android/export/gradle_export_util.h
+++ b/platform/android/export/gradle_export_util.h
@@ -104,7 +104,7 @@ Error store_string_at_path(const String &p_path, const String &p_data);
// This method will only be called as an input to export_project_files.
// It is used by the export_project_files method to save all the asset files into the gradle project.
// It's functionality mirrors that of the method save_apk_file.
-// This method will be called ONLY when custom build is enabled.
+// This method will be called ONLY when gradle build is enabled.
Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
// Creates strings.xml files inside the gradle project for different locales.
@@ -116,9 +116,9 @@ String _get_gles_tag();
String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset);
-String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset);
+String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan);
-String _get_activity_tag(const Ref<EditorExportPreset> &p_preset);
+String _get_activity_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_xr);
String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_read_write_storage_permission);
diff --git a/platform/android/java/app/AndroidManifest.xml b/platform/android/java/app/AndroidManifest.xml
index 1969f9c814..ce4a2ecfe4 100644
--- a/platform/android/java/app/AndroidManifest.xml
+++ b/platform/android/java/app/AndroidManifest.xml
@@ -31,23 +31,6 @@
android:name="org.godotengine.editor.version"
android:value="${godotEditorVersion}" />
- <!-- The following metadata values are replaced when Godot exports, modifying them here has no effect. -->
- <!-- Do these changes in the export preset. Adding new ones is fine. -->
-
- <!-- XR hand tracking metadata -->
- <!-- This is modified by the exporter based on the selected xr mode. DO NOT CHANGE the values here. -->
- <!-- Removed at export time if the xr mode is not VR or hand tracking is disabled. -->
- <meta-data
- android:name="xr_hand_tracking_metadata_name"
- android:value="xr_hand_tracking_metadata_value"/>
-
- <!-- XR hand tracking version -->
- <!-- This is modified by the exporter based on the selected xr mode. DO NOT CHANGE the values here. -->
- <!-- Removed at export time if the xr mode is not VR or hand tracking is disabled. -->
- <meta-data
- android:name="xr_hand_tracking_version_name"
- android:value="xr_hand_tracking_version_value"/>
-
<activity
android:name=".GodotApp"
android:label="@string/godot_project_name_string"
@@ -63,10 +46,6 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
-
- <!-- Enable access to OpenXR on Oculus mobile devices, no-op on other Android
- platforms. -->
- <category android:name="com.oculus.intent.category.VR" />
</intent-filter>
</activity>
diff --git a/platform/android/java/app/build.gradle b/platform/android/java/app/build.gradle
index 63b10e62b1..01b148aeef 100644
--- a/platform/android/java/app/build.gradle
+++ b/platform/android/java/app/build.gradle
@@ -50,7 +50,7 @@ dependencies {
} else if (rootProject.findProject(":godot:lib")) {
implementation project(":godot:lib")
} else {
- // Custom build mode. In this scenario this project is the only one around and the Godot
+ // Godot gradle build mode. In this scenario this project is the only one around and the Godot
// library is available through the pre-generated godot-lib.*.aar android archive files.
debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar', '*.aar'])
devImplementation fileTree(dir: 'libs/dev', include: ['*.jar', '*.aar'])
@@ -153,7 +153,7 @@ android {
debug {
// Signing and zip-aligning are skipped for prebuilt builds, but
- // performed for custom builds.
+ // performed for Godot gradle builds.
zipAlignEnabled shouldZipAlign()
if (shouldSign()) {
signingConfig signingConfigs.debug
@@ -165,7 +165,7 @@ android {
dev {
initWith debug
// Signing and zip-aligning are skipped for prebuilt builds, but
- // performed for custom builds.
+ // performed for Godot gradle builds.
zipAlignEnabled shouldZipAlign()
if (shouldSign()) {
signingConfig signingConfigs.debug
@@ -176,7 +176,7 @@ android {
release {
// Signing and zip-aligning are skipped for prebuilt builds, but
- // performed for custom builds.
+ // performed for Godot gradle builds.
zipAlignEnabled shouldZipAlign()
if (shouldSign()) {
signingConfig signingConfigs.release
diff --git a/platform/android/java/app/gradle.properties b/platform/android/java/app/gradle.properties
index 0ad8e611ca..d9f79b6818 100644
--- a/platform/android/java/app/gradle.properties
+++ b/platform/android/java/app/gradle.properties
@@ -1,5 +1,5 @@
-# Godot custom build Gradle settings.
-# These properties apply when running custom build from the Godot editor.
+# Godot gradle build settings.
+# These properties apply when running a gradle build from the Godot editor.
# NOTE: This should be kept in sync with 'godot/platform/android/java/gradle.properties' except
# where otherwise specified.
diff --git a/platform/android/java/app/settings.gradle b/platform/android/java/app/settings.gradle
index ba53aefe7f..b4524a3f60 100644
--- a/platform/android/java/app/settings.gradle
+++ b/platform/android/java/app/settings.gradle
@@ -1,4 +1,4 @@
-// This is the root directory of the Godot custom build.
+// This is the root directory of the Godot Android gradle build.
pluginManagement {
apply from: 'config.gradle'
diff --git a/platform/android/java/app/src/com/godot/game/GodotApp.java b/platform/android/java/app/src/com/godot/game/GodotApp.java
index a43e289b6b..1d2cc05715 100644
--- a/platform/android/java/app/src/com/godot/game/GodotApp.java
+++ b/platform/android/java/app/src/com/godot/game/GodotApp.java
@@ -35,7 +35,7 @@ import org.godotengine.godot.FullScreenGodotApp;
import android.os.Bundle;
/**
- * Template activity for Godot Android custom builds.
+ * Template activity for Godot Android builds.
* Feel free to extend and modify this class for your custom logic.
*/
public class GodotApp extends FullScreenGodotApp {
diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle
index 5a91e5ce32..cffe0a33d9 100644
--- a/platform/android/java/build.gradle
+++ b/platform/android/java/build.gradle
@@ -152,14 +152,14 @@ task copyReleaseAARToBin(type: Copy) {
}
/**
- * Generate Godot custom build template by zipping the source files from the app directory, as well
+ * Generate Godot gradle build template by zipping the source files from the app directory, as well
* as the AAR files generated by 'copyDebugAAR', 'copyDevAAR' and 'copyReleaseAAR'.
- * The zip file also includes some gradle tools to allow building of the custom build.
+ * The zip file also includes some gradle tools to enable gradle builds from the Godot Editor.
*/
-task zipCustomBuild(type: Zip) {
+task zipGradleBuild(type: Zip) {
onlyIf { generateGodotTemplates.state.executed || generateDevTemplate.state.executed }
doFirst {
- logger.lifecycle("Generating Godot custom build template")
+ logger.lifecycle("Generating Godot gradle build template")
}
from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradlew', 'gradlew.bat', 'gradle/**']))
include '**/*'
@@ -195,7 +195,7 @@ def templateBuildTasks() {
&& targetLibs.listFiles() != null
&& targetLibs.listFiles().length > 0) {
String capitalizedTarget = target.capitalize()
- // Copy the generated aar library files to the custom build directory.
+ // Copy the generated aar library files to the build directory.
tasks += "copy" + capitalizedTarget + "AARToAppModule"
// Copy the generated aar library files to the bin directory.
tasks += "copy" + capitalizedTarget + "AARToBin"
@@ -260,7 +260,7 @@ task generateGodotTemplates {
gradle.startParameter.excludedTaskNames += templateExcludedBuildTask()
dependsOn = templateBuildTasks()
- finalizedBy 'zipCustomBuild'
+ finalizedBy 'zipGradleBuild'
}
/**
@@ -273,7 +273,7 @@ task generateDevTemplate {
gradle.startParameter.excludedTaskNames += templateExcludedBuildTask()
dependsOn = templateBuildTasks()
- finalizedBy 'zipCustomBuild'
+ finalizedBy 'zipGradleBuild'
}
task clean(type: Delete) {
diff --git a/platform/android/java/gradle.properties b/platform/android/java/gradle.properties
index 5cd94e85d9..39a0dcda16 100644
--- a/platform/android/java/gradle.properties
+++ b/platform/android/java/gradle.properties
@@ -24,5 +24,5 @@ org.gradle.jvmargs=-Xmx4536m
org.gradle.warning.mode=all
# Disable resource optimizations for template release build.
-# NOTE: This is turned on for custom build in order to improve the release build.
+# NOTE: This is turned on for Godot Editor's gradle builds in order to improve the release build.
android.enableResourceOptimizations=false
diff --git a/platform/android/java/lib/res/values/strings.xml b/platform/android/java/lib/res/values/strings.xml
index 7efac4ce71..f76f597140 100644
--- a/platform/android/java/lib/res/values/strings.xml
+++ b/platform/android/java/lib/res/values/strings.xml
@@ -14,6 +14,7 @@
<string name="text_button_cancel_verify">Cancel Verification</string>
<string name="text_error_title">Error!</string>
<string name="error_engine_setup_message">Unable to setup the Godot Engine! Aborting…</string>
+ <string name="error_missing_vulkan_requirements_message">This device does not meet the requirements for Vulkan support! Aborting…</string>
<!-- APK Expansion Strings -->
diff --git a/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java b/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java
index 65032d6a68..677c9d8f13 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java
@@ -99,7 +99,7 @@ public abstract class FullScreenGodotApp extends FragmentActivity implements God
// from scratch. Therefore, we need to kill the whole app process and relaunch it.
//
// Restarting only the activity, wouldn't be enough unless it did proper cleanup (including
- // releasing and reloading native libs or resetting their state somehow and clearing statics).
+ // releasing and reloading native libs or resetting their state somehow and clearing static data).
Log.v(TAG, "Restarting Godot instance...");
ProcessPhoenix.triggerRebirth(FullScreenGodotApp.this);
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
index 50263bc392..307fa7bae1 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
@@ -258,13 +258,13 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
*/
@Keep
private boolean onVideoInit() {
- final Activity activity = getActivity();
+ final Activity activity = requireActivity();
containerLayout = new FrameLayout(activity);
containerLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// GodotEditText layout
GodotEditText editText = new GodotEditText(activity);
- editText.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,
+ editText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
(int)getResources().getDimension(R.dimen.text_edit_height)));
// ...add to FrameLayout
containerLayout.addView(editText);
@@ -275,11 +275,16 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
return false;
}
- final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method");
- if (renderer.equals("gl_compatibility")) {
- mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
- } else {
+ if (usesVulkan()) {
+ if (!meetsVulkanRequirements(activity.getPackageManager())) {
+ Log.e(TAG, "Missing requirements for vulkan support! Aborting...");
+ alert(R.string.error_missing_vulkan_requirements_message, R.string.text_error_title, this::forceQuit);
+ return false;
+ }
mRenderView = new GodotVulkanRenderView(activity, this);
+ } else {
+ // Fallback to openGl
+ mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
}
View view = mRenderView.getView();
@@ -317,6 +322,26 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
return true;
}
+ /**
+ * Returns true if `Vulkan` is used for rendering.
+ */
+ private boolean usesVulkan() {
+ final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method");
+ final String renderingDevice = GodotLib.getGlobal("rendering/rendering_device/driver");
+ return ("forward_plus".equals(renderer) || "mobile".equals(renderer)) && "vulkan".equals(renderingDevice);
+ }
+
+ /**
+ * Returns true if the device meets the base requirements for Vulkan support, false otherwise.
+ */
+ private boolean meetsVulkanRequirements(@Nullable PackageManager packageManager) {
+ if (packageManager == null) {
+ return false;
+ }
+
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && packageManager.hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_LEVEL, 1);
+ }
+
public void setKeepScreenOn(final boolean p_enabled) {
runOnUiThread(() -> {
if (p_enabled) {
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 75c23655f2..41d1f1d050 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -81,7 +81,7 @@ void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) {
List<String> args;
if (program.ends_with("zenity")) {
- args.push_back("--error");
+ args.push_back("--warning");
args.push_back("--width");
args.push_back("500");
args.push_back("--title");
@@ -91,7 +91,9 @@ void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) {
}
if (program.ends_with("kdialog")) {
- args.push_back("--error");
+ // `--sorry` uses the same icon as `--warning` in Zenity.
+ // As of KDialog 22.12.1, its `--warning` options are only available for yes/no questions.
+ args.push_back("--sorry");
args.push_back(p_alert);
args.push_back("--title");
args.push_back(p_title);
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp
index 8377e81a53..493e4ad20f 100644
--- a/platform/linuxbsd/x11/display_server_x11.cpp
+++ b/platform/linuxbsd/x11/display_server_x11.cpp
@@ -4109,7 +4109,7 @@ void DisplayServerX11::process_events() {
case FocusIn: {
DEBUG_LOG_X11("[%u] FocusIn window=%lu (%u), mode='%u' \n", frame, event.xfocus.window, window_id, event.xfocus.mode);
- if (ime_window_event) {
+ if (ime_window_event || (event.xfocus.detail == NotifyInferior)) {
break;
}
@@ -4157,7 +4157,7 @@ void DisplayServerX11::process_events() {
case FocusOut: {
DEBUG_LOG_X11("[%u] FocusOut window=%lu (%u), mode='%u' \n", frame, event.xfocus.window, window_id, event.xfocus.mode);
WindowData &wd = windows[window_id];
- if (wd.ime_active && event.xfocus.detail == NotifyInferior) {
+ if (ime_window_event || (event.xfocus.detail == NotifyInferior)) {
break;
}
if (wd.ime_active) {
diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm
index b1880c2fb6..65546392c1 100644
--- a/platform/macos/display_server_macos.mm
+++ b/platform/macos/display_server_macos.mm
@@ -3920,6 +3920,7 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM
}
}
show_window(MAIN_WINDOW_ID);
+ force_process_and_drop_events();
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl3") {
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 777d05584c..fe7d91dc18 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -829,6 +829,10 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
DestroyWindow(windows[p_window].hWnd);
windows.erase(p_window);
+
+ if (last_focused_window == p_window) {
+ last_focused_window = INVALID_WINDOW_ID;
+ }
}
void DisplayServerWindows::gl_window_make_current(DisplayServer::WindowID p_window_id) {
@@ -3959,10 +3963,19 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
wd.im_position = Vector2();
- // FIXME this is wrong in cases where the window coordinates were changed due to full screen mode; use WindowRect
- wd.last_pos = p_rect.position;
- wd.width = p_rect.size.width;
- wd.height = p_rect.size.height;
+ if (p_mode == WINDOW_MODE_FULLSCREEN || p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN || p_mode == WINDOW_MODE_MAXIMIZED) {
+ RECT r;
+ GetClientRect(wd.hWnd, &r);
+ ClientToScreen(wd.hWnd, (POINT *)&r.left);
+ ClientToScreen(wd.hWnd, (POINT *)&r.right);
+ wd.last_pos = Point2i(r.left, r.top) - _get_screens_origin();
+ wd.width = r.right - r.left;
+ wd.height = r.bottom - r.top;
+ } else {
+ wd.last_pos = p_rect.position;
+ wd.width = p_rect.size.width;
+ wd.height = p_rect.size.height;
+ }
window_id_counter++;
}
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 49c5501e77..fe6bee0f1b 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -250,7 +250,7 @@ void Camera2D::_notification(int p_what) {
add_to_group(group_name);
add_to_group(canvas_group_name);
- if (enabled && !viewport->get_camera_2d()) {
+ if (!Engine::get_singleton()->is_editor_hint() && enabled && !viewport->get_camera_2d()) {
make_current();
}
@@ -260,11 +260,11 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
+ remove_from_group(group_name);
+ remove_from_group(canvas_group_name);
if (is_current()) {
clear_current();
}
- remove_from_group(group_name);
- remove_from_group(canvas_group_name);
viewport = nullptr;
} break;
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index 380a684c9b..85f6840fde 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -140,7 +140,7 @@ void NavigationAgent2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POST_ENTER_TREE: {
// need to use POST_ENTER_TREE cause with normal ENTER_TREE not all required Nodes are ready.
- // cannot use READY as ready does not get called if Node is readded to SceneTree
+ // cannot use READY as ready does not get called if Node is re-added to SceneTree
set_agent_parent(get_parent());
set_physics_process_internal(true);
@@ -168,6 +168,17 @@ void NavigationAgent2D::_notification(int p_what) {
set_physics_process_internal(false);
} break;
+ case NOTIFICATION_EXIT_TREE: {
+ set_agent_parent(nullptr);
+ set_physics_process_internal(false);
+
+#ifdef DEBUG_ENABLED
+ if (debug_path_instance.is_valid()) {
+ RenderingServer::get_singleton()->canvas_item_set_visible(debug_path_instance, false);
+ }
+#endif // DEBUG_ENABLED
+ } break;
+
case NOTIFICATION_PAUSED: {
if (agent_parent && !agent_parent->can_process()) {
map_before_pause = NavigationServer2D::get_singleton()->agent_get_map(get_rid());
@@ -188,17 +199,6 @@ void NavigationAgent2D::_notification(int p_what) {
}
} break;
- case NOTIFICATION_EXIT_TREE: {
- agent_parent = nullptr;
- set_physics_process_internal(false);
-
-#ifdef DEBUG_ENABLED
- if (debug_path_instance.is_valid()) {
- RenderingServer::get_singleton()->canvas_item_set_visible(debug_path_instance, false);
- }
-#endif // DEBUG_ENABLED
- } break;
-
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent && target_position_submitted) {
if (avoidance_enabled) {
@@ -208,7 +208,6 @@ void NavigationAgent2D::_notification(int p_what) {
}
_check_distance_to_target();
}
-
#ifdef DEBUG_ENABLED
if (debug_path_dirty) {
_update_debug_path();
@@ -220,11 +219,11 @@ void NavigationAgent2D::_notification(int p_what) {
NavigationAgent2D::NavigationAgent2D() {
agent = NavigationServer2D::get_singleton()->agent_create();
- set_neighbor_distance(neighbor_distance);
- set_max_neighbors(max_neighbors);
- set_time_horizon(time_horizon);
- set_radius(radius);
- set_max_speed(max_speed);
+ NavigationServer2D::get_singleton()->agent_set_neighbor_distance(agent, neighbor_distance);
+ NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
+ NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, time_horizon);
+ NavigationServer2D::get_singleton()->agent_set_radius(agent, radius);
+ NavigationServer2D::get_singleton()->agent_set_max_speed(agent, max_speed);
// Preallocate query and result objects to improve performance.
navigation_query = Ref<NavigationPathQueryParameters2D>();
@@ -254,7 +253,12 @@ NavigationAgent2D::~NavigationAgent2D() {
}
void NavigationAgent2D::set_avoidance_enabled(bool p_enabled) {
+ if (avoidance_enabled == p_enabled) {
+ return;
+ }
+
avoidance_enabled = p_enabled;
+
if (avoidance_enabled) {
NavigationServer2D::get_singleton()->agent_set_callback(agent, callable_mp(this, &NavigationAgent2D::_avoidance_done));
} else {
@@ -267,6 +271,10 @@ bool NavigationAgent2D::get_avoidance_enabled() const {
}
void NavigationAgent2D::set_agent_parent(Node *p_agent_parent) {
+ if (agent_parent == p_agent_parent) {
+ return;
+ }
+
// remove agent from any avoidance map before changing parent or there will be leftovers on the RVO map
NavigationServer2D::get_singleton()->agent_set_callback(agent, Callable());
@@ -280,7 +288,9 @@ void NavigationAgent2D::set_agent_parent(Node *p_agent_parent) {
}
// create new avoidance callback if enabled
- set_avoidance_enabled(avoidance_enabled);
+ if (avoidance_enabled) {
+ NavigationServer2D::get_singleton()->agent_set_callback(agent, callable_mp(this, &NavigationAgent2D::_avoidance_done));
+ }
} else {
agent_parent = nullptr;
NavigationServer2D::get_singleton()->agent_set_map(get_rid(), RID());
@@ -288,11 +298,13 @@ void NavigationAgent2D::set_agent_parent(Node *p_agent_parent) {
}
void NavigationAgent2D::set_navigation_layers(uint32_t p_navigation_layers) {
- bool navigation_layers_changed = navigation_layers != p_navigation_layers;
- navigation_layers = p_navigation_layers;
- if (navigation_layers_changed) {
- _request_repath();
+ if (navigation_layers == p_navigation_layers) {
+ return;
}
+
+ navigation_layers = p_navigation_layers;
+
+ _request_repath();
}
uint32_t NavigationAgent2D::get_navigation_layers() const {
@@ -326,7 +338,12 @@ void NavigationAgent2D::set_path_metadata_flags(BitField<NavigationPathQueryPara
}
void NavigationAgent2D::set_navigation_map(RID p_navigation_map) {
+ if (map_override == p_navigation_map) {
+ return;
+ }
+
map_override = p_navigation_map;
+
NavigationServer2D::get_singleton()->agent_set_map(agent, map_override);
_request_repath();
}
@@ -340,41 +357,78 @@ RID NavigationAgent2D::get_navigation_map() const {
return RID();
}
-void NavigationAgent2D::set_path_desired_distance(real_t p_dd) {
- path_desired_distance = p_dd;
+void NavigationAgent2D::set_path_desired_distance(real_t p_path_desired_distance) {
+ if (Math::is_equal_approx(path_desired_distance, p_path_desired_distance)) {
+ return;
+ }
+
+ path_desired_distance = p_path_desired_distance;
}
-void NavigationAgent2D::set_target_desired_distance(real_t p_dd) {
- target_desired_distance = p_dd;
+void NavigationAgent2D::set_target_desired_distance(real_t p_target_desired_distance) {
+ if (Math::is_equal_approx(target_desired_distance, p_target_desired_distance)) {
+ return;
+ }
+
+ target_desired_distance = p_target_desired_distance;
}
void NavigationAgent2D::set_radius(real_t p_radius) {
+ if (Math::is_equal_approx(radius, p_radius)) {
+ return;
+ }
+
radius = p_radius;
+
NavigationServer2D::get_singleton()->agent_set_radius(agent, radius);
}
void NavigationAgent2D::set_neighbor_distance(real_t p_distance) {
+ if (Math::is_equal_approx(neighbor_distance, p_distance)) {
+ return;
+ }
+
neighbor_distance = p_distance;
+
NavigationServer2D::get_singleton()->agent_set_neighbor_distance(agent, neighbor_distance);
}
void NavigationAgent2D::set_max_neighbors(int p_count) {
+ if (max_neighbors == p_count) {
+ return;
+ }
+
max_neighbors = p_count;
+
NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
}
void NavigationAgent2D::set_time_horizon(real_t p_time) {
+ if (Math::is_equal_approx(time_horizon, p_time)) {
+ return;
+ }
+
time_horizon = p_time;
+
NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, time_horizon);
}
void NavigationAgent2D::set_max_speed(real_t p_max_speed) {
+ if (Math::is_equal_approx(max_speed, p_max_speed)) {
+ return;
+ }
+
max_speed = p_max_speed;
+
NavigationServer2D::get_singleton()->agent_set_max_speed(agent, max_speed);
}
-void NavigationAgent2D::set_path_max_distance(real_t p_pmd) {
- path_max_distance = p_pmd;
+void NavigationAgent2D::set_path_max_distance(real_t p_path_max_distance) {
+ if (Math::is_equal_approx(path_max_distance, p_path_max_distance)) {
+ return;
+ }
+
+ path_max_distance = p_path_max_distance;
}
real_t NavigationAgent2D::get_path_max_distance() {
@@ -382,8 +436,13 @@ real_t NavigationAgent2D::get_path_max_distance() {
}
void NavigationAgent2D::set_target_position(Vector2 p_position) {
+ if (target_position.is_equal_approx(p_position)) {
+ return;
+ }
+
target_position = p_position;
target_position_submitted = true;
+
_request_repath();
}
@@ -432,10 +491,15 @@ Vector2 NavigationAgent2D::get_final_position() {
}
void NavigationAgent2D::set_velocity(Vector2 p_velocity) {
+ if (target_velocity.is_equal_approx(p_velocity)) {
+ return;
+ }
+
target_velocity = p_velocity;
+ velocity_submitted = true;
+
NavigationServer2D::get_singleton()->agent_set_target_velocity(agent, target_velocity);
NavigationServer2D::get_singleton()->agent_set_velocity(agent, prev_safe_velocity);
- velocity_submitted = true;
}
void NavigationAgent2D::_avoidance_done(Vector3 p_new_velocity) {
@@ -608,6 +672,10 @@ void NavigationAgent2D::_check_distance_to_target() {
#ifdef DEBUG_ENABLED
void NavigationAgent2D::set_debug_enabled(bool p_enabled) {
+ if (debug_enabled == p_enabled) {
+ return;
+ }
+
debug_enabled = p_enabled;
debug_path_dirty = true;
}
@@ -617,6 +685,10 @@ bool NavigationAgent2D::get_debug_enabled() const {
}
void NavigationAgent2D::set_debug_use_custom(bool p_enabled) {
+ if (debug_use_custom == p_enabled) {
+ return;
+ }
+
debug_use_custom = p_enabled;
debug_path_dirty = true;
}
@@ -626,6 +698,10 @@ bool NavigationAgent2D::get_debug_use_custom() const {
}
void NavigationAgent2D::set_debug_path_custom_color(Color p_color) {
+ if (debug_path_custom_color == p_color) {
+ return;
+ }
+
debug_path_custom_color = p_color;
debug_path_dirty = true;
}
@@ -635,6 +711,10 @@ Color NavigationAgent2D::get_debug_path_custom_color() const {
}
void NavigationAgent2D::set_debug_path_custom_point_size(float p_point_size) {
+ if (Math::is_equal_approx(debug_path_custom_point_size, p_point_size)) {
+ return;
+ }
+
debug_path_custom_point_size = MAX(0.1, p_point_size);
debug_path_dirty = true;
}
@@ -644,6 +724,10 @@ float NavigationAgent2D::get_debug_path_custom_point_size() const {
}
void NavigationAgent2D::set_debug_path_custom_line_width(float p_line_width) {
+ if (Math::is_equal_approx(debug_path_custom_line_width, p_line_width)) {
+ return;
+ }
+
debug_path_custom_line_width = p_line_width;
debug_path_dirty = true;
}
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 8f4a373327..5278c81f66 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -57,7 +57,6 @@ class NavigationAgent2D : public Node {
int max_neighbors = 10;
real_t time_horizon = 1.0;
real_t max_speed = 100.0;
-
real_t path_max_distance = 100.0;
Vector2 target_position;
diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp
index 4bd170301a..d7ef77e25b 100644
--- a/scene/2d/navigation_obstacle_2d.cpp
+++ b/scene/2d/navigation_obstacle_2d.cpp
@@ -185,6 +185,10 @@ real_t NavigationObstacle2D::estimate_agent_radius() const {
}
void NavigationObstacle2D::set_agent_parent(Node *p_agent_parent) {
+ if (parent_node2d == p_agent_parent) {
+ return;
+ }
+
if (Object::cast_to<Node2D>(p_agent_parent) != nullptr) {
parent_node2d = Object::cast_to<Node2D>(p_agent_parent);
if (map_override.is_valid()) {
@@ -200,7 +204,12 @@ void NavigationObstacle2D::set_agent_parent(Node *p_agent_parent) {
}
void NavigationObstacle2D::set_navigation_map(RID p_navigation_map) {
+ if (map_override == p_navigation_map) {
+ return;
+ }
+
map_override = p_navigation_map;
+
NavigationServer2D::get_singleton()->agent_set_map(agent, map_override);
}
@@ -214,13 +223,23 @@ RID NavigationObstacle2D::get_navigation_map() const {
}
void NavigationObstacle2D::set_estimate_radius(bool p_estimate_radius) {
+ if (estimate_radius == p_estimate_radius) {
+ return;
+ }
+
estimate_radius = p_estimate_radius;
+
notify_property_list_changed();
reevaluate_agent_radius();
}
void NavigationObstacle2D::set_radius(real_t p_radius) {
ERR_FAIL_COND_MSG(p_radius <= 0.0, "Radius must be greater than 0.");
+ if (Math::is_equal_approx(radius, p_radius)) {
+ return;
+ }
+
radius = p_radius;
+
reevaluate_agent_radius();
}
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index 5db8611d72..524304425c 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -143,7 +143,7 @@ void NavigationAgent3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POST_ENTER_TREE: {
// need to use POST_ENTER_TREE cause with normal ENTER_TREE not all required Nodes are ready.
- // cannot use READY as ready does not get called if Node is readded to SceneTree
+ // cannot use READY as ready does not get called if Node is re-added to SceneTree
set_agent_parent(get_parent());
set_physics_process_internal(true);
@@ -207,7 +207,7 @@ void NavigationAgent3D::_notification(int p_what) {
if (avoidance_enabled) {
// agent_position on NavigationServer is avoidance only and has nothing to do with pathfinding
// no point in flooding NavigationServer queue with agent position updates that get send to the void if avoidance is not used
- NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
+ NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
}
_check_distance_to_target();
}
@@ -222,12 +222,12 @@ void NavigationAgent3D::_notification(int p_what) {
NavigationAgent3D::NavigationAgent3D() {
agent = NavigationServer3D::get_singleton()->agent_create();
- set_neighbor_distance(50.0);
- set_max_neighbors(10);
- set_time_horizon(5.0);
- set_radius(1.0);
- set_max_speed(10.0);
- set_ignore_y(true);
+ NavigationServer3D::get_singleton()->agent_set_neighbor_distance(agent, neighbor_distance);
+ NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
+ NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, time_horizon);
+ NavigationServer3D::get_singleton()->agent_set_radius(agent, radius);
+ NavigationServer3D::get_singleton()->agent_set_max_speed(agent, max_speed);
+ NavigationServer3D::get_singleton()->agent_set_ignore_y(agent, ignore_y);
// Preallocate query and result objects to improve performance.
navigation_query = Ref<NavigationPathQueryParameters3D>();
@@ -260,7 +260,12 @@ NavigationAgent3D::~NavigationAgent3D() {
}
void NavigationAgent3D::set_avoidance_enabled(bool p_enabled) {
+ if (avoidance_enabled == p_enabled) {
+ return;
+ }
+
avoidance_enabled = p_enabled;
+
if (avoidance_enabled) {
NavigationServer3D::get_singleton()->agent_set_callback(agent, callable_mp(this, &NavigationAgent3D::_avoidance_done));
} else {
@@ -273,6 +278,10 @@ bool NavigationAgent3D::get_avoidance_enabled() const {
}
void NavigationAgent3D::set_agent_parent(Node *p_agent_parent) {
+ if (agent_parent == p_agent_parent) {
+ return;
+ }
+
// remove agent from any avoidance map before changing parent or there will be leftovers on the RVO map
NavigationServer3D::get_singleton()->agent_set_callback(agent, Callable());
@@ -286,7 +295,9 @@ void NavigationAgent3D::set_agent_parent(Node *p_agent_parent) {
}
// create new avoidance callback if enabled
- set_avoidance_enabled(avoidance_enabled);
+ if (avoidance_enabled) {
+ NavigationServer3D::get_singleton()->agent_set_callback(agent, callable_mp(this, &NavigationAgent3D::_avoidance_done));
+ }
} else {
agent_parent = nullptr;
NavigationServer3D::get_singleton()->agent_set_map(get_rid(), RID());
@@ -294,11 +305,13 @@ void NavigationAgent3D::set_agent_parent(Node *p_agent_parent) {
}
void NavigationAgent3D::set_navigation_layers(uint32_t p_navigation_layers) {
- bool navigation_layers_changed = navigation_layers != p_navigation_layers;
- navigation_layers = p_navigation_layers;
- if (navigation_layers_changed) {
- _request_repath();
+ if (navigation_layers == p_navigation_layers) {
+ return;
}
+
+ navigation_layers = p_navigation_layers;
+
+ _request_repath();
}
uint32_t NavigationAgent3D::get_navigation_layers() const {
@@ -332,7 +345,12 @@ void NavigationAgent3D::set_path_metadata_flags(BitField<NavigationPathQueryPara
}
void NavigationAgent3D::set_navigation_map(RID p_navigation_map) {
+ if (map_override == p_navigation_map) {
+ return;
+ }
+
map_override = p_navigation_map;
+
NavigationServer3D::get_singleton()->agent_set_map(agent, map_override);
_request_repath();
}
@@ -346,50 +364,96 @@ RID NavigationAgent3D::get_navigation_map() const {
return RID();
}
-void NavigationAgent3D::set_path_desired_distance(real_t p_dd) {
- path_desired_distance = p_dd;
+void NavigationAgent3D::set_path_desired_distance(real_t p_path_desired_distance) {
+ if (Math::is_equal_approx(path_desired_distance, p_path_desired_distance)) {
+ return;
+ }
+
+ path_desired_distance = p_path_desired_distance;
}
-void NavigationAgent3D::set_target_desired_distance(real_t p_dd) {
- target_desired_distance = p_dd;
+void NavigationAgent3D::set_target_desired_distance(real_t p_target_desired_distance) {
+ if (Math::is_equal_approx(target_desired_distance, p_target_desired_distance)) {
+ return;
+ }
+
+ target_desired_distance = p_target_desired_distance;
}
void NavigationAgent3D::set_radius(real_t p_radius) {
+ if (Math::is_equal_approx(radius, p_radius)) {
+ return;
+ }
+
radius = p_radius;
+
NavigationServer3D::get_singleton()->agent_set_radius(agent, radius);
}
-void NavigationAgent3D::set_agent_height_offset(real_t p_hh) {
- navigation_height_offset = p_hh;
+void NavigationAgent3D::set_agent_height_offset(real_t p_agent_height_offset) {
+ if (Math::is_equal_approx(navigation_height_offset, p_agent_height_offset)) {
+ return;
+ }
+
+ navigation_height_offset = p_agent_height_offset;
}
void NavigationAgent3D::set_ignore_y(bool p_ignore_y) {
+ if (ignore_y == p_ignore_y) {
+ return;
+ }
+
ignore_y = p_ignore_y;
+
NavigationServer3D::get_singleton()->agent_set_ignore_y(agent, ignore_y);
}
void NavigationAgent3D::set_neighbor_distance(real_t p_distance) {
+ if (Math::is_equal_approx(neighbor_distance, p_distance)) {
+ return;
+ }
+
neighbor_distance = p_distance;
+
NavigationServer3D::get_singleton()->agent_set_neighbor_distance(agent, neighbor_distance);
}
void NavigationAgent3D::set_max_neighbors(int p_count) {
+ if (max_neighbors == p_count) {
+ return;
+ }
+
max_neighbors = p_count;
+
NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
}
void NavigationAgent3D::set_time_horizon(real_t p_time) {
+ if (Math::is_equal_approx(time_horizon, p_time)) {
+ return;
+ }
+
time_horizon = p_time;
+
NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, time_horizon);
}
void NavigationAgent3D::set_max_speed(real_t p_max_speed) {
+ if (Math::is_equal_approx(max_speed, p_max_speed)) {
+ return;
+ }
+
max_speed = p_max_speed;
+
NavigationServer3D::get_singleton()->agent_set_max_speed(agent, max_speed);
}
-void NavigationAgent3D::set_path_max_distance(real_t p_pmd) {
- path_max_distance = p_pmd;
+void NavigationAgent3D::set_path_max_distance(real_t p_path_max_distance) {
+ if (Math::is_equal_approx(path_max_distance, p_path_max_distance)) {
+ return;
+ }
+
+ path_max_distance = p_path_max_distance;
}
real_t NavigationAgent3D::get_path_max_distance() {
@@ -397,8 +461,13 @@ real_t NavigationAgent3D::get_path_max_distance() {
}
void NavigationAgent3D::set_target_position(Vector3 p_position) {
+ if (target_position.is_equal_approx(p_position)) {
+ return;
+ }
+
target_position = p_position;
target_position_submitted = true;
+
_request_repath();
}
@@ -412,7 +481,7 @@ Vector3 NavigationAgent3D::get_next_path_position() {
const Vector<Vector3> &navigation_path = navigation_result->get_path();
if (navigation_path.size() == 0) {
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector3(), "The agent has no parent.");
- return agent_parent->get_global_transform().origin;
+ return agent_parent->get_global_position();
} else {
return navigation_path[navigation_path_index] - Vector3(0, navigation_height_offset, 0);
}
@@ -420,7 +489,7 @@ Vector3 NavigationAgent3D::get_next_path_position() {
real_t NavigationAgent3D::distance_to_target() const {
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
- return agent_parent->get_global_transform().origin.distance_to(target_position);
+ return agent_parent->get_global_position().distance_to(target_position);
}
bool NavigationAgent3D::is_target_reached() const {
@@ -447,10 +516,15 @@ Vector3 NavigationAgent3D::get_final_position() {
}
void NavigationAgent3D::set_velocity(Vector3 p_velocity) {
+ if (target_velocity.is_equal_approx(p_velocity)) {
+ return;
+ }
+
target_velocity = p_velocity;
+ velocity_submitted = true;
+
NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, target_velocity);
NavigationServer3D::get_singleton()->agent_set_velocity(agent, prev_safe_velocity);
- velocity_submitted = true;
}
void NavigationAgent3D::_avoidance_done(Vector3 p_new_velocity) {
@@ -491,7 +565,7 @@ void NavigationAgent3D::update_navigation() {
update_frame_id = Engine::get_singleton()->get_physics_frames();
- Vector3 origin = agent_parent->get_global_transform().origin;
+ Vector3 origin = agent_parent->get_global_position();
bool reload_path = false;
@@ -624,6 +698,10 @@ void NavigationAgent3D::_check_distance_to_target() {
#ifdef DEBUG_ENABLED
void NavigationAgent3D::set_debug_enabled(bool p_enabled) {
+ if (debug_enabled == p_enabled) {
+ return;
+ }
+
debug_enabled = p_enabled;
debug_path_dirty = true;
}
@@ -633,6 +711,10 @@ bool NavigationAgent3D::get_debug_enabled() const {
}
void NavigationAgent3D::set_debug_use_custom(bool p_enabled) {
+ if (debug_use_custom == p_enabled) {
+ return;
+ }
+
debug_use_custom = p_enabled;
debug_path_dirty = true;
}
@@ -642,6 +724,10 @@ bool NavigationAgent3D::get_debug_use_custom() const {
}
void NavigationAgent3D::set_debug_path_custom_color(Color p_color) {
+ if (debug_path_custom_color == p_color) {
+ return;
+ }
+
debug_path_custom_color = p_color;
debug_path_dirty = true;
}
@@ -651,6 +737,10 @@ Color NavigationAgent3D::get_debug_path_custom_color() const {
}
void NavigationAgent3D::set_debug_path_custom_point_size(float p_point_size) {
+ if (Math::is_equal_approx(debug_path_custom_point_size, p_point_size)) {
+ return;
+ }
+
debug_path_custom_point_size = p_point_size;
debug_path_dirty = true;
}
diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h
index 98bf395d7c..209b2a0989 100644
--- a/scene/3d/navigation_agent_3d.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -52,14 +52,13 @@ class NavigationAgent3D : public Node {
real_t path_desired_distance = 1.0;
real_t target_desired_distance = 1.0;
- real_t radius = 0.0;
+ real_t radius = 1.0;
real_t navigation_height_offset = 0.0;
- bool ignore_y = false;
- real_t neighbor_distance = 0.0;
- int max_neighbors = 0;
- real_t time_horizon = 0.0;
- real_t max_speed = 0.0;
-
+ bool ignore_y = true;
+ real_t neighbor_distance = 50.0;
+ int max_neighbors = 10;
+ real_t time_horizon = 5.0;
+ real_t max_speed = 10.0;
real_t path_max_distance = 3.0;
Vector3 target_position;
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index c706f55566..85b3c164cc 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -192,6 +192,10 @@ real_t NavigationObstacle3D::estimate_agent_radius() const {
}
void NavigationObstacle3D::set_agent_parent(Node *p_agent_parent) {
+ if (parent_node3d == p_agent_parent) {
+ return;
+ }
+
if (Object::cast_to<Node3D>(p_agent_parent) != nullptr) {
parent_node3d = Object::cast_to<Node3D>(p_agent_parent);
if (map_override.is_valid()) {
@@ -207,7 +211,12 @@ void NavigationObstacle3D::set_agent_parent(Node *p_agent_parent) {
}
void NavigationObstacle3D::set_navigation_map(RID p_navigation_map) {
+ if (map_override == p_navigation_map) {
+ return;
+ }
+
map_override = p_navigation_map;
+
NavigationServer3D::get_singleton()->agent_set_map(agent, map_override);
}
@@ -221,13 +230,23 @@ RID NavigationObstacle3D::get_navigation_map() const {
}
void NavigationObstacle3D::set_estimate_radius(bool p_estimate_radius) {
+ if (estimate_radius == p_estimate_radius) {
+ return;
+ }
+
estimate_radius = p_estimate_radius;
+
notify_property_list_changed();
reevaluate_agent_radius();
}
void NavigationObstacle3D::set_radius(real_t p_radius) {
ERR_FAIL_COND_MSG(p_radius <= 0.0, "Radius must be greater than 0.");
+ if (Math::is_equal_approx(radius, p_radius)) {
+ return;
+ }
+
radius = p_radius;
+
reevaluate_agent_radius();
}
diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp
index d28a6fcc04..0e9e02f247 100644
--- a/scene/animation/animation_blend_space_1d.cpp
+++ b/scene/animation/animation_blend_space_1d.cpp
@@ -61,7 +61,15 @@ void AnimationNodeBlendSpace1D::_validate_property(PropertyInfo &p_property) con
}
void AnimationNodeBlendSpace1D::_tree_changed() {
- emit_signal(SNAME("tree_changed"));
+ AnimationRootNode::_tree_changed();
+}
+
+void AnimationNodeBlendSpace1D::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
+ AnimationRootNode::_animation_node_renamed(p_oid, p_old_name, p_new_name);
+}
+
+void AnimationNodeBlendSpace1D::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
+ AnimationRootNode::_animation_node_removed(p_oid, p_node);
}
void AnimationNodeBlendSpace1D::_bind_methods() {
@@ -137,6 +145,8 @@ void AnimationNodeBlendSpace1D::add_blend_point(const Ref<AnimationRootNode> &p_
blend_points[p_at_index].position = p_position;
blend_points[p_at_index].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_at_index].node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_at_index].node->connect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
blend_points_used++;
emit_signal(SNAME("tree_changed"));
@@ -154,10 +164,14 @@ void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<Anim
if (blend_points[p_point].node.is_valid()) {
blend_points[p_point].node->disconnect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed));
+ blend_points[p_point].node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_renamed));
+ blend_points[p_point].node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_removed));
}
blend_points[p_point].node = p_node;
blend_points[p_point].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_point].node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_point].node->connect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
emit_signal(SNAME("tree_changed"));
}
@@ -177,12 +191,16 @@ void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) {
ERR_FAIL_COND(blend_points[p_point].node.is_null());
blend_points[p_point].node->disconnect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed));
+ blend_points[p_point].node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_renamed));
+ blend_points[p_point].node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace1D::_animation_node_removed));
for (int i = p_point; i < blend_points_used - 1; i++) {
blend_points[i] = blend_points[i + 1];
}
blend_points_used--;
+
+ emit_signal(SNAME("animation_node_removed"), get_instance_id(), itos(p_point));
emit_signal(SNAME("tree_changed"));
}
diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h
index a1e9a7a764..4007df0ded 100644
--- a/scene/animation/animation_blend_space_1d.h
+++ b/scene/animation/animation_blend_space_1d.h
@@ -66,20 +66,21 @@ protected:
void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node);
- void _tree_changed();
-
StringName blend_position = "blend_position";
StringName closest = "closest";
StringName length_internal = "length_internal";
BlendMode blend_mode = BLEND_MODE_INTERPOLATED;
-protected:
bool sync = false;
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
+ virtual void _tree_changed() override;
+ virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;
+ virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;
+
public:
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index c37d54961e..ae5b0d5779 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -81,6 +81,8 @@ void AnimationNodeBlendSpace2D::add_blend_point(const Ref<AnimationRootNode> &p_
blend_points[p_at_index].position = p_position;
blend_points[p_at_index].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace2D::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_at_index].node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_at_index].node->connect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
blend_points_used++;
_queue_auto_triangles();
@@ -100,9 +102,13 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim
if (blend_points[p_point].node.is_valid()) {
blend_points[p_point].node->disconnect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace2D::_tree_changed));
+ blend_points[p_point].node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_renamed));
+ blend_points[p_point].node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_removed));
}
blend_points[p_point].node = p_node;
blend_points[p_point].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace2D::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_point].node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ blend_points[p_point].node->connect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
emit_signal(SNAME("tree_changed"));
}
@@ -122,6 +128,8 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) {
ERR_FAIL_COND(blend_points[p_point].node.is_null());
blend_points[p_point].node->disconnect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace2D::_tree_changed));
+ blend_points[p_point].node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_renamed));
+ blend_points[p_point].node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeBlendSpace2D::_animation_node_removed));
for (int i = 0; i < triangles.size(); i++) {
bool erase = false;
@@ -144,6 +152,8 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) {
blend_points[i] = blend_points[i + 1];
}
blend_points_used--;
+
+ emit_signal(SNAME("animation_node_removed"), get_instance_id(), itos(p_point));
emit_signal(SNAME("tree_changed"));
}
@@ -598,10 +608,6 @@ Ref<AnimationNode> AnimationNodeBlendSpace2D::get_child_by_name(const StringName
return get_blend_point_node(p_name.operator String().to_int());
}
-void AnimationNodeBlendSpace2D::_tree_changed() {
- emit_signal(SNAME("tree_changed"));
-}
-
void AnimationNodeBlendSpace2D::set_blend_mode(BlendMode p_blend_mode) {
blend_mode = p_blend_mode;
}
@@ -618,6 +624,18 @@ bool AnimationNodeBlendSpace2D::is_using_sync() const {
return sync;
}
+void AnimationNodeBlendSpace2D::_tree_changed() {
+ AnimationRootNode::_tree_changed();
+}
+
+void AnimationNodeBlendSpace2D::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
+ AnimationRootNode::_animation_node_renamed(p_oid, p_old_name, p_new_name);
+}
+
+void AnimationNodeBlendSpace2D::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
+ AnimationRootNode::_animation_node_removed(p_oid, p_node);
+}
+
void AnimationNodeBlendSpace2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_blend_point", "node", "pos", "at_index"), &AnimationNodeBlendSpace2D::add_blend_point, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_blend_point_position", "point", "pos"), &AnimationNodeBlendSpace2D::set_blend_point_position);
diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h
index 044c93d9f6..a770bf01ee 100644
--- a/scene/animation/animation_blend_space_2d.h
+++ b/scene/animation/animation_blend_space_2d.h
@@ -85,14 +85,15 @@ protected:
void _update_triangles();
void _queue_auto_triangles();
- void _tree_changed();
-
-protected:
bool sync = false;
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
+ virtual void _tree_changed() override;
+ virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;
+ virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;
+
public:
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 797999625b..3fe46b380f 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -518,7 +518,7 @@ void AnimationNodeBlend2::get_parameter_list(List<PropertyInfo> *r_list) const {
}
Variant AnimationNodeBlend2::get_parameter_default_value(const StringName &p_parameter) const {
- return 0; //for blend amount
+ return 0; // For blend amount.
}
String AnimationNodeBlend2::get_caption() const {
@@ -531,7 +531,7 @@ double AnimationNodeBlend2::process(double p_time, bool p_seek, bool p_is_extern
double rem0 = blend_input(0, p_time, p_seek, p_is_external_seeking, 1.0 - amount, FILTER_BLEND, sync);
double rem1 = blend_input(1, p_time, p_seek, p_is_external_seeking, amount, FILTER_PASS, sync);
- return amount > 0.5 ? rem1 : rem0; //hacky but good enough
+ return amount > 0.5 ? rem1 : rem0; // Hacky but good enough.
}
bool AnimationNodeBlend2::has_filter() const {
@@ -553,7 +553,7 @@ void AnimationNodeBlend3::get_parameter_list(List<PropertyInfo> *r_list) const {
}
Variant AnimationNodeBlend3::get_parameter_default_value(const StringName &p_parameter) const {
- return 0; //for blend amount
+ return 0; // For blend amount.
}
String AnimationNodeBlend3::get_caption() const {
@@ -566,7 +566,7 @@ double AnimationNodeBlend3::process(double p_time, bool p_seek, bool p_is_extern
double rem1 = blend_input(1, p_time, p_seek, p_is_external_seeking, 1.0 - ABS(amount), FILTER_IGNORE, sync);
double rem2 = blend_input(2, p_time, p_seek, p_is_external_seeking, MAX(0, amount), FILTER_IGNORE, sync);
- return amount > 0.5 ? rem2 : (amount < -0.5 ? rem0 : rem1); //hacky but good enough
+ return amount > 0.5 ? rem2 : (amount < -0.5 ? rem0 : rem1); // Hacky but good enough.
}
void AnimationNodeBlend3::_bind_methods() {
@@ -585,7 +585,7 @@ void AnimationNodeTimeScale::get_parameter_list(List<PropertyInfo> *r_list) cons
}
Variant AnimationNodeTimeScale::get_parameter_default_value(const StringName &p_parameter) const {
- return 1.0; //initial timescale
+ return 1.0; // Initial timescale.
}
String AnimationNodeTimeScale::get_caption() const {
@@ -611,24 +611,24 @@ AnimationNodeTimeScale::AnimationNodeTimeScale() {
////////////////////////////////////
void AnimationNodeTimeSeek::get_parameter_list(List<PropertyInfo> *r_list) const {
- r_list->push_back(PropertyInfo(Variant::FLOAT, seek_pos, PROPERTY_HINT_RANGE, "-1,3600,0.01,or_greater"));
+ r_list->push_back(PropertyInfo(Variant::FLOAT, seek_pos_request, PROPERTY_HINT_RANGE, "-1,3600,0.01,or_greater")); // It will be reset to -1 after seeking the position immediately.
}
Variant AnimationNodeTimeSeek::get_parameter_default_value(const StringName &p_parameter) const {
- return 1.0; //initial timescale
+ return -1.0; // Initial seek request.
}
String AnimationNodeTimeSeek::get_caption() const {
- return "Seek";
+ return "TimeSeek";
}
double AnimationNodeTimeSeek::process(double p_time, bool p_seek, bool p_is_external_seeking) {
- double cur_seek_pos = get_parameter(seek_pos);
+ double cur_seek_pos = get_parameter(seek_pos_request);
if (p_seek) {
return blend_input(0, p_time, true, p_is_external_seeking, 1.0, FILTER_IGNORE, true);
} else if (cur_seek_pos >= 0) {
double ret = blend_input(0, cur_seek_pos, true, true, 1.0, FILTER_IGNORE, true);
- set_parameter(seek_pos, -1.0); //reset
+ set_parameter(seek_pos_request, -1.0); // Reset.
return ret;
} else {
return blend_input(0, p_time, false, p_is_external_seeking, 1.0, FILTER_IGNORE, true);
@@ -721,12 +721,10 @@ void AnimationNodeTransition::get_parameter_list(List<PropertyInfo> *r_list) con
Variant AnimationNodeTransition::get_parameter_default_value(const StringName &p_parameter) const {
if (p_parameter == time || p_parameter == prev_xfading) {
return 0.0;
- } else if (p_parameter == prev_index) {
+ } else if (p_parameter == prev_index || p_parameter == current_index) {
return -1;
- } else if (p_parameter == transition_request || p_parameter == current_state) {
- return String();
} else {
- return 0;
+ return String();
}
}
@@ -748,6 +746,10 @@ void AnimationNodeTransition::set_input_count(int p_inputs) {
while (get_input_count() > p_inputs) {
remove_input(get_input_count() - 1);
}
+
+ pending_update = true;
+
+ emit_signal(SNAME("tree_changed")); // For updating connect activity map.
notify_property_list_changed();
}
@@ -764,6 +766,11 @@ void AnimationNodeTransition::remove_input(int p_index) {
AnimationNode::remove_input(p_index);
}
+bool AnimationNodeTransition::set_input_name(int p_input, const String &p_name) {
+ pending_update = true;
+ return AnimationNode::set_input_name(p_input, p_name);
+}
+
void AnimationNodeTransition::set_input_as_auto_advance(int p_input, bool p_enable) {
ERR_FAIL_INDEX(p_input, get_input_count());
input_data.write[p_input].auto_advance = p_enable;
@@ -819,6 +826,22 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
bool switched = false;
bool restart = false;
+ if (pending_update) {
+ if (cur_current_index < 0 || cur_current_index >= get_input_count()) {
+ set_parameter(prev_index, -1);
+ if (get_input_count() > 0) {
+ set_parameter(current_index, 0);
+ set_parameter(current_state, get_input_name(0));
+ } else {
+ set_parameter(current_index, -1);
+ set_parameter(current_state, StringName());
+ }
+ } else {
+ set_parameter(current_state, get_input_name(cur_current_index));
+ }
+ pending_update = false;
+ }
+
if (!cur_transition_request.is_empty()) {
int new_idx = find_input(cur_transition_request);
if (new_idx >= 0) {
@@ -871,7 +894,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
}
}
- if (cur_prev_index < 0) { // process current animation, check for transition
+ if (cur_prev_index < 0) { // Process current animation, check for transition.
rem = blend_input(cur_current_index, p_time, p_seek, p_is_external_seeking, 1.0, FILTER_IGNORE, true);
@@ -885,7 +908,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
set_parameter(transition_request, get_input_name((cur_current_index + 1) % get_input_count()));
}
- } else { // cross-fading from prev to current
+ } else { // Cross-fading from prev to current.
real_t blend = xfade_time == 0 ? 0 : (cur_prev_xfading / xfade_time);
if (xfade_curve.is_valid()) {
@@ -894,7 +917,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
// Blend values must be more than CMP_EPSILON to process discrete keys in edge.
real_t blend_inv = 1.0 - blend;
- if (input_data[cur_current_index].reset && !p_seek && switched) { //just switched, seek to start of current
+ if (input_data[cur_current_index].reset && !p_seek && switched) { // Just switched, seek to start of current.
rem = blend_input(cur_current_index, 0, true, p_is_external_seeking, Math::is_zero_approx(blend_inv) ? CMP_EPSILON : blend_inv, FILTER_IGNORE, true);
} else {
rem = blend_input(cur_current_index, p_time, p_seek, p_is_external_seeking, Math::is_zero_approx(blend_inv) ? CMP_EPSILON : blend_inv, FILTER_IGNORE, true);
@@ -985,6 +1008,8 @@ void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNod
emit_signal(SNAME("tree_changed"));
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendTree::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ p_node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendTree::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ p_node->connect("animation_node_removed", callable_mp(this, &AnimationNodeBlendTree::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
p_node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed).bind(p_name), CONNECT_REFERENCE_COUNTED);
}
@@ -1047,12 +1072,14 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
{
Ref<AnimationNode> node = nodes[p_name].node;
node->disconnect("tree_changed", callable_mp(this, &AnimationNodeBlendTree::_tree_changed));
+ node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeBlendTree::_animation_node_renamed));
+ node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeBlendTree::_animation_node_removed));
node->disconnect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed));
}
nodes.erase(p_name);
- //erase connections to name
+ // Erase connections to name.
for (KeyValue<StringName, Node> &E : nodes) {
for (int i = 0; i < E.value.connections.size(); i++) {
if (E.value.connections[i] == p_name) {
@@ -1061,6 +1088,7 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
}
}
+ emit_signal(SNAME("animation_node_removed"), get_instance_id(), p_name);
emit_changed();
emit_signal(SNAME("tree_changed"));
}
@@ -1076,7 +1104,7 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN
nodes[p_new_name] = nodes[p_name];
nodes.erase(p_name);
- //rename connections
+ // Rename connections.
for (KeyValue<StringName, Node> &E : nodes) {
for (int i = 0; i < E.value.connections.size(); i++) {
if (E.value.connections[i] == p_name) {
@@ -1084,9 +1112,10 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN
}
}
}
- //connection must be done with new name
+ // Connection must be done with new name.
nodes[p_new_name].node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed).bind(p_new_name), CONNECT_REFERENCE_COUNTED);
+ emit_signal(SNAME("animation_node_renamed"), get_instance_id(), p_name, p_new_name);
emit_signal(SNAME("tree_changed"));
}
@@ -1287,6 +1316,18 @@ void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) cons
p_list->push_back(PropertyInfo(Variant::ARRAY, "node_connections", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
}
+void AnimationNodeBlendTree::_tree_changed() {
+ AnimationRootNode::_tree_changed();
+}
+
+void AnimationNodeBlendTree::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
+ AnimationRootNode::_animation_node_renamed(p_oid, p_old_name, p_new_name);
+}
+
+void AnimationNodeBlendTree::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
+ AnimationRootNode::_animation_node_removed(p_oid, p_node);
+}
+
void AnimationNodeBlendTree::reset_state() {
graph_offset = Vector2();
nodes.clear();
@@ -1295,10 +1336,6 @@ void AnimationNodeBlendTree::reset_state() {
emit_signal(SNAME("tree_changed"));
}
-void AnimationNodeBlendTree::_tree_changed() {
- emit_signal(SNAME("tree_changed"));
-}
-
void AnimationNodeBlendTree::_node_changed(const StringName &p_node) {
ERR_FAIL_COND(!nodes.has(p_node));
nodes[p_node].connections.resize(nodes[p_node].node->get_input_count());
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 20f8e9b190..d4827180bb 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -257,7 +257,7 @@ public:
class AnimationNodeTimeSeek : public AnimationNode {
GDCLASS(AnimationNodeTimeSeek, AnimationNode);
- StringName seek_pos = PNAME("seek_position");
+ StringName seek_pos_request = PNAME("seek_request");
protected:
static void _bind_methods();
@@ -296,6 +296,8 @@ class AnimationNodeTransition : public AnimationNodeSync {
Ref<Curve> xfade_curve;
bool allow_transition_to_self = false;
+ bool pending_update = false;
+
protected:
bool _get(const StringName &p_path, Variant &r_ret) const;
bool _set(const StringName &p_path, const Variant &p_value);
@@ -313,6 +315,7 @@ public:
virtual bool add_input(const String &p_name) override;
virtual void remove_input(int p_index) override;
+ virtual bool set_input_name(int p_input, const String &p_name) override;
void set_input_as_auto_advance(int p_input, bool p_enable);
bool is_input_set_as_auto_advance(int p_input) const;
@@ -358,7 +361,6 @@ class AnimationNodeBlendTree : public AnimationRootNode {
Vector2 graph_offset;
- void _tree_changed();
void _node_changed(const StringName &p_node);
void _initialize_node_tree();
@@ -369,6 +371,10 @@ protected:
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
+ virtual void _tree_changed() override;
+ virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;
+ virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;
+
virtual void reset_state() override;
public:
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index ec28a5cca1..d19d3cc7a3 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -791,6 +791,8 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation
emit_signal(SNAME("tree_changed"));
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ p_node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ p_node->connect("animation_node_removed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
}
void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<AnimationNode> p_node) {
@@ -802,6 +804,8 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima
Ref<AnimationNode> node = states[p_name].node;
if (node.is_valid()) {
node->disconnect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed));
+ node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_renamed));
+ node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_removed));
}
}
@@ -811,6 +815,8 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima
emit_signal(SNAME("tree_changed"));
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), CONNECT_REFERENCE_COUNTED);
+ p_node->connect("animation_node_renamed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_renamed), CONNECT_REFERENCE_COUNTED);
+ p_node->connect("animation_node_removed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_removed), CONNECT_REFERENCE_COUNTED);
}
void AnimationNodeStateMachine::set_allow_transition_to_self(bool p_enable) {
@@ -884,10 +890,13 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) {
Ref<AnimationNode> node = states[p_name].node;
ERR_FAIL_COND(node.is_null());
node->disconnect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed));
+ node->disconnect("animation_node_renamed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_renamed));
+ node->disconnect("animation_node_removed", callable_mp(this, &AnimationNodeStateMachine::_animation_node_removed));
}
states.erase(p_name);
+ emit_signal(SNAME("animation_node_removed"), get_instance_id(), p_name);
emit_changed();
emit_signal(SNAME("tree_changed"));
}
@@ -907,6 +916,7 @@ void AnimationNodeStateMachine::rename_node(const StringName &p_name, const Stri
_rename_transitions(p_name, p_new_name);
+ emit_signal(SNAME("animation_node_renamed"), get_instance_id(), p_name, p_new_name);
emit_changed();
emit_signal(SNAME("tree_changed"));
}
@@ -1365,7 +1375,15 @@ Vector2 AnimationNodeStateMachine::get_node_position(const StringName &p_name) c
void AnimationNodeStateMachine::_tree_changed() {
emit_changed();
- emit_signal(SNAME("tree_changed"));
+ AnimationRootNode::_tree_changed();
+}
+
+void AnimationNodeStateMachine::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
+ AnimationRootNode::_animation_node_renamed(p_oid, p_old_name, p_new_name);
+}
+
+void AnimationNodeStateMachine::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
+ AnimationRootNode::_animation_node_removed(p_oid, p_node);
}
void AnimationNodeStateMachine::_bind_methods() {
diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h
index 5c2a4d6264..5867b6c65a 100644
--- a/scene/animation/animation_node_state_machine.h
+++ b/scene/animation/animation_node_state_machine.h
@@ -207,7 +207,6 @@ private:
Vector2 graph_offset;
- void _tree_changed();
void _remove_transition(const Ref<AnimationNodeStateMachineTransition> p_transition);
void _rename_transitions(const StringName &p_name, const StringName &p_new_name);
bool _can_connect(const StringName &p_name, Vector<AnimationNodeStateMachine *> p_parents = Vector<AnimationNodeStateMachine *>());
@@ -221,6 +220,10 @@ protected:
void _get_property_list(List<PropertyInfo> *p_list) const;
bool _check_advance_condition(const Ref<AnimationNodeStateMachine> p_state_machine, const Ref<AnimationNodeStateMachineTransition> p_transition) const;
+ virtual void _tree_changed() override;
+ virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;
+ virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;
+
virtual void reset_state() override;
public:
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 2e25d685d6..8087ac6250 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -857,7 +857,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
HashMap<int, TrackNodeCache::PlayingAudioStreamInfo> &map = aa->playing_streams;
// Find stream.
int idx = -1;
- if (p_seeked) {
+ if (p_seeked || p_started) {
idx = a->track_find_key(i, p_time);
// Discard previous stream when seeking.
if (map.has(idx)) {
@@ -866,12 +866,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
}
} else {
List<int> to_play;
- if (p_started) {
- int first_key = a->track_find_key(i, p_prev_time, Animation::FIND_MODE_EXACT);
- if (first_key >= 0) {
- to_play.push_back(first_key);
- }
- }
+
a->track_get_key_indices_in_range(i, p_time, p_delta, &to_play, p_looped_flag);
if (to_play.size()) {
idx = to_play.back()->get();
@@ -888,6 +883,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
double end_ofs = a->audio_track_get_key_end_offset(i, idx);
double len = stream->get_length();
+ if (p_seeked || p_started) {
+ start_ofs += p_time - a->track_get_key_time(i, idx);
+ }
+
if (aa->object->call(SNAME("get_stream")) != aa->audio_stream) {
aa->object->call(SNAME("set_stream"), aa->audio_stream);
aa->audio_stream_playback.unref();
@@ -1286,6 +1285,8 @@ void AnimationPlayer::_animation_process(double p_delta) {
_animation_update_transforms();
if (end_reached) {
+ _clear_audio_streams();
+ _stop_playing_caches(false);
if (queued.size()) {
String old = playback.assigned;
play(queued.front()->get());
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index fa72bbc593..7c2edef1de 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -453,6 +453,8 @@ void AnimationNode::_bind_methods() {
GDVIRTUAL_BIND(_has_filter);
ADD_SIGNAL(MethodInfo("tree_changed"));
+ ADD_SIGNAL(MethodInfo("animation_node_renamed", PropertyInfo(Variant::INT, "object_id"), PropertyInfo(Variant::STRING, "old_name"), PropertyInfo(Variant::STRING, "new_name")));
+ ADD_SIGNAL(MethodInfo("animation_node_removed", PropertyInfo(Variant::INT, "object_id"), PropertyInfo(Variant::STRING, "name")));
BIND_ENUM_CONSTANT(FILTER_IGNORE);
BIND_ENUM_CONSTANT(FILTER_PASS);
@@ -465,15 +467,33 @@ AnimationNode::AnimationNode() {
////////////////////
+void AnimationRootNode::_tree_changed() {
+ emit_signal(SNAME("tree_changed"));
+}
+
+void AnimationRootNode::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
+ emit_signal(SNAME("animation_node_renamed"), p_oid, p_old_name, p_new_name);
+}
+
+void AnimationRootNode::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
+ emit_signal(SNAME("animation_node_removed"), p_oid, p_node);
+}
+
+////////////////////
+
void AnimationTree::set_tree_root(const Ref<AnimationNode> &p_root) {
if (root.is_valid()) {
root->disconnect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed));
+ root->disconnect("animation_node_renamed", callable_mp(this, &AnimationTree::_animation_node_renamed));
+ root->disconnect("animation_node_removed", callable_mp(this, &AnimationTree::_animation_node_removed));
}
root = p_root;
if (root.is_valid()) {
root->connect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed));
+ root->connect("animation_node_renamed", callable_mp(this, &AnimationTree::_animation_node_renamed));
+ root->connect("animation_node_removed", callable_mp(this, &AnimationTree::_animation_node_removed));
}
properties_dirty = true;
@@ -1546,6 +1566,10 @@ void AnimationTree::_process_graph(double p_delta) {
double end_ofs = a->audio_track_get_key_end_offset(i, idx);
double len = stream->get_length();
+ if (seeked) {
+ start_ofs += time - a->track_get_key_time(i, idx);
+ }
+
if (t->object->call(SNAME("get_stream")) != t->audio_stream) {
t->object->call(SNAME("set_stream"), t->audio_stream);
t->audio_stream_playback.unref();
@@ -1982,11 +2006,46 @@ void AnimationTree::_tree_changed() {
properties_dirty = true;
}
+void AnimationTree::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
+ ERR_FAIL_COND(!property_reference_map.has(p_oid));
+ String base_path = property_reference_map[p_oid];
+ String old_base = base_path + p_old_name;
+ String new_base = base_path + p_new_name;
+ for (const PropertyInfo &E : properties) {
+ if (E.name.begins_with(old_base)) {
+ String new_name = E.name.replace_first(old_base, new_base);
+ property_map[new_name] = property_map[E.name];
+ property_map.erase(E.name);
+ }
+ }
+
+ //update tree second
+ properties_dirty = true;
+ _update_properties();
+}
+
+void AnimationTree::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
+ ERR_FAIL_COND(!property_reference_map.has(p_oid));
+ String base_path = String(property_reference_map[p_oid]) + String(p_node);
+ for (const PropertyInfo &E : properties) {
+ if (E.name.begins_with(base_path)) {
+ property_map.erase(E.name);
+ }
+ }
+
+ //update tree second
+ properties_dirty = true;
+ _update_properties();
+}
+
void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node) {
ERR_FAIL_COND(node.is_null());
if (!property_parent_map.has(p_base_path)) {
property_parent_map[p_base_path] = HashMap<StringName, StringName>();
}
+ if (!property_reference_map.has(node->get_instance_id())) {
+ property_reference_map[node->get_instance_id()] = p_base_path;
+ }
if (node->get_input_count() && !input_activity_map.has(p_base_path)) {
Vector<Activity> activity;
@@ -2032,6 +2091,7 @@ void AnimationTree::_update_properties() {
}
properties.clear();
+ property_reference_map.clear();
property_parent_map.clear();
input_activity_map.clear();
input_activity_map_get.clear();
@@ -2084,20 +2144,6 @@ void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) {
- //rename values first
- for (const PropertyInfo &E : properties) {
- if (E.name.begins_with(p_base)) {
- String new_name = E.name.replace_first(p_base, p_new_base);
- property_map[new_name] = property_map[E.name];
- }
- }
-
- //update tree second
- properties_dirty = true;
- _update_properties();
-}
-
real_t AnimationTree::get_connection_activity(const StringName &p_path, int p_connection) const {
if (!input_activity_map_get.has(p_path)) {
return 0;
@@ -2143,8 +2189,6 @@ void AnimationTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_properties"), &AnimationTree::_update_properties);
- ClassDB::bind_method(D_METHOD("rename_parameter", "old_name", "new_name"), &AnimationTree::rename_parameter);
-
ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationTree::advance);
GDVIRTUAL_BIND(_post_process_key_value, "animation", "track", "value", "object", "object_idx");
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index a6fb4a8430..0540add85b 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -167,6 +167,11 @@ VARIANT_ENUM_CAST(AnimationNode::FilterAction)
class AnimationRootNode : public AnimationNode {
GDCLASS(AnimationRootNode, AnimationNode);
+protected:
+ virtual void _tree_changed();
+ virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name);
+ virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node);
+
public:
AnimationRootNode() {}
};
@@ -326,9 +331,12 @@ private:
friend class AnimationNode;
bool properties_dirty = true;
void _tree_changed();
+ void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name);
+ void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node);
void _update_properties();
List<PropertyInfo> properties;
HashMap<StringName, HashMap<StringName, StringName>> property_parent_map;
+ HashMap<ObjectID, StringName> property_reference_map;
HashMap<StringName, Pair<Variant, bool>> property_map; // Property value and read-only flag.
struct Activity {
@@ -389,8 +397,6 @@ public:
real_t get_connection_activity(const StringName &p_path, int p_connection) const;
void advance(double p_time);
- void rename_parameter(const String &p_base, const String &p_new_base);
-
uint64_t get_last_process_pass() const;
AnimationTree();
~AnimationTree();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 6f5e2cf058..ec75fcb665 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -644,8 +644,10 @@ Rect2 Control::get_parent_anchorable_rect() const {
parent_rect = data.parent_canvas_item->get_anchorable_rect();
} else {
#ifdef TOOLS_ENABLED
- Node *edited_root = get_tree()->get_edited_scene_root();
- if (edited_root && (this == edited_root || edited_root->is_ancestor_of(this))) {
+ Node *edited_scene_root = get_tree()->get_edited_scene_root();
+ Node *scene_root_parent = edited_scene_root ? edited_scene_root->get_parent() : nullptr;
+
+ if (scene_root_parent && get_viewport() == scene_root_parent->get_viewport()) {
parent_rect.size = Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height"));
} else {
parent_rect = get_viewport()->get_visible_rect();
@@ -692,7 +694,7 @@ Transform2D Control::get_transform() const {
return xform;
}
-void Control::_toplevel_changed_on_parent() {
+void Control::_top_level_changed_on_parent() {
// Update root control status.
_notification(NOTIFICATION_EXIT_CANVAS);
_notification(NOTIFICATION_ENTER_CANVAS);
@@ -3390,7 +3392,7 @@ void Control::_bind_methods() {
ADD_SIGNAL(MethodInfo("minimum_size_changed"));
ADD_SIGNAL(MethodInfo("theme_changed"));
- GDVIRTUAL_BIND(_has_point, "position");
+ GDVIRTUAL_BIND(_has_point, "point");
GDVIRTUAL_BIND(_structured_text_parser, "args", "text");
GDVIRTUAL_BIND(_get_minimum_size);
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 5977f4dbea..2fb5d559b6 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -292,8 +292,8 @@ private:
void _update_minimum_size();
void _size_changed();
- void _toplevel_changed() override{}; // Controls don't need to do anything, only other CanvasItems.
- void _toplevel_changed_on_parent() override;
+ void _top_level_changed() override {} // Controls don't need to do anything, only other CanvasItems.
+ void _top_level_changed_on_parent() override;
void _clear_size_warning();
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index dba08e16cb..16a718722c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -84,6 +84,7 @@ void LineEdit::_move_caret_left(bool p_select, bool p_move_by_word) {
}
shift_selection_check_post(p_select);
+ _reset_caret_blink_timer();
}
void LineEdit::_move_caret_right(bool p_select, bool p_move_by_word) {
@@ -116,6 +117,7 @@ void LineEdit::_move_caret_right(bool p_select, bool p_move_by_word) {
}
shift_selection_check_post(p_select);
+ _reset_caret_blink_timer();
}
void LineEdit::_move_caret_start(bool p_select) {
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 027c97b383..dc1d6cc73e 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -491,9 +491,11 @@ void OptionButton::show_popup() {
return;
}
- Size2 button_size = get_global_transform_with_canvas().get_scale() * get_size();
- popup->set_position(get_screen_position() + Size2(0, button_size.height));
- popup->set_size(Size2i(button_size.width, 0));
+ Rect2 rect = get_screen_rect();
+ rect.position.y += rect.size.height;
+ rect.size.height = 0;
+ popup->set_position(rect.position);
+ popup->set_size(rect.size);
// If not triggered by the mouse, start the popup with the checked item (or the first enabled one) focused.
if (current != NONE_SELECTED && !popup->is_item_disabled(current)) {
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 3051502dd0..f9c9906efa 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -2031,7 +2031,7 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) {
}
}
if (b->get_button_index() == MouseButton::RIGHT && context_menu_enabled) {
- _generate_context_menu();
+ _update_context_menu();
menu->set_position(get_screen_position() + b->get_position());
menu->reset_size();
menu->popup();
@@ -2090,7 +2090,7 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) {
}
if (k->is_action("ui_menu", true)) {
if (context_menu_enabled) {
- _generate_context_menu();
+ _update_context_menu();
menu->set_position(get_screen_position());
menu->reset_size();
menu->popup();
@@ -4992,7 +4992,9 @@ bool RichTextLabel::is_shortcut_keys_enabled() const {
// Context menu.
PopupMenu *RichTextLabel::get_menu() const {
- const_cast<RichTextLabel *>(this)->_generate_context_menu();
+ if (!menu) {
+ const_cast<RichTextLabel *>(this)->_generate_context_menu();
+ }
return menu;
}
@@ -5466,6 +5468,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_menu"), &RichTextLabel::get_menu);
ClassDB::bind_method(D_METHOD("is_menu_visible"), &RichTextLabel::is_menu_visible);
+ ClassDB::bind_method(D_METHOD("menu_option", "option"), &RichTextLabel::menu_option);
ClassDB::bind_method(D_METHOD("_thread_end"), &RichTextLabel::_thread_end);
@@ -5544,6 +5547,10 @@ void RichTextLabel::_bind_methods() {
BIND_ENUM_CONSTANT(ITEM_HINT);
BIND_ENUM_CONSTANT(ITEM_DROPCAP);
BIND_ENUM_CONSTANT(ITEM_CUSTOMFX);
+
+ BIND_ENUM_CONSTANT(MENU_COPY);
+ BIND_ENUM_CONSTANT(MENU_SELECT_ALL);
+ BIND_ENUM_CONSTANT(MENU_MAX);
}
TextServer::VisibleCharactersBehavior RichTextLabel::get_visible_characters_behavior() const {
@@ -5675,19 +5682,32 @@ Size2 RichTextLabel::get_minimum_size() const {
// Context menu.
void RichTextLabel::_generate_context_menu() {
- if (!menu) {
- menu = memnew(PopupMenu);
- add_child(menu, false, INTERNAL_MODE_FRONT);
+ menu = memnew(PopupMenu);
+ add_child(menu, false, INTERNAL_MODE_FRONT);
+ menu->connect("id_pressed", callable_mp(this, &RichTextLabel::menu_option));
+
+ menu->add_item(RTR("Copy"), MENU_COPY);
+ menu->add_item(RTR("Select All"), MENU_SELECT_ALL);
+}
- menu->connect("id_pressed", callable_mp(this, &RichTextLabel::_menu_option));
+void RichTextLabel::_update_context_menu() {
+ if (!menu) {
+ _generate_context_menu();
}
- // Reorganize context menu.
- menu->clear();
- if (selection.enabled) {
- menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_copy") : Key::NONE);
- menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_text_select_all") : Key::NONE);
+ int idx = -1;
+
+#define MENU_ITEM_ACTION_DISABLED(m_menu, m_id, m_action, m_disabled) \
+ idx = m_menu->get_item_index(m_id); \
+ if (idx >= 0) { \
+ m_menu->set_item_accelerator(idx, shortcut_keys_enabled ? _get_menu_action_accelerator(m_action) : Key::NONE); \
+ m_menu->set_item_disabled(idx, m_disabled); \
}
+
+ MENU_ITEM_ACTION_DISABLED(menu, MENU_COPY, "ui_copy", !selection.enabled)
+ MENU_ITEM_ACTION_DISABLED(menu, MENU_SELECT_ALL, "ui_text_select_all", !selection.enabled)
+
+#undef MENU_ITEM_ACTION_DISABLED
}
Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) {
@@ -5715,7 +5735,7 @@ Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) {
}
}
-void RichTextLabel::_menu_option(int p_option) {
+void RichTextLabel::menu_option(int p_option) {
switch (p_option) {
case MENU_COPY: {
selection_copy();
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index fcbb91f67e..b01fccf14c 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -81,6 +81,7 @@ public:
enum MenuItems {
MENU_COPY,
MENU_SELECT_ALL,
+ MENU_MAX
};
enum DefaultFont {
@@ -454,8 +455,8 @@ private:
// Context menu.
PopupMenu *menu = nullptr;
void _generate_context_menu();
+ void _update_context_menu();
Key _get_menu_action_accelerator(const String &p_action);
- void _menu_option(int p_option);
int visible_characters = -1;
float visible_ratio = 1.0;
@@ -688,6 +689,7 @@ public:
// Context menu.
PopupMenu *get_menu() const;
bool is_menu_visible() const;
+ void menu_option(int p_option);
void parse_bbcode(const String &p_bbcode);
void append_text(const String &p_bbcode);
@@ -739,5 +741,6 @@ public:
VARIANT_ENUM_CAST(RichTextLabel::ListType);
VARIANT_ENUM_CAST(RichTextLabel::ItemType);
+VARIANT_ENUM_CAST(RichTextLabel::MenuItems);
#endif // RICH_TEXT_LABEL_H
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index ead9550b93..0c0125df76 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -115,7 +115,7 @@ void SplitContainerDragger::_notification(int p_what) {
return;
}
- Ref<Texture2D> tex = sc->get_theme_icon(SNAME("grabber"));
+ Ref<Texture2D> tex = sc->_get_grabber_icon();
draw_texture(tex, (get_size() - tex->get_size()) / 2);
} break;
}
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 541c7a0587..906b478eb3 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -185,7 +185,7 @@ void CanvasItem::_top_level_raise_self() {
}
void CanvasItem::_enter_canvas() {
- // Resolves to nullptr if the node is toplevel.
+ // Resolves to nullptr if the node is top_level.
CanvasItem *parent_item = get_parent_item();
if (parent_item) {
@@ -400,26 +400,26 @@ void CanvasItem::set_as_top_level(bool p_top_level) {
_exit_canvas();
top_level = p_top_level;
- _toplevel_changed();
+ _top_level_changed();
_enter_canvas();
_notify_transform();
}
-void CanvasItem::_toplevel_changed() {
- // Inform children that toplevel status has changed on a parent.
+void CanvasItem::_top_level_changed() {
+ // Inform children that top_level status has changed on a parent.
int children = get_child_count();
for (int i = 0; i < children; i++) {
CanvasItem *child = Object::cast_to<CanvasItem>(get_child(i));
if (child) {
- child->_toplevel_changed_on_parent();
+ child->_top_level_changed_on_parent();
}
}
}
-void CanvasItem::_toplevel_changed_on_parent() {
- // Inform children that toplevel status has changed on a parent.
- _toplevel_changed();
+void CanvasItem::_top_level_changed_on_parent() {
+ // Inform children that top_level status has changed on a parent.
+ _top_level_changed();
}
bool CanvasItem::is_set_as_top_level() const {
@@ -491,6 +491,17 @@ int CanvasItem::get_z_index() const {
return z_index;
}
+int CanvasItem::get_effective_z_index() const {
+ int effective_z_index = z_index;
+ if (is_z_relative()) {
+ CanvasItem *p = get_parent_item();
+ if (p) {
+ effective_z_index += p->get_effective_z_index();
+ }
+ }
+ return effective_z_index;
+}
+
void CanvasItem::set_y_sort_enabled(bool p_enabled) {
y_sort_enabled = p_enabled;
RS::get_singleton()->canvas_item_set_sort_children_by_y(canvas_item, y_sort_enabled);
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index 1ddfaa288c..5fbf043159 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -125,8 +125,8 @@ private:
void _propagate_visibility_changed(bool p_parent_visible_in_tree);
void _handle_visibility_change(bool p_visible);
- virtual void _toplevel_changed();
- virtual void _toplevel_changed_on_parent();
+ virtual void _top_level_changed();
+ virtual void _top_level_changed_on_parent();
void _redraw_callback();
@@ -246,6 +246,7 @@ public:
void set_z_index(int p_z);
int get_z_index() const;
+ int get_effective_z_index() const;
void set_z_as_relative(bool p_enabled);
bool is_z_relative() const;
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index ba75c92c85..52c1df8110 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2135,13 +2135,13 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c
} else if ((p_flags & DUPLICATE_USE_INSTANTIATION) && !get_scene_file_path().is_empty()) {
Ref<PackedScene> res = ResourceLoader::load(get_scene_file_path());
ERR_FAIL_COND_V(res.is_null(), nullptr);
- PackedScene::GenEditState ges = PackedScene::GEN_EDIT_STATE_DISABLED;
+ PackedScene::GenEditState edit_state = PackedScene::GEN_EDIT_STATE_DISABLED;
#ifdef TOOLS_ENABLED
if (p_flags & DUPLICATE_FROM_EDITOR) {
- ges = PackedScene::GEN_EDIT_STATE_INSTANCE;
+ edit_state = PackedScene::GEN_EDIT_STATE_INSTANCE;
}
#endif
- node = res->instantiate(ges);
+ node = res->instantiate(edit_state);
ERR_FAIL_COND_V(!node, nullptr);
node->set_scene_instance_load_placeholder(get_scene_instance_load_placeholder());
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index c31155bd5c..cbb34a480b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -36,6 +36,7 @@
#include "core/object/message_queue.h"
#include "core/string/translation.h"
#include "core/templates/pair.h"
+#include "core/templates/sort_array.h"
#include "scene/2d/audio_listener_2d.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/collision_object_2d.h"
@@ -524,7 +525,7 @@ void Viewport::_process_picking() {
if (!physics_object_picking) {
return;
}
- if (to_screen_rect != Rect2i() && Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
+ if (Object::cast_to<Window>(this) && Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
return;
}
if (!gui.mouse_in_viewport) {
@@ -613,7 +614,7 @@ void Viewport::_process_picking() {
physics_last_mouse_state.mouse_mask.clear_flag(mouse_button_to_mask(mb->get_button_index()));
// If touch mouse raised, assume we don't know last mouse pos until new events come
- if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) {
+ if (mb->get_device() == InputEvent::DEVICE_ID_EMULATION) {
physics_has_last_mousepos = false;
}
}
@@ -669,6 +670,25 @@ void Viewport::_process_picking() {
point_params.pick_point = true;
int rc = ss2d->intersect_point(point_params, res, 64);
+ if (physics_object_picking_sort) {
+ struct ComparatorCollisionObjects {
+ bool operator()(const PhysicsDirectSpaceState2D::ShapeResult &p_a, const PhysicsDirectSpaceState2D::ShapeResult &p_b) const {
+ CollisionObject2D *a = Object::cast_to<CollisionObject2D>(p_a.collider);
+ CollisionObject2D *b = Object::cast_to<CollisionObject2D>(p_b.collider);
+ if (!a || !b) {
+ return false;
+ }
+ int za = a->get_effective_z_index();
+ int zb = b->get_effective_z_index();
+ if (za != zb) {
+ return zb < za;
+ }
+ return a->is_greater_than(b);
+ }
+ };
+ SortArray<PhysicsDirectSpaceState2D::ShapeResult, ComparatorCollisionObjects> sorter;
+ sorter.sort(res, rc);
+ }
for (int i = 0; i < rc; i++) {
if (res[i].collider_id.is_valid() && res[i].collider) {
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(res[i].collider);
@@ -796,14 +816,14 @@ void Viewport::update_canvas_items() {
_update_canvas_items(this);
}
-void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, bool p_allocated) {
+void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated) {
Transform2D stretch_transform_new = Transform2D();
if (is_size_2d_override_stretch_enabled() && p_size_2d_override.width > 0 && p_size_2d_override.height > 0) {
Size2 scale = Size2(p_size) / Size2(p_size_2d_override);
stretch_transform_new.scale(scale);
}
- if (size == p_size && size_allocated == p_allocated && stretch_transform == stretch_transform_new && p_size_2d_override == size_2d_override && to_screen_rect == p_to_screen_rect) {
+ if (size == p_size && size_allocated == p_allocated && stretch_transform == stretch_transform_new && p_size_2d_override == size_2d_override) {
return;
}
@@ -811,7 +831,6 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override,
size_allocated = p_allocated;
size_2d_override = p_size_2d_override;
stretch_transform = stretch_transform_new;
- to_screen_rect = p_to_screen_rect;
#ifndef _3D_DISABLED
if (!use_xr) {
@@ -1053,7 +1072,7 @@ Camera2D *Viewport::get_camera_2d() const {
}
Transform2D Viewport::get_final_transform() const {
- return _get_input_pre_xform().affine_inverse() * stretch_transform * global_canvas_transform;
+ return stretch_transform * global_canvas_transform;
}
void Viewport::assign_next_enabled_camera_2d(const StringName &p_camera_group) {
@@ -1061,10 +1080,14 @@ void Viewport::assign_next_enabled_camera_2d(const StringName &p_camera_group) {
get_tree()->get_nodes_in_group(p_camera_group, &camera_list);
Camera2D *new_camera = nullptr;
- for (const Node *E : camera_list) {
- const Camera2D *cam = Object::cast_to<Camera2D>(E);
+ for (Node *E : camera_list) {
+ Camera2D *cam = Object::cast_to<Camera2D>(E);
+ if (!cam) {
+ continue; // Non-camera node (e.g. ParallaxBackground).
+ }
+
if (cam->is_enabled()) {
- new_camera = const_cast<Camera2D *>(cam);
+ new_camera = cam;
break;
}
}
@@ -1139,14 +1162,6 @@ Viewport::PositionalShadowAtlasQuadrantSubdiv Viewport::get_positional_shadow_at
return positional_shadow_atlas_quadrant_subdiv[p_quadrant];
}
-Transform2D Viewport::_get_input_pre_xform() const {
- const Window *this_window = Object::cast_to<Window>(this);
- if (this_window) {
- return this_window->window_transform.affine_inverse();
- }
- return Transform2D();
-}
-
Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
if (ev.is_null()) {
return ev; // No transformation defined for null event
@@ -1333,7 +1348,7 @@ bool Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
Ref<InputEvent> ev = p_input;
// Returns true if an event should be impacted by a control's mouse filter.
- bool is_mouse_event = Ref<InputEventMouse>(p_input).is_valid();
+ bool is_pointer_event = Ref<InputEventMouse>(p_input).is_valid() || Ref<InputEventScreenDrag>(p_input).is_valid() || Ref<InputEventScreenTouch>(p_input).is_valid();
Ref<InputEventMouseButton> mb = p_input;
bool is_scroll_event = mb.is_valid() &&
@@ -1357,8 +1372,8 @@ bool Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
stopped = true;
break;
}
- if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP && is_mouse_event && !(is_scroll_event && control->data.force_pass_scroll_events)) {
- // Mouse events are stopped by default with MOUSE_FILTER_STOP, unless we have a scroll event and force_pass_scroll_events set to true
+ if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP && is_pointer_event && !(is_scroll_event && control->data.force_pass_scroll_events)) {
+ // Mouse, ScreenDrag and ScreenTouch events are stopped by default with MOUSE_FILTER_STOP, unless we have a scroll event and force_pass_scroll_events set to true
stopped = true;
break;
}
@@ -2275,6 +2290,7 @@ void Viewport::_drop_mouse_focus() {
mb->set_global_position(c->get_local_mouse_position());
mb->set_button_index(MouseButton(i + 1));
mb->set_pressed(false);
+ mb->set_device(InputEvent::DEVICE_ID_INTERNAL);
c->_call_gui_input(mb);
}
}
@@ -2386,6 +2402,7 @@ void Viewport::_post_gui_grab_click_focus() {
mb->set_position(click);
mb->set_button_index(MouseButton(i + 1));
mb->set_pressed(false);
+ mb->set_device(InputEvent::DEVICE_ID_INTERNAL);
gui.mouse_focus->_call_gui_input(mb);
}
}
@@ -2403,6 +2420,7 @@ void Viewport::_post_gui_grab_click_focus() {
mb->set_position(click);
mb->set_button_index(MouseButton(i + 1));
mb->set_pressed(true);
+ mb->set_device(InputEvent::DEVICE_ID_INTERNAL);
MessageQueue::get_singleton()->push_callable(callable_mp(gui.mouse_focus, &Control::_call_gui_input), mb);
}
}
@@ -2869,6 +2887,14 @@ bool Viewport::get_physics_object_picking() {
return physics_object_picking;
}
+void Viewport::set_physics_object_picking_sort(bool p_enable) {
+ physics_object_picking_sort = p_enable;
+}
+
+bool Viewport::get_physics_object_picking_sort() {
+ return physics_object_picking_sort;
+}
+
Vector2 Viewport::get_camera_coords(const Vector2 &p_viewport_coords) const {
Transform2D xf = stretch_transform * global_canvas_transform;
return xf.xform(p_viewport_coords);
@@ -3803,6 +3829,8 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_physics_object_picking", "enable"), &Viewport::set_physics_object_picking);
ClassDB::bind_method(D_METHOD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
+ ClassDB::bind_method(D_METHOD("set_physics_object_picking_sort", "enable"), &Viewport::set_physics_object_picking_sort);
+ ClassDB::bind_method(D_METHOD("get_physics_object_picking_sort"), &Viewport::get_physics_object_picking_sort);
ClassDB::bind_method(D_METHOD("get_viewport_rid"), &Viewport::get_viewport_rid);
ClassDB::bind_method(D_METHOD("push_text_input", "text"), &Viewport::push_text_input);
@@ -3954,6 +3982,7 @@ void Viewport::_bind_methods() {
#endif
ADD_GROUP("Physics", "physics_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "physics_object_picking"), "set_physics_object_picking", "get_physics_object_picking");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "physics_object_picking_sort"), "set_physics_object_picking_sort", "get_physics_object_picking_sort");
ADD_GROUP("GUI", "gui_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled");
@@ -4143,7 +4172,7 @@ void SubViewport::_internal_set_size(const Size2i &p_size, bool p_force) {
return;
}
- _set_size(p_size, _get_size_2d_override(), Rect2i(), true);
+ _set_size(p_size, _get_size_2d_override(), true);
if (c) {
c->update_minimum_size();
@@ -4155,7 +4184,7 @@ Size2i SubViewport::get_size() const {
}
void SubViewport::set_size_2d_override(const Size2i &p_size) {
- _set_size(_get_size(), p_size, Rect2i(), true);
+ _set_size(_get_size(), p_size, true);
}
Size2i SubViewport::get_size_2d_override() const {
@@ -4168,7 +4197,7 @@ void SubViewport::set_size_2d_override_stretch(bool p_enable) {
}
size_2d_override_stretch = p_enable;
- _set_size(_get_size(), _get_size_2d_override(), Rect2i(), true);
+ _set_size(_get_size(), _get_size_2d_override(), true);
}
bool SubViewport::is_size_2d_override_stretch_enabled() const {
@@ -4208,7 +4237,7 @@ Transform2D SubViewport::get_screen_transform() const {
} else {
WARN_PRINT_ONCE("SubViewport is not a child of a SubViewportContainer. get_screen_transform doesn't return the actual screen position.");
}
- return container_transform * Viewport::get_screen_transform();
+ return container_transform * get_final_transform();
}
Transform2D SubViewport::get_popup_base_transform() const {
@@ -4217,13 +4246,13 @@ Transform2D SubViewport::get_popup_base_transform() const {
}
SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent());
if (!c) {
- return Viewport::get_screen_transform();
+ return get_final_transform();
}
Transform2D container_transform;
if (c->is_stretch_enabled()) {
container_transform.scale(Vector2(c->get_stretch_shrink(), c->get_stretch_shrink()));
}
- return c->get_screen_transform() * container_transform * Viewport::get_screen_transform();
+ return c->get_screen_transform() * container_transform * get_final_transform();
}
void SubViewport::_notification(int p_what) {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 7546838568..4144eaabb9 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -246,6 +246,7 @@ private:
bool snap_2d_vertices_to_pixel = false;
bool physics_object_picking = false;
+ bool physics_object_picking_sort = false;
List<Ref<InputEvent>> physics_picking_events;
ObjectID physics_object_capture;
ObjectID physics_object_over;
@@ -275,7 +276,6 @@ private:
Ref<World2D> world_2d;
- Rect2i to_screen_rect;
StringName input_group;
StringName gui_input_group;
StringName shortcut_input_group;
@@ -408,8 +408,6 @@ private:
void _perform_drop(Control *p_control = nullptr, Point2 p_pos = Point2());
void _gui_cleanup_internal_state(Ref<InputEvent> p_event);
- _FORCE_INLINE_ Transform2D _get_input_pre_xform() const;
-
Ref<InputEvent> _make_input_local(const Ref<InputEvent> &ev);
friend class Control;
@@ -471,7 +469,7 @@ private:
uint64_t event_count = 0;
protected:
- void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, bool p_allocated);
+ void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated);
Size2i _get_size() const;
Size2i _get_size_2d_override() const;
@@ -510,7 +508,7 @@ public:
void set_global_canvas_transform(const Transform2D &p_transform);
Transform2D get_global_canvas_transform() const;
- Transform2D get_final_transform() const;
+ virtual Transform2D get_final_transform() const;
void assign_next_enabled_camera_2d(const StringName &p_camera_group);
void gui_set_root_order_dirty();
@@ -577,6 +575,8 @@ public:
void set_physics_object_picking(bool p_enable);
bool get_physics_object_picking();
+ void set_physics_object_picking_sort(bool p_enable);
+ bool get_physics_object_picking_sort();
Variant gui_get_drag_data() const;
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index b6f1d3f54b..9fcfb29ef7 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -647,6 +647,7 @@ void Window::update_mouse_cursor_shape() {
mm.instantiate();
mm->set_position(pos);
mm->set_global_position(xform.xform(pos));
+ mm->set_device(InputEvent::DEVICE_ID_INTERNAL);
push_input(mm);
}
@@ -1004,7 +1005,7 @@ void Window::_update_viewport_size() {
}
bool allocate = is_inside_tree() && visible && (window_id != DisplayServer::INVALID_WINDOW_ID || embedder != nullptr);
- _set_size(final_size, final_size_override, attach_to_screen_rect, allocate);
+ _set_size(final_size, final_size_override, allocate);
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id);
@@ -2115,13 +2116,17 @@ bool Window::is_auto_translating() const {
return auto_translate;
}
+Transform2D Window::get_final_transform() const {
+ return window_transform * stretch_transform * global_canvas_transform;
+}
+
Transform2D Window::get_screen_transform() const {
Transform2D embedder_transform;
if (_get_embedder()) {
embedder_transform.translate_local(get_position());
embedder_transform = _get_embedder()->get_screen_transform() * embedder_transform;
}
- return embedder_transform * Viewport::get_screen_transform();
+ return embedder_transform * get_final_transform();
}
Transform2D Window::get_popup_base_transform() const {
@@ -2130,7 +2135,7 @@ Transform2D Window::get_popup_base_transform() const {
}
Transform2D popup_base_transform;
popup_base_transform.set_origin(get_position());
- popup_base_transform *= Viewport::get_screen_transform();
+ popup_base_transform *= get_final_transform();
if (_get_embedder()) {
return _get_embedder()->get_popup_base_transform() * popup_base_transform;
}
diff --git a/scene/main/window.h b/scene/main/window.h
index 1730de0b33..9861fefc68 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -376,6 +376,7 @@ public:
//
+ virtual Transform2D get_final_transform() const override;
virtual Transform2D get_screen_transform() const override;
virtual Transform2D get_popup_base_transform() const override;
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index e5a1adff20..0f7985bee6 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -2712,6 +2712,9 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
for (const StringName &E : theme_types) {
if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
+ if (f == this) {
+ continue;
+ }
if (f.is_valid()) {
theme_font = f;
theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
@@ -2729,6 +2732,9 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
for (const StringName &E : theme_types) {
if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
+ if (f == this) {
+ continue;
+ }
if (f.is_valid()) {
theme_font = f;
theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
@@ -2739,11 +2745,13 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
// If they don't exist, use any type to return the default/empty value.
Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName());
- if (f.is_valid()) {
- theme_font = f;
- theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
+ if (f != this) {
+ if (f.is_valid()) {
+ theme_font = f;
+ theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
+ }
+ return f;
}
- return f;
}
return Ref<Font>();
@@ -3061,6 +3069,9 @@ Ref<Font> SystemFont::_get_base_font_or_default() const {
for (const StringName &E : theme_types) {
if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
+ if (f == this) {
+ continue;
+ }
if (f.is_valid()) {
theme_font = f;
theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
@@ -3078,6 +3089,9 @@ Ref<Font> SystemFont::_get_base_font_or_default() const {
for (const StringName &E : theme_types) {
if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
+ if (f == this) {
+ continue;
+ }
if (f.is_valid()) {
theme_font = f;
theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
@@ -3088,11 +3102,13 @@ Ref<Font> SystemFont::_get_base_font_or_default() const {
// If they don't exist, use any type to return the default/empty value.
Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName());
- if (f.is_valid()) {
- theme_font = f;
- theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
+ if (f != this) {
+ if (f.is_valid()) {
+ theme_font = f;
+ theme_font->connect(CoreStringNames::get_singleton()->changed, callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
+ }
+ return f;
}
- return f;
}
return Ref<Font>();
diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp
index 7e1b42c80b..1d13f07b12 100644
--- a/scene/resources/navigation_mesh.cpp
+++ b/scene/resources/navigation_mesh.cpp
@@ -278,7 +278,7 @@ bool NavigationMesh::get_filter_walkable_low_height_spans() const {
void NavigationMesh::set_filter_baking_aabb(const AABB &p_aabb) {
filter_baking_aabb = p_aabb;
- notify_property_list_changed();
+ emit_changed();
}
AABB NavigationMesh::get_filter_baking_aabb() const {
@@ -287,7 +287,7 @@ AABB NavigationMesh::get_filter_baking_aabb() const {
void NavigationMesh::set_filter_baking_aabb_offset(const Vector3 &p_aabb_offset) {
filter_baking_aabb_offset = p_aabb_offset;
- notify_property_list_changed();
+ emit_changed();
}
Vector3 NavigationMesh::get_filter_baking_aabb_offset() const {
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 86ed0001dd..ef1f6459e9 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -257,7 +257,7 @@ void PrimitiveMesh::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, "suffix:m"), "set_custom_aabb", "get_custom_aabb");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "add_uv2"), "set_add_uv2", "get_add_uv2");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "uv2_padding"), "set_uv2_padding", "get_uv2_padding");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "uv2_padding", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), "set_uv2_padding", "get_uv2_padding");
GDVIRTUAL_BIND(_create_mesh_array);
}
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 608d15019e..3006da5309 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -2379,15 +2379,15 @@ Error ResourceFormatSaverText::set_uid(const String &p_path, ResourceUID::ID p_u
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = OK;
{
- Ref<FileAccess> fo = FileAccess::open(p_path, FileAccess::READ);
- if (fo.is_null()) {
+ Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ);
+ if (file.is_null()) {
ERR_FAIL_V(ERR_CANT_OPEN);
}
ResourceLoaderText loader;
loader.local_path = local_path;
loader.res_path = loader.local_path;
- err = loader.set_uid(fo, p_uid);
+ err = loader.set_uid(file, p_uid);
}
if (err == OK) {
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 4132972cb3..3a6d40d22c 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -815,6 +815,8 @@ void VisualShader::remove_node(Type p_type, int p_id) {
if (E->get().from_node == p_id) {
g->nodes[E->get().to_node].prev_connected_nodes.erase(p_id);
g->nodes[E->get().to_node].node->set_input_port_connected(E->get().to_port, false);
+ } else if (E->get().to_node == p_id) {
+ g->nodes[E->get().from_node].next_connected_nodes.erase(p_id);
}
}
E = N;
@@ -981,6 +983,7 @@ void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from
c.to_node = p_to_node;
c.to_port = p_to_port;
g->connections.push_back(c);
+ g->nodes[p_from_node].next_connected_nodes.push_back(p_to_node);
g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node);
g->nodes[p_from_node].node->set_output_port_connected(p_from_port, true);
g->nodes[p_to_node].node->set_input_port_connected(p_to_port, true);
@@ -1014,6 +1017,7 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port,
c.to_node = p_to_node;
c.to_port = p_to_port;
g->connections.push_back(c);
+ g->nodes[p_from_node].next_connected_nodes.push_back(p_to_node);
g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node);
g->nodes[p_from_node].node->set_output_port_connected(p_from_port, true);
g->nodes[p_to_node].node->set_input_port_connected(p_to_port, true);
@@ -1029,6 +1033,7 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por
for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) {
if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) {
g->connections.erase(E);
+ g->nodes[p_from_node].next_connected_nodes.erase(p_to_node);
g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node);
g->nodes[p_from_node].node->set_output_port_connected(p_from_port, false);
g->nodes[p_to_node].node->set_input_port_connected(p_to_port, false);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index fc5e48410b..2838a49209 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -122,7 +122,8 @@ private:
struct Node {
Ref<VisualShaderNode> node;
Vector2 position;
- List<int> prev_connected_nodes;
+ LocalVector<int> prev_connected_nodes;
+ LocalVector<int> next_connected_nodes;
};
struct Graph {
@@ -199,6 +200,16 @@ public: // internal methods
Vector2 get_node_position(Type p_type, int p_id) const;
Ref<VisualShaderNode> get_node(Type p_type, int p_id) const;
+ _FORCE_INLINE_ Ref<VisualShaderNode> get_node_unchecked(Type p_type, int p_id) const {
+ return graph[p_type].nodes[p_id].node;
+ }
+ _FORCE_INLINE_ void get_next_connected_nodes(Type p_type, int p_id, LocalVector<int> &r_list) const {
+ r_list = graph[p_type].nodes[p_id].next_connected_nodes;
+ }
+ _FORCE_INLINE_ void get_prev_connected_nodes(Type p_type, int p_id, LocalVector<int> &r_list) const {
+ r_list = graph[p_type].nodes[p_id].prev_connected_nodes;
+ }
+
Vector<int> get_node_list(Type p_type) const;
int get_valid_node_id(Type p_type) const;
diff --git a/servers/rendering/dummy/storage/light_storage.h b/servers/rendering/dummy/storage/light_storage.h
index 9a3918fd86..b9e8bcc6f1 100644
--- a/servers/rendering/dummy/storage/light_storage.h
+++ b/servers/rendering/dummy/storage/light_storage.h
@@ -80,6 +80,7 @@ public:
virtual RS::LightBakeMode light_get_bake_mode(RID p_light) override { return RS::LIGHT_BAKE_DISABLED; }
virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override { return 0; }
virtual uint64_t light_get_version(RID p_light) const override { return 0; }
+ virtual uint32_t light_get_cull_mask(RID p_light) const override { return 0; }
/* LIGHT INSTANCE API */
diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h
index 41251b348c..67661ce821 100644
--- a/servers/rendering/dummy/storage/texture_storage.h
+++ b/servers/rendering/dummy/storage/texture_storage.h
@@ -145,6 +145,7 @@ public:
virtual void decal_set_normal_fade(RID p_decal, float p_fade) override {}
virtual AABB decal_get_aabb(RID p_decal) const override { return AABB(); }
+ virtual uint32_t decal_get_cull_mask(RID p_decal) const override { return 0; }
virtual void texture_add_to_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override {}
virtual void texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override {}
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index bd8c11186e..f102bc0650 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -2634,6 +2634,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
// Default CanvasGroup shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
@@ -2661,6 +2662,7 @@ void fragment() {
// Default clip children shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index 885ea18151..5776414b14 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -280,7 +280,7 @@ void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderData
for (int i = 1; i < mipmaps; i++) {
RID source = dest;
dest = rb->get_texture_slice(RB_SCOPE_BUFFERS, RB_TEX_BLUR_0, v, i);
- Size2i msize = rb->get_texture_slice_size(RB_SCOPE_BUFFERS, RB_TEX_BLUR_0, v, i);
+ Size2i msize = rb->get_texture_slice_size(RB_SCOPE_BUFFERS, RB_TEX_BLUR_0, i);
if (can_use_storage) {
copy_effects->make_mipmap(source, dest, msize);
@@ -448,7 +448,7 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
float luminance_multiplier = _render_buffers_get_luminance_multiplier();
for (uint32_t l = 0; l < rb->get_view_count(); l++) {
for (int i = 0; i < (max_glow_level + 1); i++) {
- Size2i vp_size = rb->get_texture_slice_size(RB_SCOPE_BUFFERS, RB_TEX_BLUR_1, l, i);
+ Size2i vp_size = rb->get_texture_slice_size(RB_SCOPE_BUFFERS, RB_TEX_BLUR_1, i);
if (i == 0) {
RID luminance_texture;
@@ -502,7 +502,7 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
tonemap.glow_levels[i] = environment_get_glow_levels(p_render_data->environment)[i];
}
- Size2i msize = rb->get_texture_slice_size(RB_SCOPE_BUFFERS, RB_TEX_BLUR_1, 0, 0);
+ Size2i msize = rb->get_texture_slice_size(RB_SCOPE_BUFFERS, RB_TEX_BLUR_1, 0);
tonemap.glow_texture_size.x = msize.width;
tonemap.glow_texture_size.y = msize.height;
tonemap.glow_use_bicubic_upscale = glow_bicubic_upscale;
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
index 968f804593..e65d842a67 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
@@ -389,6 +389,13 @@ uint64_t LightStorage::light_get_version(RID p_light) const {
return light->version;
}
+uint32_t LightStorage::light_get_cull_mask(RID p_light) const {
+ const Light *light = light_owner.get_or_null(p_light);
+ ERR_FAIL_COND_V(!light, 0);
+
+ return light->cull_mask;
+}
+
AABB LightStorage::light_get_aabb(RID p_light) const {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, AABB());
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.h b/servers/rendering/renderer_rd/storage_rd/light_storage.h
index 68f439ddef..c36d1ef503 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.h
@@ -517,13 +517,6 @@ public:
return light->color;
}
- _FORCE_INLINE_ uint32_t light_get_cull_mask(RID p_light) {
- const Light *light = light_owner.get_or_null(p_light);
- ERR_FAIL_COND_V(!light, 0);
-
- return light->cull_mask;
- }
-
_FORCE_INLINE_ bool light_is_distance_fade_enabled(RID p_light) {
const Light *light = light_owner.get_or_null(p_light);
return light->distance_fade;
@@ -575,6 +568,7 @@ public:
virtual RS::LightBakeMode light_get_bake_mode(RID p_light) override;
virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override;
virtual uint64_t light_get_version(RID p_light) const override;
+ virtual uint32_t light_get_cull_mask(RID p_light) const override;
Dependency *light_get_dependency(RID p_light) const;
diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.h b/servers/rendering/renderer_rd/storage_rd/material_storage.h
index 0ac5557659..ac217d9a49 100644
--- a/servers/rendering/renderer_rd/storage_rd/material_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/material_storage.h
@@ -323,13 +323,13 @@ public:
// http://andrewthall.org/papers/df64_qf128.pdf
#ifdef REAL_T_IS_DOUBLE
- static _FORCE_INLINE_ void split_double(double a, float *ahi, float *alo) {
+ static _FORCE_INLINE_ void split_double(double a, float *a_hi, float *a_lo) {
const double SPLITTER = (1 << 29) + 1;
double t = a * SPLITTER;
- double thi = t - (t - a);
- double tlo = a - thi;
- *ahi = (float)thi;
- *alo = (float)tlo;
+ double t_hi = t - (t - a);
+ double t_lo = a - t_hi;
+ *a_hi = (float)t_hi;
+ *a_lo = (float)t_lo;
}
#endif
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index f65676185c..96618c3352 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -586,6 +586,8 @@ void MeshStorage::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
mesh->custom_aabb = p_aabb;
+
+ mesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
}
AABB MeshStorage::mesh_get_custom_aabb(RID p_mesh) const {
@@ -1803,8 +1805,12 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible
}
if (multimesh->data_cache.size()) {
- //there is a data cache..
+ // There is a data cache, but we may need to update some sections.
_multimesh_mark_all_dirty(multimesh, false, true);
+ int start = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
+ for (int i = start; i < p_visible; i++) {
+ _multimesh_mark_dirty(multimesh, i, true);
+ }
}
multimesh->visible_instances = p_visible;
diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
index 255719183f..f5d6404f01 100644
--- a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
@@ -50,25 +50,19 @@ void RenderSceneBuffersRD::_bind_methods() {
// ClassDB::bind_method(D_METHOD("create_texture_view", "context", "name", "view_name", "view"), &RenderSceneBuffersRD::has_texture);
ClassDB::bind_method(D_METHOD("get_texture", "context", "name"), &RenderSceneBuffersRD::get_texture);
// ClassDB::bind_method(D_METHOD("get_texture_format", "context", "name"), &RenderSceneBuffersRD::get_texture_format);
- ClassDB::bind_method(D_METHOD("get_texture_slice", "context", "name", "layer", "mipmap"), &RenderSceneBuffersRD::get_texture_slice);
- ClassDB::bind_method(D_METHOD("get_texture_slice_size", "context", "name", "layer", "mipmap"), &RenderSceneBuffersRD::get_texture_slice_size);
+ ClassDB::bind_method(D_METHOD("get_texture_slice", "context", "name", "layer", "mipmap", "layers", "mipmaps"), &RenderSceneBuffersRD::get_texture_slice);
+ ClassDB::bind_method(D_METHOD("get_texture_slice_size", "context", "name", "mipmap"), &RenderSceneBuffersRD::get_texture_slice_size);
ClassDB::bind_method(D_METHOD("clear_context", "context"), &RenderSceneBuffersRD::clear_context);
}
void RenderSceneBuffersRD::update_sizes(NamedTexture &p_named_texture) {
ERR_FAIL_COND(p_named_texture.texture.is_null());
- uint32_t size = p_named_texture.format.array_layers * p_named_texture.format.mipmaps;
- p_named_texture.sizes.resize(size);
+ p_named_texture.sizes.resize(p_named_texture.format.mipmaps);
Size2i mipmap_size = Size2i(p_named_texture.format.width, p_named_texture.format.height);
-
for (uint32_t mipmap = 0; mipmap < p_named_texture.format.mipmaps; mipmap++) {
- for (uint32_t layer = 0; layer < p_named_texture.format.array_layers; layer++) {
- uint32_t index = layer * p_named_texture.format.mipmaps + mipmap;
-
- p_named_texture.sizes.ptrw()[index] = mipmap_size;
- }
+ p_named_texture.sizes.ptrw()[mipmap] = mipmap_size;
mipmap_size.width = MAX(1, mipmap_size.width >> 1);
mipmap_size.height = MAX(1, mipmap_size.height >> 1);
@@ -324,7 +318,7 @@ const RD::TextureFormat RenderSceneBuffersRD::get_texture_format(const StringNam
return named_textures[key].format;
}
-RID RenderSceneBuffersRD::get_texture_slice(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_layer, const uint32_t p_mipmap) {
+RID RenderSceneBuffersRD::get_texture_slice(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_layer, const uint32_t p_mipmap, const uint32_t p_layers, const uint32_t p_mipmaps) {
NTKey key(p_context, p_texture_name);
// check if this is a known texture
@@ -334,36 +328,41 @@ RID RenderSceneBuffersRD::get_texture_slice(const StringName &p_context, const S
// check if we're in bounds
ERR_FAIL_UNSIGNED_INDEX_V(p_layer, named_texture.format.array_layers, RID());
+ ERR_FAIL_COND_V(p_layers == 0, RID());
+ ERR_FAIL_COND_V(p_layer + p_layers > named_texture.format.array_layers, RID());
ERR_FAIL_UNSIGNED_INDEX_V(p_mipmap, named_texture.format.mipmaps, RID());
+ ERR_FAIL_COND_V(p_mipmaps == 0, RID());
+ ERR_FAIL_COND_V(p_mipmap + p_mipmaps > named_texture.format.mipmaps, RID());
- // if we don't have multiple layers or mipmaps, we can just return our texture as is
- if (named_texture.format.array_layers == 1 && named_texture.format.mipmaps == 1) {
+ // asking the whole thing? just return the original
+ if (p_layer == 0 && p_mipmap == 0 && named_texture.format.array_layers == p_layers && named_texture.format.mipmaps == p_mipmaps) {
return named_texture.texture;
}
- // get our index and make sure we have enough entries in our slices vector
- uint32_t index = p_layer * named_texture.format.mipmaps + p_mipmap;
- while (named_texture.slices.size() <= int(index)) {
- named_texture.slices.push_back(RID());
+ // see if we have this
+ NTSliceKey slice_key(p_layer, p_layers, p_mipmap, p_mipmaps);
+ if (named_texture.slices.has(slice_key)) {
+ return named_texture.slices[slice_key];
}
- // create our slice if we don't have it already
- if (named_texture.slices[index].is_null()) {
- named_texture.slices.ptrw()[index] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), named_texture.texture, p_layer, p_mipmap);
+ // create our slice
+ RID &slice = named_texture.slices[slice_key];
+ slice = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), named_texture.texture, p_layer, p_mipmap, p_mipmaps, p_layers > 1 ? RD::TEXTURE_SLICE_2D_ARRAY : RD::TEXTURE_SLICE_2D, p_layers);
- Array arr;
- arr.push_back(p_context);
- arr.push_back(p_texture_name);
- arr.push_back(itos(p_layer));
- arr.push_back(itos(p_mipmap));
- RD::get_singleton()->set_resource_name(named_texture.slices[index], String("RenderBuffer {0}/{1} slice {2}/{3}").format(arr));
- }
+ Array arr;
+ arr.push_back(p_context);
+ arr.push_back(p_texture_name);
+ arr.push_back(itos(p_layer));
+ arr.push_back(itos(p_layers));
+ arr.push_back(itos(p_mipmap));
+ arr.push_back(itos(p_mipmaps));
+ RD::get_singleton()->set_resource_name(slice, String("RenderBuffer {0}/{1}, layer {2}/{3}, mipmap {4}/{5}").format(arr));
// and return our slice
- return named_texture.slices[index];
+ return slice;
}
-Size2i RenderSceneBuffersRD::get_texture_slice_size(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_layer, const uint32_t p_mipmap) {
+Size2i RenderSceneBuffersRD::get_texture_slice_size(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_mipmap) {
NTKey key(p_context, p_texture_name);
// check if this is a known texture
@@ -372,14 +371,10 @@ Size2i RenderSceneBuffersRD::get_texture_slice_size(const StringName &p_context,
ERR_FAIL_COND_V(named_texture.texture.is_null(), Size2i());
// check if we're in bounds
- ERR_FAIL_UNSIGNED_INDEX_V(p_layer, named_texture.format.array_layers, Size2i());
ERR_FAIL_UNSIGNED_INDEX_V(p_mipmap, named_texture.format.mipmaps, Size2i());
- // get our index
- uint32_t index = p_layer * named_texture.format.mipmaps + p_mipmap;
-
- // and return our size
- return named_texture.sizes[index];
+ // return our size
+ return named_texture.sizes[p_mipmap];
}
void RenderSceneBuffersRD::clear_context(const StringName &p_context) {
diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h
index 50fb06c0d9..9a299a3415 100644
--- a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h
+++ b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h
@@ -93,7 +93,6 @@ private:
}
static uint32_t hash(const NTKey &p_val) {
- // FIXME, properly hash two stringnames together
uint32_t h = p_val.context.hash();
h = hash_murmur3_one_32(p_val.buffer_name.hash(), h);
return hash_fmix32(h);
@@ -106,6 +105,33 @@ private:
}
};
+ struct NTSliceKey {
+ uint32_t layer;
+ uint32_t layers;
+ uint32_t mipmap;
+ uint32_t mipmaps;
+
+ bool operator==(const NTSliceKey &p_val) const {
+ return (layer == p_val.layer) && (layers == p_val.layers) && (mipmap == p_val.mipmap) && (mipmaps == p_val.mipmaps);
+ }
+
+ static uint32_t hash(const NTSliceKey &p_val) {
+ uint32_t h = hash_murmur3_one_32(p_val.layer);
+ h = hash_murmur3_one_32(p_val.layers, h);
+ h = hash_murmur3_one_32(p_val.mipmap, h);
+ h = hash_murmur3_one_32(p_val.mipmaps, h);
+ return hash_fmix32(h);
+ }
+
+ NTSliceKey() {}
+ NTSliceKey(uint32_t p_layer, uint32_t p_layers, uint32_t p_mipmap, uint32_t p_mipmaps) {
+ layer = p_layer;
+ layers = p_layers;
+ mipmap = p_mipmap;
+ mipmaps = p_mipmaps;
+ }
+ };
+
struct NamedTexture {
// Cache the data used to create our texture
RD::TextureFormat format;
@@ -113,7 +139,7 @@ private:
// Our texture objects, slices are lazy (i.e. only created when requested).
RID texture;
- Vector<RID> slices;
+ mutable HashMap<NTSliceKey, RID, NTSliceKey> slices;
Vector<Size2i> sizes;
};
@@ -154,8 +180,8 @@ public:
RID create_texture_view(const StringName &p_context, const StringName &p_texture_name, const StringName p_view_name, RD::TextureView p_view = RD::TextureView());
RID get_texture(const StringName &p_context, const StringName &p_texture_name) const;
const RD::TextureFormat get_texture_format(const StringName &p_context, const StringName &p_texture_name) const;
- RID get_texture_slice(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_layer, const uint32_t p_mipmap);
- Size2i get_texture_slice_size(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_layer, const uint32_t p_mipmap);
+ RID get_texture_slice(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_layer, const uint32_t p_mipmap, const uint32_t p_layers = 1, const uint32_t p_mipmaps = 1);
+ Size2i get_texture_slice_size(const StringName &p_context, const StringName &p_texture_name, const uint32_t p_mipmap);
void clear_context(const StringName &p_context);
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
index 5d845ce510..0ee9b28826 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
@@ -1906,7 +1906,7 @@ void TextureStorage::decal_set_cull_mask(RID p_decal, uint32_t p_layers) {
Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->cull_mask = p_layers;
- decal->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
+ decal->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_DECAL);
}
void TextureStorage::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) {
@@ -1952,6 +1952,13 @@ AABB TextureStorage::decal_get_aabb(RID p_decal) const {
return AABB(-decal->size / 2, decal->size);
}
+uint32_t TextureStorage::decal_get_cull_mask(RID p_decal) const {
+ Decal *decal = decal_owner.get_or_null(p_decal);
+ ERR_FAIL_COND_V(!decal, 0);
+
+ return decal->cull_mask;
+}
+
Dependency *TextureStorage::decal_get_dependency(RID p_decal) {
Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND_V(!decal, nullptr);
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h
index aeab3bf3cb..c16f5274ad 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h
@@ -638,6 +638,7 @@ public:
}
virtual AABB decal_get_aabb(RID p_decal) const override;
+ virtual uint32_t decal_get_cull_mask(RID p_decal) const override;
Dependency *decal_get_dependency(RID p_decal);
/* DECAL INSTANCE API */
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index d696955800..7d2cd12959 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -1787,6 +1787,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
pair.pair_allocator = &pair_allocator;
pair.pair_pass = pair_pass;
pair.pair_mask = 0;
+ pair.cull_mask = 0xFFFFFFFF;
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
pair.pair_mask |= 1 << RS::INSTANCE_LIGHT;
@@ -1807,12 +1808,14 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
pair.pair_mask |= (1 << RS::INSTANCE_VOXEL_GI);
pair.bvh2 = &p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES];
}
+ pair.cull_mask = RSG::light_storage->light_get_cull_mask(p_instance->base);
} else if (geometry_instance_pair_mask & (1 << RS::INSTANCE_REFLECTION_PROBE) && (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE)) {
pair.pair_mask = RS::INSTANCE_GEOMETRY_MASK;
pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY];
} else if (geometry_instance_pair_mask & (1 << RS::INSTANCE_DECAL) && (p_instance->base_type == RS::INSTANCE_DECAL)) {
pair.pair_mask = RS::INSTANCE_GEOMETRY_MASK;
pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY];
+ pair.cull_mask = RSG::texture_storage->decal_get_cull_mask(p_instance->base);
} else if (p_instance->base_type == RS::INSTANCE_PARTICLES_COLLISION) {
pair.pair_mask = (1 << RS::INSTANCE_PARTICLES);
pair.bvh = &p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY];
diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h
index 2ec75b03ef..b3874ee7ae 100644
--- a/servers/rendering/renderer_scene_cull.h
+++ b/servers/rendering/renderer_scene_cull.h
@@ -485,6 +485,7 @@ public:
singleton->_instance_queue_update(instance, true, false);
} break;
+ case Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES:
case Dependency::DEPENDENCY_CHANGED_MATERIAL: {
singleton->_instance_queue_update(instance, false, true);
} break;
@@ -496,9 +497,6 @@ public:
case Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE: {
singleton->_instance_queue_update(instance, true, true);
} break;
- case Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES: {
- //ignored
- } break;
case Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR: {
//requires repairing
if (instance->indexer_id.is_valid()) {
@@ -735,11 +733,12 @@ public:
DynamicBVH *bvh2 = nullptr; //some may need to cull in two
uint32_t pair_mask;
uint64_t pair_pass;
+ uint32_t cull_mask = 0xFFFFFFFF; // Needed for decals and lights in the mobile and compatibility renderers.
_FORCE_INLINE_ bool operator()(void *p_data) {
Instance *p_instance = (Instance *)p_data;
- if (instance != p_instance && instance->transformed_aabb.intersects(p_instance->transformed_aabb) && (pair_mask & (1 << p_instance->base_type))) {
+ if (instance != p_instance && instance->transformed_aabb.intersects(p_instance->transformed_aabb) && (pair_mask & (1 << p_instance->base_type)) && (cull_mask & p_instance->layer_mask)) {
//test is more coarse in indexer
p_instance->pair_check = pair_pass;
InstancePair *pair = pair_allocator->alloc();
diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h
index 08ca25b64b..9117669124 100644
--- a/servers/rendering/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -530,7 +530,7 @@ public:
TEXTURE_SLICE_2D_ARRAY,
};
- virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D) = 0;
+ virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps = 1, TextureSliceType p_slice_type = TEXTURE_SLICE_2D, uint32_t p_layers = 0) = 0;
virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS) = 0;
virtual Vector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer) = 0; // CPU textures will return immediately, while GPU textures will most likely force a flush
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 11a9303f11..2dc1c70064 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -1225,7 +1225,7 @@ void ShaderLanguage::clear() {
char_idx = 0;
error_set = false;
error_str = "";
- last_const = false;
+ is_const_decl = false;
while (nodes) {
Node *n = nodes;
nodes = nodes->next;
@@ -3561,6 +3561,14 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Functio
return false;
}
+ if (is_const_decl && arg->type == Node::TYPE_VARIABLE) {
+ const VariableNode *var = static_cast<const VariableNode *>(arg);
+ if (!var->is_const) {
+ _set_error(RTR("Expected constant expression."));
+ return false;
+ }
+ }
+
p_func->arguments.push_back(arg);
tk = _get_token();
@@ -4530,14 +4538,14 @@ bool ShaderLanguage::_check_node_constness(const Node *p_node) const {
case Node::TYPE_CONSTANT:
break;
case Node::TYPE_VARIABLE: {
- const VariableNode *varn = static_cast<const VariableNode *>(p_node);
- if (!varn->is_const) {
+ const VariableNode *var_node = static_cast<const VariableNode *>(p_node);
+ if (!var_node->is_const) {
return false;
}
} break;
case Node::TYPE_ARRAY: {
- const ArrayNode *arrn = static_cast<const ArrayNode *>(p_node);
- if (!arrn->is_const) {
+ const ArrayNode *arr_node = static_cast<const ArrayNode *>(p_node);
+ if (!arr_node->is_const) {
return false;
}
} break;
@@ -5184,6 +5192,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = func;
} else { //a function call
+ if (p_block == nullptr) { // Non-constructor function call in global space is forbidden.
+ if (is_const_decl) {
+ _set_error(RTR("Expected constant expression."));
+ }
+ return nullptr;
+ }
const StringName &name = identifier;
@@ -5460,6 +5474,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
_set_error(vformat(RTR("Unknown identifier in expression: '%s'."), String(identifier)));
return nullptr;
}
+ if (is_const_decl && !is_const) {
+ _set_error(RTR("Expected constant expression."));
+ return nullptr;
+ }
if (ident_type == IDENTIFIER_VARYING) {
TkPos prev_pos = _get_tkpos();
Token next_token = _get_token();
@@ -6977,6 +6995,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
}
}
#endif // DEBUG_ENABLED
+ is_const_decl = is_const;
BlockNode::Variable var;
var.type = type;
@@ -7233,6 +7252,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
vdnode->declarations.push_back(decl);
p_block->variables[name] = var;
+ is_const_decl = false;
if (!fixed_array_size) {
array_size = 0;
@@ -9101,6 +9121,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
constant.precision = precision;
constant.initializer = nullptr;
constant.array_size = array_size;
+ is_const_decl = true;
if (tk.type == TK_BRACKET_OPEN) {
Error error = _parse_array_size(nullptr, constants, false, nullptr, &constant.array_size, &unknown_size);
@@ -9360,6 +9381,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
unknown_size = false;
} else if (tk.type == TK_SEMICOLON) {
+ is_const_decl = false;
break;
} else {
_set_expected_error(",", ";");
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index 32e497aa46..aea61e42c3 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -953,7 +953,7 @@ private:
StringName shader_type_identifier;
StringName current_function;
- bool last_const = false;
+ bool is_const_decl = false;
StringName last_name;
bool is_shader_inc = false;
diff --git a/servers/rendering/storage/light_storage.h b/servers/rendering/storage/light_storage.h
index 9f3f5dd8e4..5bd4297179 100644
--- a/servers/rendering/storage/light_storage.h
+++ b/servers/rendering/storage/light_storage.h
@@ -84,6 +84,7 @@ public:
virtual RS::LightBakeMode light_get_bake_mode(RID p_light) = 0;
virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) = 0;
virtual uint64_t light_get_version(RID p_light) const = 0;
+ virtual uint32_t light_get_cull_mask(RID p_light) const = 0;
/* LIGHT INSTANCE API */
diff --git a/servers/rendering/storage/texture_storage.h b/servers/rendering/storage/texture_storage.h
index 3a9034ad0d..227d44aa27 100644
--- a/servers/rendering/storage/texture_storage.h
+++ b/servers/rendering/storage/texture_storage.h
@@ -118,6 +118,7 @@ public:
virtual void decal_set_normal_fade(RID p_decal, float p_fade) = 0;
virtual AABB decal_get_aabb(RID p_decal) const = 0;
+ virtual uint32_t decal_get_cull_mask(RID p_decal) const = 0;
virtual void texture_add_to_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) = 0;
virtual void texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) = 0;
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 1c19b9dcd0..848b6d01d4 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -2675,6 +2675,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter);
ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color);
ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_blend_mode", "light", "mode"), &RenderingServer::canvas_light_set_blend_mode);
BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_POINT);
BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_DIRECTIONAL);
diff --git a/servers/xr/xr_interface.cpp b/servers/xr/xr_interface.cpp
index 9968a47b0c..7f3d8668a4 100644
--- a/servers/xr/xr_interface.cpp
+++ b/servers/xr/xr_interface.cpp
@@ -75,6 +75,10 @@ void XRInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_transform_for_view", "view", "cam_transform"), &XRInterface::get_transform_for_view);
ClassDB::bind_method(D_METHOD("get_projection_for_view", "view", "aspect", "near", "far"), &XRInterface::get_projection_for_view);
+ /** environment blend mode. */
+ ClassDB::bind_method(D_METHOD("get_supported_environment_blend_modes"), &XRInterface::get_supported_environment_blend_modes);
+ ClassDB::bind_method(D_METHOD("set_environment_blend_mode", "mode"), &XRInterface::set_environment_blend_mode);
+
ADD_GROUP("AR", "ar_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ar_is_anchor_detection_enabled"), "set_anchor_detection_is_enabled", "get_anchor_detection_is_enabled");
@@ -97,6 +101,10 @@ void XRInterface::_bind_methods() {
BIND_ENUM_CONSTANT(XR_PLAY_AREA_SITTING);
BIND_ENUM_CONSTANT(XR_PLAY_AREA_ROOMSCALE);
BIND_ENUM_CONSTANT(XR_PLAY_AREA_STAGE);
+
+ BIND_ENUM_CONSTANT(XR_ENV_BLEND_MODE_OPAQUE);
+ BIND_ENUM_CONSTANT(XR_ENV_BLEND_MODE_ADDITIVE);
+ BIND_ENUM_CONSTANT(XR_ENV_BLEND_MODE_ALPHA_BLEND);
};
bool XRInterface::is_primary() {
@@ -273,3 +281,9 @@ XRInterface::TrackingStatus XRInterface::get_tracking_status() const {
void XRInterface::trigger_haptic_pulse(const String &p_action_name, const StringName &p_tracker_name, double p_frequency, double p_amplitude, double p_duration_sec, double p_delay_sec) {
}
+
+Array XRInterface::get_supported_environment_blend_modes() {
+ Array default_blend_modes;
+ default_blend_modes.push_back(XR_ENV_BLEND_MODE_OPAQUE);
+ return default_blend_modes;
+}
diff --git a/servers/xr/xr_interface.h b/servers/xr/xr_interface.h
index 6f70f75772..c32455f466 100644
--- a/servers/xr/xr_interface.h
+++ b/servers/xr/xr_interface.h
@@ -78,6 +78,12 @@ public:
XR_PLAY_AREA_STAGE, /* Same as roomscale but origin point is fixed to the center of the physical space, XRServer.center_on_hmd disabled */
};
+ enum EnvironmentBlendMode {
+ XR_ENV_BLEND_MODE_OPAQUE, /* You cannot see the real world, VR like */
+ XR_ENV_BLEND_MODE_ADDITIVE, /* You can see the real world, AR like */
+ XR_ENV_BLEND_MODE_ALPHA_BLEND, /* Real world is passed through where alpha channel is 0.0 and gradually blends to opaque for value 1.0. */
+ };
+
protected:
_THREAD_SAFE_CLASS_
@@ -138,6 +144,10 @@ public:
virtual bool start_passthrough() { return false; }
virtual void stop_passthrough() {}
+ /** environment blend mode. */
+ virtual Array get_supported_environment_blend_modes();
+ virtual bool set_environment_blend_mode(EnvironmentBlendMode mode) { return false; }
+
XRInterface();
~XRInterface();
@@ -151,5 +161,6 @@ private:
VARIANT_ENUM_CAST(XRInterface::Capabilities);
VARIANT_ENUM_CAST(XRInterface::TrackingStatus);
VARIANT_ENUM_CAST(XRInterface::PlayAreaMode);
+VARIANT_ENUM_CAST(XRInterface::EnvironmentBlendMode);
#endif // XR_INTERFACE_H
diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h
index f2663b037d..77312a8604 100644
--- a/tests/scene/test_text_edit.h
+++ b/tests/scene/test_text_edit.h
@@ -3086,7 +3086,7 @@ TEST_CASE("[SceneTree][TextEdit] context menu") {
text_edit->get_viewport()->set_embedding_subwindows(true); // Bypass display server for drop handling.
text_edit->set_size(Size2(800, 200));
- text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
+ text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
MessageQueue::get_singleton()->flush();
text_edit->set_context_menu_enabled(false);
@@ -3227,7 +3227,7 @@ TEST_CASE("[SceneTree][TextEdit] mouse") {
SceneTree::get_singleton()->get_root()->add_child(text_edit);
text_edit->set_size(Size2(800, 200));
- text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
+ text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
MessageQueue::get_singleton()->flush();
CHECK(text_edit->get_word_at_pos(text_edit->get_pos_at_line_column(0, 1)) == "Lorem");
@@ -3305,9 +3305,9 @@ TEST_CASE("[SceneTree][TextEdit] caret") {
SEND_GUI_ACTION(text_edit, "ui_text_caret_left");
CHECK(text_edit->get_caret_column() == 0);
- text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
+ text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
for (int i = 0; i < 3; i++) {
- text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
+ text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
}
MessageQueue::get_singleton()->flush();
@@ -3519,7 +3519,7 @@ TEST_CASE("[SceneTree][TextEdit] line wrapping") {
// Set size for boundary.
text_edit->set_size(Size2(800, 200));
- text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
+ text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
CHECK_FALSE(text_edit->is_line_wrapped(0));
CHECK(text_edit->get_line_wrap_count(0) == 0);
CHECK(text_edit->get_line_wrap_index_at_column(0, 130) == 0);
@@ -3569,7 +3569,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") {
// No subcases here for performance.
text_edit->set_size(Size2(800, 600));
for (int i = 0; i < 50; i++) {
- text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
+ text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque.");
}
MessageQueue::get_singleton()->flush();
@@ -3897,7 +3897,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") {
CHECK(text_edit->get_h_scroll() == 0);
text_edit->set_h_scroll(10000000);
- CHECK(text_edit->get_h_scroll() == 313);
+ CHECK(text_edit->get_h_scroll() == 314);
text_edit->set_h_scroll(-100);
CHECK(text_edit->get_h_scroll() == 0);