summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYRIGHT.txt2
-rw-r--r--core/config/project_settings.cpp8
-rw-r--r--doc/classes/@GlobalScope.xml8
-rw-r--r--doc/classes/AESContext.xml33
-rw-r--r--doc/classes/AStar3D.xml11
-rw-r--r--doc/classes/AnimationNodeStateMachine.xml5
-rw-r--r--doc/classes/AnimationNodeTransition.xml3
-rw-r--r--doc/classes/AudioServer.xml26
-rw-r--r--doc/classes/Camera2D.xml19
-rw-r--r--doc/classes/Color.xml13
-rw-r--r--doc/classes/Control.xml53
-rw-r--r--doc/classes/Crypto.xml30
-rw-r--r--doc/classes/DTLSServer.xml67
-rw-r--r--doc/classes/Decal.xml6
-rw-r--r--doc/classes/Dictionary.xml4
-rw-r--r--doc/classes/DirAccess.xml4
-rw-r--r--doc/classes/EditorImportPlugin.xml38
-rw-r--r--doc/classes/EditorPlugin.xml35
-rw-r--r--doc/classes/EditorScenePostImport.xml7
-rw-r--r--doc/classes/EditorScript.xml3
-rw-r--r--doc/classes/EditorSettings.xml2
-rw-r--r--doc/classes/EditorTranslationParserPlugin.xml24
-rw-r--r--doc/classes/Expression.xml10
-rw-r--r--doc/classes/FileAccess.xml4
-rw-r--r--doc/classes/FogVolume.xml10
-rw-r--r--doc/classes/GPUParticlesAttractorBox3D.xml4
-rw-r--r--doc/classes/GPUParticlesAttractorVectorField3D.xml6
-rw-r--r--doc/classes/GPUParticlesCollisionBox3D.xml4
-rw-r--r--doc/classes/GPUParticlesCollisionHeightField3D.xml6
-rw-r--r--doc/classes/GPUParticlesCollisionSDF3D.xml8
-rw-r--r--doc/classes/Geometry2D.xml7
-rw-r--r--doc/classes/GraphEdit.xml5
-rw-r--r--doc/classes/HMACContext.xml19
-rw-r--r--doc/classes/HTTPClient.xml13
-rw-r--r--doc/classes/HTTPRequest.xml16
-rw-r--r--doc/classes/HashingContext.xml16
-rw-r--r--doc/classes/InputEventMIDI.xml20
-rw-r--r--doc/classes/MainLoop.xml15
-rw-r--r--doc/classes/NavigationAgent2D.xml15
-rw-r--r--doc/classes/NavigationAgent3D.xml12
-rw-r--r--doc/classes/NavigationServer2D.xml5
-rw-r--r--doc/classes/Object.xml20
-rw-r--r--doc/classes/PackedScene.xml2
-rw-r--r--doc/classes/PhysicsPointQueryParameters2D.xml1
-rw-r--r--doc/classes/ProjectSettings.xml16
-rw-r--r--doc/classes/ReflectionProbe.xml22
-rw-r--r--doc/classes/RenderingDevice.xml35
-rw-r--r--doc/classes/RenderingServer.xml82
-rw-r--r--doc/classes/RichTextEffect.xml2
-rw-r--r--doc/classes/SceneTree.xml4
-rw-r--r--doc/classes/SceneTreeTimer.xml4
-rw-r--r--doc/classes/Sprite2D.xml6
-rw-r--r--doc/classes/StreamPeer.xml2
-rw-r--r--doc/classes/SubViewport.xml1
-rw-r--r--doc/classes/SubViewportContainer.xml1
-rw-r--r--doc/classes/Tween.xml8
-rw-r--r--doc/classes/UDPServer.xml54
-rw-r--r--doc/classes/UndoRedo.xml16
-rw-r--r--doc/classes/VoxelGI.xml6
-rw-r--r--doc/classes/VoxelGIData.xml4
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp54
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h18
-rw-r--r--drivers/gles3/environment/fog.cpp2
-rw-r--r--drivers/gles3/environment/fog.h2
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp31
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h3
-rw-r--r--drivers/gles3/shaders/scene.glsl6
-rw-r--r--drivers/gles3/shaders/sky.glsl38
-rw-r--r--drivers/gles3/storage/light_storage.cpp4
-rw-r--r--drivers/gles3/storage/light_storage.h6
-rw-r--r--drivers/gles3/storage/material_storage.cpp1
-rw-r--r--drivers/gles3/storage/texture_storage.cpp6
-rw-r--r--drivers/gles3/storage/texture_storage.h2
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp138
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h36
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp162
-rw-r--r--drivers/wasapi/audio_driver_wasapi.h36
-rw-r--r--editor/action_map_editor.cpp15
-rw-r--r--editor/action_map_editor.h3
-rw-r--r--editor/editor_node.cpp7
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp2
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp157
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp4
-rw-r--r--editor/plugins/voxel_gi_editor_plugin.cpp10
-rw-r--r--editor/project_converter_3_to_4.cpp14
-rw-r--r--editor/project_settings_editor.cpp14
-rw-r--r--editor/scene_tree_dock.cpp9
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml12
-rw-r--r--modules/gdscript/gdscript_utility_functions.cpp23
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs4
-rw-r--r--scene/2d/camera_2d.cpp78
-rw-r--r--scene/2d/camera_2d.h6
-rw-r--r--scene/2d/navigation_agent_2d.cpp162
-rw-r--r--scene/2d/navigation_agent_2d.h31
-rw-r--r--scene/3d/decal.cpp38
-rw-r--r--scene/3d/decal.h10
-rw-r--r--scene/3d/fog_volume.cpp44
-rw-r--r--scene/3d/fog_volume.h10
-rw-r--r--scene/3d/gpu_particles_collision_3d.cpp184
-rw-r--r--scene/3d/gpu_particles_collision_3d.h50
-rw-r--r--scene/3d/navigation_agent_3d.cpp180
-rw-r--r--scene/3d/navigation_agent_3d.h30
-rw-r--r--scene/3d/occluder_instance_3d.cpp5
-rw-r--r--scene/3d/physics_body_3d.cpp5
-rw-r--r--scene/3d/reflection_probe.cpp56
-rw-r--r--scene/3d/reflection_probe.h12
-rw-r--r--scene/3d/voxel_gi.cpp46
-rw-r--r--scene/3d/voxel_gi.h10
-rw-r--r--scene/animation/animation_blend_tree.cpp32
-rw-r--r--scene/animation/animation_blend_tree.h4
-rw-r--r--scene/animation/animation_node_state_machine.cpp15
-rw-r--r--scene/animation/animation_node_state_machine.h4
-rw-r--r--scene/gui/graph_edit.cpp8
-rw-r--r--scene/gui/subviewport_container.cpp4
-rw-r--r--scene/main/viewport.cpp38
-rw-r--r--scene/main/viewport.h4
-rw-r--r--scene/main/window.cpp10
-rw-r--r--scene/resources/fog_material.cpp2
-rw-r--r--scene/resources/importer_mesh.cpp2
-rw-r--r--scene/resources/packed_scene.cpp6
-rw-r--r--scene/resources/surface_tool.cpp3
-rw-r--r--scene/resources/surface_tool.h9
-rw-r--r--scene/resources/visual_shader.cpp4
-rw-r--r--scene/resources/visual_shader_nodes.cpp35
-rw-r--r--scene/resources/world_2d.cpp22
-rw-r--r--scene/resources/world_2d.h2
-rw-r--r--scene/resources/world_3d.cpp24
-rw-r--r--scene/resources/world_3d.h2
-rw-r--r--servers/audio_server.cpp50
-rw-r--r--servers/audio_server.h24
-rw-r--r--servers/navigation_server_2d.cpp36
-rw-r--r--servers/navigation_server_2d.h14
-rw-r--r--servers/navigation_server_3d.cpp98
-rw-r--r--servers/navigation_server_3d.h23
-rw-r--r--servers/physics_2d/godot_space_2d.cpp20
-rw-r--r--servers/physics_3d/godot_space_3d.cpp16
-rw-r--r--servers/physics_server_2d.cpp17
-rw-r--r--servers/physics_server_3d.cpp16
-rw-r--r--servers/rendering/dummy/environment/fog.h2
-rw-r--r--servers/rendering/dummy/storage/light_storage.h4
-rw-r--r--servers/rendering/dummy/storage/texture_storage.h2
-rw-r--r--servers/rendering/environment/renderer_fog.h2
-rw-r--r--servers/rendering/renderer_rd/cluster_builder_rd.h4
-rw-r--r--servers/rendering/renderer_rd/environment/fog.cpp22
-rw-r--r--servers/rendering/renderer_rd/environment/fog.h8
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp20
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h4
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp1
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp1
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.h4
-rw-r--r--servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl21
-rw-r--r--servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl6
-rw-r--r--servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl6
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.cpp16
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.h6
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp5
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.cpp8
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.h8
-rw-r--r--servers/rendering/renderer_scene_cull.cpp8
-rw-r--r--servers/rendering/rendering_server_default.h6
-rw-r--r--servers/rendering/shader_types.cpp4
-rw-r--r--servers/rendering/storage/light_storage.h4
-rw-r--r--servers/rendering/storage/texture_storage.h2
-rw-r--r--servers/rendering_server.cpp6
-rw-r--r--servers/rendering_server.h6
-rw-r--r--thirdparty/README.md2
-rw-r--r--thirdparty/meshoptimizer/LICENSE.md2
-rw-r--r--thirdparty/meshoptimizer/clusterizer.cpp152
-rw-r--r--thirdparty/meshoptimizer/indexgenerator.cpp6
-rw-r--r--thirdparty/meshoptimizer/meshoptimizer.h70
-rw-r--r--thirdparty/meshoptimizer/overdrawanalyzer.cpp2
-rw-r--r--thirdparty/meshoptimizer/overdrawoptimizer.cpp2
-rw-r--r--thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch30
-rw-r--r--thirdparty/meshoptimizer/patches/attribute-aware-simplify.patch49
-rw-r--r--thirdparty/meshoptimizer/simplifier.cpp24
-rw-r--r--thirdparty/meshoptimizer/spatialorder.cpp4
-rw-r--r--thirdparty/meshoptimizer/vcacheoptimizer.cpp28
-rw-r--r--thirdparty/meshoptimizer/vertexcodec.cpp88
-rw-r--r--thirdparty/meshoptimizer/vertexfilter.cpp2
180 files changed, 2560 insertions, 1290 deletions
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt
index 8a966dcb05..a3e06c545f 100644
--- a/COPYRIGHT.txt
+++ b/COPYRIGHT.txt
@@ -288,7 +288,7 @@ License: Apache-2.0
Files: ./thirdparty/meshoptimizer/
Comment: meshoptimizer
-Copyright: 2016-2021, Arseny Kapoulkine
+Copyright: 2016-2022, Arseny Kapoulkine
License: Expat
Files: ./thirdparty/minimp3/
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index ba9c6e4c60..6a1d802453 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -221,7 +221,9 @@ String ProjectSettings::localize_path(const String &p_path) const {
void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) {
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
- props[p_name].initial = p_value;
+
+ // Duplicate so that if value is array or dictionary, changing the setting will not change the stored initial value.
+ props[p_name].initial = p_value.duplicate();
}
void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) {
@@ -1116,7 +1118,9 @@ bool ProjectSettings::_property_get_revert(const StringName &p_name, Variant &r_
return false;
}
- r_property = props[p_name].initial;
+ // Duplicate so that if value is array or dictionary, changing the setting will not change the stored initial value.
+ r_property = props[p_name].initial.duplicate();
+
return true;
}
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 0d6524ccbe..3b2e260dcb 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -1271,7 +1271,13 @@
<method name="str" qualifiers="vararg">
<return type="String" />
<description>
- Converts one or more arguments of any [Variant] type to [String] in the best way possible.
+ Converts one or more arguments of any [Variant] type to a [String] in the best way possible.
+ [codeblock]
+ var a = [10, 20, 30]
+ var b = str(a)
+ print(len(a)) # Prints 3 (the number of elements in the array).
+ print(len(b)) # Prints 12 (the length of the string "[10, 20, 30]").
+ [/codeblock]
</description>
</method>
<method name="str_to_var">
diff --git a/doc/classes/AESContext.xml b/doc/classes/AESContext.xml
index 7f582e4be7..747968ea91 100644
--- a/doc/classes/AESContext.xml
+++ b/doc/classes/AESContext.xml
@@ -39,39 +39,38 @@
[/gdscript]
[csharp]
using Godot;
- using System;
using System.Diagnostics;
- public class Example : Node
+ public partial class MyNode : Node
{
- public AESContext Aes = new AESContext();
+ private AesContext _aes = new AesContext();
public override void _Ready()
{
string key = "My secret key!!!"; // Key must be either 16 or 32 bytes.
string data = "My secret text!!"; // Data size must be multiple of 16 bytes, apply padding if needed.
// Encrypt ECB
- Aes.Start(AESContext.Mode.EcbEncrypt, key.ToUTF8());
- byte[] encrypted = Aes.Update(data.ToUTF8());
- Aes.Finish();
+ _aes.Start(AesContext.Mode.EcbEncrypt, key.ToUtf8());
+ byte[] encrypted = _aes.Update(data.ToUtf8());
+ _aes.Finish();
// Decrypt ECB
- Aes.Start(AESContext.Mode.EcbDecrypt, key.ToUTF8());
- byte[] decrypted = Aes.Update(encrypted);
- Aes.Finish();
+ _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8());
+ byte[] decrypted = _aes.Update(encrypted);
+ _aes.Finish();
// Check ECB
- Debug.Assert(decrypted == data.ToUTF8());
+ Debug.Assert(decrypted == data.ToUtf8());
string iv = "My secret iv!!!!"; // IV must be of exactly 16 bytes.
// Encrypt CBC
- Aes.Start(AESContext.Mode.EcbEncrypt, key.ToUTF8(), iv.ToUTF8());
- encrypted = Aes.Update(data.ToUTF8());
- Aes.Finish();
+ _aes.Start(AesContext.Mode.EcbEncrypt, key.ToUtf8(), iv.ToUtf8());
+ encrypted = _aes.Update(data.ToUtf8());
+ _aes.Finish();
// Decrypt CBC
- Aes.Start(AESContext.Mode.EcbDecrypt, key.ToUTF8(), iv.ToUTF8());
- decrypted = Aes.Update(encrypted);
- Aes.Finish();
+ _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8(), iv.ToUtf8());
+ decrypted = _aes.Update(encrypted);
+ _aes.Finish();
// Check CBC
- Debug.Assert(decrypted == data.ToUTF8());
+ Debug.Assert(decrypted == data.ToUtf8());
}
}
[/csharp]
diff --git a/doc/classes/AStar3D.xml b/doc/classes/AStar3D.xml
index 4e8394195d..f0481c1745 100644
--- a/doc/classes/AStar3D.xml
+++ b/doc/classes/AStar3D.xml
@@ -19,15 +19,16 @@
return min(0, abs(u - v) - 1)
[/gdscript]
[csharp]
- public class MyAStar : AStar3D
+ public partial class MyAStar : AStar3D
{
- public override float _ComputeCost(int u, int v)
+ public override float _ComputeCost(long fromId, long toId)
{
- return Mathf.Abs(u - v);
+ return Mathf.Abs((int)(fromId - toId));
}
- public override float _EstimateCost(int u, int v)
+
+ public override float _EstimateCost(long fromId, long toId)
{
- return Mathf.Min(0, Mathf.Abs(u - v) - 1);
+ return Mathf.Min(0, Mathf.Abs((int)(fromId - toId)) - 1);
}
}
[/csharp]
diff --git a/doc/classes/AnimationNodeStateMachine.xml b/doc/classes/AnimationNodeStateMachine.xml
index 0fb789875f..95891a9061 100644
--- a/doc/classes/AnimationNodeStateMachine.xml
+++ b/doc/classes/AnimationNodeStateMachine.xml
@@ -161,4 +161,9 @@
</description>
</method>
</methods>
+ <members>
+ <member name="allow_transition_to_self" type="bool" setter="set_allow_transition_to_self" getter="is_allow_transition_to_self" default="false">
+ If [code]true[/code], allows teleport to the self state with [method AnimationNodeStateMachinePlayback.travel]. When the reset option is enabled in [method AnimationNodeStateMachinePlayback.travel], the animation is restarted. If [code]false[/code], nothing happens on the teleportation to the self state.
+ </member>
+ </members>
</class>
diff --git a/doc/classes/AnimationNodeTransition.xml b/doc/classes/AnimationNodeTransition.xml
index a067b0a9ba..bc3e5716dd 100644
--- a/doc/classes/AnimationNodeTransition.xml
+++ b/doc/classes/AnimationNodeTransition.xml
@@ -44,6 +44,9 @@
</method>
</methods>
<members>
+ <member name="allow_transition_to_self" type="bool" setter="set_allow_transition_to_self" getter="is_allow_transition_to_self" default="false">
+ If [code]true[/code], allows transition to the self state. When the reset option is enabled in input, the animation is restarted. If [code]false[/code], nothing happens on the transition to the self state.
+ </member>
<member name="input_count" type="int" setter="set_input_count" getter="get_input_count" default="0">
The number of enabled input ports for this node.
</member>
diff --git a/doc/classes/AudioServer.xml b/doc/classes/AudioServer.xml
index 36f12dd5c4..ae331f8491 100644
--- a/doc/classes/AudioServer.xml
+++ b/doc/classes/AudioServer.xml
@@ -29,13 +29,6 @@
Adds an [AudioEffect] effect to the bus [param bus_idx] at [param at_position].
</description>
</method>
- <method name="capture_get_device_list">
- <return type="PackedStringArray" />
- <description>
- Returns the names of all audio input devices detected on the system.
- [b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
- </description>
- </method>
<method name="generate_bus_layout" qualifiers="const">
<return type="AudioBusLayout" />
<description>
@@ -117,10 +110,11 @@
Returns the volume of the bus at index [param bus_idx] in dB.
</description>
</method>
- <method name="get_device_list">
+ <method name="get_input_device_list">
<return type="PackedStringArray" />
<description>
- Returns the names of all audio devices detected on the system.
+ Returns the names of all audio input devices detected on the system.
+ [b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
</description>
</method>
<method name="get_mix_rate" qualifiers="const">
@@ -129,6 +123,12 @@
Returns the sample rate at the output of the [AudioServer].
</description>
</method>
+ <method name="get_output_device_list">
+ <return type="PackedStringArray" />
+ <description>
+ Returns the names of all audio output devices detected on the system.
+ </description>
+ </method>
<method name="get_output_latency" qualifiers="const">
<return type="float" />
<description>
@@ -302,12 +302,12 @@
<member name="bus_count" type="int" setter="set_bus_count" getter="get_bus_count" default="1">
Number of available audio buses.
</member>
- <member name="capture_device" type="String" setter="capture_set_device" getter="capture_get_device" default="&quot;Default&quot;">
- Name of the current device for audio input (see [method capture_get_device_list]). On systems with multiple audio inputs (such as analog, USB and HDMI audio), this can be used to select the audio input device. The value [code]"Default"[/code] will record audio on the system-wide default audio input. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
+ <member name="input_device" type="String" setter="set_input_device" getter="get_input_device" default="&quot;Default&quot;">
+ Name of the current device for audio input (see [method get_input_device_list]). On systems with multiple audio inputs (such as analog, USB and HDMI audio), this can be used to select the audio input device. The value [code]"Default"[/code] will record audio on the system-wide default audio input. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
[b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
</member>
- <member name="device" type="String" setter="set_device" getter="get_device" default="&quot;Default&quot;">
- Name of the current device for audio output (see [method get_device_list]). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value [code]"Default"[/code] will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
+ <member name="output_device" type="String" setter="set_output_device" getter="get_output_device" default="&quot;Default&quot;">
+ Name of the current device for audio output (see [method get_output_device_list]). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value [code]"Default"[/code] will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
</member>
<member name="playback_speed_scale" type="float" setter="set_playback_speed_scale" getter="get_playback_speed_scale" default="1.0">
Scales the rate at which audio is played (i.e. setting it to [code]0.5[/code] will make the audio be played at half its speed).
diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml
index 9315a85e1f..4156c9451a 100644
--- a/doc/classes/Camera2D.xml
+++ b/doc/classes/Camera2D.xml
@@ -55,6 +55,18 @@
[b]Note:[/b] The returned value is not the same as [member Node2D.global_position], as it is affected by the drag properties. It is also not the same as the current position if [member position_smoothing_enabled] is [code]true[/code] (see [method get_screen_center_position]).
</description>
</method>
+ <method name="is_current" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if this [Camera2D] is the active camera (see [method Viewport.get_camera_2d]).
+ </description>
+ </method>
+ <method name="make_current">
+ <return type="void" />
+ <description>
+ Forces this [Camera2D] to become the current active one. [member enabled] must be [code]true[/code].
+ </description>
+ </method>
<method name="reset_smoothing">
<return type="void" />
<description>
@@ -83,9 +95,6 @@
<member name="anchor_mode" type="int" setter="set_anchor_mode" getter="get_anchor_mode" enum="Camera2D.AnchorMode" default="1">
The Camera2D's anchor point. See [enum AnchorMode] constants.
</member>
- <member name="current" type="bool" setter="set_current" getter="is_current" default="false">
- If [code]true[/code], the camera acts as the active camera for its [Viewport] ancestor. Only one camera can be current in a given viewport, so setting a different camera in the same viewport [code]current[/code] will disable whatever camera was already active in that viewport.
- </member>
<member name="custom_viewport" type="Node" setter="set_custom_viewport" getter="get_custom_viewport">
The custom [Viewport] node attached to the [Camera2D]. If [code]null[/code] or not a [Viewport], uses the default viewport instead.
</member>
@@ -124,6 +133,10 @@
<member name="editor_draw_screen" type="bool" setter="set_screen_drawing_enabled" getter="is_screen_drawing_enabled" default="true">
If [code]true[/code], draws the camera's screen rectangle in the editor.
</member>
+ <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
+ Controls whether the camera can be active or not. If [code]true[/code], the [Camera2D] will become the main camera when it enters the scene tree and there is no active camera currently (see [method Viewport.get_camera_2d]).
+ When the camera is currently active and [member enabled] is set to [code]false[/code], the next enabled [Camera2D] in the scene tree will become active.
+ </member>
<member name="ignore_rotation" type="bool" setter="set_ignore_rotation" getter="is_ignoring_rotation" default="true">
If [code]true[/code], the camera's rendered view is not affected by its [member Node2D.rotation] and [member Node2D.global_rotation].
</member>
diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml
index 57278d9241..cee0e3ef7d 100644
--- a/doc/classes/Color.xml
+++ b/doc/classes/Color.xml
@@ -233,7 +233,6 @@
<description>
Returns a new color from [param rgba], an HTML hexadecimal color string. [param rgba] is not case-sensitive, and may be prefixed by a hash sign ([code]#[/code]).
[param rgba] must be a valid three-digit or six-digit hexadecimal color string, and may contain an alpha channel value. If [param rgba] does not contain an alpha channel value, an alpha channel value of 1.0 is applied. If [param rgba] is invalid, returns an empty color.
- [b]Note:[/b] In C#, this method is not implemented. The same functionality is provided by the Color constructor.
[codeblocks]
[gdscript]
var blue = Color.html("#0000ff") # blue is Color(0.0, 0.0, 1.0, 1.0)
@@ -264,13 +263,13 @@
Color.html_is_valid("#55aaFF5") # Returns false
[/gdscript]
[csharp]
- Color.IsHtmlValid("#55AAFF"); // Returns true
- Color.IsHtmlValid("#55AAFF20"); // Returns true
- Color.IsHtmlValid("55AAFF"); // Returns true
- Color.IsHtmlValid("#F2C"); // Returns true
+ Color.HtmlIsValid("#55AAFF"); // Returns true
+ Color.HtmlIsValid("#55AAFF20"); // Returns true
+ Color.HtmlIsValid("55AAFF"); // Returns true
+ Color.HtmlIsValid("#F2C"); // Returns true
- Color.IsHtmlValid("#AABBC"); // Returns false
- Color.IsHtmlValid("#55aaFF5"); // Returns false
+ Color.HtmlIsValid("#AABBC"); // Returns false
+ Color.HtmlIsValid("#55aaFF5"); // Returns false
[/csharp]
[/codeblocks]
</description>
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 0d675112b8..d74ddba369 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -37,11 +37,11 @@
return typeof(data) == TYPE_DICTIONARY and data.has("expected")
[/gdscript]
[csharp]
- public override bool CanDropData(Vector2 position, object data)
+ public override bool _CanDropData(Vector2 atPosition, Variant data)
{
// Check position if it is relevant to you
// Otherwise, just check data
- return data is Godot.Collections.Dictionary &amp;&amp; (data as Godot.Collections.Dictionary).Contains("expected");
+ return data.VariantType == Variant.Type.Dictionary &amp;&amp; data.AsGodotDictionary().Contains("expected");
}
[/csharp]
[/codeblocks]
@@ -57,17 +57,19 @@
[gdscript]
func _can_drop_data(position, data):
return typeof(data) == TYPE_DICTIONARY and data.has("color")
+
func _drop_data(position, data):
var color = data["color"]
[/gdscript]
[csharp]
- public override bool CanDropData(Vector2 position, object data)
+ public override bool _CanDropData(Vector2 atPosition, Variant data)
{
- return data is Godot.Collections.Dictionary &amp;&amp; (data as Godot.Collections.Dictionary).Contains("color");
+ return data.VariantType == Variant.Type.Dictionary &amp;&amp; dict.AsGodotDictionary().Contains("color");
}
- public override void DropData(Vector2 position, object data)
+
+ public override void _DropData(Vector2 atPosition, Variant data)
{
- Color color = (Color)(data as Godot.Collections.Dictionary)["color"];
+ Color color = data.AsGodotDictionary()["color"].AsColor();
}
[/csharp]
[/codeblocks]
@@ -87,11 +89,11 @@
return mydata
[/gdscript]
[csharp]
- public override object GetDragData(Vector2 position)
+ public override Variant _GetDragData(Vector2 atPosition)
{
- object mydata = MakeData(); // This is your custom method generating the drag data.
- SetDragPreview(MakePreview(mydata)); // This is your custom method generating the preview of the drag data.
- return mydata;
+ var myData = MakeData(); // This is your custom method generating the drag data.
+ SetDragPreview(MakePreview(myData)); // This is your custom method generating the preview of the drag data.
+ return myData;
}
[/csharp]
[/codeblocks]
@@ -121,10 +123,9 @@
[csharp]
public override void _GuiInput(InputEvent @event)
{
- if (@event is InputEventMouseButton)
+ if (@event is InputEventMouseButton mb)
{
- var mb = @event as InputEventMouseButton;
- if (mb.ButtonIndex == (int)ButtonList.Left &amp;&amp; mb.Pressed)
+ if (mb.ButtonIndex == MouseButton.Left &amp;&amp; mb.Pressed)
{
GD.Print("I've been clicked D:");
}
@@ -168,7 +169,7 @@
return label
[/gdscript]
[csharp]
- public override Godot.Control _MakeCustomTooltip(String forText)
+ public override Control _MakeCustomTooltip(string forText)
{
var label = new Label();
label.Text = forText;
@@ -185,7 +186,7 @@
return tooltip
[/gdscript]
[csharp]
- public override Godot.Control _MakeCustomTooltip(String forText)
+ public override Control _MakeCustomTooltip(string forText)
{
Node tooltip = ResourceLoader.Load&lt;PackedScene&gt;("res://some_tooltip_scene.tscn").Instantiate();
tooltip.GetNode&lt;Label&gt;("Label").Text = forText;
@@ -229,11 +230,11 @@
[/gdscript]
[csharp]
// Given the child Label node "MyLabel", override its font color with a custom value.
- GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0))
+ GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0));
// Reset the font color of the child label.
- GetNode&lt;Label&gt;("MyLabel").RemoveThemeColorOverride("font_color")
+ GetNode&lt;Label&gt;("MyLabel").RemoveThemeColorOverride("font_color");
// Alternatively it can be overridden with the default value from the Label type.
- GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", GetThemeColor("font_color", "Label"))
+ GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", GetThemeColor("font_color", "Label"));
[/csharp]
[/codeblocks]
</description>
@@ -542,12 +543,12 @@
[codeblocks]
[gdscript]
func _process(delta):
- grab_click_focus() #when clicking another Control node, this node will be clicked instead
+ grab_click_focus() # When clicking another Control node, this node will be clicked instead.
[/gdscript]
[csharp]
- public override void _Process(float delta)
+ public override void _Process(double delta)
{
- GrabClickFocus(); //when clicking another Control node, this node will be clicked instead
+ GrabClickFocus(); // When clicking another Control node, this node will be clicked instead.
}
[/csharp]
[/codeblocks]
@@ -812,16 +813,16 @@
[/gdscript]
[csharp]
[Export]
- public Color Color = new Color(1, 0, 0, 1);
+ private Color _color = new Color(1, 0, 0, 1);
- public override object GetDragData(Vector2 position)
+ public override Variant _GetDragData(Vector2 atPosition)
{
// Use a control that is not in the tree
var cpb = new ColorPickerButton();
- cpb.Color = Color;
- cpb.RectSize = new Vector2(50, 50);
+ cpb.Color = _color;
+ cpb.Size = new Vector2(50, 50);
SetDragPreview(cpb);
- return Color;
+ return _color;
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/Crypto.xml b/doc/classes/Crypto.xml
index ade63225dc..a7e7e756c6 100644
--- a/doc/classes/Crypto.xml
+++ b/doc/classes/Crypto.xml
@@ -9,9 +9,11 @@
[codeblocks]
[gdscript]
extends Node
+
var crypto = Crypto.new()
var key = CryptoKey.new()
var cert = X509Certificate.new()
+
func _ready():
# Generate new RSA key.
key = crypto.generate_rsa(4096)
@@ -35,35 +37,35 @@
[/gdscript]
[csharp]
using Godot;
- using System;
using System.Diagnostics;
- public class CryptoNode : Node
+ public partial class MyNode : Node
{
- public Crypto Crypto = new Crypto();
- public CryptoKey Key = new CryptoKey();
- public X509Certificate Cert = new X509Certificate();
+ private Crypto _crypto = new Crypto();
+ private CryptoKey _key = new CryptoKey();
+ private X509Certificate _cert = new X509Certificate();
+
public override void _Ready()
{
// Generate new RSA key.
- Key = Crypto.GenerateRsa(4096);
+ _key = _crypto.GenerateRsa(4096);
// Generate new self-signed certificate with the given key.
- Cert = Crypto.GenerateSelfSignedCertificate(Key, "CN=mydomain.com,O=My Game Company,C=IT");
+ _cert = _crypto.GenerateSelfSignedCertificate(_key, "CN=mydomain.com,O=My Game Company,C=IT");
// Save key and certificate in the user folder.
- Key.Save("user://generated.key");
- Cert.Save("user://generated.crt");
+ _key.Save("user://generated.key");
+ _cert.Save("user://generated.crt");
// Encryption
string data = "Some data";
- byte[] encrypted = Crypto.Encrypt(Key, data.ToUTF8());
+ byte[] encrypted = _crypto.Encrypt(_key, data.ToUtf8());
// Decryption
- byte[] decrypted = Crypto.Decrypt(Key, encrypted);
+ byte[] decrypted = _crypto.Decrypt(_key, encrypted);
// Signing
- byte[] signature = Crypto.Sign(HashingContext.HashType.Sha256, Data.SHA256Buffer(), Key);
+ byte[] signature = _crypto.Sign(HashingContext.HashType.Sha256, Data.Sha256Buffer(), _key);
// Verifying
- bool verified = Crypto.Verify(HashingContext.HashType.Sha256, Data.SHA256Buffer(), signature, Key);
+ bool verified = _crypto.Verify(HashingContext.HashType.Sha256, Data.Sha256Buffer(), signature, _key);
// Checks
Debug.Assert(verified);
- Debug.Assert(data.ToUTF8() == decrypted);
+ Debug.Assert(data.ToUtf8() == decrypted);
}
}
[/csharp]
diff --git a/doc/classes/DTLSServer.xml b/doc/classes/DTLSServer.xml
index a3a0b0456c..ae1ba10ec7 100644
--- a/doc/classes/DTLSServer.xml
+++ b/doc/classes/DTLSServer.xml
@@ -38,45 +38,46 @@
p.put_packet("Hello DTLS client".to_utf8())
[/gdscript]
[csharp]
- using Godot;
- using System;
// ServerNode.cs
- public class ServerNode : Node
+ using Godot;
+
+ public partial class ServerNode : Node
{
- public DTLSServer Dtls = new DTLSServer();
- public UDPServer Server = new UDPServer();
- public Godot.Collections.Array&lt;PacketPeerDTLS&gt; Peers = new Godot.Collections.Array&lt;PacketPeerDTLS&gt;();
+ private DtlsServer _dtls = new DtlsServer();
+ private UdpServer _server = new UdpServer();
+ private Godot.Collections.Array&lt;PacketPeerDTLS&gt; _peers = new Godot.Collections.Array&lt;PacketPeerDTLS&gt;();
+
public override void _Ready()
{
- Server.Listen(4242);
+ _server.Listen(4242);
var key = GD.Load&lt;CryptoKey&gt;("key.key"); // Your private key.
var cert = GD.Load&lt;X509Certificate&gt;("cert.crt"); // Your X509 certificate.
- Dtls.Setup(key, cert);
+ _dtls.Setup(key, cert);
}
- public override void _Process(float delta)
+ public override void _Process(double delta)
{
while (Server.IsConnectionAvailable())
{
- PacketPeerUDP peer = Server.TakeConnection();
- PacketPeerDTLS dtlsPeer = Dtls.TakeConnection(peer);
- if (dtlsPeer.GetStatus() != PacketPeerDTLS.Status.Handshaking)
+ PacketPeerUDP peer = _server.TakeConnection();
+ PacketPeerDTLS dtlsPeer = _dtls.TakeConnection(peer);
+ if (dtlsPeer.GetStatus() != PacketPeerDtls.Status.Handshaking)
{
continue; // It is normal that 50% of the connections fails due to cookie exchange.
}
GD.Print("Peer connected!");
- Peers.Add(dtlsPeer);
+ _peers.Add(dtlsPeer);
}
- foreach (var p in Peers)
+ foreach (var p in _peers)
{
p.Poll(); // Must poll to update the state.
- if (p.GetStatus() == PacketPeerDTLS.Status.Connected)
+ if (p.GetStatus() == PacketPeerDtls.Status.Connected)
{
while (p.GetAvailablePacketCount() &gt; 0)
{
- GD.Print("Received Message From Client: " + p.GetPacket().GetStringFromUTF8());
- p.PutPacket("Hello Dtls Client".ToUTF8());
+ GD.Print($"Received Message From Client: {p.GetPacket().GetStringFromUtf8()}");
+ p.PutPacket("Hello DTLS Client".ToUtf8());
}
}
}
@@ -108,34 +109,36 @@
connected = true
[/gdscript]
[csharp]
+ // ClientNode.cs
using Godot;
using System.Text;
- // ClientNode.cs
- public class ClientNode : Node
+
+ public partial class ClientNode : Node
{
- public PacketPeerDTLS Dtls = new PacketPeerDTLS();
- public PacketPeerUDP Udp = new PacketPeerUDP();
- public bool Connected = false;
+ private PacketPeerDtls _dtls = new PacketPeerDtls();
+ private PacketPeerUdp _udp = new PacketPeerUdp();
+ private bool _connected = false;
+
public override void _Ready()
{
- Udp.ConnectToHost("127.0.0.1", 4242);
- Dtls.ConnectToPeer(Udp, false); // Use true in production for certificate validation!
+ _udp.ConnectToHost("127.0.0.1", 4242);
+ _dtls.ConnectToPeer(_udp, validateCerts: false); // Use true in production for certificate validation!
}
- public override void _Process(float delta)
+ public override void _Process(double delta)
{
- Dtls.Poll();
- if (Dtls.GetStatus() == PacketPeerDTLS.Status.Connected)
+ _dtls.Poll();
+ if (_dtls.GetStatus() == PacketPeerDtls.Status.Connected)
{
- if (!Connected)
+ if (!_connected)
{
// Try to contact server
- Dtls.PutPacket("The Answer Is..42!".ToUTF8());
+ _dtls.PutPacket("The Answer Is..42!".ToUtf8());
}
- while (Dtls.GetAvailablePacketCount() &gt; 0)
+ while (_dtls.GetAvailablePacketCount() &gt; 0)
{
- GD.Print("Connected: " + Dtls.GetPacket().GetStringFromUTF8());
- Connected = true;
+ GD.Print($"Connected: {_dtls.GetPacket().GetStringFromUtf8()}");
+ _connected = true;
}
}
}
diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml
index b9d3f1d81e..fb8bc18c1a 100644
--- a/doc/classes/Decal.xml
+++ b/doc/classes/Decal.xml
@@ -75,9 +75,6 @@
<member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy" default="1.0">
Energy multiplier for the emission texture. This will make the decal emit light at a higher or lower intensity, independently of the albedo color. See also [member modulate].
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- Sets the size of the [AABB] used by the decal. The AABB goes from [code]-extents[/code] to [code]extents[/code].
- </member>
<member name="lower_fade" type="float" setter="set_lower_fade" getter="get_lower_fade" default="0.3">
Sets the curve over which the decal will fade as the surface gets further from the center of the [AABB]. Only positive values are valid (negative values will be clamped to [code]0.0[/code]). See also [member upper_fade].
</member>
@@ -88,6 +85,9 @@
Fades the Decal if the angle between the Decal's [AABB] and the target surface becomes too large. A value of [code]0[/code] projects the Decal regardless of angle, a value of [code]1[/code] limits the Decal to surfaces that are nearly perpendicular.
[b]Note:[/b] Setting [member normal_fade] to a value greater than [code]0.0[/code] has a small performance cost due to the added normal angle computations.
</member>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ Sets the size of the [AABB] used by the decal. The AABB goes from [code]-size/2[/code] to [code]size/2[/code].
+ </member>
<member name="texture_albedo" type="Texture2D" setter="set_texture" getter="get_texture">
[Texture2D] with the base [Color] of the Decal. Either this or the [member texture_emission] must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
[b]Note:[/b] Unlike [BaseMaterial3D] whose filter mode can be adjusted on a per-material basis, the filter mode for [Decal] textures is set globally with [member ProjectSettings.rendering/textures/decals/filter].
diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml
index 1591aa59bf..a5a50b4c6a 100644
--- a/doc/classes/Dictionary.xml
+++ b/doc/classes/Dictionary.xml
@@ -51,7 +51,7 @@
[csharp]
[Export(PropertyHint.Enum, "White,Yellow,Orange")]
public string MyColor { get; set; }
- public Godot.Collections.Dictionary pointsDict = new Godot.Collections.Dictionary
+ private Godot.Collections.Dictionary _pointsDict = new Godot.Collections.Dictionary
{
{"White", 50},
{"Yellow", 75},
@@ -60,7 +60,7 @@
public override void _Ready()
{
- int points = (int)pointsDict[MyColor];
+ int points = (int)_pointsDict[MyColor];
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/DirAccess.xml b/doc/classes/DirAccess.xml
index 181d2eb485..27f2eb7f2f 100644
--- a/doc/classes/DirAccess.xml
+++ b/doc/classes/DirAccess.xml
@@ -44,11 +44,11 @@
{
if (dir.CurrentIsDir())
{
- GD.Print("Found directory: " + fileName);
+ GD.Print($"Found directory: {fileName}");
}
else
{
- GD.Print("Found file: " + fileName);
+ GD.Print($"Found file: {fileName}");
}
fileName = dir.GetNext();
}
diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml
index 50cabf3c8c..6a976d218f 100644
--- a/doc/classes/EditorImportPlugin.xml
+++ b/doc/classes/EditorImportPlugin.xml
@@ -48,61 +48,67 @@
[/gdscript]
[csharp]
using Godot;
- using System;
- public class MySpecialPlugin : EditorImportPlugin
+ public partial class MySpecialPlugin : EditorImportPlugin
{
- public override String GetImporterName()
+ public override string _GetImporterName()
{
return "my.special.plugin";
}
- public override String GetVisibleName()
+ public override string _GetVisibleName()
{
return "Special Mesh";
}
- public override Godot.Collections.Array GetRecognizedExtensions()
+ public override string[] _GetRecognizedExtensions()
{
- return new Godot.Collections.Array{"special", "spec"};
+ return new string[] { "special", "spec" };
}
- public override String GetSaveExtension()
+ public override string _GetSaveExtension()
{
return "mesh";
}
- public override String GetResourceType()
+ public override string _GetResourceType()
{
return "Mesh";
}
- public override int GetPresetCount()
+ public override int _GetPresetCount()
{
return 1;
}
- public override String GetPresetName(int i)
+ public override string _GetPresetName(int presetIndex)
{
return "Default";
}
- public override Godot.Collections.Array GetImportOptions(int i)
+ public override Godot.Collections.Array&lt;Godot.Collections.Dictionary&gt; _GetImportOptions(string path, int presetIndex)
{
- return new Godot.Collections.Array{new Godot.Collections.Dictionary{{"name", "myOption"}, {"defaultValue", false}}};
+ return new Godot.Collections.Array&lt;Godot.Collections.Dictionary&gt;
+ {
+ new Godot.Collections.Dictionary
+ {
+ { "name", "myOption" },
+ { "defaultValue", false },
+ }
+ };
}
- public override int Import(String sourceFile, String savePath, Godot.Collections.Dictionary options, Godot.Collections.Array platformVariants, Godot.Collections.Array genFiles)
+ public override int _Import(string sourceFile, string savePath, Godot.Collections.Dictionary options, Godot.Collections.Array&lt;string&gt; platformVariants, Godot.Collections.Array&lt;string&gt; genFiles)
{
- var file = new File();
- if (file.Open(sourceFile, File.ModeFlags.Read) != Error.Ok)
+ using var file = FileAccess.Open(sourceFile, FileAccess.ModeFlags.Read);
+ if (file.GetError() != Error.Ok)
{
return (int)Error.Failed;
}
var mesh = new ArrayMesh();
// Fill the Mesh with data read in "file", left as an exercise to the reader.
- String filename = savePath + "." + GetSaveExtension();
+ string filename = $"{savePath}.{_GetSaveExtension()}";
return (int)ResourceSaver.Save(mesh, filename);
}
}
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index c097c8f685..f4b912de9e 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -69,21 +69,22 @@
return EditorPlugin.AFTER_GUI_INPUT_PASS
[/gdscript]
[csharp]
- public override void _Forward3dDrawOverViewport(Godot.Control overlay)
+ public override void _Forward3DDrawOverViewport(Control viewportControl)
{
// Draw a circle at cursor position.
- overlay.DrawCircle(overlay.GetLocalMousePosition(), 64, Colors.White);
+ viewportControl.DrawCircle(viewportControl.GetLocalMousePosition(), 64, Colors.White);
}
- public override EditorPlugin.AfterGUIInput _Forward3dGuiInput(Godot.Camera3D camera, InputEvent @event)
+ public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D viewportCamera, InputEvent @event)
{
if (@event is InputEventMouseMotion)
{
// Redraw viewport when cursor is moved.
UpdateOverlays();
- return EditorPlugin.AFTER_GUI_INPUT_STOP;
+ return EditorPlugin.AfterGuiInput.Stop;
}
- return EditorPlugin.AFTER_GUI_INPUT_PASS;
+ return EditorPlugin.AfterGuiInput.Pass;
+ }
[/csharp]
[/codeblocks]
</description>
@@ -111,9 +112,9 @@
[/gdscript]
[csharp]
// Prevents the InputEvent from reaching other Editor classes.
- public override EditorPlugin.AfterGUIInput _Forward3dGuiInput(Camera3D camera, InputEvent @event)
+ public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D camera, InputEvent @event)
{
- return EditorPlugin.AFTER_GUI_INPUT_STOP;
+ return EditorPlugin.AfterGuiInput.Stop;
}
[/csharp]
[/codeblocks]
@@ -127,9 +128,9 @@
[/gdscript]
[csharp]
// Consumes InputEventMouseMotion and forwards other InputEvent types.
- public override EditorPlugin.AfterGUIInput _Forward3dGuiInput(Camera3D camera, InputEvent @event)
+ public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D camera, InputEvent @event)
{
- return @event is InputEventMouseMotion ? EditorPlugin.AFTER_GUI_INPUT_STOP : EditorPlugin.AFTER_GUI_INPUT_PASS;
+ return @event is InputEventMouseMotion ? EditorPlugin.AfterGuiInput.Stop : EditorPlugin.AfterGuiInput.Pass;
}
[/csharp]
[/codeblocks]
@@ -154,13 +155,13 @@
return false
[/gdscript]
[csharp]
- public override void ForwardCanvasDrawOverViewport(Godot.Control overlay)
+ public override void _ForwardCanvasDrawOverViewport(Control viewportControl)
{
// Draw a circle at cursor position.
- overlay.DrawCircle(overlay.GetLocalMousePosition(), 64, Colors.White);
+ viewportControl.DrawCircle(viewportControl.GetLocalMousePosition(), 64, Colors.White);
}
- public override bool ForwardCanvasGuiInput(InputEvent @event)
+ public override bool _ForwardCanvasGuiInput(InputEvent @event)
{
if (@event is InputEventMouseMotion)
{
@@ -169,6 +170,7 @@
return true;
}
return false;
+ }
[/csharp]
[/codeblocks]
</description>
@@ -213,12 +215,13 @@
[/gdscript]
[csharp]
// Consumes InputEventMouseMotion and forwards other InputEvent types.
- public override bool ForwardCanvasGuiInput(InputEvent @event)
+ public override bool _ForwardCanvasGuiInput(InputEvent @event)
{
- if (@event is InputEventMouseMotion) {
+ if (@event is InputEventMouseMotion)
+ {
return true;
}
- return false
+ return false;
}
[/csharp]
[/codeblocks]
@@ -245,7 +248,7 @@
return get_editor_interface().get_base_control().get_theme_icon("Node", "EditorIcons")
[/gdscript]
[csharp]
- public override Texture2D GetPluginIcon()
+ public override Texture2D _GetPluginIcon()
{
// You can use a custom icon:
return ResourceLoader.Load&lt;Texture2D&gt;("res://addons/my_plugin/my_plugin_icon.svg");
diff --git a/doc/classes/EditorScenePostImport.xml b/doc/classes/EditorScenePostImport.xml
index d2ad8d1bed..44bc72ea49 100644
--- a/doc/classes/EditorScenePostImport.xml
+++ b/doc/classes/EditorScenePostImport.xml
@@ -10,12 +10,14 @@
[gdscript]
@tool # Needed so it runs in editor.
extends EditorScenePostImport
+
# This sample changes all node names.
# Called right after the scene is imported and gets the root node.
func _post_import(scene):
# Change all node names to "modified_[oldnodename]"
iterate(scene)
return scene # Remember to return the imported scene
+
func iterate(node):
if node != null:
node.name = "modified_" + node.name
@@ -30,17 +32,18 @@
[Tool]
public partial class NodeRenamer : EditorScenePostImport
{
- public override Object _PostImport(Node scene)
+ public override GodotObject _PostImport(Node scene)
{
// Change all node names to "modified_[oldnodename]"
Iterate(scene);
return scene; // Remember to return the imported scene
}
+
public void Iterate(Node node)
{
if (node != null)
{
- node.Name = "modified_" + node.Name;
+ node.Name = $"modified_{node.Name}";
foreach (Node child in node.GetChildren())
{
Iterate(child);
diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml
index a02fd215d8..33d2f40d0b 100644
--- a/doc/classes/EditorScript.xml
+++ b/doc/classes/EditorScript.xml
@@ -17,10 +17,9 @@
[/gdscript]
[csharp]
using Godot;
- using System;
[Tool]
- public class HelloEditor : EditorScript
+ public partial class HelloEditor : EditorScript
{
public override void _Run()
{
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 72843eb157..1bf8cbf175 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -22,7 +22,7 @@
settings.SetSetting("some/property", Value);
// `settings.get("some/property", value)` also works as this class overrides `_get()` internally.
settings.GetSetting("some/property");
- Godot.Collections.Array listOfSettings = settings.GetPropertyList();
+ Godot.Collections.Array&lt;Godot.Collections.Dictionary&gt; listOfSettings = settings.GetPropertyList();
[/csharp]
[/codeblocks]
[b]Note:[/b] This class shouldn't be instantiated directly. Instead, access the singleton using [method EditorInterface.get_editor_settings].
diff --git a/doc/classes/EditorTranslationParserPlugin.xml b/doc/classes/EditorTranslationParserPlugin.xml
index 89746363d8..40b469de0a 100644
--- a/doc/classes/EditorTranslationParserPlugin.xml
+++ b/doc/classes/EditorTranslationParserPlugin.xml
@@ -27,27 +27,25 @@
[/gdscript]
[csharp]
using Godot;
- using System;
[Tool]
- public class CustomParser : EditorTranslationParserPlugin
+ public partial class CustomParser : EditorTranslationParserPlugin
{
- public override void ParseFile(string path, Godot.Collections.Array msgids, Godot.Collections.Array msgidsContextPlural)
+ public override void _ParseFile(string path, Godot.Collections.Array&lt;string&gt; msgids, Godot.Collections.Array&lt;Godot.Collections.Array&gt; msgidsContextPlural)
{
- var file = new File();
- file.Open(path, File.ModeFlags.Read);
+ using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
string text = file.GetAsText();
- string[] splitStrs = text.Split(",", false);
- foreach (var s in splitStrs)
+ string[] splitStrs = text.Split(",", allowEmpty: false);
+ foreach (string s in splitStrs)
{
msgids.Add(s);
- //GD.Print("Extracted string: " + s)
+ //GD.Print($"Extracted string: {s}");
}
}
- public override Godot.Collections.Array GetRecognizedExtensions()
+ public override string[] _GetRecognizedExtensions()
{
- return new Godot.Collections.Array{"csv"};
+ return new string[] { "csv" };
}
}
[/csharp]
@@ -84,16 +82,16 @@
return ["gd"]
[/gdscript]
[csharp]
- public override void ParseFile(string path, Godot.Collections.Array msgids, Godot.Collections.Array msgidsContextPlural)
+ public override void _ParseFile(string path, Godot.Collections.Array&lt;string&gt; msgids, Godot.Collections.Array&lt;Godot.Collections.Array&gt; msgidsContextPlural)
{
var res = ResourceLoader.Load&lt;Script&gt;(path, "Script");
string text = res.SourceCode;
// Parsing logic.
}
- public override Godot.Collections.Array GetRecognizedExtensions()
+ public override string[] _GetRecognizedExtensions()
{
- return new Godot.Collections.Array{"gd"};
+ return new string[] { "gd" };
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/Expression.xml b/doc/classes/Expression.xml
index 2c7d83a811..fd5a921836 100644
--- a/doc/classes/Expression.xml
+++ b/doc/classes/Expression.xml
@@ -24,7 +24,7 @@
$LineEdit.text = str(result)
[/gdscript]
[csharp]
- public Expression expression = new Expression();
+ private Expression _expression = new Expression();
public override void _Ready()
{
@@ -33,14 +33,14 @@
private void OnTextEntered(string command)
{
- Error error = expression.Parse(command);
+ Error error = _expression.Parse(command);
if (error != Error.Ok)
{
- GD.Print(expression.GetErrorText());
+ GD.Print(_expression.GetErrorText());
return;
}
- object result = expression.Execute();
- if (!expression.HasExecuteFailed())
+ Variant result = _expression.Execute();
+ if (!_expression.HasExecuteFailed())
{
GetNode&lt;LineEdit&gt;("LineEdit").Text = result.ToString();
}
diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml
index be0c8fd6ca..687a64b8ff 100644
--- a/doc/classes/FileAccess.xml
+++ b/doc/classes/FileAccess.xml
@@ -348,8 +348,8 @@
f.Seek(0); // Go back to start to read the stored value.
ushort read1 = f.Get16(); // 65494
ushort read2 = f.Get16(); // 121
- short converted1 = BitConverter.ToInt16(BitConverter.GetBytes(read1), 0); // -42
- short converted2 = BitConverter.ToInt16(BitConverter.GetBytes(read2), 0); // 121
+ short converted1 = (short)read1; // -42
+ short converted2 = (short)read2; // 121
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/FogVolume.xml b/doc/classes/FogVolume.xml
index d9fa2e6ebb..e2f9038be5 100644
--- a/doc/classes/FogVolume.xml
+++ b/doc/classes/FogVolume.xml
@@ -11,16 +11,16 @@
<tutorials>
</tutorials>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- The size of the [FogVolume] when [member shape] is [constant RenderingServer.FOG_VOLUME_SHAPE_ELLIPSOID], [constant RenderingServer.FOG_VOLUME_SHAPE_CONE], [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER] or [constant RenderingServer.FOG_VOLUME_SHAPE_BOX].
- [b]Note:[/b] Thin fog volumes may appear to flicker when the camera moves or rotates. This can be alleviated by increasing [member ProjectSettings.rendering/environment/volumetric_fog/volume_depth] (at a performance cost) or by decreasing [member Environment.volumetric_fog_length] (at no performance cost, but at the cost of lower fog range). Alternatively, the [FogVolume] can be made thicker and use a lower density in the [member material].
- [b]Note:[/b] If [member shape] is [constant RenderingServer.FOG_VOLUME_SHAPE_CONE] or [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER], the cone/cylinder will be adjusted to fit within the extents. Non-uniform scaling of cone/cylinder shapes via the [member extents] property is not supported, but you can scale the [FogVolume] node instead.
- </member>
<member name="material" type="Material" setter="set_material" getter="get_material">
The [Material] used by the [FogVolume]. Can be either a built-in [FogMaterial] or a custom [ShaderMaterial].
</member>
<member name="shape" type="int" setter="set_shape" getter="get_shape" enum="RenderingServer.FogVolumeShape" default="3">
The shape of the [FogVolume]. This can be set to either [constant RenderingServer.FOG_VOLUME_SHAPE_ELLIPSOID], [constant RenderingServer.FOG_VOLUME_SHAPE_CONE], [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER], [constant RenderingServer.FOG_VOLUME_SHAPE_BOX] or [constant RenderingServer.FOG_VOLUME_SHAPE_WORLD].
</member>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ The size of the [FogVolume] when [member shape] is [constant RenderingServer.FOG_VOLUME_SHAPE_ELLIPSOID], [constant RenderingServer.FOG_VOLUME_SHAPE_CONE], [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER] or [constant RenderingServer.FOG_VOLUME_SHAPE_BOX].
+ [b]Note:[/b] Thin fog volumes may appear to flicker when the camera moves or rotates. This can be alleviated by increasing [member ProjectSettings.rendering/environment/volumetric_fog/volume_depth] (at a performance cost) or by decreasing [member Environment.volumetric_fog_length] (at no performance cost, but at the cost of lower fog range). Alternatively, the [FogVolume] can be made thicker and use a lower density in the [member material].
+ [b]Note:[/b] If [member shape] is [constant RenderingServer.FOG_VOLUME_SHAPE_CONE] or [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER], the cone/cylinder will be adjusted to fit within the size. Non-uniform scaling of cone/cylinder shapes via the [member size] property is not supported, but you can scale the [FogVolume] node instead.
+ </member>
</members>
</class>
diff --git a/doc/classes/GPUParticlesAttractorBox3D.xml b/doc/classes/GPUParticlesAttractorBox3D.xml
index 6595428cc2..65a4c6d4a5 100644
--- a/doc/classes/GPUParticlesAttractorBox3D.xml
+++ b/doc/classes/GPUParticlesAttractorBox3D.xml
@@ -10,8 +10,8 @@
<tutorials>
</tutorials>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- The attractor box's extents in 3D units.
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ The attractor box's size in 3D units.
</member>
</members>
</class>
diff --git a/doc/classes/GPUParticlesAttractorVectorField3D.xml b/doc/classes/GPUParticlesAttractorVectorField3D.xml
index aeadfaf4ab..12e6774471 100644
--- a/doc/classes/GPUParticlesAttractorVectorField3D.xml
+++ b/doc/classes/GPUParticlesAttractorVectorField3D.xml
@@ -11,12 +11,12 @@
<tutorials>
</tutorials>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- The extents of the vector field box in 3D units.
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ The size of the vector field box in 3D units.
</member>
<member name="texture" type="Texture3D" setter="set_texture" getter="get_texture">
The 3D texture to be used. Values are linearly interpolated between the texture's pixels.
- [b]Note:[/b] To get better performance, the 3D texture's resolution should reflect the [member extents] of the attractor. Since particle attraction is usually low-frequency data, the texture can be kept at a low resolution such as 64×64×64.
+ [b]Note:[/b] To get better performance, the 3D texture's resolution should reflect the [member size] of the attractor. Since particle attraction is usually low-frequency data, the texture can be kept at a low resolution such as 64×64×64.
</member>
</members>
</class>
diff --git a/doc/classes/GPUParticlesCollisionBox3D.xml b/doc/classes/GPUParticlesCollisionBox3D.xml
index 103be18bfd..737db0ba8a 100644
--- a/doc/classes/GPUParticlesCollisionBox3D.xml
+++ b/doc/classes/GPUParticlesCollisionBox3D.xml
@@ -11,8 +11,8 @@
<tutorials>
</tutorials>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- The collision box's extents in 3D units.
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ The collision box's size in 3D units.
</member>
</members>
</class>
diff --git a/doc/classes/GPUParticlesCollisionHeightField3D.xml b/doc/classes/GPUParticlesCollisionHeightField3D.xml
index 6e996d5fbd..c8ed78b85e 100644
--- a/doc/classes/GPUParticlesCollisionHeightField3D.xml
+++ b/doc/classes/GPUParticlesCollisionHeightField3D.xml
@@ -13,9 +13,6 @@
<tutorials>
</tutorials>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- The collision heightmap's extents in 3D units. To improve heightmap quality, [member extents] should be set as small as possible while covering the parts of the scene you need.
- </member>
<member name="follow_camera_enabled" type="bool" setter="set_follow_camera_enabled" getter="is_follow_camera_enabled" default="false">
If [code]true[/code], the [GPUParticlesCollisionHeightField3D] will follow the current camera in global space. The [GPUParticlesCollisionHeightField3D] does not need to be a child of the [Camera3D] node for this to work.
Following the camera has a performance cost, as it will force the heightmap to update whenever the camera moves. Consider lowering [member resolution] to improve performance if [member follow_camera_enabled] is [code]true[/code].
@@ -23,6 +20,9 @@
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionHeightField3D.Resolution" default="2">
Higher resolutions can represent small details more accurately in large scenes, at the cost of lower performance. If [member update_mode] is [constant UPDATE_MODE_ALWAYS], consider using the lowest resolution possible.
</member>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ The collision heightmap's size in 3D units. To improve heightmap quality, [member size] should be set as small as possible while covering the parts of the scene you need.
+ </member>
<member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="GPUParticlesCollisionHeightField3D.UpdateMode" default="0">
The update policy to use for the generated heightmap.
</member>
diff --git a/doc/classes/GPUParticlesCollisionSDF3D.xml b/doc/classes/GPUParticlesCollisionSDF3D.xml
index 8467cfdda1..dc4a4a2027 100644
--- a/doc/classes/GPUParticlesCollisionSDF3D.xml
+++ b/doc/classes/GPUParticlesCollisionSDF3D.xml
@@ -6,7 +6,7 @@
<description>
Baked signed distance field 3D particle attractor affecting [GPUParticles3D] nodes.
Signed distance fields (SDF) allow for efficiently representing approximate collision shapes for convex and concave objects of any shape. This is more flexible than [GPUParticlesCollisionHeightField3D], but it requires a baking step.
- [b]Baking:[/b] The signed distance field texture can be baked by selecting the [GPUParticlesCollisionSDF3D] node in the editor, then clicking [b]Bake SDF[/b] at the top of the 3D viewport. Any [i]visible[/i] [MeshInstance3D]s touching the [member extents] will be taken into account for baking, regardless of their [member GeometryInstance3D.gi_mode].
+ [b]Baking:[/b] The signed distance field texture can be baked by selecting the [GPUParticlesCollisionSDF3D] node in the editor, then clicking [b]Bake SDF[/b] at the top of the 3D viewport. Any [i]visible[/i] [MeshInstance3D]s within the [member size] will be taken into account for baking, regardless of their [member GeometryInstance3D.gi_mode].
[b]Note:[/b] Baking a [GPUParticlesCollisionSDF3D]'s [member texture] is only possible within the editor, as there is no bake method exposed for use in exported projects. However, it's still possible to load pre-baked [Texture3D]s into its [member texture] property in an exported project.
[b]Note:[/b] [member ParticleProcessMaterial.collision_mode] must be [constant ParticleProcessMaterial.COLLISION_RIGID] or [constant ParticleProcessMaterial.COLLISION_HIDE_ON_CONTACT] on the [GPUParticles3D]'s process material for collision to work.
[b]Note:[/b] Particle collision only affects [GPUParticles3D], not [CPUParticles3D].
@@ -34,12 +34,12 @@
<member name="bake_mask" type="int" setter="set_bake_mask" getter="get_bake_mask" default="4294967295">
The visual layers to account for when baking the particle collision SDF. Only [MeshInstance3D]s whose [member VisualInstance3D.layers] match with this [member bake_mask] will be included in the generated particle collision SDF. By default, all objects are taken into account for the particle collision SDF baking.
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
- The collision SDF's extents in 3D units. To improve SDF quality, the [member extents] should be set as small as possible while covering the parts of the scene you need.
- </member>
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF3D.Resolution" default="2">
The bake resolution to use for the signed distance field [member texture]. The texture must be baked again for changes to the [member resolution] property to be effective. Higher resolutions have a greater performance cost and take more time to bake. Higher resolutions also result in larger baked textures, leading to increased VRAM and storage space requirements. To improve performance and reduce bake times, use the lowest resolution possible for the object you're representing the collision of.
</member>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
+ The collision SDF's size in 3D units. To improve SDF quality, the [member size] should be set as small as possible while covering the parts of the scene you need.
+ </member>
<member name="texture" type="Texture3D" setter="set_texture" getter="get_texture">
The 3D texture representing the signed distance field.
</member>
diff --git a/doc/classes/Geometry2D.xml b/doc/classes/Geometry2D.xml
index 0142018f1a..f015026bc1 100644
--- a/doc/classes/Geometry2D.xml
+++ b/doc/classes/Geometry2D.xml
@@ -160,14 +160,13 @@
var polygon = PackedVector2Array([Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100)])
var offset = Vector2(50, 50)
polygon = Transform2D(0, offset) * polygon
- print(polygon) # prints [Vector2(50, 50), Vector2(150, 50), Vector2(150, 150), Vector2(50, 150)]
+ print(polygon) # prints [(50, 50), (150, 50), (150, 150), (50, 150)]
[/gdscript]
[csharp]
var polygon = new Vector2[] { new Vector2(0, 0), new Vector2(100, 0), new Vector2(100, 100), new Vector2(0, 100) };
var offset = new Vector2(50, 50);
- // TODO: This code is not valid right now. Ping @aaronfranke about it before Godot 4.0 is out.
- //polygon = (Vector2[]) new Transform2D(0, offset).Xform(polygon);
- //GD.Print(polygon); // prints [Vector2(50, 50), Vector2(150, 50), Vector2(150, 150), Vector2(50, 150)]
+ polygon = new Transform2D(0, offset) * polygon;
+ GD.Print((Variant)polygon); // prints [(50, 50), (150, 50), (150, 150), (50, 150)]
[/csharp]
[/codeblocks]
</description>
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml
index ea4e4b53ba..490637374d 100644
--- a/doc/classes/GraphEdit.xml
+++ b/doc/classes/GraphEdit.xml
@@ -72,8 +72,9 @@
return from != to
[/gdscript]
[csharp]
- public override bool _IsNodeHoverValid(String from, int fromSlot, String to, int toSlot) {
- return from != to;
+ public override bool _IsNodeHoverValid(StringName fromNode, int fromPort, StringName toNode, int toPort)
+ {
+ return fromNode != toNode;
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/HMACContext.xml b/doc/classes/HMACContext.xml
index 706ee30963..fbdc6b5e64 100644
--- a/doc/classes/HMACContext.xml
+++ b/doc/classes/HMACContext.xml
@@ -26,25 +26,24 @@
[/gdscript]
[csharp]
using Godot;
- using System;
using System.Diagnostics;
- public class CryptoNode : Node
+ public partial class MyNode : Node
{
- private HMACContext ctx = new HMACContext();
+ private HmacContext _ctx = new HmacContext();
public override void _Ready()
{
- byte[] key = "supersecret".ToUTF8();
- Error err = ctx.Start(HashingContext.HashType.Sha256, key);
+ byte[] key = "supersecret".ToUtf8();
+ Error err = _ctx.Start(HashingContext.HashType.Sha256, key);
Debug.Assert(err == Error.Ok);
- byte[] msg1 = "this is ".ToUTF8();
- byte[] msg2 = "super duper secret".ToUTF8();
- err = ctx.Update(msg1);
+ byte[] msg1 = "this is ".ToUtf8();
+ byte[] msg2 = "super duper secret".ToUtf8();
+ err = _ctx.Update(msg1);
Debug.Assert(err == Error.Ok);
- err = ctx.Update(msg2);
+ err = _ctx.Update(msg2);
Debug.Assert(err == Error.Ok);
- byte[] hmac = ctx.Finish();
+ byte[] hmac = _ctx.Finish();
GD.Print(hmac.HexEncode());
}
}
diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml
index b7a5cff694..4973f3fddf 100644
--- a/doc/classes/HTTPClient.xml
+++ b/doc/classes/HTTPClient.xml
@@ -105,7 +105,7 @@
[/gdscript]
[csharp]
var fields = new Godot.Collections.Dictionary { { "username", "user" }, { "password", "pass" } };
- string queryString = new HTTPClient().QueryStringFromDict(fields);
+ string queryString = httpClient.QueryStringFromDict(fields);
// Returns "username=user&amp;password=pass"
[/csharp]
[/codeblocks]
@@ -117,8 +117,13 @@
# Returns "single=123&amp;not_valued&amp;multiple=22&amp;multiple=33&amp;multiple=44"
[/gdscript]
[csharp]
- var fields = new Godot.Collections.Dictionary{{"single", 123}, {"notValued", null}, {"multiple", new Godot.Collections.Array{22, 33, 44}}};
- string queryString = new HTTPClient().QueryStringFromDict(fields);
+ var fields = new Godot.Collections.Dictionary
+ {
+ { "single", 123 },
+ { "notValued", default },
+ { "multiple", new Godot.Collections.Array { 22, 33, 44 } },
+ };
+ string queryString = httpClient.QueryStringFromDict(fields);
// Returns "single=123&amp;not_valued&amp;multiple=22&amp;multiple=33&amp;multiple=44"
[/csharp]
[/codeblocks]
@@ -151,7 +156,7 @@
[csharp]
var fields = new Godot.Collections.Dictionary { { "username", "user" }, { "password", "pass" } };
string queryString = new HTTPClient().QueryStringFromDict(fields);
- string[] headers = {"Content-Type: application/x-www-form-urlencoded", "Content-Length: " + queryString.Length};
+ string[] headers = { "Content-Type: application/x-www-form-urlencoded", $"Content-Length: {queryString.Length}" };
var result = new HTTPClient().Request(HTTPClient.Method.Post, "index.php", headers, queryString);
[/csharp]
[/codeblocks]
diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml
index d403acf90c..5a0b12e198 100644
--- a/doc/classes/HTTPRequest.xml
+++ b/doc/classes/HTTPRequest.xml
@@ -57,7 +57,7 @@
// Perform a POST request. The URL below returns JSON as of writing.
// Note: Don't make simultaneous requests using a single HTTPRequest node.
// The snippet below is provided for reference only.
- string body = new JSON().Stringify(new Godot.Collections.Dictionary
+ string body = new Json().Stringify(new Godot.Collections.Dictionary
{
{ "name", "Godette" }
});
@@ -69,14 +69,14 @@
}
// Called when the HTTP request is completed.
- private void HttpRequestCompleted(int result, int responseCode, string[] headers, byte[] body)
+ private void HttpRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
{
- var json = new JSON();
- json.Parse(body.GetStringFromUTF8());
- var response = json.GetData() as Godot.Collections.Dictionary;
+ var json = new Json();
+ json.Parse(body.GetStringFromUtf8());
+ var response = json.GetData().AsGodotDictionary();
// Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
- GD.Print((response["headers"] as Godot.Collections.Dictionary)["User-Agent"]);
+ GD.Print((response["headers"].AsGodotDictionary())["User-Agent"]);
}
[/csharp]
[/codeblocks]
@@ -128,9 +128,9 @@
}
// Called when the HTTP request is completed.
- private void HttpRequestCompleted(int result, int responseCode, string[] headers, byte[] body)
+ private void HttpRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
{
- if (result != (int)HTTPRequest.Result.Success)
+ if (result != (long)HTTPRequest.Result.Success)
{
GD.PushError("Image couldn't be downloaded. Try a different image.");
}
diff --git a/doc/classes/HashingContext.xml b/doc/classes/HashingContext.xml
index 7c2be6f817..5223cbf52f 100644
--- a/doc/classes/HashingContext.xml
+++ b/doc/classes/HashingContext.xml
@@ -8,7 +8,7 @@
The [enum HashType] enum shows the supported hashing algorithms.
[codeblocks]
[gdscript]
- const CHUNK_SIZE = 102
+ const CHUNK_SIZE = 1024
func hash_file(path):
# Check that file exists.
@@ -32,17 +32,16 @@
public void HashFile(string path)
{
- var ctx = new HashingContext();
- var file = new File();
- // Start a SHA-256 context.
- ctx.Start(HashingContext.HashType.Sha256);
// Check that file exists.
- if (!file.FileExists(path))
+ if (!FileAccess.FileExists(path))
{
return;
}
+ // Start a SHA-256 context.
+ var ctx = new HashingContext();
+ ctx.Start(HashingContext.HashType.Sha256);
// Open the file to hash.
- file.Open(path, File.ModeFlags.Read);
+ using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
// Update the context after reading each chunk.
while (!file.EofReached())
{
@@ -51,8 +50,7 @@
// Get the computed hash.
byte[] res = ctx.Finish();
// Print the result as hex string and array.
-
- GD.PrintT(res.HexEncode(), res);
+ GD.PrintT(res.HexEncode(), (Variant)res);
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/InputEventMIDI.xml b/doc/classes/InputEventMIDI.xml
index 67e7ced2e8..e4ba380741 100644
--- a/doc/classes/InputEventMIDI.xml
+++ b/doc/classes/InputEventMIDI.xml
@@ -35,9 +35,9 @@
GD.Print(OS.GetConnectedMidiInputs());
}
- public override void _Input(InputEvent inputEvent)
+ public override void _Input(InputEvent @event)
{
- if (inputEvent is InputEventMIDI midiEvent)
+ if (@event is InputEventMIDI midiEvent)
{
PrintMIDIInfo(midiEvent);
}
@@ -46,14 +46,14 @@
private void PrintMIDIInfo(InputEventMIDI midiEvent)
{
GD.Print(midiEvent);
- GD.Print("Channel " + midiEvent.Channel);
- GD.Print("Message " + midiEvent.Message);
- GD.Print("Pitch " + midiEvent.Pitch);
- GD.Print("Velocity " + midiEvent.Velocity);
- GD.Print("Instrument " + midiEvent.Instrument);
- GD.Print("Pressure " + midiEvent.Pressure);
- GD.Print("Controller number: " + midiEvent.ControllerNumber);
- GD.Print("Controller value: " + midiEvent.ControllerValue);
+ GD.Print($"Channel {midiEvent.Channel}");
+ GD.Print($"Message {midiEvent.Message}");
+ GD.Print($"Pitch {midiEvent.Pitch}");
+ GD.Print($"Velocity {midiEvent.Velocity}");
+ GD.Print($"Instrument {midiEvent.Instrument}");
+ GD.Print($"Pressure {midiEvent.Pressure}");
+ GD.Print($"Controller number: {midiEvent.ControllerNumber}");
+ GD.Print($"Controller value: {midiEvent.ControllerValue}");
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml
index 674adb1772..260efb0eab 100644
--- a/doc/classes/MainLoop.xml
+++ b/doc/classes/MainLoop.xml
@@ -29,29 +29,28 @@
[/gdscript]
[csharp]
using Godot;
- using System;
- public class CustomMainLoop : MainLoop
+ public partial class CustomMainLoop : MainLoop
{
- public float TimeElapsed = 0;
+ private double _timeElapsed = 0;
public override void _Initialize()
{
GD.Print("Initialized:");
- GD.Print($" Starting Time: {TimeElapsed}");
+ GD.Print($" Starting Time: {_timeElapsed}");
}
- public override bool _Process(float delta)
+ public override bool _Process(double delta)
{
- TimeElapsed += delta;
+ _timeElapsed += delta;
// Return true to end the main loop.
- return Input.GetMouseButtonMask() != 0 || Input.IsKeyPressed((int)KeyList.Escape);
+ return Input.GetMouseButtonMask() != 0 || Input.IsKeyPressed(Key.Escape);
}
private void _Finalize()
{
GD.Print("Finalized:");
- GD.Print($" End Time: {TimeElapsed}");
+ GD.Print($" End Time: {_timeElapsed}");
}
}
[/csharp]
diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml
index 6ae4dc4177..92fd8bcc6a 100644
--- a/doc/classes/NavigationAgent2D.xml
+++ b/doc/classes/NavigationAgent2D.xml
@@ -111,6 +111,21 @@
<member name="avoidance_enabled" type="bool" setter="set_avoidance_enabled" getter="get_avoidance_enabled" default="false">
If [code]true[/code] the agent is registered for an RVO avoidance callback on the [NavigationServer2D]. When [method NavigationAgent2D.set_velocity] is used and the processing is completed a [code]safe_velocity[/code] Vector2 is received with a signal connection to [signal velocity_computed]. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
</member>
+ <member name="debug_enabled" type="bool" setter="set_debug_enabled" getter="get_debug_enabled" default="false">
+ If [code]true[/code] shows debug visuals for this agent.
+ </member>
+ <member name="debug_path_custom_color" type="Color" setter="set_debug_path_custom_color" getter="get_debug_path_custom_color" default="Color(1, 1, 1, 1)">
+ If [member debug_use_custom] is [code]true[/code] uses this color for this agent instead of global color.
+ </member>
+ <member name="debug_path_custom_line_width" type="float" setter="set_debug_path_custom_line_width" getter="get_debug_path_custom_line_width" default="1.0">
+ If [member debug_use_custom] is [code]true[/code] uses this line width for rendering paths for this agent instead of global line width.
+ </member>
+ <member name="debug_path_custom_point_size" type="float" setter="set_debug_path_custom_point_size" getter="get_debug_path_custom_point_size" default="4.0">
+ If [member debug_use_custom] is [code]true[/code] uses this rasterized point size for rendering path points for this agent instead of global point size.
+ </member>
+ <member name="debug_use_custom" type="bool" setter="set_debug_use_custom" getter="get_debug_use_custom" default="false">
+ If [code]true[/code] uses the defined [member debug_path_custom_color] for this agent instead of global color.
+ </member>
<member name="max_neighbors" type="int" setter="set_max_neighbors" getter="get_max_neighbors" default="10">
The maximum number of neighbors for the agent to consider.
</member>
diff --git a/doc/classes/NavigationAgent3D.xml b/doc/classes/NavigationAgent3D.xml
index a22cd6dd46..0ed11bc477 100644
--- a/doc/classes/NavigationAgent3D.xml
+++ b/doc/classes/NavigationAgent3D.xml
@@ -114,6 +114,18 @@
<member name="avoidance_enabled" type="bool" setter="set_avoidance_enabled" getter="get_avoidance_enabled" default="false">
If [code]true[/code] the agent is registered for an RVO avoidance callback on the [NavigationServer3D]. When [method NavigationAgent3D.set_velocity] is used and the processing is completed a [code]safe_velocity[/code] Vector3 is received with a signal connection to [signal velocity_computed]. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
</member>
+ <member name="debug_enabled" type="bool" setter="set_debug_enabled" getter="get_debug_enabled" default="false">
+ If [code]true[/code] shows debug visuals for this agent.
+ </member>
+ <member name="debug_path_custom_color" type="Color" setter="set_debug_path_custom_color" getter="get_debug_path_custom_color" default="Color(1, 1, 1, 1)">
+ If [member debug_use_custom] is [code]true[/code] uses this color for this agent instead of global color.
+ </member>
+ <member name="debug_path_custom_point_size" type="float" setter="set_debug_path_custom_point_size" getter="get_debug_path_custom_point_size" default="4.0">
+ If [member debug_use_custom] is [code]true[/code] uses this rasterized point size for rendering path points for this agent instead of global point size.
+ </member>
+ <member name="debug_use_custom" type="bool" setter="set_debug_use_custom" getter="get_debug_use_custom" default="false">
+ If [code]true[/code] uses the defined [member debug_path_custom_color] for this agent instead of global color.
+ </member>
<member name="ignore_y" type="bool" setter="set_ignore_y" getter="get_ignore_y" default="true">
Ignores collisions on the Y axis. Must be true to move on a horizontal plane.
</member>
diff --git a/doc/classes/NavigationServer2D.xml b/doc/classes/NavigationServer2D.xml
index 16f6de5238..7270a19b4d 100644
--- a/doc/classes/NavigationServer2D.xml
+++ b/doc/classes/NavigationServer2D.xml
@@ -528,5 +528,10 @@
Emitted when a navigation map is updated, when a region moves or is modified.
</description>
</signal>
+ <signal name="navigation_debug_changed">
+ <description>
+ Emitted when navigation debug settings are changed. Only available in debug builds.
+ </description>
+ </signal>
</signals>
</class>
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index e4607456ca..e30ff6be19 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -110,7 +110,7 @@
[/gdscript]
[csharp]
[Tool]
- public class MyNode2D : Node2D
+ public partial class MyNode2D : Node2D
{
private bool _holdingHammer;
@@ -433,9 +433,9 @@
var button = new Button();
// Option 1: In C#, we can use signals as events and connect with this idiomatic syntax:
button.ButtonDown += OnButtonDown;
- // Option 2: Object.Connect() with a constructed Callable from a method group.
+ // Option 2: GodotObject.Connect() with a constructed Callable from a method group.
button.Connect(Button.SignalName.ButtonDown, Callable.From(OnButtonDown));
- // Option 3: Object.Connect() with a constructed Callable using a target object and method name.
+ // Option 3: GodotObject.Connect() with a constructed Callable using a target object and method name.
button.Connect(Button.SignalName.ButtonDown, new Callable(this, MethodName.OnButtonDown));
}
@@ -700,10 +700,10 @@
sprite2d.is_class("Node3D") # Returns false
[/gdscript]
[csharp]
- var sprite2d = new Sprite2D();
- sprite2d.IsClass("Sprite2D"); // Returns true
- sprite2d.IsClass("Node"); // Returns true
- sprite2d.IsClass("Node3D"); // Returns false
+ var sprite2D = new Sprite2D();
+ sprite2D.IsClass("Sprite2D"); // Returns true
+ sprite2D.IsClass("Node"); // Returns true
+ sprite2D.IsClass("Node3D"); // Returns false
[/csharp]
[/codeblocks]
[b]Note:[/b] This method ignores [code]class_name[/code] declarations in the object's script.
@@ -747,10 +747,10 @@
player.SetScript(GD.Load("res://player.gd"));
player.Notification(NotificationEnterTree);
- // The call order is Object -&gt; Node -&gt; Node2D -&gt; player.gd.
+ // The call order is GodotObject -&gt; Node -&gt; Node2D -&gt; player.gd.
- player.notification(NotificationEnterTree, true);
- // The call order is player.gd -&gt; Node2D -&gt; Node -&gt; Object.
+ player.Notification(NotificationEnterTree, true);
+ // The call order is player.gd -&gt; Node2D -&gt; Node -&gt; GodotObject.
[/csharp]
[/codeblocks]
</description>
diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml
index 7ca1d5d60d..493fc9e2a8 100644
--- a/doc/classes/PackedScene.xml
+++ b/doc/classes/PackedScene.xml
@@ -104,7 +104,7 @@
</method>
</methods>
<members>
- <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{ &quot;conn_count&quot;: 0, &quot;conns&quot;: PackedInt32Array(), &quot;editable_instances&quot;: [], &quot;names&quot;: PackedStringArray(), &quot;node_count&quot;: 0, &quot;node_paths&quot;: [], &quot;nodes&quot;: PackedInt32Array(), &quot;variants&quot;: [], &quot;version&quot;: 2 }">
+ <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{ &quot;conn_count&quot;: 0, &quot;conns&quot;: PackedInt32Array(), &quot;editable_instances&quot;: [], &quot;names&quot;: PackedStringArray(), &quot;node_count&quot;: 0, &quot;node_paths&quot;: [], &quot;nodes&quot;: PackedInt32Array(), &quot;variants&quot;: [], &quot;version&quot;: 3 }">
A dictionary representation of the scene contents.
Available keys include "rnames" and "variants" for resources, "node_count", "nodes", "node_paths" for nodes, "editable_instances" for base scene children overrides, "conn_count" and "conns" for signal connections, and "version" for the format style of the PackedScene.
</member>
diff --git a/doc/classes/PhysicsPointQueryParameters2D.xml b/doc/classes/PhysicsPointQueryParameters2D.xml
index 76dc816dab..15102830f8 100644
--- a/doc/classes/PhysicsPointQueryParameters2D.xml
+++ b/doc/classes/PhysicsPointQueryParameters2D.xml
@@ -11,6 +11,7 @@
<members>
<member name="canvas_instance_id" type="int" setter="set_canvas_instance_id" getter="get_canvas_instance_id" default="0">
If different from [code]0[/code], restricts the query to a specific canvas layer specified by its instance ID. See [method Object.get_instance_id].
+ If [code]0[/code], restricts the query to the Viewport's default canvas layer.
</member>
<member name="collide_with_areas" type="bool" setter="set_collide_with_areas" getter="is_collide_with_areas_enabled" default="false">
If [code]true[/code], the query will take [Area2D]s into account.
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 95bd060fc6..e429759e93 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -528,9 +528,21 @@
<member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color(0, 0.6, 0.7, 0.42)">
Color of the collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu.
</member>
+ <member name="debug/shapes/navigation/agent_path_color" type="Color" setter="" getter="" default="Color(1, 0, 0, 1)">
+ Color to display enabled navigation agent paths when an agent has debug enabled.
+ </member>
+ <member name="debug/shapes/navigation/agent_path_point_size" type="float" setter="" getter="" default="4.0">
+ Rasterized size (pixel) used to render navigation agent path points when an agent has debug enabled.
+ </member>
<member name="debug/shapes/navigation/edge_connection_color" type="Color" setter="" getter="" default="Color(1, 0, 1, 1)">
Color to display edge connections between navigation regions, visible when "Visible Navigation" is enabled in the Debug menu.
</member>
+ <member name="debug/shapes/navigation/enable_agent_paths" type="bool" setter="" getter="" default="true">
+ If enabled, displays navigation agent paths when an agent has debug enabled.
+ </member>
+ <member name="debug/shapes/navigation/enable_agent_paths_xray" type="bool" setter="" getter="" default="true">
+ If enabled, displays navigation agent paths through geometry when an agent has debug enabled.
+ </member>
<member name="debug/shapes/navigation/enable_edge_connections" type="bool" setter="" getter="" default="true">
If enabled, displays edge connections between navigation regions when "Visible Navigation" is enabled in the Debug menu.
</member>
@@ -1743,7 +1755,7 @@
[/gdscript]
[csharp]
// Set the default gravity strength to 980.
- PhysicsServer2D.AreaSetParam(GetViewport().FindWorld2d().Space, PhysicsServer2D.AreaParameter.Gravity, 980);
+ PhysicsServer2D.AreaSetParam(GetViewport().FindWorld2D().Space, PhysicsServer2D.AreaParameter.Gravity, 980);
[/csharp]
[/codeblocks]
</member>
@@ -1757,7 +1769,7 @@
[/gdscript]
[csharp]
// Set the default gravity direction to `Vector2(0, 1)`.
- PhysicsServer2D.AreaSetParam(GetViewport().FindWorld2d().Space, PhysicsServer2D.AreaParameter.GravityVector, Vector2.Down)
+ PhysicsServer2D.AreaSetParam(GetViewport().FindWorld2D().Space, PhysicsServer2D.AreaParameter.GravityVector, Vector2.Down)
[/csharp]
[/codeblocks]
</member>
diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml
index fee48dd246..fa0b1ab00b 100644
--- a/doc/classes/ReflectionProbe.xml
+++ b/doc/classes/ReflectionProbe.xml
@@ -13,13 +13,13 @@
</tutorials>
<members>
<member name="ambient_color" type="Color" setter="set_ambient_color" getter="get_ambient_color" default="Color(0, 0, 0, 1)">
- The custom ambient color to use within the [ReflectionProbe]'s [member extents]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
+ The custom ambient color to use within the [ReflectionProbe]'s [member size]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
</member>
<member name="ambient_color_energy" type="float" setter="set_ambient_color_energy" getter="get_ambient_color_energy" default="1.0">
- The custom ambient color energy to use within the [ReflectionProbe]'s [member extents]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
+ The custom ambient color energy to use within the [ReflectionProbe]'s [member size]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
</member>
<member name="ambient_mode" type="int" setter="set_ambient_mode" getter="get_ambient_mode" enum="ReflectionProbe.AmbientMode" default="1">
- The ambient color to use within the [ReflectionProbe]'s [member extents]. The ambient color will smoothly blend with other [ReflectionProbe]s and the rest of the scene (outside the [ReflectionProbe]'s [member extents]).
+ The ambient color to use within the [ReflectionProbe]'s [member size]. The ambient color will smoothly blend with other [ReflectionProbe]s and the rest of the scene (outside the [ReflectionProbe]'s [member size]).
</member>
<member name="box_projection" type="bool" setter="set_enable_box_projection" getter="is_box_projection_enabled" default="false">
If [code]true[/code], enables box projection. This makes reflections look more correct in rectangle-shaped rooms by offsetting the reflection center depending on the camera's location.
@@ -31,10 +31,6 @@
<member name="enable_shadows" type="bool" setter="set_enable_shadows" getter="are_shadows_enabled" default="false">
If [code]true[/code], computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the [constant UPDATE_ALWAYS] [member update_mode].
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(10, 10, 10)">
- The size of the reflection probe. The larger the extents, the more space covered by the probe, which will lower the perceived resolution. It is best to keep the extents only as large as you need them.
- [b]Note:[/b] To better fit areas that are not aligned to the grid, you can rotate the [ReflectionProbe] node.
- </member>
<member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="1.0">
Defines the reflection intensity. Intensity modulates the strength of the reflection.
</member>
@@ -43,7 +39,7 @@
</member>
<member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance" default="0.0">
The maximum distance away from the [ReflectionProbe] an object can be before it is culled. Decrease this to improve performance, especially when using the [constant UPDATE_ALWAYS] [member update_mode].
- [b]Note:[/b] The maximum reflection distance is always at least equal to the [member extents]. This means that decreasing [member max_distance] will not always cull objects from reflections, especially if the reflection probe's [member extents] are already large.
+ [b]Note:[/b] The maximum reflection distance is always at least equal to the probe's extents. This means that decreasing [member max_distance] will not always cull objects from reflections, especially if the reflection probe's [member size] is already large.
</member>
<member name="mesh_lod_threshold" type="float" setter="set_mesh_lod_threshold" getter="get_mesh_lod_threshold" default="1.0">
The automatic LOD bias to use for meshes rendered within the [ReflectionProbe] (this is analog to [member Viewport.mesh_lod_threshold]). Higher values will use less detailed versions of meshes that have LOD variations generated. If set to [code]0.0[/code], automatic LOD is disabled. Increase [member mesh_lod_threshold] to improve performance at the cost of geometry detail, especially when using the [constant UPDATE_ALWAYS] [member update_mode].
@@ -52,6 +48,10 @@
<member name="origin_offset" type="Vector3" setter="set_origin_offset" getter="get_origin_offset" default="Vector3(0, 0, 0)">
Sets the origin offset to be used when this [ReflectionProbe] is in [member box_projection] mode. This can be set to a non-zero value to ensure a reflection fits a rectangle-shaped room, while reducing the number of objects that "get in the way" of the reflection.
</member>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(20, 20, 20)">
+ The size of the reflection probe. The larger the size, the more space covered by the probe, which will lower the perceived resolution. It is best to keep the size only as large as you need it.
+ [b]Note:[/b] To better fit areas that are not aligned to the grid, you can rotate the [ReflectionProbe] node.
+ </member>
<member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="ReflectionProbe.UpdateMode" default="0">
Sets how frequently the [ReflectionProbe] is updated. Can be [constant UPDATE_ONCE] or [constant UPDATE_ALWAYS].
</member>
@@ -64,13 +64,13 @@
Update the probe every frame. This provides better results for fast-moving dynamic objects (such as cars). However, it has a significant performance cost. Due to the cost, it's recommended to only use one ReflectionProbe with [constant UPDATE_ALWAYS] at most per scene. For all other use cases, use [constant UPDATE_ONCE].
</constant>
<constant name="AMBIENT_DISABLED" value="0" enum="AmbientMode">
- Do not apply any ambient lighting inside the [ReflectionProbe]'s [member extents].
+ Do not apply any ambient lighting inside the [ReflectionProbe]'s [member size].
</constant>
<constant name="AMBIENT_ENVIRONMENT" value="1" enum="AmbientMode">
- Apply automatically-sourced environment lighting inside the [ReflectionProbe]'s [member extents].
+ Apply automatically-sourced environment lighting inside the [ReflectionProbe]'s [member size].
</constant>
<constant name="AMBIENT_COLOR" value="2" enum="AmbientMode">
- Apply custom ambient lighting inside the [ReflectionProbe]'s [member extents]. See [member ambient_color] and [member ambient_color_energy].
+ Apply custom ambient lighting inside the [ReflectionProbe]'s [member size]. See [member ambient_color] and [member ambient_color_energy].
</constant>
</constants>
</class>
diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml
index f318430611..82a2871949 100644
--- a/doc/classes/RenderingDevice.xml
+++ b/doc/classes/RenderingDevice.xml
@@ -1,8 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RenderingDevice" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Abstraction for working with modern low-level graphics APIs.
</brief_description>
<description>
+ [RenderingDevice] is an abstraction for working with modern low-level graphics APIs such as Vulkan.
+ On startup, Godot creates a global [RenderingDevice] which can be retrieved using [method RenderingServer.get_rendering_device]. This global RenderingDevice performs drawing to the screen.
+ Internally, [RenderingDevice] is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required.
+ [b]Local RenderingDevices:[/b] Using [method RenderingServer.create_local_rendering_device], you can create "secondary" rendering devices to perform drawing and GPU compute operations on separate threads.
+ [b]Note:[/b] [RenderingDevice] is not available when running in headless mode or when using the OpenGL renderer.
</description>
<tutorials>
</tutorials>
@@ -1162,20 +1168,28 @@
<constant name="BARRIER_MASK_NO_BARRIER" value="8" enum="BarrierMask" is_bitfield="true">
</constant>
<constant name="TEXTURE_TYPE_1D" value="0" enum="TextureType">
+ 1-dimensional texture.
</constant>
<constant name="TEXTURE_TYPE_2D" value="1" enum="TextureType">
+ 2-dimensional texture.
</constant>
<constant name="TEXTURE_TYPE_3D" value="2" enum="TextureType">
+ 3-dimensional texture.
</constant>
<constant name="TEXTURE_TYPE_CUBE" value="3" enum="TextureType">
+ [Cubemap] texture.
</constant>
<constant name="TEXTURE_TYPE_1D_ARRAY" value="4" enum="TextureType">
+ Array of 1-dimensional textures.
</constant>
<constant name="TEXTURE_TYPE_2D_ARRAY" value="5" enum="TextureType">
+ Array of 2-dimensional textures.
</constant>
<constant name="TEXTURE_TYPE_CUBE_ARRAY" value="6" enum="TextureType">
+ Array of [Cubemap] textures.
</constant>
<constant name="TEXTURE_TYPE_MAX" value="7" enum="TextureType">
+ Represents the size of the [enum TextureType] enum.
</constant>
<constant name="TEXTURE_SAMPLES_1" value="0" enum="TextureSamples">
</constant>
@@ -1192,6 +1206,7 @@
<constant name="TEXTURE_SAMPLES_64" value="6" enum="TextureSamples">
</constant>
<constant name="TEXTURE_SAMPLES_MAX" value="7" enum="TextureSamples">
+ Represents the size of the [enum TextureSamples] enum.
</constant>
<constant name="TEXTURE_USAGE_SAMPLING_BIT" value="1" enum="TextureUsageBits" is_bitfield="true">
</constant>
@@ -1236,8 +1251,10 @@
<constant name="TEXTURE_SLICE_3D" value="2" enum="TextureSliceType">
</constant>
<constant name="SAMPLER_FILTER_NEAREST" value="0" enum="SamplerFilter">
+ Nearest-neighbor sampler filtering. Sampling at higher resolutions than the source will result in a pixelated look.
</constant>
<constant name="SAMPLER_FILTER_LINEAR" value="1" enum="SamplerFilter">
+ Bilinear sampler filtering. Sampling at higher resolutions than the source will result in a blurry look.
</constant>
<constant name="SAMPLER_REPEAT_MODE_REPEAT" value="0" enum="SamplerRepeatMode">
</constant>
@@ -1298,8 +1315,10 @@
<constant name="UNIFORM_TYPE_MAX" value="10" enum="UniformType">
</constant>
<constant name="RENDER_PRIMITIVE_POINTS" value="0" enum="RenderPrimitive">
+ Point rendering primitive (with constant size, regardless of distance from camera).
</constant>
<constant name="RENDER_PRIMITIVE_LINES" value="1" enum="RenderPrimitive">
+ Line rendering primitive.
</constant>
<constant name="RENDER_PRIMITIVE_LINES_WITH_ADJACENCY" value="2" enum="RenderPrimitive">
</constant>
@@ -1380,6 +1399,7 @@
<constant name="LOGIC_OP_NO_OP" value="5" enum="LogicOperation">
</constant>
<constant name="LOGIC_OP_XOR" value="6" enum="LogicOperation">
+ Exclusive or (XOR) logic operation.
</constant>
<constant name="LOGIC_OP_OR" value="7" enum="LogicOperation">
</constant>
@@ -1442,16 +1462,22 @@
<constant name="BLEND_FACTOR_MAX" value="19" enum="BlendFactor">
</constant>
<constant name="BLEND_OP_ADD" value="0" enum="BlendOperation">
+ Additive blending operation ([code]source + destination[/code]).
</constant>
<constant name="BLEND_OP_SUBTRACT" value="1" enum="BlendOperation">
+ Subtractive blending operation ([code]source - destination[/code]).
</constant>
<constant name="BLEND_OP_REVERSE_SUBTRACT" value="2" enum="BlendOperation">
+ Reverse subtractive blending operation ([code]destination - source[/code]).
</constant>
<constant name="BLEND_OP_MINIMUM" value="3" enum="BlendOperation">
+ Minimum blending operation (keep the lowest value of the two).
</constant>
<constant name="BLEND_OP_MAXIMUM" value="4" enum="BlendOperation">
+ Maximum blending operation (keep the highest value of the two).
</constant>
<constant name="BLEND_OP_MAX" value="5" enum="BlendOperation">
+ Represents the size of the [enum BlendOperation] enum.
</constant>
<constant name="DYNAMIC_STATE_LINE_WIDTH" value="1" enum="PipelineDynamicStateFlags" is_bitfield="true">
</constant>
@@ -1544,12 +1570,16 @@
<constant name="LIMIT_MAX_TEXTURE_ARRAY_LAYERS" value="10" enum="Limit">
</constant>
<constant name="LIMIT_MAX_TEXTURE_SIZE_1D" value="11" enum="Limit">
+ Maximum supported 1-dimensional texture size (in pixels on a single axis).
</constant>
<constant name="LIMIT_MAX_TEXTURE_SIZE_2D" value="12" enum="Limit">
+ Maximum supported 2-dimensional texture size (in pixels on a single axis).
</constant>
<constant name="LIMIT_MAX_TEXTURE_SIZE_3D" value="13" enum="Limit">
+ Maximum supported 3-dimensional texture size (in pixels on a single axis).
</constant>
<constant name="LIMIT_MAX_TEXTURE_SIZE_CUBE" value="14" enum="Limit">
+ Maximum supported cubemap texture size (in pixels on a single axis of a single face).
</constant>
<constant name="LIMIT_MAX_TEXTURES_PER_SHADER_STAGE" value="15" enum="Limit">
</constant>
@@ -1596,14 +1626,19 @@
<constant name="LIMIT_MAX_VIEWPORT_DIMENSIONS_Y" value="36" enum="Limit">
</constant>
<constant name="MEMORY_TEXTURES" value="0" enum="MemoryType">
+ Memory taken by textures.
</constant>
<constant name="MEMORY_BUFFERS" value="1" enum="MemoryType">
+ Memory taken by buffers.
</constant>
<constant name="MEMORY_TOTAL" value="2" enum="MemoryType">
+ Total memory taken. This is greater than the sum of [constant MEMORY_TEXTURES] and [constant MEMORY_BUFFERS], as it also includes miscellaneous memory usage.
</constant>
<constant name="INVALID_ID" value="-1">
+ Returned by functions that return an ID if a value is invalid.
</constant>
<constant name="INVALID_FORMAT_ID" value="-1">
+ Returned by functions that return a format ID if a value is invalid.
</constant>
</constants>
</class>
diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml
index 8bb3073000..f92ea255cc 100644
--- a/doc/classes/RenderingServer.xml
+++ b/doc/classes/RenderingServer.xml
@@ -4,10 +4,10 @@
Server for anything visible.
</brief_description>
<description>
- Server for anything visible. The rendering server is the API backend for everything visible. The whole scene system mounts on it to display.
+ The rendering server is the API backend for everything visible. The whole scene system mounts on it to display.
The rendering server is completely opaque, the internals are entirely implementation specific and cannot be accessed.
- The rendering server can be used to bypass the scene system entirely.
- Resources are created using the [code]*_create[/code] functions.
+ The rendering server can be used to bypass the scene/[Node] system entirely.
+ Resources are created using the [code]*_create[/code] functions. These functions return [RID]s which are not references to the objects themselves, but opaque [i]pointers[/i] towards these objects.
All objects are drawn to a viewport. You can use the [Viewport] attached to the [SceneTree] or you can create one yourself with [method viewport_create]. When using a custom scenario or canvas, the scenario or canvas needs to be attached to the viewport using [method viewport_set_scenario] or [method viewport_attach_canvas].
In 3D, all visual objects must be associated with a scenario. The scenario is a visual representation of the world. If accessing the rendering server from a running game, the scenario can be accessed from the scene tree from any [Node3D] node with [method Node3D.get_world_3d]. Otherwise, a scenario can be created with [method scenario_create].
Similarly, in 2D, a canvas is needed to draw all canvas items.
@@ -25,6 +25,7 @@
<param index="1" name="material_overrides" type="RID[]" />
<param index="2" name="image_size" type="Vector2i" />
<description>
+ Bakes the material data of the Mesh passed in the [param base] parameter with optional [param material_overrides] to a set of [Image]s of size [param image_size]. Returns an array of [Image]s containing material properties as specified in [enum BakeChannels].
</description>
</method>
<method name="camera_attributes_create">
@@ -43,6 +44,7 @@
<param index="4" name="speed" type="float" />
<param index="5" name="scale" type="float" />
<description>
+ Sets the parameters to use with the auto-exposure effect. These parameters take on the same meaning as their counterparts in [CameraAttributes] and [CameraAttributesPractical].
</description>
</method>
<method name="camera_attributes_set_dof_blur">
@@ -56,12 +58,14 @@
<param index="6" name="near_transition" type="float" />
<param index="7" name="amount" type="float" />
<description>
+ Sets the parameters to use with the dof blur effect. These parameters take on the same meaning as their counterparts in [CameraAttributesPractical].
</description>
</method>
<method name="camera_attributes_set_dof_blur_bokeh_shape">
<return type="void" />
<param index="0" name="shape" type="int" enum="RenderingServer.DOFBokehShape" />
<description>
+ Sets the shape of the dof bokeh pattern. Different shapes may be used to acheive artistic effect, or to meet performance targets. For more detail on available options see [enum DOFBokehShape].
</description>
</method>
<method name="camera_attributes_set_dof_blur_quality">
@@ -69,6 +73,7 @@
<param index="0" name="quality" type="int" enum="RenderingServer.DOFBlurQuality" />
<param index="1" name="use_jitter" type="bool" />
<description>
+ Sets the quality level of the dof blur effect to one of the options in [enum DOFBlurQuality]. [param use_jitter] can be used to jitter samples taken during the blur pass to hide artifacts at the cost of looking more fuzzy.
</description>
</method>
<method name="camera_attributes_set_exposure">
@@ -102,6 +107,7 @@
<param index="0" name="camera" type="RID" />
<param index="1" name="effects" type="RID" />
<description>
+ Sets the camera_attributes created with [method camera_attributes_create] to the given camera.
</description>
</method>
<method name="camera_set_cull_mask">
@@ -192,6 +198,7 @@
<param index="2" name="radius" type="float" />
<param index="3" name="color" type="Color" />
<description>
+ Draws a circle on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_circle].
</description>
</method>
<method name="canvas_item_add_clip_ignore">
@@ -199,6 +206,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="ignore" type="bool" />
<description>
+ If [param ignore] is [code]true[/code], ignore clipping on items drawn with this canvas item until this is called again with [param ignore] set to false.
</description>
</method>
<method name="canvas_item_add_lcd_texture_rect_region">
@@ -209,6 +217,7 @@
<param index="3" name="src_rect" type="Rect2" />
<param index="4" name="modulate" type="Color" />
<description>
+ See also [method CanvasItem.draw_lcd_texture_rect_region].
</description>
</method>
<method name="canvas_item_add_line">
@@ -220,6 +229,7 @@
<param index="4" name="width" type="float" default="-1.0" />
<param index="5" name="antialiased" type="bool" default="false" />
<description>
+ Draws a line on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_line].
</description>
</method>
<method name="canvas_item_add_mesh">
@@ -230,6 +240,7 @@
<param index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<param index="4" name="texture" type="RID" />
<description>
+ Draws a mesh created with [method mesh_create] with given [param transform], [param modulate] color, and [param texture]. This is used internally by [MeshInstance2D].
</description>
</method>
<method name="canvas_item_add_msdf_texture_rect_region">
@@ -243,6 +254,7 @@
<param index="6" name="px_range" type="float" default="1.0" />
<param index="7" name="scale" type="float" default="1.0" />
<description>
+ See also [method CanvasItem.draw_msdf_texture_rect_region].
</description>
</method>
<method name="canvas_item_add_multimesh">
@@ -251,6 +263,7 @@
<param index="1" name="mesh" type="RID" />
<param index="2" name="texture" type="RID" />
<description>
+ Draws a 2D [MultiMesh] on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_multimesh].
</description>
</method>
<method name="canvas_item_add_nine_patch">
@@ -266,6 +279,7 @@
<param index="8" name="draw_center" type="bool" default="true" />
<param index="9" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<description>
+ Draws a nine-patch rectangle on the [CanvasItem] pointed to by the [param item] [RID].
</description>
</method>
<method name="canvas_item_add_particles">
@@ -274,6 +288,7 @@
<param index="1" name="particles" type="RID" />
<param index="2" name="texture" type="RID" />
<description>
+ Draws particles on the [CanvasItem] pointed to by the [param item] [RID].
</description>
</method>
<method name="canvas_item_add_polygon">
@@ -284,6 +299,7 @@
<param index="3" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" />
<param index="4" name="texture" type="RID" />
<description>
+ Draws a 2D polygon on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_polygon].
</description>
</method>
<method name="canvas_item_add_polyline">
@@ -294,6 +310,7 @@
<param index="3" name="width" type="float" default="-1.0" />
<param index="4" name="antialiased" type="bool" default="false" />
<description>
+ Draws a 2D polyline on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_polyline].
</description>
</method>
<method name="canvas_item_add_primitive">
@@ -304,6 +321,7 @@
<param index="3" name="uvs" type="PackedVector2Array" />
<param index="4" name="texture" type="RID" />
<description>
+ Draws a 2D primitive on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_primitive].
</description>
</method>
<method name="canvas_item_add_rect">
@@ -312,6 +330,7 @@
<param index="1" name="rect" type="Rect2" />
<param index="2" name="color" type="Color" />
<description>
+ Draws a rectangle on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_rect].
</description>
</method>
<method name="canvas_item_add_set_transform">
@@ -319,6 +338,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="transform" type="Transform2D" />
<description>
+ Sets a [Transform2D] that will be used to transform subsequent canvas item commands.
</description>
</method>
<method name="canvas_item_add_texture_rect">
@@ -368,6 +388,7 @@
<method name="canvas_item_create">
<return type="RID" />
<description>
+ Creates a new [CanvasItem] instance and returns its [RID].
</description>
</method>
<method name="canvas_item_set_canvas_group_mode">
@@ -877,13 +898,6 @@
<description>
</description>
</method>
- <method name="decal_set_extents">
- <return type="void" />
- <param index="0" name="decal" type="RID" />
- <param index="1" name="extents" type="Vector3" />
- <description>
- </description>
- </method>
<method name="decal_set_fade">
<return type="void" />
<param index="0" name="decal" type="RID" />
@@ -906,6 +920,13 @@
<description>
</description>
</method>
+ <method name="decal_set_size">
+ <return type="void" />
+ <param index="0" name="decal" type="RID" />
+ <param index="1" name="size" type="Vector3" />
+ <description>
+ </description>
+ </method>
<method name="decal_set_texture">
<return type="void" />
<param index="0" name="decal" type="RID" />
@@ -1218,14 +1239,6 @@
Creates a new fog volume and allocates an RID.
</description>
</method>
- <method name="fog_volume_set_extents">
- <return type="void" />
- <param index="0" name="fog_volume" type="RID" />
- <param index="1" name="extents" type="Vector3" />
- <description>
- Sets the size of the fog volume when shape is [constant RenderingServer.FOG_VOLUME_SHAPE_ELLIPSOID], [constant RenderingServer.FOG_VOLUME_SHAPE_CONE], [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER] or [constant RenderingServer.FOG_VOLUME_SHAPE_BOX].
- </description>
- </method>
<method name="fog_volume_set_material">
<return type="void" />
<param index="0" name="fog_volume" type="RID" />
@@ -1242,6 +1255,14 @@
Sets the shape of the fog volume to either [constant RenderingServer.FOG_VOLUME_SHAPE_ELLIPSOID], [constant RenderingServer.FOG_VOLUME_SHAPE_CONE], [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER], [constant RenderingServer.FOG_VOLUME_SHAPE_BOX] or [constant RenderingServer.FOG_VOLUME_SHAPE_WORLD].
</description>
</method>
+ <method name="fog_volume_set_size">
+ <return type="void" />
+ <param index="0" name="fog_volume" type="RID" />
+ <param index="1" name="size" type="Vector3" />
+ <description>
+ Sets the size of the fog volume when shape is [constant RenderingServer.FOG_VOLUME_SHAPE_ELLIPSOID], [constant RenderingServer.FOG_VOLUME_SHAPE_CONE], [constant RenderingServer.FOG_VOLUME_SHAPE_CYLINDER] or [constant RenderingServer.FOG_VOLUME_SHAPE_BOX].
+ </description>
+ </method>
<method name="force_draw">
<return type="void" />
<param index="0" name="swap_buffers" type="bool" default="true" />
@@ -1792,6 +1813,7 @@
<method name="lightmap_create">
<return type="RID" />
<description>
+ Creates a new [LightmapGI] instance.
</description>
</method>
<method name="lightmap_get_probe_capture_bsp_tree" qualifiers="const">
@@ -2655,14 +2677,6 @@
If [code]true[/code], computes shadows in the reflection probe. This makes the reflection much slower to compute. Equivalent to [member ReflectionProbe.enable_shadows].
</description>
</method>
- <method name="reflection_probe_set_extents">
- <return type="void" />
- <param index="0" name="probe" type="RID" />
- <param index="1" name="extents" type="Vector3" />
- <description>
- Sets the size of the area that the reflection probe will capture. Equivalent to [member ReflectionProbe.extents].
- </description>
- </method>
<method name="reflection_probe_set_intensity">
<return type="void" />
<param index="0" name="probe" type="RID" />
@@ -2701,6 +2715,14 @@
<description>
</description>
</method>
+ <method name="reflection_probe_set_size">
+ <return type="void" />
+ <param index="0" name="probe" type="RID" />
+ <param index="1" name="size" type="Vector3" />
+ <description>
+ Sets the size of the area that the reflection probe will capture. Equivalent to [member ReflectionProbe.size].
+ </description>
+ </method>
<method name="reflection_probe_set_update_mode">
<return type="void" />
<param index="0" name="probe" type="RID" />
@@ -4091,10 +4113,10 @@
[FogVolume] will be shaped like an ellipsoid (stretched sphere).
</constant>
<constant name="FOG_VOLUME_SHAPE_CONE" value="1" enum="FogVolumeShape">
- [FogVolume] will be shaped like a cone pointing upwards (in local coordinates). The cone's angle is set automatically to fill the extents. The cone will be adjusted to fit within the extents. Rotate the [FogVolume] node to reorient the cone. Non-uniform scaling via extents is not supported (scale the [FogVolume] node instead).
+ [FogVolume] will be shaped like a cone pointing upwards (in local coordinates). The cone's angle is set automatically to fill the size. The cone will be adjusted to fit within the size. Rotate the [FogVolume] node to reorient the cone. Non-uniform scaling via size is not supported (scale the [FogVolume] node instead).
</constant>
<constant name="FOG_VOLUME_SHAPE_CYLINDER" value="2" enum="FogVolumeShape">
- [FogVolume] will be shaped like an upright cylinder (in local coordinates). Rotate the [FogVolume] node to reorient the cylinder. The cylinder will be adjusted to fit within the extents. Non-uniform scaling via extents is not supported (scale the [FogVolume] node instead).
+ [FogVolume] will be shaped like an upright cylinder (in local coordinates). Rotate the [FogVolume] node to reorient the cylinder. The cylinder will be adjusted to fit within the size. Non-uniform scaling via size is not supported (scale the [FogVolume] node instead).
</constant>
<constant name="FOG_VOLUME_SHAPE_BOX" value="3" enum="FogVolumeShape">
[FogVolume] will be shaped like a box.
@@ -4565,12 +4587,16 @@
Fade-in the given instance's dependencies when reaching its visibility range limits.
</constant>
<constant name="BAKE_CHANNEL_ALBEDO_ALPHA" value="0" enum="BakeChannels">
+ Index of [Image] in array of [Image]s returned by [method bake_render_uv2]. Image uses [constant Image.FORMAT_RGBA8] and contains albedo color in the [code].rgb[/code] channels and alpha in the [code].a[/code] channel.
</constant>
<constant name="BAKE_CHANNEL_NORMAL" value="1" enum="BakeChannels">
+ Index of [Image] in array of [Image]s returned by [method bake_render_uv2]. Image uses [constant Image.FORMAT_RGBA8] and contains the per-pixel normal of the object in the [code].rgb[/code] channels and nothing in the [code].a[/code] channel. The per-pixel normal is encoded as [code]normal * 0.5 + 0.5[/code].
</constant>
<constant name="BAKE_CHANNEL_ORM" value="2" enum="BakeChannels">
+ Index of [Image] in array of [Image]s returned by [method bake_render_uv2]. Image uses [constant Image.FORMAT_RGBA8] and contains ambient occlusion (from material and decals only) in the [code].r[/code] channel, roughness in the [code].g[/code] channel, metallic in the [code].b[/code] channel and sub surface scattering amount in the [code].a[/code] channel.
</constant>
<constant name="BAKE_CHANNEL_EMISSION" value="3" enum="BakeChannels">
+ Index of [Image] in array of [Image]s returned by [method bake_render_uv2]. Image uses [constant Image.FORMAT_RGBAH] and contains emission color in the [code].rgb[/code] channels and nothing in the [code].a[/code] channel.
</constant>
<constant name="CANVAS_TEXTURE_CHANNEL_DIFFUSE" value="0" enum="CanvasTextureChannel">
</constant>
diff --git a/doc/classes/RichTextEffect.xml b/doc/classes/RichTextEffect.xml
index c01546524d..333d34d1b7 100644
--- a/doc/classes/RichTextEffect.xml
+++ b/doc/classes/RichTextEffect.xml
@@ -13,7 +13,7 @@
[/gdscript]
[csharp]
// The RichTextEffect will be usable like this: `[example]Some text[/example]`
- public string bbcode = "example";
+ string bbcode = "example";
[/csharp]
[/codeblocks]
[b]Note:[/b] As soon as a [RichTextLabel] contains at least one [RichTextEffect], it will continuously process the effect unless the project is paused. This may impact battery life negatively.
diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml
index bf19ebc23a..6adb37a3f7 100644
--- a/doc/classes/SceneTree.xml
+++ b/doc/classes/SceneTree.xml
@@ -74,10 +74,10 @@
print("end")
[/gdscript]
[csharp]
- public async void SomeFunction()
+ public async Task SomeFunction()
{
GD.Print("start");
- await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
+ await ToSignal(GetTree().CreateTimer(1.0f), SceneTreeTimer.SignalName.Timeout);
GD.Print("end");
}
[/csharp]
diff --git a/doc/classes/SceneTreeTimer.xml b/doc/classes/SceneTreeTimer.xml
index f28e65c5bf..42b070d7d9 100644
--- a/doc/classes/SceneTreeTimer.xml
+++ b/doc/classes/SceneTreeTimer.xml
@@ -14,10 +14,10 @@
print("Timer ended.")
[/gdscript]
[csharp]
- public async void SomeFunction()
+ public async Task SomeFunction()
{
GD.Print("Timer started.");
- await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
+ await ToSignal(GetTree().CreateTimer(1.0f), SceneTreeTimer.SignalName.Timeout);
GD.Print("Timer ended.");
}
[/csharp]
diff --git a/doc/classes/Sprite2D.xml b/doc/classes/Sprite2D.xml
index 235fef0bdd..033dbf51f3 100644
--- a/doc/classes/Sprite2D.xml
+++ b/doc/classes/Sprite2D.xml
@@ -23,11 +23,11 @@
print("A click!")
[/gdscript]
[csharp]
- public override void _Input(InputEvent inputEvent)
+ public override void _Input(InputEvent @event)
{
- if (inputEvent is InputEventMouseButton inputEventMouse)
+ if (@event is InputEventMouseButton inputEventMouse)
{
- if (inputEventMouse.Pressed &amp;&amp; inputEventMouse.ButtonIndex == (int)ButtonList.Left)
+ if (inputEventMouse.Pressed &amp;&amp; inputEventMouse.ButtonIndex == MouseButton.Left)
{
if (GetRect().HasPoint(ToLocal(inputEventMouse.Position)))
{
diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml
index f05b5f7dbf..969cbac57d 100644
--- a/doc/classes/StreamPeer.xml
+++ b/doc/classes/StreamPeer.xml
@@ -223,7 +223,7 @@
put_data("Hello world".to_utf8())
[/gdscript]
[csharp]
- PutData("Hello World".ToUTF8());
+ PutData("Hello World".ToUtf8());
[/csharp]
[/codeblocks]
</description>
diff --git a/doc/classes/SubViewport.xml b/doc/classes/SubViewport.xml
index 7020cae1de..bb76a82ef3 100644
--- a/doc/classes/SubViewport.xml
+++ b/doc/classes/SubViewport.xml
@@ -26,6 +26,7 @@
</member>
<member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(512, 512)">
The width and height of the sub-viewport. Must be set to a value greater than or equal to 2 pixels on both dimensions. Otherwise, nothing will be displayed.
+ [b]Note:[/b] If the parent node is a [SubViewportContainer] and its [member SubViewportContainer.stretch] is [code]true[/code], the viewport size cannot be changed manually.
</member>
<member name="size_2d_override" type="Vector2i" setter="set_size_2d_override" getter="get_size_2d_override" default="Vector2i(0, 0)">
The 2D size override of the sub-viewport. If either the width or height is [code]0[/code], the override is disabled.
diff --git a/doc/classes/SubViewportContainer.xml b/doc/classes/SubViewportContainer.xml
index 77aa7e3ff4..11137222a9 100644
--- a/doc/classes/SubViewportContainer.xml
+++ b/doc/classes/SubViewportContainer.xml
@@ -13,6 +13,7 @@
<members>
<member name="stretch" type="bool" setter="set_stretch" getter="is_stretch_enabled" default="false">
If [code]true[/code], the sub-viewport will be automatically resized to the control's size.
+ [b]Note:[/b] If [code]true[/code], this will prohibit changing [member SubViewport.size] of its children manually.
</member>
<member name="stretch_shrink" type="int" setter="set_stretch_shrink" getter="get_stretch_shrink" default="1">
Divides the sub-viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering.
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml
index 9bb92cf362..16e4ce3714 100644
--- a/doc/classes/Tween.xml
+++ b/doc/classes/Tween.xml
@@ -77,13 +77,13 @@
tween = create_tween()
[/gdscript]
[csharp]
- private Tween tween;
+ private Tween _tween;
public void Animate()
{
- if (tween != null)
- tween.Kill(); // Abort the previous animation
- tween = CreateTween();
+ if (_tween != null)
+ _tween.Kill(); // Abort the previous animation
+ _tween = CreateTween();
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/UDPServer.xml b/doc/classes/UDPServer.xml
index c3a3a49a80..8151ecb625 100644
--- a/doc/classes/UDPServer.xml
+++ b/doc/classes/UDPServer.xml
@@ -9,7 +9,8 @@
Below a small example of how it can be used:
[codeblocks]
[gdscript]
- class_name Server
+ # server_node.gd
+ class_name ServerNode
extends Node
var server := UDPServer.new()
@@ -34,35 +35,35 @@
pass # Do something with the connected peers.
[/gdscript]
[csharp]
+ // ServerNode.cs
using Godot;
- using System;
using System.Collections.Generic;
- public class Server : Node
+ public partial class ServerNode : Node
{
- public UDPServer Server = new UDPServer();
- public List&lt;PacketPeerUDP&gt; Peers = new List&lt;PacketPeerUDP&gt;();
+ private UdpServer _server = new UdpServer();
+ private List&lt;PacketPeerUdp&gt; _peers = new List&lt;PacketPeerUdp&gt;();
public override void _Ready()
{
- Server.Listen(4242);
+ _server.Listen(4242);
}
- public override void _Process(float delta)
+ public override void _Process(double delta)
{
- Server.Poll(); // Important!
- if (Server.IsConnectionAvailable())
+ _server.Poll(); // Important!
+ if (_server.IsConnectionAvailable())
{
- PacketPeerUDP peer = Server.TakeConnection();
+ PacketPeerUdp peer = _server.TakeConnection();
byte[] packet = peer.GetPacket();
- GD.Print($"Accepted Peer: {peer.GetPacketIp()}:{peer.GetPacketPort()}");
- GD.Print($"Received Data: {packet.GetStringFromUTF8()}");
+ GD.Print($"Accepted Peer: {peer.GetPacketIP()}:{peer.GetPacketPort()}");
+ GD.Print($"Received Data: {packet.GetStringFromUtf8()}");
// Reply so it knows we received the message.
peer.PutPacket(packet);
// Keep a reference so we can keep contacting the remote peer.
- Peers.Add(peer);
+ _peers.Add(peer);
}
- foreach (var peer in Peers)
+ foreach (var peer in _peers)
{
// Do something with the peers.
}
@@ -72,7 +73,8 @@
[/codeblocks]
[codeblocks]
[gdscript]
- class_name Client
+ # client_node.gd
+ class_name ClientNode
extends Node
var udp := PacketPeerUDP.new()
@@ -90,30 +92,30 @@
connected = true
[/gdscript]
[csharp]
+ // ClientNode.cs
using Godot;
- using System;
- public class Client : Node
+ public partial class ClientNode : Node
{
- public PacketPeerUDP Udp = new PacketPeerUDP();
- public bool Connected = false;
+ private PacketPeerUdp _udp = new PacketPeerUdp();
+ private bool _connected = false;
public override void _Ready()
{
- Udp.ConnectToHost("127.0.0.1", 4242);
+ _udp.ConnectToHost("127.0.0.1", 4242);
}
- public override void _Process(float delta)
+ public override void _Process(double delta)
{
- if (!Connected)
+ if (!_connected)
{
// Try to contact server
- Udp.PutPacket("The Answer Is..42!".ToUTF8());
+ _udp.PutPacket("The Answer Is..42!".ToUtf8());
}
- if (Udp.GetAvailablePacketCount() &gt; 0)
+ if (_udp.GetAvailablePacketCount() &gt; 0)
{
- GD.Print($"Connected: {Udp.GetPacket().GetStringFromUTF8()}");
- Connected = true;
+ GD.Print($"Connected: {_udp.GetPacket().GetStringFromUtf8()}");
+ _connected = true;
}
}
}
diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml
index 6c151ef958..e43bceb941 100644
--- a/doc/classes/UndoRedo.xml
+++ b/doc/classes/UndoRedo.xml
@@ -27,11 +27,11 @@
undo_redo.commit_action()
[/gdscript]
[csharp]
- public UndoRedo UndoRedo;
+ private UndoRedo _undoRedo;
public override void _Ready()
{
- UndoRedo = GetUndoRedo(); // Method of EditorPlugin.
+ _undoRedo = GetUndoRedo(); // Method of EditorPlugin.
}
public void DoSomething()
@@ -47,12 +47,12 @@
private void OnMyButtonPressed()
{
var node = GetNode&lt;Node2D&gt;("MyNode2D");
- UndoRedo.CreateAction("Move the node");
- UndoRedo.AddDoMethod(this, MethodName.DoSomething);
- UndoRedo.AddUndoMethod(this, MethodName.UndoSomething);
- UndoRedo.AddDoProperty(node, Node2D.PropertyName.Position, new Vector2(100, 100));
- UndoRedo.AddUndoProperty(node, Node2D.PropertyName.Position, node.Position);
- UndoRedo.CommitAction();
+ _undoRedo.CreateAction("Move the node");
+ _undoRedo.AddDoMethod(new Callable(this, MethodName.DoSomething));
+ _undoRedo.AddUndoMethod(new Callable(this, MethodName.UndoSomething));
+ _undoRedo.AddDoProperty(node, "position", new Vector2(100, 100));
+ _undoRedo.AddUndoProperty(node, "position", node.Position);
+ _undoRedo.CommitAction();
}
[/csharp]
[/codeblocks]
diff --git a/doc/classes/VoxelGI.xml b/doc/classes/VoxelGI.xml
index 394611b78f..4347c5845f 100644
--- a/doc/classes/VoxelGI.xml
+++ b/doc/classes/VoxelGI.xml
@@ -38,9 +38,9 @@
<member name="data" type="VoxelGIData" setter="set_probe_data" getter="get_probe_data">
The [VoxelGIData] resource that holds the data for this [VoxelGI].
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(10, 10, 10)">
- The size of the area covered by the [VoxelGI]. If you make the extents larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting.
- [b]Note:[/b] Extents are clamped to 1.0 unit or more on each axis.
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(20, 20, 20)">
+ The size of the area covered by the [VoxelGI]. If you make the size larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting.
+ [b]Note:[/b] Size is clamped to 1.0 unit or more on each axis.
</member>
<member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" enum="VoxelGI.Subdiv" default="1">
Number of times to subdivide the grid that the [VoxelGI] operates on. A higher number results in finer detail and thus higher visual quality, while lower numbers result in better performance.
diff --git a/doc/classes/VoxelGIData.xml b/doc/classes/VoxelGIData.xml
index bd9df18394..541a3bc4a6 100644
--- a/doc/classes/VoxelGIData.xml
+++ b/doc/classes/VoxelGIData.xml
@@ -26,8 +26,8 @@
<method name="get_bounds" qualifiers="const">
<return type="AABB" />
<description>
- Returns the bounds of the baked voxel data as an [AABB], which should match [member VoxelGI.extents] after being baked (which only contains the size as a [Vector3]).
- [b]Note:[/b] If the extents were modified without baking the VoxelGI data, then the value of [method get_bounds] and [member VoxelGI.extents] will not match.
+ Returns the bounds of the baked voxel data as an [AABB], which should match [member VoxelGI.size] after being baked (which only contains the size as a [Vector3]).
+ [b]Note:[/b] If the size was modified without baking the VoxelGI data, then the value of [method get_bounds] and [member VoxelGI.size] will not match.
</description>
</method>
<method name="get_data_cells" qualifiers="const">
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index e9eb11e2e3..c454da8e23 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -44,10 +44,10 @@ OSStatus AudioDriverCoreAudio::input_device_address_cb(AudioObjectID inObjectID,
void *inClientData) {
AudioDriverCoreAudio *driver = static_cast<AudioDriverCoreAudio *>(inClientData);
- // If our selected device is the Default call set_device to update the
+ // If our selected input device is the Default, call set_input_device to update the
// kAudioOutputUnitProperty_CurrentDevice property
- if (driver->capture_device_name == "Default") {
- driver->capture_set_device("Default");
+ if (driver->input_device_name == "Default") {
+ driver->set_input_device("Default");
}
return noErr;
@@ -58,10 +58,10 @@ OSStatus AudioDriverCoreAudio::output_device_address_cb(AudioObjectID inObjectID
void *inClientData) {
AudioDriverCoreAudio *driver = static_cast<AudioDriverCoreAudio *>(inClientData);
- // If our selected device is the Default call set_device to update the
+ // If our selected output device is the Default call set_output_device to update the
// kAudioOutputUnitProperty_CurrentDevice property
- if (driver->device_name == "Default") {
- driver->set_device("Default");
+ if (driver->output_device_name == "Default") {
+ driver->set_output_device("Default");
}
return noErr;
@@ -495,7 +495,7 @@ Error AudioDriverCoreAudio::capture_stop() {
#ifdef MACOS_ENABLED
-PackedStringArray AudioDriverCoreAudio::_get_device_list(bool capture) {
+PackedStringArray AudioDriverCoreAudio::_get_device_list(bool input) {
PackedStringArray list;
list.push_back("Default");
@@ -514,7 +514,7 @@ PackedStringArray AudioDriverCoreAudio::_get_device_list(bool capture) {
UInt32 deviceCount = size / sizeof(AudioDeviceID);
for (UInt32 i = 0; i < deviceCount; i++) {
- prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ prop.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
@@ -555,10 +555,10 @@ PackedStringArray AudioDriverCoreAudio::_get_device_list(bool capture) {
return list;
}
-void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
+void AudioDriverCoreAudio::_set_device(const String &output_device, bool input) {
AudioDeviceID deviceId;
bool found = false;
- if (device != "Default") {
+ if (output_device != "Default") {
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDevices;
@@ -573,7 +573,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
UInt32 deviceCount = size / sizeof(AudioDeviceID);
for (UInt32 i = 0; i < deviceCount && !found; i++) {
- prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ prop.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
@@ -602,7 +602,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
ERR_FAIL_NULL_MSG(buffer, "Out of memory.");
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
String name = String::utf8(buffer) + " (" + itos(audioDevices[i]) + ")";
- if (name == device) {
+ if (name == output_device) {
deviceId = audioDevices[i];
found = true;
}
@@ -618,7 +618,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
if (!found) {
// If we haven't found the desired device get the system default one
UInt32 size = sizeof(AudioDeviceID);
- UInt32 elem = capture ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice;
+ UInt32 elem = input ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice;
AudioObjectPropertyAddress property = { elem, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId);
@@ -628,10 +628,10 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
if (found) {
- OSStatus result = AudioUnitSetProperty(capture ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID));
+ OSStatus result = AudioUnitSetProperty(input ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID));
ERR_FAIL_COND(result != noErr);
- if (capture) {
+ if (input) {
// Reset audio input to keep synchronization.
input_position = 0;
input_size = 0;
@@ -639,34 +639,34 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
}
-PackedStringArray AudioDriverCoreAudio::get_device_list() {
+PackedStringArray AudioDriverCoreAudio::get_output_device_list() {
return _get_device_list();
}
-String AudioDriverCoreAudio::get_device() {
- return device_name;
+String AudioDriverCoreAudio::get_output_device() {
+ return output_device_name;
}
-void AudioDriverCoreAudio::set_device(String device) {
- device_name = device;
+void AudioDriverCoreAudio::set_output_device(String output_device) {
+ output_device_name = output_device;
if (active) {
- _set_device(device_name);
+ _set_device(output_device_name);
}
}
-void AudioDriverCoreAudio::capture_set_device(const String &p_name) {
- capture_device_name = p_name;
+void AudioDriverCoreAudio::set_input_device(const String &p_name) {
+ input_device_name = p_name;
if (active) {
- _set_device(capture_device_name, true);
+ _set_device(input_device_name, true);
}
}
-PackedStringArray AudioDriverCoreAudio::capture_get_device_list() {
+PackedStringArray AudioDriverCoreAudio::get_input_device_list() {
return _get_device_list(true);
}
-String AudioDriverCoreAudio::capture_get_device() {
- return capture_device_name;
+String AudioDriverCoreAudio::get_input_device() {
+ return input_device_name;
}
#endif
diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h
index 675265757b..2b192e630e 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -47,8 +47,8 @@ class AudioDriverCoreAudio : public AudioDriver {
bool active = false;
Mutex mutex;
- String device_name = "Default";
- String capture_device_name = "Default";
+ String output_device_name = "Default";
+ String input_device_name = "Default";
int mix_rate = 0;
unsigned int channels = 2;
@@ -60,7 +60,7 @@ class AudioDriverCoreAudio : public AudioDriver {
#ifdef MACOS_ENABLED
PackedStringArray _get_device_list(bool capture = false);
- void _set_device(const String &device, bool capture = false);
+ void _set_device(const String &output_device, bool capture = false);
static OSStatus input_device_address_cb(AudioObjectID inObjectID,
UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses,
@@ -107,13 +107,13 @@ public:
void stop();
#ifdef MACOS_ENABLED
- virtual PackedStringArray get_device_list();
- virtual String get_device();
- virtual void set_device(String device);
+ virtual PackedStringArray get_output_device_list();
+ virtual String get_output_device();
+ virtual void set_output_device(String output_device);
- virtual PackedStringArray capture_get_device_list();
- virtual void capture_set_device(const String &p_name);
- virtual String capture_get_device();
+ virtual PackedStringArray get_input_device_list();
+ virtual void set_input_device(const String &p_name);
+ virtual String get_input_device();
#endif
AudioDriverCoreAudio();
diff --git a/drivers/gles3/environment/fog.cpp b/drivers/gles3/environment/fog.cpp
index 87470b454b..6083c4da46 100644
--- a/drivers/gles3/environment/fog.cpp
+++ b/drivers/gles3/environment/fog.cpp
@@ -49,7 +49,7 @@ void Fog::fog_volume_free(RID p_rid) {
void Fog::fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) {
}
-void Fog::fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) {
+void Fog::fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) {
}
void Fog::fog_volume_set_material(RID p_fog_volume, RID p_material) {
diff --git a/drivers/gles3/environment/fog.h b/drivers/gles3/environment/fog.h
index 99f2e27c44..7dc0265917 100644
--- a/drivers/gles3/environment/fog.h
+++ b/drivers/gles3/environment/fog.h
@@ -49,7 +49,7 @@ public:
virtual void fog_volume_free(RID p_rid) override;
virtual void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) override;
- virtual void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) override;
+ virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) override;
virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) override;
virtual AABB fog_volume_get_aabb(RID p_fog_volume) const override;
virtual RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override;
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 949f2953d3..1a18f35e64 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -731,6 +731,11 @@ void RasterizerSceneGLES3::_setup_sky(const RenderDataGLES3 *p_render_data, cons
}
}
+ if (p_render_data->view_count > 1) {
+ glBindBufferBase(GL_UNIFORM_BUFFER, SKY_MULTIVIEW_UNIFORM_LOCATION, scene_state.multiview_buffer);
+ glBindBuffer(GL_UNIFORM_BUFFER, 0);
+ }
+
if (!sky->radiance) {
_invalidate_sky(sky);
_update_dirty_skys();
@@ -738,7 +743,7 @@ void RasterizerSceneGLES3::_setup_sky(const RenderDataGLES3 *p_render_data, cons
}
}
-void RasterizerSceneGLES3::_draw_sky(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier) {
+void RasterizerSceneGLES3::_draw_sky(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier, bool p_use_multiview, bool p_flip_y) {
GLES3::MaterialStorage *material_storage = GLES3::MaterialStorage::get_singleton();
ERR_FAIL_COND(p_env.is_null());
@@ -748,6 +753,11 @@ void RasterizerSceneGLES3::_draw_sky(RID p_env, const Projection &p_projection,
GLES3::SkyMaterialData *material_data = nullptr;
RID sky_material;
+ uint64_t spec_constants = p_use_multiview ? SkyShaderGLES3::USE_MULTIVIEW : 0;
+ if (p_flip_y) {
+ spec_constants |= SkyShaderGLES3::USE_INVERTED_Y;
+ }
+
RS::EnvironmentBG background = environment_get_background(p_env);
if (sky) {
@@ -792,16 +802,21 @@ void RasterizerSceneGLES3::_draw_sky(RID p_env, const Projection &p_projection,
sky_transform.invert();
sky_transform = sky_transform * p_transform.basis;
- bool success = material_storage->shaders.sky_shader.version_bind_shader(shader_data->version, SkyShaderGLES3::MODE_BACKGROUND);
+ bool success = material_storage->shaders.sky_shader.version_bind_shader(shader_data->version, SkyShaderGLES3::MODE_BACKGROUND, spec_constants);
if (!success) {
return;
}
- material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::ORIENTATION, sky_transform, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND);
- material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::PROJECTION, camera.columns[2][0], camera.columns[0][0], camera.columns[2][1], camera.columns[1][1], shader_data->version, SkyShaderGLES3::MODE_BACKGROUND);
- material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::POSITION, p_transform.origin, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND);
- material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::TIME, time, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND);
- material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::LUMINANCE_MULTIPLIER, p_luminance_multiplier, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND);
+ material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::ORIENTATION, sky_transform, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND, spec_constants);
+ material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::PROJECTION, camera.columns[2][0], camera.columns[0][0], camera.columns[2][1], camera.columns[1][1], shader_data->version, SkyShaderGLES3::MODE_BACKGROUND, spec_constants);
+ material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::POSITION, p_transform.origin, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND, spec_constants);
+ material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::TIME, time, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND, spec_constants);
+ material_storage->shaders.sky_shader.version_set_uniform(SkyShaderGLES3::LUMINANCE_MULTIPLIER, p_luminance_multiplier, shader_data->version, SkyShaderGLES3::MODE_BACKGROUND, spec_constants);
+
+ if (p_use_multiview) {
+ glBindBufferBase(GL_UNIFORM_BUFFER, SKY_MULTIVIEW_UNIFORM_LOCATION, scene_state.multiview_buffer);
+ glBindBuffer(GL_UNIFORM_BUFFER, 0);
+ }
glBindVertexArray(sky_globals.screen_triangle_array);
glDrawArrays(GL_TRIANGLES, 0, 3);
@@ -1975,7 +1990,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
scene_state.current_depth_draw = GLES3::SceneShaderData::DEPTH_DRAW_DISABLED;
scene_state.cull_mode = GLES3::SceneShaderData::CULL_BACK;
- _draw_sky(render_data.environment, render_data.cam_projection, render_data.cam_transform, sky_energy_multiplier);
+ _draw_sky(render_data.environment, render_data.cam_projection, render_data.cam_transform, sky_energy_multiplier, p_camera_data->view_count > 1, flip_y);
}
RENDER_TIMESTAMP("Render 3D Transparent Pass");
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 7977e562c0..ff043d67f6 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -83,6 +83,7 @@ enum SkyUniformLocation {
SKY_EMPTY, // Unused, put here to avoid conflicts with SCENE_DATA_UNIFORM_LOCATION.
SKY_MATERIAL_UNIFORM_LOCATION,
SKY_DIRECTIONAL_LIGHT_UNIFORM_LOCATION,
+ SKY_MULTIVIEW_UNIFORM_LOCATION,
};
struct RenderDataGLES3 {
@@ -570,7 +571,7 @@ protected:
void _update_dirty_skys();
void _update_sky_radiance(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier);
void _filter_sky_radiance(Sky *p_sky, int p_base_layer);
- void _draw_sky(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier);
+ void _draw_sky(RID p_env, const Projection &p_projection, const Transform3D &p_transform, float p_luminance_multiplier, bool p_use_multiview, bool p_flip_y);
void _free_sky_data(Sky *p_sky);
public:
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index f977c8ceaf..0b389b0478 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -268,9 +268,11 @@ void main() {
#ifdef USE_MULTIVIEW
mat4 projection_matrix = multiview_data.projection_matrix_view[ViewIndex];
mat4 inv_projection_matrix = multiview_data.inv_projection_matrix_view[ViewIndex];
+ vec3 eye_offset = multiview_data.eye_offset[ViewIndex].xyz;
#else
mat4 projection_matrix = scene_data.projection_matrix;
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;
+ vec3 eye_offset = vec3(0.0, 0.0, 0.0);
#endif //USE_MULTIVIEW
#ifdef USE_INSTANCING
@@ -930,10 +932,12 @@ void main() {
//lay out everything, whatever is unused is optimized away anyway
vec3 vertex = vertex_interp;
#ifdef USE_MULTIVIEW
- vec3 view = -normalize(vertex_interp - multiview_data.eye_offset[ViewIndex].xyz);
+ vec3 eye_offset = multiview_data.eye_offset[ViewIndex].xyz;
+ vec3 view = -normalize(vertex_interp - eye_offset);
mat4 projection_matrix = multiview_data.projection_matrix_view[ViewIndex];
mat4 inv_projection_matrix = multiview_data.inv_projection_matrix_view[ViewIndex];
#else
+ vec3 eye_offset = vec3(0.0, 0.0, 0.0);
vec3 view = -normalize(vertex_interp);
mat4 projection_matrix = scene_data.projection_matrix;
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;
diff --git a/drivers/gles3/shaders/sky.glsl b/drivers/gles3/shaders/sky.glsl
index 4c0fe47f6b..e59bca8b07 100644
--- a/drivers/gles3/shaders/sky.glsl
+++ b/drivers/gles3/shaders/sky.glsl
@@ -10,6 +10,9 @@ mode_cubemap_quarter_res = #define USE_CUBEMAP_PASS \n#define USE_QUARTER_RES_PA
#[specializations]
+USE_MULTIVIEW = false
+USE_INVERTED_Y = true
+
#[vertex]
layout(location = 0) in vec2 vertex_attrib;
@@ -19,7 +22,11 @@ out vec2 uv_interp;
void main() {
uv_interp = vertex_attrib;
+#ifdef USE_INVERTED_Y
gl_Position = vec4(uv_interp, 1.0, 1.0);
+#else
+ gl_Position = vec4(uv_interp.x, uv_interp.y * -1.0, 1.0, 1.0);
+#endif
}
/* clang-format off */
@@ -37,6 +44,9 @@ uniform samplerCube radiance; //texunit:-1
#ifdef USE_CUBEMAP_PASS
uniform samplerCube half_res; //texunit:-2
uniform samplerCube quarter_res; //texunit:-3
+#elif defined(USE_MULTIVIEW)
+uniform sampler2DArray half_res; //texunit:-2
+uniform sampler2DArray quarter_res; //texunit:-3
#else
uniform sampler2D half_res; //texunit:-2
uniform sampler2D quarter_res; //texunit:-3
@@ -102,6 +112,15 @@ uniform float fog_density;
uniform float z_far;
uniform uint directional_light_count;
+#ifdef USE_MULTIVIEW
+layout(std140) uniform MultiviewData { // ubo:5
+ highp mat4 projection_matrix_view[MAX_VIEWS];
+ highp mat4 inv_projection_matrix_view[MAX_VIEWS];
+ highp vec4 eye_offset[MAX_VIEWS];
+}
+multiview_data;
+#endif
+
layout(location = 0) out vec4 frag_color;
#ifdef USE_DEBANDING
@@ -115,9 +134,20 @@ vec3 interleaved_gradient_noise(vec2 pos) {
void main() {
vec3 cube_normal;
+#ifdef USE_MULTIVIEW
+ // In multiview our projection matrices will contain positional and rotational offsets that we need to properly unproject.
+ vec4 unproject = vec4(uv_interp.x, uv_interp.y, 1.0, 1.0);
+ vec4 unprojected = multiview_data.inv_projection_matrix_view[ViewIndex] * unproject;
+ cube_normal = unprojected.xyz / unprojected.w;
+ cube_normal += multiview_data.eye_offset[ViewIndex].xyz;
+#else
cube_normal.z = -1.0;
cube_normal.x = (uv_interp.x + projection.x) / projection.y;
cube_normal.y = (-uv_interp.y - projection.z) / projection.w;
+#endif
+#ifndef USE_INVERTED_Y
+ cube_normal.y *= -1.0;
+#endif
cube_normal = mat3(orientation) * cube_normal;
cube_normal = normalize(cube_normal);
@@ -146,12 +176,20 @@ void main() {
#endif
#else
#ifdef USES_HALF_RES_COLOR
+#ifdef USE_MULTIVIEW
+ half_res_color = textureLod(sampler2DArray(half_res, material_samplers[SAMPLER_LINEAR_CLAMP]), vec3(uv, ViewIndex), 0.0);
+#else
half_res_color = textureLod(sampler2D(half_res, material_samplers[SAMPLER_LINEAR_CLAMP]), uv, 0.0);
#endif
+#endif
#ifdef USES_QUARTER_RES_COLOR
+#ifdef USE_MULTIVIEW
+ quarter_res_color = textureLod(sampler2DArray(quarter_res, material_samplers[SAMPLER_LINEAR_CLAMP]), vec3(uv, ViewIndex), 0.0);
+#else
quarter_res_color = textureLod(sampler2D(quarter_res, material_samplers[SAMPLER_LINEAR_CLAMP]), uv, 0.0);
#endif
#endif
+#endif
{
diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp
index a325f79d8c..138498220d 100644
--- a/drivers/gles3/storage/light_storage.cpp
+++ b/drivers/gles3/storage/light_storage.cpp
@@ -403,7 +403,7 @@ void LightStorage::reflection_probe_set_ambient_energy(RID p_probe, float p_ener
void LightStorage::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
}
-void LightStorage::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
+void LightStorage::reflection_probe_set_size(RID p_probe, const Vector3 &p_size) {
}
void LightStorage::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
@@ -436,7 +436,7 @@ uint32_t LightStorage::reflection_probe_get_cull_mask(RID p_probe) const {
return 0;
}
-Vector3 LightStorage::reflection_probe_get_extents(RID p_probe) const {
+Vector3 LightStorage::reflection_probe_get_size(RID p_probe) const {
return Vector3();
}
diff --git a/drivers/gles3/storage/light_storage.h b/drivers/gles3/storage/light_storage.h
index 8b2bdaf872..f6f7628a90 100644
--- a/drivers/gles3/storage/light_storage.h
+++ b/drivers/gles3/storage/light_storage.h
@@ -113,7 +113,7 @@ struct ReflectionProbe {
Color ambient_color;
float ambient_color_energy = 1.0;
float max_distance = 0;
- Vector3 extents = Vector3(10, 10, 10);
+ Vector3 size = Vector3(20, 20, 20);
Vector3 origin_offset;
bool interior = false;
bool box_projection = false;
@@ -332,7 +332,7 @@ public:
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) override;
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) override;
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) override;
- virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) override;
+ virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) override;
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) override;
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) override;
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) override;
@@ -345,7 +345,7 @@ public:
virtual AABB reflection_probe_get_aabb(RID p_probe) const override;
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const override;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const override;
- virtual Vector3 reflection_probe_get_extents(RID p_probe) const override;
+ virtual Vector3 reflection_probe_get_size(RID p_probe) const override;
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const override;
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const override;
virtual bool reflection_probe_renders_shadows(RID p_probe) const override;
diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp
index 4fb780b665..aa8df606cf 100644
--- a/drivers/gles3/storage/material_storage.cpp
+++ b/drivers/gles3/storage/material_storage.cpp
@@ -1639,6 +1639,7 @@ MaterialStorage::MaterialStorage() {
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "uint(0)";
actions.renames["VIEW_RIGHT"] = "uint(1)";
+ actions.renames["EYE_OFFSET"] = "eye_offset";
//for light
actions.renames["VIEW"] = "view";
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp
index 97698af0a0..9c9c39cc0e 100644
--- a/drivers/gles3/storage/texture_storage.cpp
+++ b/drivers/gles3/storage/texture_storage.cpp
@@ -1547,7 +1547,7 @@ RID TextureStorage::decal_allocate() {
void TextureStorage::decal_initialize(RID p_rid) {
}
-void TextureStorage::decal_set_extents(RID p_decal, const Vector3 &p_extents) {
+void TextureStorage::decal_set_size(RID p_decal, const Vector3 &p_size) {
}
void TextureStorage::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) {
@@ -1822,6 +1822,10 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) {
rt->overridden.color = RID();
} else if (rt->color) {
glDeleteTextures(1, &rt->color);
+ if (rt->texture.is_valid()) {
+ Texture *tex = get_texture(rt->texture);
+ tex->tex_id = 0;
+ }
}
rt->color = 0;
diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h
index 522be64d35..017e74fc4d 100644
--- a/drivers/gles3/storage/texture_storage.h
+++ b/drivers/gles3/storage/texture_storage.h
@@ -574,7 +574,7 @@ public:
virtual void decal_initialize(RID p_rid) override;
virtual void decal_free(RID p_rid) override{};
- virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) override;
+ virtual void decal_set_size(RID p_decal, const Vector3 &p_size) override;
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) override;
virtual void decal_set_emission_energy(RID p_decal, float p_energy) override;
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) override;
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index e14c3c7f7a..f96247a473 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -106,15 +106,15 @@ void AudioDriverPulseAudio::pa_server_info_cb(pa_context *c, const pa_server_inf
ERR_FAIL_COND_MSG(!i, "PulseAudio server info is null.");
AudioDriverPulseAudio *ad = static_cast<AudioDriverPulseAudio *>(userdata);
- ad->capture_default_device = i->default_source_name;
- ad->default_device = i->default_sink_name;
+ ad->default_input_device = i->default_source_name;
+ ad->default_output_device = i->default_sink_name;
ad->pa_status++;
}
-Error AudioDriverPulseAudio::detect_channels(bool capture) {
- pa_channel_map_init_stereo(capture ? &pa_rec_map : &pa_map);
+Error AudioDriverPulseAudio::detect_channels(bool input) {
+ pa_channel_map_init_stereo(input ? &pa_rec_map : &pa_map);
- String device = capture ? capture_device_name : device_name;
+ String device = input ? input_device_name : output_device_name;
if (device == "Default") {
// Get the default output device name
pa_status = 0;
@@ -136,7 +136,7 @@ Error AudioDriverPulseAudio::detect_channels(bool capture) {
char dev[1024];
if (device == "Default") {
- strcpy(dev, capture ? capture_default_device.utf8().get_data() : default_device.utf8().get_data());
+ strcpy(dev, input ? default_input_device.utf8().get_data() : default_output_device.utf8().get_data());
} else {
strcpy(dev, device.utf8().get_data());
}
@@ -145,7 +145,7 @@ Error AudioDriverPulseAudio::detect_channels(bool capture) {
// Now using the device name get the amount of channels
pa_status = 0;
pa_operation *pa_op;
- if (capture) {
+ if (input) {
pa_op = pa_context_get_source_info_by_name(pa_ctx, dev, &AudioDriverPulseAudio::pa_source_info_cb, (void *)this);
} else {
pa_op = pa_context_get_sink_info_by_name(pa_ctx, dev, &AudioDriverPulseAudio::pa_sink_info_cb, (void *)this);
@@ -165,7 +165,7 @@ Error AudioDriverPulseAudio::detect_channels(bool capture) {
return FAILED;
}
} else {
- if (capture) {
+ if (input) {
ERR_PRINT("pa_context_get_source_info_by_name error");
} else {
ERR_PRINT("pa_context_get_sink_info_by_name error");
@@ -175,13 +175,13 @@ Error AudioDriverPulseAudio::detect_channels(bool capture) {
return OK;
}
-Error AudioDriverPulseAudio::init_device() {
- // If there is a specified device check that it is really present
- if (device_name != "Default") {
- PackedStringArray list = get_device_list();
- if (list.find(device_name) == -1) {
- device_name = "Default";
- new_device = "Default";
+Error AudioDriverPulseAudio::init_output_device() {
+ // If there is a specified output device, check that it is really present
+ if (output_device_name != "Default") {
+ PackedStringArray list = get_output_device_list();
+ if (list.find(output_device_name) == -1) {
+ output_device_name = "Default";
+ new_output_device = "Default";
}
}
@@ -192,7 +192,7 @@ Error AudioDriverPulseAudio::init_device() {
Error err = detect_channels();
if (err != OK) {
// This most likely means there are no sinks.
- ERR_PRINT("PulseAudio: init device failed to detect number of output channels");
+ ERR_PRINT("PulseAudio: init_output_device failed to detect number of output channels");
return err;
}
@@ -256,7 +256,7 @@ Error AudioDriverPulseAudio::init_device() {
attr.maxlength = (uint32_t)-1;
attr.minreq = (uint32_t)-1;
- const char *dev = device_name == "Default" ? nullptr : device_name.utf8().get_data();
+ const char *dev = output_device_name == "Default" ? nullptr : output_device_name.utf8().get_data();
pa_stream_flags flags = pa_stream_flags(PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE);
int error_code = pa_stream_connect_playback(pa_str, dev, &attr, flags, nullptr, nullptr);
ERR_FAIL_COND_V(error_code < 0, ERR_CANT_OPEN);
@@ -346,7 +346,7 @@ Error AudioDriverPulseAudio::init() {
return ERR_CANT_OPEN;
}
- init_device();
+ init_output_device();
thread.start(AudioDriverPulseAudio::thread_func, this);
return OK;
@@ -448,18 +448,18 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
}
}
- // User selected a new device, finish the current one so we'll init the new device
- if (ad->device_name != ad->new_device) {
- ad->device_name = ad->new_device;
- ad->finish_device();
+ // User selected a new output device, finish the current one so we'll init the new output device
+ if (ad->output_device_name != ad->new_output_device) {
+ ad->output_device_name = ad->new_output_device;
+ ad->finish_output_device();
- Error err = ad->init_device();
+ Error err = ad->init_output_device();
if (err != OK) {
- ERR_PRINT("PulseAudio: init_device error");
- ad->device_name = "Default";
- ad->new_device = "Default";
+ ERR_PRINT("PulseAudio: init_output_device error");
+ ad->output_device_name = "Default";
+ ad->new_output_device = "Default";
- err = ad->init_device();
+ err = ad->init_output_device();
if (err != OK) {
ad->active.clear();
ad->exit_thread.set();
@@ -471,11 +471,11 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
write_ofs = 0;
}
- // If we're using the default device check that the current device is still the default
- if (ad->device_name == "Default") {
+ // If we're using the default output device, check that the current output device is still the default
+ if (ad->output_device_name == "Default") {
uint64_t msec = OS::get_singleton()->get_ticks_msec();
if (msec > (default_device_msec + 1000)) {
- String old_default_device = ad->default_device;
+ String old_default_device = ad->default_output_device;
default_device_msec = msec;
@@ -494,12 +494,12 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
ERR_PRINT("pa_context_get_server_info error: " + String(pa_strerror(pa_context_errno(ad->pa_ctx))));
}
- if (old_default_device != ad->default_device) {
- ad->finish_device();
+ if (old_default_device != ad->default_output_device) {
+ ad->finish_output_device();
- Error err = ad->init_device();
+ Error err = ad->init_output_device();
if (err != OK) {
- ERR_PRINT("PulseAudio: init_device error");
+ ERR_PRINT("PulseAudio: init_output_device error");
ad->active.clear();
ad->exit_thread.set();
break;
@@ -541,18 +541,18 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
}
}
- // User selected a new device, finish the current one so we'll init the new device
- if (ad->capture_device_name != ad->capture_new_device) {
- ad->capture_device_name = ad->capture_new_device;
- ad->capture_finish_device();
+ // User selected a new input device, finish the current one so we'll init the new input device
+ if (ad->input_device_name != ad->new_input_device) {
+ ad->input_device_name = ad->new_input_device;
+ ad->finish_input_device();
- Error err = ad->capture_init_device();
+ Error err = ad->init_input_device();
if (err != OK) {
- ERR_PRINT("PulseAudio: capture_init_device error");
- ad->capture_device_name = "Default";
- ad->capture_new_device = "Default";
+ ERR_PRINT("PulseAudio: init_input_device error");
+ ad->input_device_name = "Default";
+ ad->new_input_device = "Default";
- err = ad->capture_init_device();
+ err = ad->init_input_device();
if (err != OK) {
ad->active.clear();
ad->exit_thread.set();
@@ -596,7 +596,7 @@ void AudioDriverPulseAudio::pa_sinklist_cb(pa_context *c, const pa_sink_info *l,
ad->pa_status++;
}
-PackedStringArray AudioDriverPulseAudio::get_device_list() {
+PackedStringArray AudioDriverPulseAudio::get_output_device_list() {
pa_devices.clear();
pa_devices.push_back("Default");
@@ -606,7 +606,7 @@ PackedStringArray AudioDriverPulseAudio::get_device_list() {
lock();
- // Get the device list
+ // Get the output device list
pa_status = 0;
pa_operation *pa_op = pa_context_get_sink_info_list(pa_ctx, pa_sinklist_cb, (void *)this);
if (pa_op) {
@@ -627,13 +627,13 @@ PackedStringArray AudioDriverPulseAudio::get_device_list() {
return pa_devices;
}
-String AudioDriverPulseAudio::get_device() {
- return device_name;
+String AudioDriverPulseAudio::get_output_device() {
+ return output_device_name;
}
-void AudioDriverPulseAudio::set_device(String device) {
+void AudioDriverPulseAudio::set_output_device(String output_device) {
lock();
- new_device = device;
+ new_output_device = output_device;
unlock();
}
@@ -645,7 +645,7 @@ void AudioDriverPulseAudio::unlock() {
mutex.unlock();
}
-void AudioDriverPulseAudio::finish_device() {
+void AudioDriverPulseAudio::finish_output_device() {
if (pa_str) {
pa_stream_disconnect(pa_str);
pa_stream_unref(pa_str);
@@ -661,7 +661,7 @@ void AudioDriverPulseAudio::finish() {
exit_thread.set();
thread.wait_to_finish();
- finish_device();
+ finish_output_device();
if (pa_ctx) {
pa_context_disconnect(pa_ctx);
@@ -675,13 +675,13 @@ void AudioDriverPulseAudio::finish() {
}
}
-Error AudioDriverPulseAudio::capture_init_device() {
- // If there is a specified device check that it is really present
- if (capture_device_name != "Default") {
- PackedStringArray list = capture_get_device_list();
- if (list.find(capture_device_name) == -1) {
- capture_device_name = "Default";
- capture_new_device = "Default";
+Error AudioDriverPulseAudio::init_input_device() {
+ // If there is a specified input device, check that it is really present
+ if (input_device_name != "Default") {
+ PackedStringArray list = get_input_device_list();
+ if (list.find(input_device_name) == -1) {
+ input_device_name = "Default";
+ new_input_device = "Default";
}
}
@@ -718,7 +718,7 @@ Error AudioDriverPulseAudio::capture_init_device() {
ERR_FAIL_V(ERR_CANT_OPEN);
}
- const char *dev = capture_device_name == "Default" ? nullptr : capture_device_name.utf8().get_data();
+ const char *dev = input_device_name == "Default" ? nullptr : input_device_name.utf8().get_data();
pa_stream_flags flags = pa_stream_flags(PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE);
int error_code = pa_stream_connect_record(pa_rec_str, dev, &attr, flags);
if (error_code < 0) {
@@ -734,7 +734,7 @@ Error AudioDriverPulseAudio::capture_init_device() {
return OK;
}
-void AudioDriverPulseAudio::capture_finish_device() {
+void AudioDriverPulseAudio::finish_input_device() {
if (pa_rec_str) {
int ret = pa_stream_disconnect(pa_rec_str);
if (ret != 0) {
@@ -745,25 +745,25 @@ void AudioDriverPulseAudio::capture_finish_device() {
}
}
-Error AudioDriverPulseAudio::capture_start() {
+Error AudioDriverPulseAudio::input_start() {
lock();
- Error err = capture_init_device();
+ Error err = init_input_device();
unlock();
return err;
}
-Error AudioDriverPulseAudio::capture_stop() {
+Error AudioDriverPulseAudio::input_stop() {
lock();
- capture_finish_device();
+ finish_input_device();
unlock();
return OK;
}
-void AudioDriverPulseAudio::capture_set_device(const String &p_name) {
+void AudioDriverPulseAudio::set_input_device(const String &p_name) {
lock();
- capture_new_device = p_name;
+ new_input_device = p_name;
unlock();
}
@@ -782,7 +782,7 @@ void AudioDriverPulseAudio::pa_sourcelist_cb(pa_context *c, const pa_source_info
ad->pa_status++;
}
-PackedStringArray AudioDriverPulseAudio::capture_get_device_list() {
+PackedStringArray AudioDriverPulseAudio::get_input_device_list() {
pa_rec_devices.clear();
pa_rec_devices.push_back("Default");
@@ -813,9 +813,9 @@ PackedStringArray AudioDriverPulseAudio::capture_get_device_list() {
return pa_rec_devices;
}
-String AudioDriverPulseAudio::capture_get_device() {
+String AudioDriverPulseAudio::get_input_device() {
lock();
- String name = capture_device_name;
+ String name = input_device_name;
unlock();
return name;
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index 16398e67eb..68df03cb60 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -51,13 +51,13 @@ class AudioDriverPulseAudio : public AudioDriver {
pa_channel_map pa_map = {};
pa_channel_map pa_rec_map = {};
- String device_name = "Default";
- String new_device = "Default";
- String default_device;
+ String output_device_name = "Default";
+ String new_output_device = "Default";
+ String default_output_device;
- String capture_device_name;
- String capture_new_device;
- String capture_default_device;
+ String input_device_name;
+ String new_input_device;
+ String default_input_device;
Vector<int32_t> samples_in;
Vector<int16_t> samples_out;
@@ -83,11 +83,11 @@ class AudioDriverPulseAudio : public AudioDriver {
static void pa_sinklist_cb(pa_context *c, const pa_sink_info *l, int eol, void *userdata);
static void pa_sourcelist_cb(pa_context *c, const pa_source_info *l, int eol, void *userdata);
- Error init_device();
- void finish_device();
+ Error init_output_device();
+ void finish_output_device();
- Error capture_init_device();
- void capture_finish_device();
+ Error init_input_device();
+ void finish_input_device();
Error detect_channels(bool capture = false);
@@ -103,13 +103,13 @@ public:
virtual int get_mix_rate() const;
virtual SpeakerMode get_speaker_mode() const;
- virtual PackedStringArray get_device_list();
- virtual String get_device();
- virtual void set_device(String device);
+ virtual PackedStringArray get_output_device_list();
+ virtual String get_output_device();
+ virtual void set_output_device(String output_device);
- virtual PackedStringArray capture_get_device_list();
- virtual void capture_set_device(const String &p_name);
- virtual String capture_get_device();
+ virtual PackedStringArray get_input_device_list();
+ virtual void set_input_device(const String &p_name);
+ virtual String get_input_device();
virtual void lock();
virtual void unlock();
@@ -117,8 +117,8 @@ public:
virtual float get_latency();
- virtual Error capture_start();
- virtual Error capture_stop();
+ virtual Error input_start();
+ virtual Error input_stop();
AudioDriverPulseAudio();
~AudioDriverPulseAudio() {}
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index b2745b1e86..42a2b85200 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -118,8 +118,8 @@ const IID IID_IAudioCaptureClient = __uuidof(IAudioCaptureClient);
#define CAPTURE_BUFFER_CHANNELS 2
-static bool default_render_device_changed = false;
-static bool default_capture_device_changed = false;
+static bool default_output_device_changed = false;
+static bool default_input_device_changed = false;
// Silence warning due to a COM API weirdness (GH-35194).
#if defined(__GNUC__) && !defined(__clang__)
@@ -181,9 +181,9 @@ public:
HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) {
if (role == eConsole) {
if (flow == eRender) {
- default_render_device_changed = true;
+ default_output_device_changed = true;
} else if (flow == eCapture) {
- default_capture_device_changed = true;
+ default_input_device_changed = true;
}
}
@@ -201,10 +201,10 @@ public:
static CMMNotificationClient notif_client;
-Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool p_reinit, bool p_no_audio_client_3) {
+Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_input, bool p_reinit, bool p_no_audio_client_3) {
WAVEFORMATEX *pwfex;
IMMDeviceEnumerator *enumerator = nullptr;
- IMMDevice *device = nullptr;
+ IMMDevice *output_device = nullptr;
CoInitialize(nullptr);
@@ -212,11 +212,11 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
if (p_device->device_name == "Default") {
- hr = enumerator->GetDefaultAudioEndpoint(p_capture ? eCapture : eRender, eConsole, &device);
+ hr = enumerator->GetDefaultAudioEndpoint(p_input ? eCapture : eRender, eConsole, &output_device);
} else {
IMMDeviceCollection *devices = nullptr;
- hr = enumerator->EnumAudioEndpoints(p_capture ? eCapture : eRender, DEVICE_STATE_ACTIVE, &devices);
+ hr = enumerator->EnumAudioEndpoints(p_input ? eCapture : eRender, DEVICE_STATE_ACTIVE, &devices);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
LPWSTR strId = nullptr;
@@ -255,20 +255,20 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
}
if (found) {
- hr = enumerator->GetDevice(strId, &device);
+ hr = enumerator->GetDevice(strId, &output_device);
}
if (strId) {
CoTaskMemFree(strId);
}
- if (device == nullptr) {
- hr = enumerator->GetDefaultAudioEndpoint(p_capture ? eCapture : eRender, eConsole, &device);
+ if (output_device == nullptr) {
+ hr = enumerator->GetDefaultAudioEndpoint(p_input ? eCapture : eRender, eConsole, &output_device);
}
}
if (p_reinit) {
- // In case we're trying to re-initialize the device prevent throwing this error on the console,
+ // In case we're trying to re-initialize the device, prevent throwing this error on the console,
// otherwise if there is currently no device available this will spam the console.
if (hr != S_OK) {
return ERR_CANT_OPEN;
@@ -284,28 +284,28 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
ERR_PRINT("WASAPI: RegisterEndpointNotificationCallback error");
}
- using_audio_client_3 = !p_capture; // IID_IAudioClient3 is only used for adjustable output latency (not input)
+ using_audio_client_3 = !p_input; // IID_IAudioClient3 is only used for adjustable output latency (not input)
if (p_no_audio_client_3) {
using_audio_client_3 = false;
}
if (using_audio_client_3) {
- hr = device->Activate(IID_IAudioClient3, CLSCTX_ALL, nullptr, (void **)&p_device->audio_client);
+ hr = output_device->Activate(IID_IAudioClient3, CLSCTX_ALL, nullptr, (void **)&p_device->audio_client);
if (hr != S_OK) {
// IID_IAudioClient3 will never activate on OS versions before Windows 10.
// Older Windows versions should fall back gracefully.
using_audio_client_3 = false;
- print_verbose("WASAPI: Couldn't activate device with IAudioClient3 interface, falling back to IAudioClient interface");
+ print_verbose("WASAPI: Couldn't activate output_device with IAudioClient3 interface, falling back to IAudioClient interface");
} else {
- print_verbose("WASAPI: Activated device using IAudioClient3 interface");
+ print_verbose("WASAPI: Activated output_device using IAudioClient3 interface");
}
}
if (!using_audio_client_3) {
- hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, (void **)&p_device->audio_client);
+ hr = output_device->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, (void **)&p_device->audio_client);
}
- SAFE_RELEASE(device)
+ SAFE_RELEASE(output_device)
if (p_reinit) {
if (hr != S_OK) {
@@ -339,7 +339,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
WAVEFORMATEX *closest = nullptr;
hr = p_device->audio_client->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, pwfex, &closest);
if (hr == S_FALSE) {
- WARN_PRINT("WASAPI: Mix format is not supported by the Device");
+ WARN_PRINT("WASAPI: Mix format is not supported by the output_device");
if (closest) {
print_verbose("WASAPI: closest->wFormatTag = " + itos(closest->wFormatTag));
print_verbose("WASAPI: closest->nChannels = " + itos(closest->nChannels));
@@ -385,14 +385,14 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
pwfex->nSamplesPerSec = mix_rate;
pwfex->nAvgBytesPerSec = pwfex->nSamplesPerSec * pwfex->nChannels * (pwfex->wBitsPerSample / 8);
}
- hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, nullptr);
+ hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_input ? REFTIMES_PER_SEC : 0, 0, pwfex, nullptr);
ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_CANT_OPEN, "WASAPI: Initialize failed with error 0x" + String::num_uint64(hr, 16) + ".");
UINT32 max_frames;
hr = p_device->audio_client->GetBufferSize(&max_frames);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
// Due to WASAPI Shared Mode we have no control of the buffer size
- if (!p_capture) {
+ if (!p_input) {
buffer_frames = max_frames;
int64_t latency = 0;
@@ -421,8 +421,8 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
if (hr != S_OK) {
print_verbose("WASAPI: GetSharedModeEnginePeriod failed with error 0x" + String::num_uint64(hr, 16) + ", falling back to IAudioClient.");
CoTaskMemFree(pwfex);
- SAFE_RELEASE(device)
- return audio_device_init(p_device, p_capture, p_reinit, true);
+ SAFE_RELEASE(output_device)
+ return audio_device_init(p_device, p_input, p_reinit, true);
}
// Period frames must be an integral multiple of fundamental_period_frames or IAudioClient3 initialization will fail,
@@ -443,8 +443,8 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
if (hr != S_OK) {
print_verbose("WASAPI: InitializeSharedAudioStream failed with error 0x" + String::num_uint64(hr, 16) + ", falling back to IAudioClient.");
CoTaskMemFree(pwfex);
- SAFE_RELEASE(device);
- return audio_device_init(p_device, p_capture, p_reinit, true);
+ SAFE_RELEASE(output_device);
+ return audio_device_init(p_device, p_input, p_reinit, true);
} else {
uint32_t output_latency_in_frames;
WAVEFORMATEX *current_pwfex;
@@ -455,13 +455,13 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
} else {
print_verbose("WASAPI: GetCurrentSharedModeEnginePeriod failed with error 0x" + String::num_uint64(hr, 16) + ", falling back to IAudioClient.");
CoTaskMemFree(pwfex);
- SAFE_RELEASE(device);
- return audio_device_init(p_device, p_capture, p_reinit, true);
+ SAFE_RELEASE(output_device);
+ return audio_device_init(p_device, p_input, p_reinit, true);
}
}
}
- if (p_capture) {
+ if (p_input) {
hr = p_device->audio_client->GetService(IID_IAudioCaptureClient, (void **)&p_device->capture_client);
} else {
hr = p_device->audio_client->GetService(IID_IAudioRenderClient, (void **)&p_device->render_client);
@@ -470,12 +470,12 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
// Free memory
CoTaskMemFree(pwfex);
- SAFE_RELEASE(device)
+ SAFE_RELEASE(output_device)
return OK;
}
-Error AudioDriverWASAPI::init_render_device(bool p_reinit) {
+Error AudioDriverWASAPI::init_output_device(bool p_reinit) {
Error err = audio_device_init(&audio_output, false, p_reinit);
if (err != OK) {
return err;
@@ -507,7 +507,7 @@ Error AudioDriverWASAPI::init_render_device(bool p_reinit) {
return OK;
}
-Error AudioDriverWASAPI::init_capture_device(bool p_reinit) {
+Error AudioDriverWASAPI::init_input_device(bool p_reinit) {
Error err = audio_device_init(&audio_input, true, p_reinit);
if (err != OK) {
return err;
@@ -538,11 +538,11 @@ Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
return OK;
}
-Error AudioDriverWASAPI::finish_render_device() {
+Error AudioDriverWASAPI::finish_output_device() {
return audio_device_finish(&audio_output);
}
-Error AudioDriverWASAPI::finish_capture_device() {
+Error AudioDriverWASAPI::finish_input_device() {
return audio_device_finish(&audio_input);
}
@@ -551,9 +551,9 @@ Error AudioDriverWASAPI::init() {
target_latency_ms = GLOBAL_GET("audio/driver/output_latency");
- Error err = init_render_device();
+ Error err = init_output_device();
if (err != OK) {
- ERR_PRINT("WASAPI: init_render_device error");
+ ERR_PRINT("WASAPI: init_output_device error");
}
exit_thread.clear();
@@ -575,7 +575,7 @@ AudioDriver::SpeakerMode AudioDriverWASAPI::get_speaker_mode() const {
return get_speaker_mode_by_total_channels(channels);
}
-PackedStringArray AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
+PackedStringArray AudioDriverWASAPI::audio_device_get_list(bool p_input) {
PackedStringArray list;
IMMDeviceCollection *devices = nullptr;
IMMDeviceEnumerator *enumerator = nullptr;
@@ -587,7 +587,7 @@ PackedStringArray AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&enumerator);
ERR_FAIL_COND_V(hr != S_OK, PackedStringArray());
- hr = enumerator->EnumAudioEndpoints(p_capture ? eCapture : eRender, DEVICE_STATE_ACTIVE, &devices);
+ hr = enumerator->EnumAudioEndpoints(p_input ? eCapture : eRender, DEVICE_STATE_ACTIVE, &devices);
ERR_FAIL_COND_V(hr != S_OK, PackedStringArray());
UINT count = 0;
@@ -595,13 +595,13 @@ PackedStringArray AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
ERR_FAIL_COND_V(hr != S_OK, PackedStringArray());
for (ULONG i = 0; i < count; i++) {
- IMMDevice *device = nullptr;
+ IMMDevice *output_device = nullptr;
- hr = devices->Item(i, &device);
+ hr = devices->Item(i, &output_device);
ERR_BREAK(hr != S_OK);
IPropertyStore *props = nullptr;
- hr = device->OpenPropertyStore(STGM_READ, &props);
+ hr = output_device->OpenPropertyStore(STGM_READ, &props);
ERR_BREAK(hr != S_OK);
PROPVARIANT propvar;
@@ -614,7 +614,7 @@ PackedStringArray AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
PropVariantClear(&propvar);
props->Release();
- device->Release();
+ output_device->Release();
}
devices->Release();
@@ -622,11 +622,11 @@ PackedStringArray AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
return list;
}
-PackedStringArray AudioDriverWASAPI::get_device_list() {
+PackedStringArray AudioDriverWASAPI::get_output_device_list() {
return audio_device_get_list(false);
}
-String AudioDriverWASAPI::get_device() {
+String AudioDriverWASAPI::get_output_device() {
lock();
String name = audio_output.device_name;
unlock();
@@ -634,9 +634,9 @@ String AudioDriverWASAPI::get_device() {
return name;
}
-void AudioDriverWASAPI::set_device(String device) {
+void AudioDriverWASAPI::set_output_device(String output_device) {
lock();
- audio_output.new_device = device;
+ audio_output.new_device = output_device;
unlock();
}
@@ -769,13 +769,13 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
avail_frames -= write_frames;
written_frames += write_frames;
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
- // Device is not valid anymore, reopen it
+ // output_device is not valid anymore, reopen it
- Error err = ad->finish_render_device();
+ Error err = ad->finish_output_device();
if (err != OK) {
- ERR_PRINT("WASAPI: finish_render_device error");
+ ERR_PRINT("WASAPI: finish_output_device error");
} else {
- // We reopened the device and samples_in may have resized, so invalidate the current avail_frames
+ // We reopened the output device and samples_in may have resized, so invalidate the current avail_frames
avail_frames = 0;
}
} else {
@@ -790,37 +790,37 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
}
if (invalidated) {
- // Device is not valid anymore
- WARN_PRINT("WASAPI: Current device invalidated, closing device");
+ // output_device is not valid anymore
+ WARN_PRINT("WASAPI: Current output_device invalidated, closing output_device");
- Error err = ad->finish_render_device();
+ Error err = ad->finish_output_device();
if (err != OK) {
- ERR_PRINT("WASAPI: finish_render_device error");
+ ERR_PRINT("WASAPI: finish_output_device error");
}
}
}
- // If we're using the Default device and it changed finish it so we'll re-init the device
- if (ad->audio_output.device_name == "Default" && default_render_device_changed) {
- Error err = ad->finish_render_device();
+ // If we're using the Default output device and it changed finish it so we'll re-init the output device
+ if (ad->audio_output.device_name == "Default" && default_output_device_changed) {
+ Error err = ad->finish_output_device();
if (err != OK) {
- ERR_PRINT("WASAPI: finish_render_device error");
+ ERR_PRINT("WASAPI: finish_output_device error");
}
- default_render_device_changed = false;
+ default_output_device_changed = false;
}
- // User selected a new device, finish the current one so we'll init the new device
+ // User selected a new output device, finish the current one so we'll init the new output device
if (ad->audio_output.device_name != ad->audio_output.new_device) {
ad->audio_output.device_name = ad->audio_output.new_device;
- Error err = ad->finish_render_device();
+ Error err = ad->finish_output_device();
if (err != OK) {
- ERR_PRINT("WASAPI: finish_render_device error");
+ ERR_PRINT("WASAPI: finish_output_device error");
}
}
if (!ad->audio_output.audio_client) {
- Error err = ad->init_render_device(true);
+ Error err = ad->init_output_device(true);
if (err == OK) {
ad->start();
}
@@ -873,29 +873,29 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
}
}
- // If we're using the Default device and it changed finish it so we'll re-init the device
- if (ad->audio_input.device_name == "Default" && default_capture_device_changed) {
- Error err = ad->finish_capture_device();
+ // If we're using the Default output device and it changed finish it so we'll re-init the output device
+ if (ad->audio_input.device_name == "Default" && default_input_device_changed) {
+ Error err = ad->finish_input_device();
if (err != OK) {
- ERR_PRINT("WASAPI: finish_capture_device error");
+ ERR_PRINT("WASAPI: finish_input_device error");
}
- default_capture_device_changed = false;
+ default_input_device_changed = false;
}
- // User selected a new device, finish the current one so we'll init the new device
+ // User selected a new input device, finish the current one so we'll init the new input device
if (ad->audio_input.device_name != ad->audio_input.new_device) {
ad->audio_input.device_name = ad->audio_input.new_device;
- Error err = ad->finish_capture_device();
+ Error err = ad->finish_input_device();
if (err != OK) {
- ERR_PRINT("WASAPI: finish_capture_device error");
+ ERR_PRINT("WASAPI: finish_input_device error");
}
}
if (!ad->audio_input.audio_client) {
- Error err = ad->init_capture_device(true);
+ Error err = ad->init_input_device(true);
if (err == OK) {
- ad->capture_start();
+ ad->input_start();
}
}
}
@@ -933,14 +933,14 @@ void AudioDriverWASAPI::finish() {
exit_thread.set();
thread.wait_to_finish();
- finish_capture_device();
- finish_render_device();
+ finish_input_device();
+ finish_output_device();
}
-Error AudioDriverWASAPI::capture_start() {
- Error err = init_capture_device();
+Error AudioDriverWASAPI::input_start() {
+ Error err = init_input_device();
if (err != OK) {
- ERR_PRINT("WASAPI: init_capture_device error");
+ ERR_PRINT("WASAPI: init_input_device error");
return err;
}
@@ -953,7 +953,7 @@ Error AudioDriverWASAPI::capture_start() {
return OK;
}
-Error AudioDriverWASAPI::capture_stop() {
+Error AudioDriverWASAPI::input_stop() {
if (audio_input.active.is_set()) {
audio_input.audio_client->Stop();
audio_input.active.clear();
@@ -964,17 +964,17 @@ Error AudioDriverWASAPI::capture_stop() {
return FAILED;
}
-void AudioDriverWASAPI::capture_set_device(const String &p_name) {
+void AudioDriverWASAPI::set_input_device(const String &p_name) {
lock();
audio_input.new_device = p_name;
unlock();
}
-PackedStringArray AudioDriverWASAPI::capture_get_device_list() {
+PackedStringArray AudioDriverWASAPI::get_input_device_list() {
return audio_device_get_list(true);
}
-String AudioDriverWASAPI::capture_get_device() {
+String AudioDriverWASAPI::get_input_device() {
lock();
String name = audio_input.device_name;
unlock();
diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h
index 6eea24f78a..bf18ba8c99 100644
--- a/drivers/wasapi/audio_driver_wasapi.h
+++ b/drivers/wasapi/audio_driver_wasapi.h
@@ -47,8 +47,8 @@ class AudioDriverWASAPI : public AudioDriver {
class AudioDeviceWASAPI {
public:
IAudioClient *audio_client = nullptr;
- IAudioRenderClient *render_client = nullptr;
- IAudioCaptureClient *capture_client = nullptr;
+ IAudioRenderClient *render_client = nullptr; // Output
+ IAudioCaptureClient *capture_client = nullptr; // Input
SafeFlag active;
WORD format_tag = 0;
@@ -56,8 +56,8 @@ class AudioDriverWASAPI : public AudioDriver {
unsigned int channels = 0;
unsigned int frame_size = 0;
- String device_name = "Default";
- String new_device = "Default";
+ String device_name = "Default"; // Output OR Input
+ String new_device = "Default"; // Output OR Input
AudioDeviceWASAPI() {}
};
@@ -83,15 +83,15 @@ class AudioDriverWASAPI : public AudioDriver {
static _FORCE_INLINE_ int32_t read_sample(WORD format_tag, int bits_per_sample, BYTE *buffer, int i);
static void thread_func(void *p_udata);
- Error init_render_device(bool p_reinit = false);
- Error init_capture_device(bool p_reinit = false);
+ Error init_output_device(bool p_reinit = false);
+ Error init_input_device(bool p_reinit = false);
- Error finish_render_device();
- Error finish_capture_device();
+ Error finish_output_device();
+ Error finish_input_device();
- Error audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool p_reinit, bool p_no_audio_client_3 = false);
+ Error audio_device_init(AudioDeviceWASAPI *p_device, bool p_input, bool p_reinit, bool p_no_audio_client_3 = false);
Error audio_device_finish(AudioDeviceWASAPI *p_device);
- PackedStringArray audio_device_get_list(bool p_capture);
+ PackedStringArray audio_device_get_list(bool p_input);
public:
virtual const char *get_name() const {
@@ -103,18 +103,18 @@ public:
virtual int get_mix_rate() const;
virtual float get_latency();
virtual SpeakerMode get_speaker_mode() const;
- virtual PackedStringArray get_device_list();
- virtual String get_device();
- virtual void set_device(String device);
+ virtual PackedStringArray get_output_device_list();
+ virtual String get_output_device();
+ virtual void set_output_device(String output_device);
virtual void lock();
virtual void unlock();
virtual void finish();
- virtual Error capture_start();
- virtual Error capture_stop();
- virtual PackedStringArray capture_get_device_list();
- virtual void capture_set_device(const String &p_name);
- virtual String capture_get_device();
+ virtual Error input_start();
+ virtual Error input_stop();
+ virtual PackedStringArray get_input_device_list();
+ virtual void set_input_device(const String &p_name);
+ virtual String get_input_device();
AudioDriverWASAPI();
};
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp
index ae54c20fe2..146b5a794c 100644
--- a/editor/action_map_editor.cpp
+++ b/editor/action_map_editor.cpp
@@ -198,6 +198,14 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i
emit_signal(SNAME("action_edited"), action_name, action);
} break;
+ case ActionMapEditor::BUTTON_REVERT_ACTION: {
+ ERR_FAIL_COND_MSG(!item->has_meta("__action_initial"), "Tree Item for action which can be reverted is expected to have meta value with initial value of action.");
+
+ Dictionary action = item->get_meta("__action_initial").duplicate();
+ String action_name = item->get_meta("__name");
+
+ emit_signal(SNAME("action_edited"), action_name, action);
+ } break;
default:
break;
}
@@ -427,6 +435,13 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
action_item->set_range(1, deadzone);
// Third column - buttons
+ if (action_info.has_initial) {
+ bool deadzone_eq = action_info.action_initial["deadzone"] == action_info.action["deadzone"];
+ bool events_eq = Shortcut::is_event_array_equal(action_info.action_initial["events"], action_info.action["events"]);
+ bool action_eq = deadzone_eq && events_eq;
+ action_item->set_meta("__action_initial", action_info.action_initial);
+ action_item->add_button(2, action_tree->get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons")), BUTTON_REVERT_ACTION, action_eq, action_eq ? TTR("Cannot Revert - Action is same as initial") : TTR("Revert Action"));
+ }
action_item->add_button(2, action_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), BUTTON_ADD_EVENT, false, TTR("Add Event"));
action_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? TTR("Remove Action") : TTR("Cannot Remove Action"));
diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h
index 433a72a807..2848d23e83 100644
--- a/editor/action_map_editor.h
+++ b/editor/action_map_editor.h
@@ -49,6 +49,8 @@ public:
struct ActionInfo {
String name;
Dictionary action;
+ bool has_initial = false;
+ Dictionary action_initial;
Ref<Texture2D> icon = Ref<Texture2D>();
bool editable = true;
@@ -60,6 +62,7 @@ private:
BUTTON_EDIT_EVENT,
BUTTON_REMOVE_ACTION,
BUTTON_REMOVE_EVENT,
+ BUTTON_REVERT_ACTION,
};
Vector<ActionInfo> actions_cache;
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 0405749147..fe62d9dda0 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2136,6 +2136,13 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) {
}
}
+void EditorNode::push_node_item(Node *p_node) {
+ if (p_node || Object::cast_to<Node>(InspectorDock::get_inspector_singleton()->get_edited_object())) {
+ // Don't push null if the currently edited object is not a Node.
+ push_item(p_node);
+ }
+}
+
void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) {
if (!p_object) {
InspectorDock::get_inspector_singleton()->edit(nullptr);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 3967f64c6b..914dab0254 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -798,6 +798,7 @@ public:
void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false);
void edit_item(Object *p_object, Object *p_editing_owner);
+ void push_node_item(Node *p_node);
void hide_unused_editors(const Object *p_editing_owner = nullptr);
void select_editor_by_name(const String &p_name);
diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
index 72c234c1d4..477a094d01 100644
--- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
@@ -77,7 +77,7 @@ void GPUParticlesCollisionSDF3DEditorPlugin::_notification(int p_what) {
const Vector3i size = col_sdf->get_estimated_cell_size();
- const Vector3 extents = col_sdf->get_extents();
+ const Vector3 extents = col_sdf->get_size() / 2;
int data_size = 2;
const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index e11dc1c81d..e48a5bb95d 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -1805,7 +1805,7 @@ void Camera3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
} else {
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb);
- float d = ra.x * 2.0;
+ float d = ra.x * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -2099,7 +2099,7 @@ void OccluderInstance3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo,
Ref<BoxOccluder3D> bo = o;
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (snap_enabled) {
d = Math::snapped(d, snap);
}
@@ -2109,7 +2109,7 @@ void OccluderInstance3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo,
}
Vector3 he = bo->get_size();
- he[p_id] = d * 2;
+ he[p_id] = d;
bo->set_size(he);
}
@@ -3184,7 +3184,7 @@ String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGiz
}
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
- return "Extents";
+ return "Size";
}
return "";
@@ -3198,7 +3198,7 @@ Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(const EditorNode3DG
}
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
- return Vector3(p_gizmo->get_node_3d()->call("get_extents"));
+ return Vector3(p_gizmo->get_node_3d()->call("get_size"));
}
return Variant();
@@ -3235,7 +3235,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g
axis[p_id] = 1.0;
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -3244,9 +3244,9 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g
d = 0.001;
}
- Vector3 he = sn->call("get_extents");
+ Vector3 he = sn->call("get_size");
he[p_id] = d;
- sn->call("set_extents", he);
+ sn->call("set_size", he);
}
}
@@ -3268,14 +3268,14 @@ void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *
if (Object::cast_to<GPUParticlesCollisionBox3D>(sn) || Object::cast_to<GPUParticlesAttractorBox3D>(sn) || Object::cast_to<GPUParticlesAttractorVectorField3D>(sn) || Object::cast_to<GPUParticlesCollisionSDF3D>(sn) || Object::cast_to<GPUParticlesCollisionHeightField3D>(sn)) {
if (p_cancel) {
- sn->call("set_extents", p_restore);
+ sn->call("set_size", p_restore);
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
- ur->create_action(TTR("Change Box Shape Extents"));
- ur->add_do_method(sn, "set_extents", sn->call("get_extents"));
- ur->add_undo_method(sn, "set_extents", p_restore);
+ ur->create_action(TTR("Change Box Shape Size"));
+ ur->add_do_method(sn, "set_size", sn->call("get_size"));
+ ur->add_undo_method(sn, "set_size", p_restore);
ur->commit_action();
}
}
@@ -3342,8 +3342,8 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
Vector<Vector3> lines;
AABB aabb;
- aabb.position = -cs->call("get_extents").operator Vector3();
- aabb.size = aabb.position * -2;
+ aabb.size = cs->call("get_size").operator Vector3();
+ aabb.position = aabb.size / -2;
for (int i = 0; i < 12; i++) {
Vector3 a, b;
@@ -3356,7 +3356,7 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
for (int i = 0; i < 3; i++) {
Vector3 ax;
- ax[i] = cs->call("get_extents").operator Vector3()[i];
+ ax[i] = cs->call("get_size").operator Vector3()[i] / 2;
handles.push_back(ax);
}
@@ -3442,11 +3442,11 @@ int ReflectionProbeGizmoPlugin::get_priority() const {
String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
switch (p_id) {
case 0:
- return "Extents X";
+ return "Size X";
case 1:
- return "Extents Y";
+ return "Size Y";
case 2:
- return "Extents Z";
+ return "Size Z";
case 3:
return "Origin X";
case 4:
@@ -3460,7 +3460,7 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi
Variant ReflectionProbeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d());
- return AABB(probe->get_extents(), probe->get_origin_offset());
+ return AABB(probe->get_origin_offset(), probe->get_size());
}
void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
@@ -3470,7 +3470,7 @@ void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, in
Transform3D gi = gt.affine_inverse();
if (p_id < 3) {
- Vector3 extents = probe->get_extents();
+ Vector3 size = probe->get_size();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@@ -3482,7 +3482,7 @@ void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, in
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -3491,8 +3491,8 @@ void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, in
d = 0.001;
}
- extents[p_id] = d;
- probe->set_extents(extents);
+ size[p_id] = d;
+ probe->set_size(size);
} else {
p_id -= 3;
@@ -3526,17 +3526,17 @@ void ReflectionProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo,
AABB restore = p_restore;
if (p_cancel) {
- probe->set_extents(restore.position);
- probe->set_origin_offset(restore.size);
+ probe->set_origin_offset(restore.position);
+ probe->set_size(restore.size);
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
- ur->create_action(TTR("Change Probe Extents"));
- ur->add_do_method(probe, "set_extents", probe->get_extents());
+ ur->create_action(TTR("Change Probe Size"));
+ ur->add_do_method(probe, "set_size", probe->get_size());
ur->add_do_method(probe, "set_origin_offset", probe->get_origin_offset());
- ur->add_undo_method(probe, "set_extents", restore.position);
- ur->add_undo_method(probe, "set_origin_offset", restore.size);
+ ur->add_undo_method(probe, "set_size", restore.size);
+ ur->add_undo_method(probe, "set_origin_offset", restore.position);
ur->commit_action();
}
@@ -3547,11 +3547,11 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> lines;
Vector<Vector3> internal_lines;
- Vector3 extents = probe->get_extents();
+ Vector3 size = probe->get_size();
AABB aabb;
- aabb.position = -extents;
- aabb.size = extents * 2;
+ aabb.position = -size / 2;
+ aabb.size = size;
for (int i = 0; i < 12; i++) {
Vector3 a, b;
@@ -3593,7 +3593,7 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
if (p_gizmo->is_selected()) {
Ref<Material> solid_material = get_material("reflection_probe_solid_material", p_gizmo);
- p_gizmo->add_solid_box(solid_material, probe->get_extents() * 2.0);
+ p_gizmo->add_solid_box(solid_material, probe->get_size());
}
p_gizmo->add_unscaled_billboard(icon, 0.05);
@@ -3627,11 +3627,11 @@ int DecalGizmoPlugin::get_priority() const {
String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
switch (p_id) {
case 0:
- return "Extents X";
+ return "Size X";
case 1:
- return "Extents Y";
+ return "Size Y";
case 2:
- return "Extents Z";
+ return "Size Z";
}
return "";
@@ -3639,7 +3639,7 @@ String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p
Variant DecalGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
Decal *decal = Object::cast_to<Decal>(p_gizmo->get_node_3d());
- return decal->get_extents();
+ return decal->get_size();
}
void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
@@ -3648,7 +3648,7 @@ void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bo
Transform3D gi = gt.affine_inverse();
- Vector3 extents = decal->get_extents();
+ Vector3 size = decal->get_size();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@@ -3660,7 +3660,7 @@ void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bo
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -3669,8 +3669,8 @@ void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bo
d = 0.001;
}
- extents[p_id] = d;
- decal->set_extents(extents);
+ size[p_id] = d;
+ decal->set_size(size);
}
void DecalGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
@@ -3679,14 +3679,14 @@ void DecalGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
Vector3 restore = p_restore;
if (p_cancel) {
- decal->set_extents(restore);
+ decal->set_size(restore);
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
- ur->create_action(TTR("Change Decal Extents"));
- ur->add_do_method(decal, "set_extents", decal->get_extents());
- ur->add_undo_method(decal, "set_extents", restore);
+ ur->create_action(TTR("Change Decal Size"));
+ ur->add_do_method(decal, "set_size", decal->get_size());
+ ur->add_undo_method(decal, "set_size", restore);
ur->commit_action();
}
@@ -3696,11 +3696,11 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
Vector<Vector3> lines;
- Vector3 extents = decal->get_extents();
+ Vector3 size = decal->get_size();
AABB aabb;
- aabb.position = -extents;
- aabb.size = extents * 2;
+ aabb.position = -size / 2;
+ aabb.size = size;
for (int i = 0; i < 12; i++) {
Vector3 a, b;
@@ -3718,8 +3718,9 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
}
- lines.push_back(Vector3(0, extents.y, 0));
- lines.push_back(Vector3(0, extents.y * 1.2, 0));
+ float half_size_y = size.y / 2;
+ lines.push_back(Vector3(0, half_size_y, 0));
+ lines.push_back(Vector3(0, half_size_y * 1.2, 0));
Vector<Vector3> handles;
@@ -3767,11 +3768,11 @@ int VoxelGIGizmoPlugin::get_priority() const {
String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
switch (p_id) {
case 0:
- return "Extents X";
+ return "Size X";
case 1:
- return "Extents Y";
+ return "Size Y";
case 2:
- return "Extents Z";
+ return "Size Z";
}
return "";
@@ -3779,7 +3780,7 @@ String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int
Variant VoxelGIGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
- return probe->get_extents();
+ return probe->get_size();
}
void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
@@ -3788,7 +3789,7 @@ void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
Transform3D gt = probe->get_global_transform();
Transform3D gi = gt.affine_inverse();
- Vector3 extents = probe->get_extents();
+ Vector3 size = probe->get_size();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@@ -3800,7 +3801,7 @@ void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -3809,8 +3810,8 @@ void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
d = 0.001;
}
- extents[p_id] = d;
- probe->set_extents(extents);
+ size[p_id] = d;
+ probe->set_size(size);
}
void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
@@ -3819,14 +3820,14 @@ void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_i
Vector3 restore = p_restore;
if (p_cancel) {
- probe->set_extents(restore);
+ probe->set_size(restore);
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
- ur->create_action(TTR("Change Probe Extents"));
- ur->add_do_method(probe, "set_extents", probe->get_extents());
- ur->add_undo_method(probe, "set_extents", restore);
+ ur->create_action(TTR("Change Probe Size"));
+ ur->add_do_method(probe, "set_size", probe->get_size());
+ ur->add_undo_method(probe, "set_size", restore);
ur->commit_action();
}
@@ -3840,11 +3841,11 @@ void VoxelGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
Vector<Vector3> lines;
- Vector3 extents = probe->get_extents();
+ Vector3 size = probe->get_size();
static const int subdivs[VoxelGI::SUBDIV_MAX] = { 64, 128, 256, 512 };
- AABB aabb = AABB(-extents, extents * 2);
+ AABB aabb = AABB(-size / 2, size);
int subdiv = subdivs[probe->get_subdiv()];
float cell_size = aabb.get_longest_axis_size() / subdiv;
@@ -4363,7 +4364,7 @@ void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
Ref<BoxShape3D> bs = s;
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -4373,7 +4374,7 @@ void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
}
Vector3 he = bs->get_size();
- he[p_id] = d * 2;
+ he[p_id] = d;
bs->set_size(he);
}
@@ -5902,11 +5903,11 @@ int FogVolumeGizmoPlugin::get_priority() const {
}
String FogVolumeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- return "Extents";
+ return "Size";
}
Variant FogVolumeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
- return Vector3(p_gizmo->get_node_3d()->call("get_extents"));
+ return Vector3(p_gizmo->get_node_3d()->call("get_size"));
}
void FogVolumeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
@@ -5924,7 +5925,7 @@ void FogVolumeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id
axis[p_id] = 1.0;
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
- float d = ra[p_id];
+ float d = ra[p_id] * 2;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
@@ -5933,23 +5934,23 @@ void FogVolumeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id
d = 0.001;
}
- Vector3 he = sn->call("get_extents");
+ Vector3 he = sn->call("get_size");
he[p_id] = d;
- sn->call("set_extents", he);
+ sn->call("set_size", he);
}
void FogVolumeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
Node3D *sn = p_gizmo->get_node_3d();
if (p_cancel) {
- sn->call("set_extents", p_restore);
+ sn->call("set_size", p_restore);
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
- ur->create_action(TTR("Change Fog Volume Extents"));
- ur->add_do_method(sn, "set_extents", sn->call("get_extents"));
- ur->add_undo_method(sn, "set_extents", p_restore);
+ ur->create_action(TTR("Change Fog Volume Size"));
+ ur->add_do_method(sn, "set_size", sn->call("get_size"));
+ ur->add_undo_method(sn, "set_size", p_restore);
ur->commit_action();
}
@@ -5968,8 +5969,8 @@ void FogVolumeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> lines;
AABB aabb;
- aabb.position = -cs->call("get_extents").operator Vector3();
- aabb.size = aabb.position * -2;
+ aabb.size = cs->call("get_size").operator Vector3();
+ aabb.position = aabb.size / -2;
for (int i = 0; i < 12; i++) {
Vector3 a, b;
@@ -5982,7 +5983,7 @@ void FogVolumeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
for (int i = 0; i < 3; i++) {
Vector3 ax;
- ax[i] = cs->call("get_extents").operator Vector3()[i];
+ ax[i] = cs->call("get_size").operator Vector3()[i] / 2;
handles.push_back(ax);
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 13caa30b2c..59b5795ae3 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -5536,6 +5536,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("ViewIndex", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_index", "VIEW_INDEX"), { "view_index" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("ViewMonoLeft", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_mono_left", "VIEW_MONO_LEFT"), { "view_mono_left" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("ViewRight", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_right", "VIEW_RIGHT"), { "view_right" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("EyeOffset", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "eye_offset", "EYE_OFFSET"), { "eye_offset" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("NodePositionWorld", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "node_position_world", "NODE_POSITION_WORLD"), { "node_position_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("CameraPositionWorld", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "camera_position_world", "CAMERA_POSITION_WORLD"), { "camera_position_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("CameraDirectionWorld", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "camera_direction_world", "CAMERA_DIRECTION_WORLD"), { "camera_direction_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
@@ -5554,6 +5555,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("ViewIndex", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_index", "VIEW_INDEX"), { "view_index" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("ViewMonoLeft", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_mono_left", "VIEW_MONO_LEFT"), { "view_mono_left" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("ViewRight", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_right", "VIEW_RIGHT"), { "view_right" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("EyeOffset", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "eye_offset", "EYE_OFFSET"), { "eye_offset" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("NodePositionWorld", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "node_position_world", "NODE_POSITION_WORLD"), { "node_position_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("CameraPositionWorld", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "camera_position_world", "CAMERA_POSITION_WORLD"), { "camera_position_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("CameraDirectionWorld", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "camera_direction_world", "CAMERA_DIRECTION_WORLD"), { "camera_direction_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
@@ -5647,7 +5649,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("WorldPosition", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "world_position", "WORLD_POSITION"), { "world_position" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FOG, Shader::MODE_FOG));
add_options.push_back(AddOption("ObjectPosition", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "object_position", "OBJECT_POSITION"), { "object_position" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FOG, Shader::MODE_FOG));
add_options.push_back(AddOption("UVW", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "uvw", "UVW"), { "uvw" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FOG, Shader::MODE_FOG));
- add_options.push_back(AddOption("Extents", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "extents", "EXTENTS"), { "extents" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FOG, Shader::MODE_FOG));
+ add_options.push_back(AddOption("Size", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "size", "SIZE"), { "size" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FOG, Shader::MODE_FOG));
add_options.push_back(AddOption("SDF", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "sdf", "SDF"), { "sdf" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FOG, Shader::MODE_FOG));
add_options.push_back(AddOption("Time", "Input/Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "time", "TIME"), { "time" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FOG, Shader::MODE_FOG));
diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp
index f9f72fee77..1087a50df6 100644
--- a/editor/plugins/voxel_gi_editor_plugin.cpp
+++ b/editor/plugins/voxel_gi_editor_plugin.cpp
@@ -101,12 +101,12 @@ void VoxelGIEditorPlugin::_notification(int p_what) {
// Set information tooltip on the Bake button. This information is useful
// to optimize performance (video RAM size) and reduce light leaking (individual cell size).
- const Vector3i size = voxel_gi->get_estimated_cell_size();
+ const Vector3i cell_size = voxel_gi->get_estimated_cell_size();
- const Vector3 extents = voxel_gi->get_extents();
+ const Vector3 half_size = voxel_gi->get_size() / 2;
const int data_size = 4;
- const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
+ const double size_mb = cell_size.x * cell_size.y * cell_size.z * data_size / (1024.0 * 1024.0);
// Add a qualitative measurement to help the user assess whether a VoxelGI node is using a lot of VRAM.
String size_quality;
if (size_mb < 16.0) {
@@ -118,8 +118,8 @@ void VoxelGIEditorPlugin::_notification(int p_what) {
}
String text;
- text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n";
- text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n";
+ text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), cell_size.x, cell_size.y, cell_size.z)) + "\n";
+ text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), half_size.x / cell_size.x, half_size.y / cell_size.y, half_size.z / cell_size.z)) + "\n";
text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality);
// Only update the tooltip when needed to avoid constant redrawing.
diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp
index 058d77380f..d3e16211f7 100644
--- a/editor/project_converter_3_to_4.cpp
+++ b/editor/project_converter_3_to_4.cpp
@@ -241,6 +241,9 @@ const char *ProjectConverter3To4::gdscript_function_renames[][2] = {
{ "can_generate_small_preview", "_can_generate_small_preview" }, // EditorResourcePreviewGenerator
{ "can_instance", "can_instantiate" }, // PackedScene, Script
{ "canvas_light_set_scale", "canvas_light_set_texture_scale" }, // RenderingServer
+ { "capture_get_device", "get_input_device" }, // AudioServer
+ { "capture_get_device_list", "get_input_device_list" }, // AudioServer
+ { "capture_set_device", "set_input_device" }, // AudioServer
{ "center_viewport_to_cursor", "center_viewport_to_caret" }, // TextEdit
{ "change_scene", "change_scene_to_file" }, // SceneTree
{ "change_scene_to", "change_scene_to_packed" }, // SceneTree
@@ -301,6 +304,8 @@ const char *ProjectConverter3To4::gdscript_function_renames[][2] = {
{ "get_cursor_position", "get_caret_column" }, // LineEdit
{ "get_d", "get_distance" }, // LineShape2D
{ "get_depth_bias_enable", "get_depth_bias_enabled" }, // RDPipelineRasterizationState
+ { "get_device", "get_output_device" }, // AudioServer
+ { "get_device_list", "get_output_device_list" }, // AudioServer
{ "get_drag_data", "_get_drag_data" }, // Control
{ "get_editor_viewport", "get_editor_main_screen" }, // EditorPlugin
{ "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton
@@ -499,6 +504,7 @@ const char *ProjectConverter3To4::gdscript_function_renames[][2] = {
{ "set_cursor_position", "set_caret_column" }, // LineEdit
{ "set_d", "set_distance" }, // WorldMarginShape2D
{ "set_depth_bias_enable", "set_depth_bias_enabled" }, // RDPipelineRasterizationState
+ { "set_device", "set_output_device" }, // AudioServer
{ "set_doubleclick", "set_double_click" }, // InputEventMouseButton
{ "set_draw_red", "set_draw_warning" }, // EditorProperty
{ "set_enable_follow_smoothing", "set_position_smoothing_enabled" }, // Camera2D
@@ -697,6 +703,9 @@ const char *ProjectConverter3To4::csharp_function_renames[][2] = {
{ "CanGenerateSmallPreview", "_CanGenerateSmallPreview" }, // EditorResourcePreviewGenerator
{ "CanInstance", "CanInstantiate" }, // PackedScene, Script
{ "CanvasLightSetScale", "CanvasLightSetTextureScale" }, // RenderingServer
+ { "CaptureGetDevice", "GetInputDevice" }, // AudioServer
+ { "CaptureGetDeviceList", "GetInputDeviceList" }, // AudioServer
+ { "CaptureSetDevice", "SetInputDevice" }, // AudioServer
{ "CenterViewportToCursor", "CenterViewportToCaret" }, // TextEdit
{ "ChangeScene", "ChangeSceneToFile" }, // SceneTree
{ "ChangeSceneTo", "ChangeSceneToPacked" }, // SceneTree
@@ -754,6 +763,8 @@ const char *ProjectConverter3To4::csharp_function_renames[][2] = {
{ "GetCursorPosition", "GetCaretColumn" }, // LineEdit
{ "GetD", "GetDistance" }, // LineShape2D
{ "GetDepthBiasEnable", "GetDepthBiasEnabled" }, // RDPipelineRasterizationState
+ { "GetDevice", "GetOutputDevice" }, // AudioServer
+ { "GetDeviceList", "GetOutputDeviceList" }, // AudioServer
{ "GetDragDataFw", "_GetDragDataFw" }, // ScriptEditor
{ "GetEditorViewport", "GetViewport" }, // EditorPlugin
{ "GetEnabledFocusMode", "GetFocusMode" }, // BaseButton
@@ -942,6 +953,7 @@ const char *ProjectConverter3To4::csharp_function_renames[][2] = {
{ "SetCursorPosition", "SetCaretColumn" }, // LineEdit
{ "SetD", "SetDistance" }, // WorldMarginShape2D
{ "SetDepthBiasEnable", "SetDepthBiasEnabled" }, // RDPipelineRasterizationState
+ { "SetDevice", "SetOutputDevice" }, // AudioServer
{ "SetDoubleclick", "SetDoubleClick" }, // InputEventMouseButton
{ "SetEnableFollowSmoothing", "SetFollowSmoothingEnabled" }, // Camera2D
{ "SetEnabledFocusMode", "SetFocusMode" }, // BaseButton
@@ -1070,6 +1082,7 @@ const char *ProjectConverter3To4::gdscript_properties_renames[][2] = {
// // {"shift","shift_pressed"},// This may broke a lot of comments and user variables
// { "autowrap", "autowrap_mode" }, // Label
// { "cast_to", "target_position" }, // RayCast2D, RayCast3D
+ // { "device", "output_device"}, // AudioServer - Too vague, most likely breaks comments & variables
// { "doubleclick", "double_click" }, // InputEventMouseButton
// { "group", "button_group" }, // BaseButton
// { "process_mode", "process_callback" }, // AnimationTree, Camera2D
@@ -1085,6 +1098,7 @@ const char *ProjectConverter3To4::gdscript_properties_renames[][2] = {
{ "bbcode_text", "text" }, // RichTextLabel
{ "bg", "panel" }, // Theme
{ "bg_focus", "focus" }, // Theme
+ { "capture_device", "input_device" }, // AudioServer
{ "caret_blink_speed", "caret_blink_interval" }, // TextEdit, LineEdit
{ "caret_moving_by_right_click", "caret_move_on_right_click" }, // TextEdit
{ "caret_position", "caret_column" }, // LineEdit
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 560549d249..a43745b70f 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -370,17 +370,7 @@ void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionar
} else {
// Events changed
- int act_event_count = ((Array)p_action["events"]).size();
- int old_event_count = ((Array)old_val["events"]).size();
-
- if (act_event_count == old_event_count) {
- undo_redo->create_action(TTR("Edit Input Action Event"));
- } else if (act_event_count > old_event_count) {
- undo_redo->create_action(TTR("Add Input Action Event"));
- } else {
- undo_redo->create_action(TTR("Remove Input Action Event"));
- }
-
+ undo_redo->create_action(TTR("Change Input Action Event(s)"));
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", property_name, p_action);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property_name, old_val);
}
@@ -527,6 +517,8 @@ void ProjectSettingsEditor::_update_action_map_editor() {
if (is_builtin_input) {
action_info.editable = false;
action_info.icon = builtin_icon;
+ action_info.has_initial = true;
+ action_info.action_initial = ProjectSettings::get_singleton()->property_get_revert(property_name);
}
actions.push_back(action_info);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 86e77fbbbe..d8f1d92e44 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1427,7 +1427,14 @@ void SceneTreeDock::_script_open_request(const Ref<Script> &p_script) {
}
void SceneTreeDock::_push_item(Object *p_object) {
- EditorNode::get_singleton()->push_item(p_object);
+ Node *node = Object::cast_to<Node>(p_object);
+ if (node || !p_object) {
+ // Assume that null object is a Node.
+ EditorNode::get_singleton()->push_node_item(node);
+ } else {
+ EditorNode::get_singleton()->push_item(p_object);
+ }
+
if (p_object == nullptr) {
EditorNode::get_singleton()->hide_unused_editors(this);
}
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index cd837b3a91..32acad76aa 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -227,18 +227,6 @@
[/codeblock]
</description>
</method>
- <method name="str" qualifiers="vararg">
- <return type="String" />
- <description>
- Converts one or more arguments to a [String] in the best way possible.
- [codeblock]
- var a = [10, 20, 30]
- var b = str(a);
- len(a) # Returns 3
- len(b) # Returns 12
- [/codeblock]
- </description>
- </method>
<method name="type_exists">
<return type="bool" />
<param index="0" name="type" type="StringName" />
diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp
index 10d83dcfe5..758b61bb31 100644
--- a/modules/gdscript/gdscript_utility_functions.cpp
+++ b/modules/gdscript/gdscript_utility_functions.cpp
@@ -112,28 +112,6 @@ struct GDScriptUtilityFunctionsDefinitions {
*r_ret = String(result);
}
- static inline void str(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
- if (p_arg_count < 1) {
- r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
- r_error.argument = 1;
- r_error.expected = 1;
- *r_ret = Variant();
- return;
- }
-
- String str;
- for (int i = 0; i < p_arg_count; i++) {
- String os = p_args[i]->operator String();
-
- if (i == 0) {
- str = os;
- } else {
- str += os;
- }
- }
- *r_ret = str;
- }
-
static inline void range(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
switch (p_arg_count) {
case 0: {
@@ -651,7 +629,6 @@ void GDScriptUtilityFunctions::register_functions() {
REGISTER_VARIANT_FUNC(convert, true, VARARG("what"), ARG("type", Variant::INT));
REGISTER_FUNC(type_exists, true, Variant::BOOL, ARG("type", Variant::STRING_NAME));
REGISTER_FUNC(_char, true, Variant::STRING, ARG("char", Variant::INT));
- REGISTER_VARARG_FUNC(str, true, Variant::STRING);
REGISTER_VARARG_FUNC(range, false, Variant::ARRAY);
REGISTER_CLASS_FUNC(load, false, "Resource", ARG("path", Variant::STRING));
REGISTER_FUNC(inst_to_dict, false, Variant::DICTIONARY, ARG("instance", Variant::OBJECT));
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
index 8463403096..4610761bdb 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
@@ -7,7 +7,7 @@ namespace Godot
/// <summary>
/// Instantiates the scene's node hierarchy, erroring on failure.
/// Triggers child scene instantiation(s). Triggers a
- /// <see cref="Node.NotificationInstanced"/> notification on the root node.
+ /// <see cref="Node.NotificationSceneInstantiated"/> notification on the root node.
/// </summary>
/// <seealso cref="InstantiateOrNull{T}(GenEditState)"/>
/// <exception cref="InvalidCastException">
@@ -23,7 +23,7 @@ namespace Godot
/// <summary>
/// Instantiates the scene's node hierarchy, returning <see langword="null"/> on failure.
/// Triggers child scene instantiation(s). Triggers a
- /// <see cref="Node.NotificationInstanced"/> notification on the root node.
+ /// <see cref="Node.NotificationSceneInstantiated"/> notification on the root node.
/// </summary>
/// <seealso cref="Instantiate{T}(GenEditState)"/>
/// <typeparam name="T">The type to cast to. Should be a descendant of <see cref="Node"/>.</typeparam>
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 71b8fdb539..49c5501e77 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -50,7 +50,7 @@ void Camera2D::_update_scroll() {
return;
}
- if (current) {
+ if (is_current()) {
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Transform2D xform = get_camera_transform();
@@ -241,10 +241,6 @@ void Camera2D::_notification(int p_what) {
viewport = get_viewport();
}
- if (is_current()) {
- viewport->_camera_2d_set(this);
- }
-
canvas = get_canvas();
RID vp = viewport->get_viewport_rid();
@@ -254,6 +250,10 @@ void Camera2D::_notification(int p_what) {
add_to_group(group_name);
add_to_group(canvas_group_name);
+ if (enabled && !viewport->get_camera_2d()) {
+ make_current();
+ }
+
_update_process_callback();
first = true;
_update_scroll();
@@ -261,11 +261,7 @@ void Camera2D::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
if (is_current()) {
- if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
- viewport->set_canvas_transform(Transform2D());
- clear_current();
- current = true;
- }
+ clear_current();
}
remove_from_group(group_name);
remove_from_group(canvas_group_name);
@@ -397,19 +393,31 @@ void Camera2D::set_process_callback(Camera2DProcessCallback p_mode) {
_update_process_callback();
}
+void Camera2D::set_enabled(bool p_enabled) {
+ enabled = p_enabled;
+
+ if (enabled && is_inside_tree() && !viewport->get_camera_2d()) {
+ make_current();
+ } else if (!enabled && is_current()) {
+ clear_current();
+ }
+}
+
+bool Camera2D::is_enabled() const {
+ return enabled;
+}
+
Camera2D::Camera2DProcessCallback Camera2D::get_process_callback() const {
return process_callback;
}
void Camera2D::_make_current(Object *p_which) {
if (p_which == this) {
- current = true;
if (is_inside_tree()) {
get_viewport()->_camera_2d_set(this);
queue_redraw();
}
} else {
- current = false;
if (is_inside_tree()) {
if (get_viewport()->get_camera_2d() == this) {
get_viewport()->_camera_2d_set(nullptr);
@@ -419,43 +427,32 @@ void Camera2D::_make_current(Object *p_which) {
}
}
-void Camera2D::set_current(bool p_current) {
- if (p_current) {
- make_current();
- } else {
- if (current) {
- clear_current();
- }
- }
-}
-
void Camera2D::_update_process_internal_for_smoothing() {
bool is_not_in_scene_or_editor = !(is_inside_tree() && Engine::get_singleton()->is_editor_hint());
bool is_any_smoothing_valid = position_smoothing_speed > 0 || rotation_smoothing_speed > 0;
- bool enabled = is_any_smoothing_valid && is_not_in_scene_or_editor;
- set_process_internal(enabled);
-}
-
-bool Camera2D::is_current() const {
- return current;
+ bool enable = is_any_smoothing_valid && is_not_in_scene_or_editor;
+ set_process_internal(enable);
}
void Camera2D::make_current() {
- if (is_inside_tree()) {
- get_tree()->call_group(group_name, "_make_current", this);
- } else {
- current = true;
- }
+ ERR_FAIL_COND(!enabled || !is_inside_tree());
+ get_tree()->call_group(group_name, "_make_current", this);
_update_scroll();
}
void Camera2D::clear_current() {
- if (is_inside_tree()) {
- get_tree()->call_group(group_name, "_make_current", (Object *)nullptr);
- } else {
- current = false;
+ ERR_FAIL_COND(!is_current());
+ if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
+ viewport->assign_next_enabled_camera_2d(group_name);
+ }
+}
+
+bool Camera2D::is_current() const {
+ if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
+ return viewport->get_camera_2d() == this;
}
+ return false;
}
void Camera2D::set_limit(Side p_side, int p_limit) {
@@ -715,7 +712,10 @@ void Camera2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_process_callback", "mode"), &Camera2D::set_process_callback);
ClassDB::bind_method(D_METHOD("get_process_callback"), &Camera2D::get_process_callback);
- ClassDB::bind_method(D_METHOD("set_current", "current"), &Camera2D::set_current);
+ ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &Camera2D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"), &Camera2D::is_enabled);
+
+ ClassDB::bind_method(D_METHOD("make_current"), &Camera2D::make_current);
ClassDB::bind_method(D_METHOD("is_current"), &Camera2D::is_current);
ClassDB::bind_method(D_METHOD("_make_current"), &Camera2D::_make_current);
@@ -779,7 +779,7 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset", PROPERTY_HINT_NONE, "suffix:px"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_mode", PROPERTY_HINT_ENUM, "Fixed TopLeft,Drag Center"), "set_anchor_mode", "get_anchor_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_rotation"), "set_ignore_rotation", "is_ignoring_rotation");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), "set_current", "is_current");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "zoom", PROPERTY_HINT_LINK), "set_zoom", "get_zoom");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport");
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_callback", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_callback", "get_process_callback");
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 304b4ceaa6..7a77266db8 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -64,7 +64,7 @@ protected:
Vector2 zoom_scale = Vector2(1, 1);
AnchorMode anchor_mode = ANCHOR_MODE_DRAG_CENTER;
bool ignore_rotation = true;
- bool current = false;
+ bool enabled = true;
real_t position_smoothing_speed = 5.0;
bool follow_smoothing_enabled = false;
@@ -88,7 +88,6 @@ protected:
void _update_scroll();
void _make_current(Object *p_which);
- void set_current(bool p_current);
void _set_old_smoothing(real_t p_enable);
@@ -155,6 +154,9 @@ public:
void set_process_callback(Camera2DProcessCallback p_mode);
Camera2DProcessCallback get_process_callback() const;
+ void set_enabled(bool p_enabled);
+ bool is_enabled() const;
+
void make_current();
void clear_current();
bool is_current() const;
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index e73b6e7e23..380a684c9b 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -108,6 +108,26 @@ void NavigationAgent2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_horizon", PROPERTY_HINT_RANGE, "0.1,10,0.01,suffix:s"), "set_time_horizon", "get_time_horizon");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_speed", PROPERTY_HINT_RANGE, "0.1,10000,0.01,suffix:px/s"), "set_max_speed", "get_max_speed");
+#ifdef DEBUG_ENABLED
+ ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationAgent2D::set_debug_enabled);
+ ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationAgent2D::get_debug_enabled);
+ ClassDB::bind_method(D_METHOD("set_debug_use_custom", "enabled"), &NavigationAgent2D::set_debug_use_custom);
+ ClassDB::bind_method(D_METHOD("get_debug_use_custom"), &NavigationAgent2D::get_debug_use_custom);
+ ClassDB::bind_method(D_METHOD("set_debug_path_custom_color", "color"), &NavigationAgent2D::set_debug_path_custom_color);
+ ClassDB::bind_method(D_METHOD("get_debug_path_custom_color"), &NavigationAgent2D::get_debug_path_custom_color);
+ ClassDB::bind_method(D_METHOD("set_debug_path_custom_point_size", "point_size"), &NavigationAgent2D::set_debug_path_custom_point_size);
+ ClassDB::bind_method(D_METHOD("get_debug_path_custom_point_size"), &NavigationAgent2D::get_debug_path_custom_point_size);
+ ClassDB::bind_method(D_METHOD("set_debug_path_custom_line_width", "line_width"), &NavigationAgent2D::set_debug_path_custom_line_width);
+ ClassDB::bind_method(D_METHOD("get_debug_path_custom_line_width"), &NavigationAgent2D::get_debug_path_custom_line_width);
+
+ ADD_GROUP("Debug", "");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_enabled"), "set_debug_enabled", "get_debug_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_use_custom"), "set_debug_use_custom", "get_debug_use_custom");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "debug_path_custom_line_width", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_line_width", "get_debug_path_custom_line_width");
+#endif // DEBUG_ENABLED
+
ADD_SIGNAL(MethodInfo("path_changed"));
ADD_SIGNAL(MethodInfo("target_reached"));
ADD_SIGNAL(MethodInfo("waypoint_reached", PropertyInfo(Variant::DICTIONARY, "details")));
@@ -123,6 +143,12 @@ void NavigationAgent2D::_notification(int p_what) {
// cannot use READY as ready does not get called if Node is readded to SceneTree
set_agent_parent(get_parent());
set_physics_process_internal(true);
+
+#ifdef DEBUG_ENABLED
+ if (NavigationServer2D::get_singleton()->get_debug_enabled()) {
+ debug_path_dirty = true;
+ }
+#endif // DEBUG_ENABLED
} break;
case NOTIFICATION_PARENTED: {
@@ -165,6 +191,12 @@ void NavigationAgent2D::_notification(int p_what) {
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: {
@@ -176,6 +208,12 @@ void NavigationAgent2D::_notification(int p_what) {
}
_check_distance_to_target();
}
+
+#ifdef DEBUG_ENABLED
+ if (debug_path_dirty) {
+ _update_debug_path();
+ }
+#endif // DEBUG_ENABLED
} break;
}
}
@@ -194,12 +232,25 @@ NavigationAgent2D::NavigationAgent2D() {
navigation_result = Ref<NavigationPathQueryResult2D>();
navigation_result.instantiate();
+
+#ifdef DEBUG_ENABLED
+ NavigationServer2D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent2D::_navigation_debug_changed));
+#endif // DEBUG_ENABLED
}
NavigationAgent2D::~NavigationAgent2D() {
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
NavigationServer2D::get_singleton()->free(agent);
agent = RID(); // Pointless
+
+#ifdef DEBUG_ENABLED
+ NavigationServer2D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent2D::_navigation_debug_changed));
+
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
+ if (debug_path_instance.is_valid()) {
+ RenderingServer::get_singleton()->free(debug_path_instance);
+ }
+#endif // DEBUG_ENABLED
}
void NavigationAgent2D::set_avoidance_enabled(bool p_enabled) {
@@ -463,6 +514,9 @@ void NavigationAgent2D::update_navigation() {
}
NavigationServer2D::get_singleton()->query_path(navigation_query, navigation_result);
+#ifdef DEBUG_ENABLED
+ debug_path_dirty = true;
+#endif // DEBUG_ENABLED
navigation_finished = false;
navigation_path_index = 0;
emit_signal(SNAME("path_changed"));
@@ -549,3 +603,111 @@ void NavigationAgent2D::_check_distance_to_target() {
}
}
}
+
+////////DEBUG////////////////////////////////////////////////////////////
+
+#ifdef DEBUG_ENABLED
+void NavigationAgent2D::set_debug_enabled(bool p_enabled) {
+ debug_enabled = p_enabled;
+ debug_path_dirty = true;
+}
+
+bool NavigationAgent2D::get_debug_enabled() const {
+ return debug_enabled;
+}
+
+void NavigationAgent2D::set_debug_use_custom(bool p_enabled) {
+ debug_use_custom = p_enabled;
+ debug_path_dirty = true;
+}
+
+bool NavigationAgent2D::get_debug_use_custom() const {
+ return debug_use_custom;
+}
+
+void NavigationAgent2D::set_debug_path_custom_color(Color p_color) {
+ debug_path_custom_color = p_color;
+ debug_path_dirty = true;
+}
+
+Color NavigationAgent2D::get_debug_path_custom_color() const {
+ return debug_path_custom_color;
+}
+
+void NavigationAgent2D::set_debug_path_custom_point_size(float p_point_size) {
+ debug_path_custom_point_size = MAX(0.1, p_point_size);
+ debug_path_dirty = true;
+}
+
+float NavigationAgent2D::get_debug_path_custom_point_size() const {
+ return debug_path_custom_point_size;
+}
+
+void NavigationAgent2D::set_debug_path_custom_line_width(float p_line_width) {
+ debug_path_custom_line_width = p_line_width;
+ debug_path_dirty = true;
+}
+
+float NavigationAgent2D::get_debug_path_custom_line_width() const {
+ return debug_path_custom_line_width;
+}
+
+void NavigationAgent2D::_navigation_debug_changed() {
+ debug_path_dirty = true;
+}
+
+void NavigationAgent2D::_update_debug_path() {
+ if (!debug_path_dirty) {
+ return;
+ }
+ debug_path_dirty = false;
+
+ if (!debug_path_instance.is_valid()) {
+ debug_path_instance = RenderingServer::get_singleton()->canvas_item_create();
+ }
+
+ RenderingServer::get_singleton()->canvas_item_clear(debug_path_instance);
+
+ if (!(debug_enabled && NavigationServer2D::get_singleton()->get_debug_navigation_enable_agent_paths())) {
+ return;
+ }
+
+ if (!(agent_parent && agent_parent->is_inside_tree())) {
+ return;
+ }
+
+ RenderingServer::get_singleton()->canvas_item_set_parent(debug_path_instance, agent_parent->get_canvas());
+ RenderingServer::get_singleton()->canvas_item_set_visible(debug_path_instance, agent_parent->is_visible_in_tree());
+
+ const Vector<Vector2> &navigation_path = navigation_result->get_path();
+
+ if (navigation_path.size() <= 1) {
+ return;
+ }
+
+ Color debug_path_color = NavigationServer2D::get_singleton()->get_debug_navigation_agent_path_color();
+ if (debug_use_custom) {
+ debug_path_color = debug_path_custom_color;
+ }
+
+ Vector<Color> debug_path_colors;
+ debug_path_colors.resize(navigation_path.size());
+ debug_path_colors.fill(debug_path_color);
+
+ RenderingServer::get_singleton()->canvas_item_add_polyline(debug_path_instance, navigation_path, debug_path_colors, debug_path_custom_line_width, false);
+
+ float point_size = NavigationServer2D::get_singleton()->get_debug_navigation_agent_path_point_size();
+ float half_point_size = point_size * 0.5;
+
+ if (debug_use_custom) {
+ point_size = debug_path_custom_point_size;
+ half_point_size = debug_path_custom_point_size * 0.5;
+ }
+
+ for (int i = 0; i < navigation_path.size(); i++) {
+ const Vector2 &vert = navigation_path[i];
+ Rect2 path_point_rect = Rect2(vert.x - half_point_size, vert.y - half_point_size, point_size, point_size);
+ RenderingServer::get_singleton()->canvas_item_add_rect(debug_path_instance, path_point_rect, debug_path_color);
+ }
+}
+#endif // DEBUG_ENABLED
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 9787bb1bdb..8f4a373327 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -74,6 +74,20 @@ class NavigationAgent2D : public Node {
// No initialized on purpose
uint32_t update_frame_id = 0;
+#ifdef DEBUG_ENABLED
+ bool debug_enabled = false;
+ bool debug_path_dirty = true;
+ RID debug_path_instance;
+ float debug_path_custom_point_size = 4.0;
+ float debug_path_custom_line_width = 1.0;
+ bool debug_use_custom = false;
+ Color debug_path_custom_color = Color(1.0, 1.0, 1.0, 1.0);
+
+private:
+ void _navigation_debug_changed();
+ void _update_debug_path();
+#endif // DEBUG_ENABLED
+
protected:
static void _bind_methods();
void _notification(int p_what);
@@ -169,6 +183,23 @@ public:
PackedStringArray get_configuration_warnings() const override;
+#ifdef DEBUG_ENABLED
+ void set_debug_enabled(bool p_enabled);
+ bool get_debug_enabled() const;
+
+ void set_debug_use_custom(bool p_enabled);
+ bool get_debug_use_custom() const;
+
+ void set_debug_path_custom_color(Color p_color);
+ Color get_debug_path_custom_color() const;
+
+ void set_debug_path_custom_point_size(float p_point_size);
+ float get_debug_path_custom_point_size() const;
+
+ void set_debug_path_custom_line_width(float p_line_width);
+ float get_debug_path_custom_line_width() const;
+#endif // DEBUG_ENABLED
+
private:
void update_navigation();
void _request_repath();
diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp
index fbcb1c8f2c..e122adcc8c 100644
--- a/scene/3d/decal.cpp
+++ b/scene/3d/decal.cpp
@@ -30,14 +30,14 @@
#include "decal.h"
-void Decal::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- RS::get_singleton()->decal_set_extents(decal, p_extents);
+void Decal::set_size(const Vector3 &p_size) {
+ size = p_size;
+ RS::get_singleton()->decal_set_size(decal, p_size);
update_gizmos();
}
-Vector3 Decal::get_extents() const {
- return extents;
+Vector3 Decal::get_size() const {
+ return size;
}
void Decal::set_texture(DecalTexture p_type, const Ref<Texture2D> &p_texture) {
@@ -147,8 +147,8 @@ uint32_t Decal::get_cull_mask() const {
AABB Decal::get_aabb() const {
AABB aabb;
- aabb.position = -extents;
- aabb.size = extents * 2.0;
+ aabb.position = -size / 2;
+ aabb.size = size;
return aabb;
}
@@ -181,8 +181,8 @@ PackedStringArray Decal::get_configuration_warnings() const {
}
void Decal::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &Decal::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &Decal::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &Decal::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &Decal::get_size);
ClassDB::bind_method(D_METHOD("set_texture", "type", "texture"), &Decal::set_texture);
ClassDB::bind_method(D_METHOD("get_texture", "type"), &Decal::get_texture);
@@ -217,7 +217,7 @@ void Decal::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_cull_mask", "mask"), &Decal::set_cull_mask);
ClassDB::bind_method(D_METHOD("get_cull_mask"), &Decal::get_cull_mask);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0,1024,0.001,or_greater,suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0,1024,0.001,or_greater,suffix:m"), "set_size", "get_size");
ADD_GROUP("Textures", "texture_");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_albedo", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ALBEDO);
@@ -252,6 +252,24 @@ void Decal::_bind_methods() {
BIND_ENUM_CONSTANT(TEXTURE_MAX);
}
+#ifndef DISABLE_DEPRECATED
+bool Decal::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool Decal::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
Decal::Decal() {
decal = RenderingServer::get_singleton()->decal_create();
RS::get_singleton()->instance_set_base(get_instance(), decal);
diff --git a/scene/3d/decal.h b/scene/3d/decal.h
index 5797a2f645..171b52815a 100644
--- a/scene/3d/decal.h
+++ b/scene/3d/decal.h
@@ -47,7 +47,7 @@ public:
private:
RID decal;
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
Ref<Texture2D> textures[TEXTURE_MAX];
real_t emission_energy = 1.0;
real_t albedo_mix = 1.0;
@@ -63,12 +63,16 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
virtual PackedStringArray get_configuration_warnings() const override;
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
void set_texture(DecalTexture p_type, const Ref<Texture2D> &p_texture);
Ref<Texture2D> get_texture(DecalTexture p_type) const;
diff --git a/scene/3d/fog_volume.cpp b/scene/3d/fog_volume.cpp
index 30dfb45836..9b0a7bb302 100644
--- a/scene/3d/fog_volume.cpp
+++ b/scene/3d/fog_volume.cpp
@@ -34,36 +34,54 @@
///////////////////////////
void FogVolume::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &FogVolume::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &FogVolume::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &FogVolume::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &FogVolume::get_size);
ClassDB::bind_method(D_METHOD("set_shape", "shape"), &FogVolume::set_shape);
ClassDB::bind_method(D_METHOD("get_shape"), &FogVolume::get_shape);
ClassDB::bind_method(D_METHOD("set_material", "material"), &FogVolume::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &FogVolume::get_material);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shape", PROPERTY_HINT_ENUM, "Ellipsoid (Local),Cone (Local),Cylinder (Local),Box (Local),World (Global)"), "set_shape", "get_shape");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "FogMaterial,ShaderMaterial"), "set_material", "get_material");
}
void FogVolume::_validate_property(PropertyInfo &p_property) const {
- if (p_property.name == "extents" && shape == RS::FOG_VOLUME_SHAPE_WORLD) {
+ if (p_property.name == "size" && shape == RS::FOG_VOLUME_SHAPE_WORLD) {
p_property.usage = PROPERTY_USAGE_NONE;
return;
}
}
-void FogVolume::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- extents.x = MAX(0.0, extents.x);
- extents.y = MAX(0.0, extents.y);
- extents.z = MAX(0.0, extents.z);
- RS::get_singleton()->fog_volume_set_extents(_get_volume(), extents);
+#ifndef DISABLE_DEPRECATED
+bool FogVolume::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool FogVolume::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
+void FogVolume::set_size(const Vector3 &p_size) {
+ size = p_size;
+ size.x = MAX(0.0, size.x);
+ size.y = MAX(0.0, size.y);
+ size.z = MAX(0.0, size.z);
+ RS::get_singleton()->fog_volume_set_size(_get_volume(), size);
update_gizmos();
}
-Vector3 FogVolume::get_extents() const {
- return extents;
+Vector3 FogVolume::get_size() const {
+ return size;
}
void FogVolume::set_shape(RS::FogVolumeShape p_type) {
@@ -94,7 +112,7 @@ Ref<Material> FogVolume::get_material() const {
AABB FogVolume::get_aabb() const {
if (shape != RS::FOG_VOLUME_SHAPE_WORLD) {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
return AABB();
}
diff --git a/scene/3d/fog_volume.h b/scene/3d/fog_volume.h
index fa02834762..f7e861e3d0 100644
--- a/scene/3d/fog_volume.h
+++ b/scene/3d/fog_volume.h
@@ -40,7 +40,7 @@
class FogVolume : public VisualInstance3D {
GDCLASS(FogVolume, VisualInstance3D);
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
Ref<Material> material;
RS::FogVolumeShape shape = RS::FOG_VOLUME_SHAPE_BOX;
@@ -50,10 +50,14 @@ protected:
_FORCE_INLINE_ RID _get_volume() { return volume; }
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
void set_shape(RS::FogVolumeShape p_type);
RS::FogVolumeShape get_shape() const;
diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp
index d1f2dfb25f..137d578291 100644
--- a/scene/3d/gpu_particles_collision_3d.cpp
+++ b/scene/3d/gpu_particles_collision_3d.cpp
@@ -95,24 +95,42 @@ GPUParticlesCollisionSphere3D::~GPUParticlesCollisionSphere3D() {
///////////////////////////
void GPUParticlesCollisionBox3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionBox3D::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionBox3D::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &GPUParticlesCollisionBox3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &GPUParticlesCollisionBox3D::get_size);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_size", "get_size");
}
-void GPUParticlesCollisionBox3D::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
+#ifndef DISABLE_DEPRECATED
+bool GPUParticlesCollisionBox3D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool GPUParticlesCollisionBox3D::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
+void GPUParticlesCollisionBox3D::set_size(const Vector3 &p_size) {
+ size = p_size;
+ RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), size / 2);
update_gizmos();
}
-Vector3 GPUParticlesCollisionBox3D::get_extents() const {
- return extents;
+Vector3 GPUParticlesCollisionBox3D::get_size() const {
+ return size;
}
AABB GPUParticlesCollisionBox3D::get_aabb() const {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
GPUParticlesCollisionBox3D::GPUParticlesCollisionBox3D() :
@@ -359,7 +377,7 @@ Vector3i GPUParticlesCollisionSDF3D::get_estimated_cell_size() const {
static const int subdivs[RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 };
int subdiv = subdivs[get_resolution()];
- AABB aabb(-extents, extents * 2);
+ AABB aabb(-size / 2, size);
float cell_size = aabb.get_longest_axis_size() / float(subdiv);
@@ -374,7 +392,7 @@ Ref<Image> GPUParticlesCollisionSDF3D::bake() {
static const int subdivs[RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 };
int subdiv = subdivs[get_resolution()];
- AABB aabb(-extents, extents * 2);
+ AABB aabb(-size / 2, size);
float cell_size = aabb.get_longest_axis_size() / float(subdiv);
@@ -515,8 +533,8 @@ PackedStringArray GPUParticlesCollisionSDF3D::get_configuration_warnings() const
}
void GPUParticlesCollisionSDF3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionSDF3D::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionSDF3D::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &GPUParticlesCollisionSDF3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &GPUParticlesCollisionSDF3D::get_size);
ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionSDF3D::set_resolution);
ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionSDF3D::get_resolution);
@@ -532,7 +550,7 @@ void GPUParticlesCollisionSDF3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bake_mask_value", "layer_number", "value"), &GPUParticlesCollisionSDF3D::set_bake_mask_value);
ClassDB::bind_method(D_METHOD("get_bake_mask_value", "layer_number"), &GPUParticlesCollisionSDF3D::get_bake_mask_value);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "resolution", PROPERTY_HINT_ENUM, "16,32,64,128,256,512"), "set_resolution", "get_resolution");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "thickness", PROPERTY_HINT_RANGE, "0.0,2.0,0.01,suffix:m"), "set_thickness", "get_thickness");
ADD_PROPERTY(PropertyInfo(Variant::INT, "bake_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_bake_mask", "get_bake_mask");
@@ -547,6 +565,24 @@ void GPUParticlesCollisionSDF3D::_bind_methods() {
BIND_ENUM_CONSTANT(RESOLUTION_MAX);
}
+#ifndef DISABLE_DEPRECATED
+bool GPUParticlesCollisionSDF3D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool GPUParticlesCollisionSDF3D::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
void GPUParticlesCollisionSDF3D::set_thickness(float p_thickness) {
thickness = p_thickness;
}
@@ -555,14 +591,14 @@ float GPUParticlesCollisionSDF3D::get_thickness() const {
return thickness;
}
-void GPUParticlesCollisionSDF3D::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
+void GPUParticlesCollisionSDF3D::set_size(const Vector3 &p_size) {
+ size = p_size;
+ RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), size / 2);
update_gizmos();
}
-Vector3 GPUParticlesCollisionSDF3D::get_extents() const {
- return extents;
+Vector3 GPUParticlesCollisionSDF3D::get_size() const {
+ return size;
}
void GPUParticlesCollisionSDF3D::set_resolution(Resolution p_resolution) {
@@ -610,7 +646,7 @@ Ref<Texture3D> GPUParticlesCollisionSDF3D::get_texture() const {
}
AABB GPUParticlesCollisionSDF3D::get_aabb() const {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
GPUParticlesCollisionSDF3D::BakeBeginFunc GPUParticlesCollisionSDF3D::bake_begin_function = nullptr;
@@ -675,8 +711,8 @@ void GPUParticlesCollisionHeightField3D::_notification(int p_what) {
}
void GPUParticlesCollisionHeightField3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionHeightField3D::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionHeightField3D::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &GPUParticlesCollisionHeightField3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &GPUParticlesCollisionHeightField3D::get_size);
ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionHeightField3D::set_resolution);
ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionHeightField3D::get_resolution);
@@ -687,7 +723,7 @@ void GPUParticlesCollisionHeightField3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_follow_camera_enabled", "enabled"), &GPUParticlesCollisionHeightField3D::set_follow_camera_enabled);
ClassDB::bind_method(D_METHOD("is_follow_camera_enabled"), &GPUParticlesCollisionHeightField3D::is_follow_camera_enabled);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "resolution", PROPERTY_HINT_ENUM, "256 (Fastest),512 (Fast),1024 (Average),2048 (Slow),4096 (Slower),8192 (Slowest)"), "set_resolution", "get_resolution");
ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "When Moved (Fast),Always (Slow)"), "set_update_mode", "get_update_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_camera_enabled"), "set_follow_camera_enabled", "is_follow_camera_enabled");
@@ -704,15 +740,33 @@ void GPUParticlesCollisionHeightField3D::_bind_methods() {
BIND_ENUM_CONSTANT(UPDATE_MODE_ALWAYS);
}
-void GPUParticlesCollisionHeightField3D::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
+#ifndef DISABLE_DEPRECATED
+bool GPUParticlesCollisionHeightField3D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool GPUParticlesCollisionHeightField3D::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
+void GPUParticlesCollisionHeightField3D::set_size(const Vector3 &p_size) {
+ size = p_size;
+ RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), size / 2);
update_gizmos();
RS::get_singleton()->particles_collision_height_field_update(_get_collision());
}
-Vector3 GPUParticlesCollisionHeightField3D::get_extents() const {
- return extents;
+Vector3 GPUParticlesCollisionHeightField3D::get_size() const {
+ return size;
}
void GPUParticlesCollisionHeightField3D::set_resolution(Resolution p_resolution) {
@@ -745,7 +799,7 @@ bool GPUParticlesCollisionHeightField3D::is_follow_camera_enabled() const {
}
AABB GPUParticlesCollisionHeightField3D::get_aabb() const {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
GPUParticlesCollisionHeightField3D::GPUParticlesCollisionHeightField3D() :
@@ -857,24 +911,42 @@ GPUParticlesAttractorSphere3D::~GPUParticlesAttractorSphere3D() {
///////////////////////////
void GPUParticlesAttractorBox3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorBox3D::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorBox3D::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &GPUParticlesAttractorBox3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &GPUParticlesAttractorBox3D::get_size);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_size", "get_size");
+}
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_extents", "get_extents");
+#ifndef DISABLE_DEPRECATED
+bool GPUParticlesAttractorBox3D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
}
-void GPUParticlesAttractorBox3D::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
+bool GPUParticlesAttractorBox3D::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
+void GPUParticlesAttractorBox3D::set_size(const Vector3 &p_size) {
+ size = p_size;
+ RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), size / 2);
update_gizmos();
}
-Vector3 GPUParticlesAttractorBox3D::get_extents() const {
- return extents;
+Vector3 GPUParticlesAttractorBox3D::get_size() const {
+ return size;
}
AABB GPUParticlesAttractorBox3D::get_aabb() const {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
GPUParticlesAttractorBox3D::GPUParticlesAttractorBox3D() :
@@ -887,24 +959,42 @@ GPUParticlesAttractorBox3D::~GPUParticlesAttractorBox3D() {
///////////////////////////
void GPUParticlesAttractorVectorField3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorVectorField3D::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorVectorField3D::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &GPUParticlesAttractorVectorField3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &GPUParticlesAttractorVectorField3D::get_size);
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesAttractorVectorField3D::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesAttractorVectorField3D::get_texture);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture3D"), "set_texture", "get_texture");
}
-void GPUParticlesAttractorVectorField3D::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
- RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
+#ifndef DISABLE_DEPRECATED
+bool GPUParticlesAttractorVectorField3D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool GPUParticlesAttractorVectorField3D::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
+void GPUParticlesAttractorVectorField3D::set_size(const Vector3 &p_size) {
+ size = p_size;
+ RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), size / 2);
update_gizmos();
}
-Vector3 GPUParticlesAttractorVectorField3D::get_extents() const {
- return extents;
+Vector3 GPUParticlesAttractorVectorField3D::get_size() const {
+ return size;
}
void GPUParticlesAttractorVectorField3D::set_texture(const Ref<Texture3D> &p_texture) {
@@ -918,7 +1008,7 @@ Ref<Texture3D> GPUParticlesAttractorVectorField3D::get_texture() const {
}
AABB GPUParticlesAttractorVectorField3D::get_aabb() const {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
GPUParticlesAttractorVectorField3D::GPUParticlesAttractorVectorField3D() :
diff --git a/scene/3d/gpu_particles_collision_3d.h b/scene/3d/gpu_particles_collision_3d.h
index 3c569ac73d..1649320069 100644
--- a/scene/3d/gpu_particles_collision_3d.h
+++ b/scene/3d/gpu_particles_collision_3d.h
@@ -74,14 +74,18 @@ public:
class GPUParticlesCollisionBox3D : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionBox3D, GPUParticlesCollision3D);
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
virtual AABB get_aabb() const override;
@@ -108,7 +112,7 @@ public:
typedef void (*BakeEndFunc)();
private:
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
Resolution resolution = RESOLUTION_64;
uint32_t bake_mask = 0xFFFFFFFF;
Ref<Texture3D> texture;
@@ -160,6 +164,10 @@ private:
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
virtual PackedStringArray get_configuration_warnings() const override;
@@ -167,8 +175,8 @@ public:
void set_thickness(float p_thickness);
float get_thickness() const;
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
void set_resolution(Resolution p_resolution);
Resolution get_resolution() const;
@@ -217,7 +225,7 @@ public:
};
private:
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
Resolution resolution = RESOLUTION_1024;
bool follow_camera_mode = false;
@@ -226,10 +234,14 @@ private:
protected:
void _notification(int p_what);
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
void set_resolution(Resolution p_resolution);
Resolution get_resolution() const;
@@ -301,14 +313,18 @@ public:
class GPUParticlesAttractorBox3D : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorBox3D, GPUParticlesAttractor3D);
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
virtual AABB get_aabb() const override;
@@ -319,15 +335,19 @@ public:
class GPUParticlesAttractorVectorField3D : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorVectorField3D, GPUParticlesAttractor3D);
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
Ref<Texture3D> texture;
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
void set_texture(const Ref<Texture3D> &p_texture);
Ref<Texture3D> get_texture() const;
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index 4aa6e61ec5..5db8611d72 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -120,6 +120,23 @@ void NavigationAgent3D::_bind_methods() {
ADD_SIGNAL(MethodInfo("link_reached", PropertyInfo(Variant::DICTIONARY, "details")));
ADD_SIGNAL(MethodInfo("navigation_finished"));
ADD_SIGNAL(MethodInfo("velocity_computed", PropertyInfo(Variant::VECTOR3, "safe_velocity")));
+
+#ifdef DEBUG_ENABLED
+ ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationAgent3D::set_debug_enabled);
+ ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationAgent3D::get_debug_enabled);
+ ClassDB::bind_method(D_METHOD("set_debug_use_custom", "enabled"), &NavigationAgent3D::set_debug_use_custom);
+ ClassDB::bind_method(D_METHOD("get_debug_use_custom"), &NavigationAgent3D::get_debug_use_custom);
+ ClassDB::bind_method(D_METHOD("set_debug_path_custom_color", "color"), &NavigationAgent3D::set_debug_path_custom_color);
+ ClassDB::bind_method(D_METHOD("get_debug_path_custom_color"), &NavigationAgent3D::get_debug_path_custom_color);
+ ClassDB::bind_method(D_METHOD("set_debug_path_custom_point_size", "point_size"), &NavigationAgent3D::set_debug_path_custom_point_size);
+ ClassDB::bind_method(D_METHOD("get_debug_path_custom_point_size"), &NavigationAgent3D::get_debug_path_custom_point_size);
+
+ ADD_GROUP("Debug", "");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_enabled"), "set_debug_enabled", "get_debug_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_use_custom"), "set_debug_use_custom", "get_debug_use_custom");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size");
+#endif // DEBUG_ENABLED
}
void NavigationAgent3D::_notification(int p_what) {
@@ -129,6 +146,12 @@ void NavigationAgent3D::_notification(int p_what) {
// cannot use READY as ready does not get called if Node is readded to SceneTree
set_agent_parent(get_parent());
set_physics_process_internal(true);
+
+#ifdef DEBUG_ENABLED
+ if (NavigationServer3D::get_singleton()->get_debug_enabled()) {
+ debug_path_dirty = true;
+ }
+#endif // DEBUG_ENABLED
} break;
case NOTIFICATION_PARENTED: {
@@ -151,6 +174,12 @@ void NavigationAgent3D::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
set_agent_parent(nullptr);
set_physics_process_internal(false);
+
+#ifdef DEBUG_ENABLED
+ if (debug_path_instance.is_valid()) {
+ RS::get_singleton()->instance_set_visible(debug_path_instance, false);
+ }
+#endif // DEBUG_ENABLED
} break;
case NOTIFICATION_PAUSED: {
@@ -182,6 +211,11 @@ void NavigationAgent3D::_notification(int p_what) {
}
_check_distance_to_target();
}
+#ifdef DEBUG_ENABLED
+ if (debug_path_dirty) {
+ _update_debug_path();
+ }
+#endif // DEBUG_ENABLED
} break;
}
}
@@ -201,12 +235,28 @@ NavigationAgent3D::NavigationAgent3D() {
navigation_result = Ref<NavigationPathQueryResult3D>();
navigation_result.instantiate();
+
+#ifdef DEBUG_ENABLED
+ NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent3D::_navigation_debug_changed));
+#endif // DEBUG_ENABLED
}
NavigationAgent3D::~NavigationAgent3D() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
NavigationServer3D::get_singleton()->free(agent);
agent = RID(); // Pointless
+
+#ifdef DEBUG_ENABLED
+ NavigationServer3D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent3D::_navigation_debug_changed));
+
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
+ if (debug_path_instance.is_valid()) {
+ RenderingServer::get_singleton()->free(debug_path_instance);
+ }
+ if (debug_path_mesh.is_valid()) {
+ RenderingServer::get_singleton()->free(debug_path_mesh->get_rid());
+ }
+#endif // DEBUG_ENABLED
}
void NavigationAgent3D::set_avoidance_enabled(bool p_enabled) {
@@ -480,6 +530,9 @@ void NavigationAgent3D::update_navigation() {
}
NavigationServer3D::get_singleton()->query_path(navigation_query, navigation_result);
+#ifdef DEBUG_ENABLED
+ debug_path_dirty = true;
+#endif // DEBUG_ENABLED
navigation_finished = false;
navigation_path_index = 0;
emit_signal(SNAME("path_changed"));
@@ -566,3 +619,130 @@ void NavigationAgent3D::_check_distance_to_target() {
}
}
}
+
+////////DEBUG////////////////////////////////////////////////////////////
+
+#ifdef DEBUG_ENABLED
+void NavigationAgent3D::set_debug_enabled(bool p_enabled) {
+ debug_enabled = p_enabled;
+ debug_path_dirty = true;
+}
+
+bool NavigationAgent3D::get_debug_enabled() const {
+ return debug_enabled;
+}
+
+void NavigationAgent3D::set_debug_use_custom(bool p_enabled) {
+ debug_use_custom = p_enabled;
+ debug_path_dirty = true;
+}
+
+bool NavigationAgent3D::get_debug_use_custom() const {
+ return debug_use_custom;
+}
+
+void NavigationAgent3D::set_debug_path_custom_color(Color p_color) {
+ debug_path_custom_color = p_color;
+ debug_path_dirty = true;
+}
+
+Color NavigationAgent3D::get_debug_path_custom_color() const {
+ return debug_path_custom_color;
+}
+
+void NavigationAgent3D::set_debug_path_custom_point_size(float p_point_size) {
+ debug_path_custom_point_size = p_point_size;
+ debug_path_dirty = true;
+}
+
+float NavigationAgent3D::get_debug_path_custom_point_size() const {
+ return debug_path_custom_point_size;
+}
+
+void NavigationAgent3D::_navigation_debug_changed() {
+ debug_path_dirty = true;
+}
+
+void NavigationAgent3D::_update_debug_path() {
+ if (!debug_path_dirty) {
+ return;
+ }
+ debug_path_dirty = false;
+
+ if (!debug_path_instance.is_valid()) {
+ debug_path_instance = RenderingServer::get_singleton()->instance_create();
+ }
+
+ if (!debug_path_mesh.is_valid()) {
+ debug_path_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ }
+
+ debug_path_mesh->clear_surfaces();
+
+ if (!(debug_enabled && NavigationServer3D::get_singleton()->get_debug_navigation_enable_agent_paths())) {
+ return;
+ }
+
+ if (!(agent_parent && agent_parent->is_inside_tree())) {
+ return;
+ }
+
+ const Vector<Vector3> &navigation_path = navigation_result->get_path();
+
+ if (navigation_path.size() <= 1) {
+ return;
+ }
+
+ Vector<Vector3> debug_path_lines_vertex_array;
+
+ for (int i = 0; i < navigation_path.size() - 1; i++) {
+ debug_path_lines_vertex_array.push_back(navigation_path[i]);
+ debug_path_lines_vertex_array.push_back(navigation_path[i + 1]);
+ }
+
+ Array debug_path_lines_mesh_array;
+ debug_path_lines_mesh_array.resize(Mesh::ARRAY_MAX);
+ debug_path_lines_mesh_array[Mesh::ARRAY_VERTEX] = debug_path_lines_vertex_array;
+
+ debug_path_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, debug_path_lines_mesh_array);
+
+ Ref<StandardMaterial3D> debug_agent_path_line_material = NavigationServer3D::get_singleton()->get_debug_navigation_agent_path_line_material();
+ if (debug_use_custom) {
+ if (!debug_agent_path_line_custom_material.is_valid()) {
+ debug_agent_path_line_custom_material = debug_agent_path_line_material->duplicate();
+ }
+ debug_agent_path_line_custom_material->set_albedo(debug_path_custom_color);
+ debug_path_mesh->surface_set_material(0, debug_agent_path_line_custom_material);
+ } else {
+ debug_path_mesh->surface_set_material(0, debug_agent_path_line_material);
+ }
+
+ Vector<Vector3> debug_path_points_vertex_array;
+
+ for (int i = 0; i < navigation_path.size(); i++) {
+ debug_path_points_vertex_array.push_back(navigation_path[i]);
+ }
+
+ Array debug_path_points_mesh_array;
+ debug_path_points_mesh_array.resize(Mesh::ARRAY_MAX);
+ debug_path_points_mesh_array[Mesh::ARRAY_VERTEX] = debug_path_lines_vertex_array;
+
+ debug_path_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, debug_path_points_mesh_array);
+
+ Ref<StandardMaterial3D> debug_agent_path_point_material = NavigationServer3D::get_singleton()->get_debug_navigation_agent_path_point_material();
+ if (debug_use_custom) {
+ if (!debug_agent_path_point_custom_material.is_valid()) {
+ debug_agent_path_point_custom_material = debug_agent_path_point_material->duplicate();
+ }
+ debug_agent_path_point_custom_material->set_albedo(debug_path_custom_color);
+ debug_agent_path_point_custom_material->set_point_size(debug_path_custom_point_size);
+ debug_path_mesh->surface_set_material(1, debug_agent_path_point_custom_material);
+ } else {
+ debug_path_mesh->surface_set_material(1, debug_agent_path_point_material);
+ }
+
+ RS::get_singleton()->instance_set_base(debug_path_instance, debug_path_mesh->get_rid());
+ RS::get_singleton()->instance_set_scenario(debug_path_instance, agent_parent->get_world_3d()->get_scenario());
+ RS::get_singleton()->instance_set_visible(debug_path_instance, agent_parent->is_visible_in_tree());
+}
+#endif // DEBUG_ENABLED
diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h
index 12f83ce6a8..98bf395d7c 100644
--- a/scene/3d/navigation_agent_3d.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -76,6 +76,22 @@ class NavigationAgent3D : public Node {
// No initialized on purpose
uint32_t update_frame_id = 0;
+#ifdef DEBUG_ENABLED
+ bool debug_enabled = false;
+ bool debug_path_dirty = true;
+ RID debug_path_instance;
+ Ref<ArrayMesh> debug_path_mesh;
+ float debug_path_custom_point_size = 4.0;
+ bool debug_use_custom = false;
+ Color debug_path_custom_color = Color(1.0, 1.0, 1.0, 1.0);
+ Ref<StandardMaterial3D> debug_agent_path_line_custom_material;
+ Ref<StandardMaterial3D> debug_agent_path_point_custom_material;
+
+private:
+ void _navigation_debug_changed();
+ void _update_debug_path();
+#endif // DEBUG_ENABLED
+
protected:
static void _bind_methods();
void _notification(int p_what);
@@ -181,6 +197,20 @@ public:
PackedStringArray get_configuration_warnings() const override;
+#ifdef DEBUG_ENABLED
+ void set_debug_enabled(bool p_enabled);
+ bool get_debug_enabled() const;
+
+ void set_debug_use_custom(bool p_enabled);
+ bool get_debug_use_custom() const;
+
+ void set_debug_path_custom_color(Color p_color);
+ Color get_debug_path_custom_color() const;
+
+ void set_debug_path_custom_point_size(float p_point_size);
+ float get_debug_path_custom_point_size() const;
+#endif // DEBUG_ENABLED
+
private:
void update_navigation();
void _request_repath();
diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp
index 632b27953f..594580a205 100644
--- a/scene/3d/occluder_instance_3d.cpp
+++ b/scene/3d/occluder_instance_3d.cpp
@@ -542,13 +542,14 @@ void OccluderInstance3D::_bake_surface(const Transform3D &p_transform, Array p_s
float error = -1.0f;
int target_index_count = MIN(indices.size(), 36);
+ const int simplify_options = SurfaceTool::SIMPLIFY_LOCK_BORDER;
+
uint32_t index_count = SurfaceTool::simplify_func(
(unsigned int *)indices.ptrw(),
(unsigned int *)indices.ptr(),
indices.size(),
vertices_f32.ptr(), vertices.size(), sizeof(float) * 3,
- target_index_count, target_error, &error);
-
+ target_index_count, target_error, simplify_options, &error);
indices.resize(index_count);
}
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index f4ab09cd9b..c8cfcf7d7a 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -333,6 +333,11 @@ void AnimatableBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
}
void AnimatableBody3D::_notification(int p_what) {
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ return;
+ }
+#endif
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
last_valid_transform = get_global_transform();
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 606f6140cb..62202c0b1b 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -85,38 +85,40 @@ float ReflectionProbe::get_mesh_lod_threshold() const {
return mesh_lod_threshold;
}
-void ReflectionProbe::set_extents(const Vector3 &p_extents) {
- extents = p_extents;
+void ReflectionProbe::set_size(const Vector3 &p_size) {
+ size = p_size;
for (int i = 0; i < 3; i++) {
- if (extents[i] < 0.01) {
- extents[i] = 0.01;
+ float half_size = size[i] / 2;
+ if (half_size < 0.01) {
+ half_size = 0.01;
}
- if (extents[i] - 0.01 < ABS(origin_offset[i])) {
- origin_offset[i] = SIGN(origin_offset[i]) * (extents[i] - 0.01);
+ if (half_size - 0.01 < ABS(origin_offset[i])) {
+ origin_offset[i] = SIGN(origin_offset[i]) * (half_size - 0.01);
}
}
- RS::get_singleton()->reflection_probe_set_extents(probe, extents);
+ RS::get_singleton()->reflection_probe_set_size(probe, size);
RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
update_gizmos();
}
-Vector3 ReflectionProbe::get_extents() const {
- return extents;
+Vector3 ReflectionProbe::get_size() const {
+ return size;
}
-void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) {
- origin_offset = p_extents;
+void ReflectionProbe::set_origin_offset(const Vector3 &p_offset) {
+ origin_offset = p_offset;
for (int i = 0; i < 3; i++) {
- if (extents[i] - 0.01 < ABS(origin_offset[i])) {
- origin_offset[i] = SIGN(origin_offset[i]) * (extents[i] - 0.01);
+ float half_size = size[i] / 2;
+ if (half_size - 0.01 < ABS(origin_offset[i])) {
+ origin_offset[i] = SIGN(origin_offset[i]) * (half_size - 0.01);
}
}
- RS::get_singleton()->reflection_probe_set_extents(probe, extents);
+ RS::get_singleton()->reflection_probe_set_size(probe, size);
RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
update_gizmos();
@@ -174,7 +176,7 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
AABB ReflectionProbe::get_aabb() const {
AABB aabb;
aabb.position = -origin_offset;
- aabb.size = origin_offset + extents;
+ aabb.size = origin_offset + size / 2;
return aabb;
}
@@ -205,8 +207,8 @@ void ReflectionProbe::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mesh_lod_threshold", "ratio"), &ReflectionProbe::set_mesh_lod_threshold);
ClassDB::bind_method(D_METHOD("get_mesh_lod_threshold"), &ReflectionProbe::get_mesh_lod_threshold);
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &ReflectionProbe::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &ReflectionProbe::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &ReflectionProbe::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &ReflectionProbe::get_size);
ClassDB::bind_method(D_METHOD("set_origin_offset", "origin_offset"), &ReflectionProbe::set_origin_offset);
ClassDB::bind_method(D_METHOD("get_origin_offset"), &ReflectionProbe::get_origin_offset);
@@ -229,7 +231,7 @@ void ReflectionProbe::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "Once (Fast),Always (Slow)"), "set_update_mode", "get_update_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_intensity", "get_intensity");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_distance", PROPERTY_HINT_RANGE, "0,16384,0.1,or_greater,exp,suffix:m"), "set_max_distance", "get_max_distance");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_NONE, "suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_NONE, "suffix:m"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "origin_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_origin_offset", "get_origin_offset");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "box_projection"), "set_enable_box_projection", "is_box_projection_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_as_interior", "is_set_as_interior");
@@ -250,6 +252,24 @@ void ReflectionProbe::_bind_methods() {
BIND_ENUM_CONSTANT(AMBIENT_COLOR);
}
+#ifndef DISABLE_DEPRECATED
+bool ReflectionProbe::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool ReflectionProbe::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
ReflectionProbe::ReflectionProbe() {
probe = RenderingServer::get_singleton()->reflection_probe_create();
RS::get_singleton()->instance_set_base(get_instance(), probe);
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index cb417c3eea..738277ad39 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -52,7 +52,7 @@ private:
RID probe;
float intensity = 1.0;
float max_distance = 0.0;
- Vector3 extents = Vector3(10, 10, 10);
+ Vector3 size = Vector3(20, 20, 20);
Vector3 origin_offset = Vector3(0, 0, 0);
bool box_projection = false;
bool enable_shadows = false;
@@ -68,6 +68,10 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
void set_intensity(float p_intensity);
@@ -91,10 +95,10 @@ public:
void set_mesh_lod_threshold(float p_pixels);
float get_mesh_lod_threshold() const;
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
- void set_origin_offset(const Vector3 &p_extents);
+ void set_origin_offset(const Vector3 &p_offset);
Vector3 get_origin_offset() const;
void set_as_interior(bool p_enable);
diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp
index 41dc27352f..36a877246e 100644
--- a/scene/3d/voxel_gi.cpp
+++ b/scene/3d/voxel_gi.cpp
@@ -237,6 +237,24 @@ void VoxelGIData::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior");
}
+#ifndef DISABLE_DEPRECATED
+bool VoxelGI::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ set_size((Vector3)p_value * 2);
+ return true;
+ }
+ return false;
+}
+
+bool VoxelGI::_get(const StringName &p_name, Variant &r_property) const {
+ if (p_name == "extents") { // Compatibility with Godot 3.x.
+ r_property = size / 2;
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
VoxelGIData::VoxelGIData() {
probe = RS::get_singleton()->voxel_gi_create();
}
@@ -273,14 +291,14 @@ VoxelGI::Subdiv VoxelGI::get_subdiv() const {
return subdiv;
}
-void VoxelGI::set_extents(const Vector3 &p_extents) {
- // Prevent very small extents as these break baking if other extents are set very high.
- extents = Vector3(MAX(1.0, p_extents.x), MAX(1.0, p_extents.y), MAX(1.0, p_extents.z));
+void VoxelGI::set_size(const Vector3 &p_size) {
+ // Prevent very small size dimensions as these breaks baking if other size dimensions are set very high.
+ size = Vector3(MAX(1.0, p_size.x), MAX(1.0, p_size.y), MAX(1.0, p_size.z));
update_gizmos();
}
-Vector3 VoxelGI::get_extents() const {
- return extents;
+Vector3 VoxelGI::get_size() const {
+ return size;
}
void VoxelGI::set_camera_attributes(const Ref<CameraAttributes> &p_camera_attributes) {
@@ -300,7 +318,7 @@ void VoxelGI::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
Transform3D xf = get_global_transform().affine_inverse() * mi->get_global_transform();
- if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ if (AABB(-size / 2, size).intersects(xf.xform(aabb))) {
PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
@@ -328,7 +346,7 @@ void VoxelGI::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
Transform3D xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
- if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ if (AABB(-size / 2, size).intersects(xf.xform(aabb))) {
PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
@@ -352,7 +370,7 @@ Vector3i VoxelGI::get_estimated_cell_size() const {
static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 };
int cell_subdiv = subdiv_value[subdiv];
int axis_cell_size[3];
- AABB bounds = AABB(-extents, extents * 2.0);
+ AABB bounds = AABB(-size / 2, size);
int longest_axis = bounds.get_longest_axis_index();
axis_cell_size[longest_axis] = 1 << cell_subdiv;
@@ -390,7 +408,7 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) {
Voxelizer baker;
- baker.begin_bake(subdiv_value[subdiv], AABB(-extents, extents * 2.0), exposure_normalization);
+ baker.begin_bake(subdiv_value[subdiv], AABB(-size / 2, size), exposure_normalization);
List<PlotMesh> mesh_list;
@@ -448,7 +466,7 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) {
RS::get_singleton()->voxel_gi_set_baked_exposure_normalization(probe_data_new->get_rid(), exposure_normalization);
- probe_data_new->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_voxel_gi_octree_size(), baker.get_voxel_gi_octree_cells(), baker.get_voxel_gi_data_cells(), df, baker.get_voxel_gi_level_cell_count());
+ probe_data_new->allocate(baker.get_to_cell_space_xform(), AABB(-size / 2, size), baker.get_voxel_gi_octree_size(), baker.get_voxel_gi_octree_cells(), baker.get_voxel_gi_data_cells(), df, baker.get_voxel_gi_level_cell_count());
set_probe_data(probe_data_new);
#ifdef TOOLS_ENABLED
@@ -468,7 +486,7 @@ void VoxelGI::_debug_bake() {
}
AABB VoxelGI::get_aabb() const {
- return AABB(-extents, extents * 2);
+ return AABB(-size / 2, size);
}
PackedStringArray VoxelGI::get_configuration_warnings() const {
@@ -489,8 +507,8 @@ void VoxelGI::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_subdiv", "subdiv"), &VoxelGI::set_subdiv);
ClassDB::bind_method(D_METHOD("get_subdiv"), &VoxelGI::get_subdiv);
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &VoxelGI::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &VoxelGI::get_extents);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &VoxelGI::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &VoxelGI::get_size);
ClassDB::bind_method(D_METHOD("set_camera_attributes", "camera_attributes"), &VoxelGI::set_camera_attributes);
ClassDB::bind_method(D_METHOD("get_camera_attributes"), &VoxelGI::get_camera_attributes);
@@ -500,7 +518,7 @@ void VoxelGI::_bind_methods() {
ClassDB::set_method_flags(get_class_static(), _scs_create("debug_bake"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdiv", PROPERTY_HINT_ENUM, "64,128,256,512"), "set_subdiv", "get_subdiv");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_NONE, "suffix:m"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_NONE, "suffix:m"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_attributes", PROPERTY_HINT_RESOURCE_TYPE, "CameraAttributesPractical,CameraAttributesPhysical"), "set_camera_attributes", "get_camera_attributes");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "VoxelGIData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_ALWAYS_DUPLICATE), "set_probe_data", "get_probe_data");
diff --git a/scene/3d/voxel_gi.h b/scene/3d/voxel_gi.h
index ae348daf9e..d276186dd1 100644
--- a/scene/3d/voxel_gi.h
+++ b/scene/3d/voxel_gi.h
@@ -118,7 +118,7 @@ private:
RID voxel_gi;
Subdiv subdiv = SUBDIV_128;
- Vector3 extents = Vector3(10, 10, 10);
+ Vector3 size = Vector3(20, 20, 20);
Ref<CameraAttributes> camera_attributes;
struct PlotMesh {
@@ -133,6 +133,10 @@ private:
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_property) const;
+#endif // DISABLE_DEPRECATED
public:
static BakeBeginFunc bake_begin_function;
@@ -145,8 +149,8 @@ public:
void set_subdiv(Subdiv p_subdiv);
Subdiv get_subdiv() const;
- void set_extents(const Vector3 &p_extents);
- Vector3 get_extents() const;
+ void set_size(const Vector3 &p_size);
+ Vector3 get_size() const;
void set_camera_attributes(const Ref<CameraAttributes> &p_camera_attributes);
Ref<CameraAttributes> get_camera_attributes() const;
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 45f4f690b9..797999625b 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -800,6 +800,14 @@ Ref<Curve> AnimationNodeTransition::get_xfade_curve() const {
return xfade_curve;
}
+void AnimationNodeTransition::set_allow_transition_to_self(bool p_enable) {
+ allow_transition_to_self = p_enable;
+}
+
+bool AnimationNodeTransition::is_allow_transition_to_self() const {
+ return allow_transition_to_self;
+}
+
double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_external_seeking) {
String cur_transition_request = get_parameter(transition_request);
int cur_current_index = get_parameter(current_index);
@@ -815,20 +823,22 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
int new_idx = find_input(cur_transition_request);
if (new_idx >= 0) {
if (cur_current_index == new_idx) {
- // Transition to same state.
- restart = input_data[cur_current_index].reset;
- cur_prev_xfading = 0;
- set_parameter(prev_xfading, 0);
- cur_prev_index = -1;
- set_parameter(prev_index, -1);
+ if (allow_transition_to_self) {
+ // Transition to same state.
+ restart = input_data[cur_current_index].reset;
+ cur_prev_xfading = 0;
+ set_parameter(prev_xfading, 0);
+ cur_prev_index = -1;
+ set_parameter(prev_index, -1);
+ }
} else {
switched = true;
cur_prev_index = cur_current_index;
set_parameter(prev_index, cur_current_index);
+ cur_current_index = new_idx;
+ set_parameter(current_index, cur_current_index);
+ set_parameter(current_state, cur_transition_request);
}
- cur_current_index = new_idx;
- set_parameter(current_index, cur_current_index);
- set_parameter(current_state, cur_transition_request);
} else {
ERR_PRINT("No such input: '" + cur_transition_request + "'");
}
@@ -932,8 +942,12 @@ void AnimationNodeTransition::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_xfade_curve", "curve"), &AnimationNodeTransition::set_xfade_curve);
ClassDB::bind_method(D_METHOD("get_xfade_curve"), &AnimationNodeTransition::get_xfade_curve);
+ ClassDB::bind_method(D_METHOD("set_allow_transition_to_self", "enable"), &AnimationNodeTransition::set_allow_transition_to_self);
+ ClassDB::bind_method(D_METHOD("is_allow_transition_to_self"), &AnimationNodeTransition::is_allow_transition_to_self);
+
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "xfade_time", PROPERTY_HINT_RANGE, "0,120,0.01,suffix:s"), "set_xfade_time", "get_xfade_time");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "xfade_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_xfade_curve", "get_xfade_curve");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_transition_to_self"), "set_allow_transition_to_self", "is_allow_transition_to_self");
ADD_PROPERTY(PropertyInfo(Variant::INT, "input_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ARRAY | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED, "Inputs,input_"), "set_input_count", "get_input_count");
}
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 3c27edbf70..20f8e9b190 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -294,6 +294,7 @@ class AnimationNodeTransition : public AnimationNodeSync {
double xfade_time = 0.0;
Ref<Curve> xfade_curve;
+ bool allow_transition_to_self = false;
protected:
bool _get(const StringName &p_path, Variant &r_ret) const;
@@ -325,6 +326,9 @@ public:
void set_xfade_curve(const Ref<Curve> &p_curve);
Ref<Curve> get_xfade_curve() const;
+ void set_allow_transition_to_self(bool p_enable);
+ bool is_allow_transition_to_self() const;
+
double process(double p_time, bool p_seek, bool p_is_external_seeking) override;
AnimationNodeTransition();
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index 7fb831b3b2..ec28a5cca1 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -252,7 +252,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
path.clear(); //a new one will be needed
if (current == p_travel) {
- return false; // Will teleport oneself (restart).
+ return !p_state_machine->is_allow_transition_to_self();
}
Vector2 current_pos = p_state_machine->states[current].position;
@@ -813,6 +813,14 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), CONNECT_REFERENCE_COUNTED);
}
+void AnimationNodeStateMachine::set_allow_transition_to_self(bool p_enable) {
+ allow_transition_to_self = p_enable;
+}
+
+bool AnimationNodeStateMachine::is_allow_transition_to_self() const {
+ return allow_transition_to_self;
+}
+
bool AnimationNodeStateMachine::can_edit_node(const StringName &p_name) const {
if (states.has(p_name)) {
return !(states[p_name].node->is_class("AnimationNodeStartState") || states[p_name].node->is_class("AnimationNodeEndState"));
@@ -1383,6 +1391,11 @@ void AnimationNodeStateMachine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_graph_offset", "offset"), &AnimationNodeStateMachine::set_graph_offset);
ClassDB::bind_method(D_METHOD("get_graph_offset"), &AnimationNodeStateMachine::get_graph_offset);
+
+ ClassDB::bind_method(D_METHOD("set_allow_transition_to_self", "enable"), &AnimationNodeStateMachine::set_allow_transition_to_self);
+ ClassDB::bind_method(D_METHOD("is_allow_transition_to_self"), &AnimationNodeStateMachine::is_allow_transition_to_self);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_transition_to_self"), "set_allow_transition_to_self", "is_allow_transition_to_self");
}
AnimationNodeStateMachine::AnimationNodeStateMachine() {
diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h
index cf4d850aa6..5c2a4d6264 100644
--- a/scene/animation/animation_node_state_machine.h
+++ b/scene/animation/animation_node_state_machine.h
@@ -188,6 +188,7 @@ private:
};
HashMap<StringName, State> states;
+ bool allow_transition_to_self = false;
struct Transition {
StringName from;
@@ -254,6 +255,9 @@ public:
void remove_transition_by_index(const int p_transition);
void remove_transition(const StringName &p_from, const StringName &p_to);
+ void set_allow_transition_to_self(bool p_enable);
+ bool is_allow_transition_to_self() const;
+
bool can_edit_node(const StringName &p_name) const;
AnimationNodeStateMachine *get_prev_state_machine() const;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index dc23bcb14a..fe2eed6755 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -264,10 +264,6 @@ void GraphEdit::_scroll_moved(double) {
top_layer->queue_redraw();
minimap->queue_redraw();
queue_redraw();
-
- if (!setting_scroll_ofs) { //in godot, signals on change value are avoided as a convention
- emit_signal(SNAME("scroll_offset_changed"), get_scroll_ofs());
- }
}
void GraphEdit::_update_scroll_offset() {
@@ -290,6 +286,10 @@ void GraphEdit::_update_scroll_offset() {
connections_layer->set_position(-Point2(h_scroll->get_value(), v_scroll->get_value()));
set_block_minimum_size_adjust(false);
awaiting_scroll_offset_update = false;
+
+ if (!setting_scroll_ofs) { //in godot, signals on change value are avoided as a convention
+ emit_signal(SNAME("scroll_offset_changed"), get_scroll_ofs());
+ }
}
void GraphEdit::_update_scroll() {
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp
index 7c1d2f95a9..f10e1c2cd1 100644
--- a/scene/gui/subviewport_container.cpp
+++ b/scene/gui/subviewport_container.cpp
@@ -85,7 +85,7 @@ void SubViewportContainer::set_stretch_shrink(int p_shrink) {
continue;
}
- c->set_size(get_size() / shrink);
+ c->set_size_force(get_size() / shrink);
}
queue_redraw();
@@ -116,7 +116,7 @@ void SubViewportContainer::_notification(int p_what) {
continue;
}
- c->set_size(get_size() / shrink);
+ c->set_size_force(get_size() / shrink);
}
} break;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 64bd3fe2c1..fe82fed2f7 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1045,6 +1045,25 @@ Transform2D Viewport::get_final_transform() const {
return _get_input_pre_xform().affine_inverse() * stretch_transform * global_canvas_transform;
}
+void Viewport::assign_next_enabled_camera_2d(const StringName &p_camera_group) {
+ List<Node *> camera_list;
+ 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);
+ if (cam->is_enabled()) {
+ new_camera = const_cast<Camera2D *>(cam);
+ break;
+ }
+ }
+
+ _camera_2d_set(new_camera);
+ if (!camera_2d) {
+ set_canvas_transform(Transform2D());
+ }
+}
+
void Viewport::_update_canvas_items(Node *p_node) {
if (p_node != this) {
Window *w = Object::cast_to<Window>(p_node);
@@ -4095,9 +4114,26 @@ Viewport::~Viewport() {
/////////////////////////////////
void SubViewport::set_size(const Size2i &p_size) {
- _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
+ _internal_set_size(p_size);
+}
+void SubViewport::set_size_force(const Size2i &p_size) {
+ // Use only for setting the size from the parent SubViewportContainer with enabled stretch mode.
+ // Don't expose function to scripting.
+ _internal_set_size(p_size, true);
+}
+
+void SubViewport::_internal_set_size(const Size2i &p_size, bool p_force) {
SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent());
+ if (!p_force && c && c->is_stretch_enabled()) {
+#ifdef DEBUG_ENABLED
+ WARN_PRINT("Can't change the size of a `SubViewport` with a `SubViewportContainer` parent that has `stretch` enabled. Set `SubViewportContainer.stretch` to `false` to allow changing the size manually.");
+#endif // DEBUG_ENABLED
+ return;
+ }
+
+ _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
+
if (c) {
c->update_minimum_size();
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index d5d5201e9a..2a4ddc422f 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -511,6 +511,7 @@ public:
Transform2D get_global_canvas_transform() const;
Transform2D get_final_transform() const;
+ void assign_next_enabled_camera_2d(const StringName &p_camera_group);
void gui_set_root_order_dirty();
@@ -753,6 +754,8 @@ private:
ClearMode clear_mode = CLEAR_MODE_ALWAYS;
bool size_2d_override_stretch = false;
+ void _internal_set_size(const Size2i &p_size, bool p_force = false);
+
protected:
static void _bind_methods();
virtual DisplayServer::WindowID get_window_id() const override;
@@ -762,6 +765,7 @@ protected:
public:
void set_size(const Size2i &p_size);
Size2i get_size() const;
+ void set_size_force(const Size2i &p_size);
void set_size_2d_override(const Size2i &p_size);
Size2i get_size_2d_override() const;
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 1f629aaf94..b1f2bc65dc 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -2135,13 +2135,13 @@ Transform2D Window::get_popup_base_transform() const {
if (is_embedding_subwindows()) {
return Transform2D();
}
- Transform2D window_transform;
- window_transform.set_origin(get_position());
- window_transform *= Viewport::get_screen_transform();
+ Transform2D popup_base_transform;
+ popup_base_transform.set_origin(get_position());
+ popup_base_transform *= Viewport::get_screen_transform();
if (_get_embedder()) {
- return _get_embedder()->get_popup_base_transform() * window_transform;
+ return _get_embedder()->get_popup_base_transform() * popup_base_transform;
}
- return window_transform;
+ return popup_base_transform;
}
void Window::_bind_methods() {
diff --git a/scene/resources/fog_material.cpp b/scene/resources/fog_material.cpp
index 4e51bbaa73..aabaa54505 100644
--- a/scene/resources/fog_material.cpp
+++ b/scene/resources/fog_material.cpp
@@ -159,7 +159,7 @@ uniform sampler3D density_texture: hint_default_white;
void fog() {
DENSITY = density * clamp(exp2(-height_falloff * (WORLD_POSITION.y - OBJECT_POSITION.y)), 0.0, 1.0);
DENSITY *= texture(density_texture, UVW).r;
- DENSITY *= pow(clamp(-SDF / min(min(EXTENTS.x, EXTENTS.y), EXTENTS.z), 0.0, 1.0), edge_fade);
+ DENSITY *= pow(clamp(-2.0 * SDF / min(min(SIZE.x, SIZE.y), SIZE.z), 0.0, 1.0), edge_fade);
ALBEDO = albedo.rgb;
EMISSION = emission.rgb;
}
diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp
index 742ac2bbd9..672581bbe2 100644
--- a/scene/resources/importer_mesh.cpp
+++ b/scene/resources/importer_mesh.cpp
@@ -452,6 +452,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
new_indices.resize(index_count);
Vector<float> merged_normals_f32 = vector3_to_float32_array(merged_normals.ptr(), merged_normals.size());
+ const int simplify_options = SurfaceTool::SIMPLIFY_LOCK_BORDER;
size_t new_index_count = SurfaceTool::simplify_with_attrib_func(
(unsigned int *)new_indices.ptrw(),
@@ -460,6 +461,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
sizeof(float) * 3, // Vertex stride
index_target,
max_mesh_error,
+ simplify_options,
&mesh_error,
merged_normals_f32.ptr(),
normal_weights.ptr(), 3);
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 7984ec735e..1e9038139e 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -43,7 +43,7 @@
#include "scene/main/missing_node.h"
#include "scene/property_utils.h"
-#define PACKED_SCENE_VERSION 2
+#define PACKED_SCENE_VERSION 3
#define META_POINTER_PROPERTY_BASE "metadata/_editor_prop_ptr_"
bool SceneState::can_instantiate() const {
return nodes.size() > 0;
@@ -1294,6 +1294,9 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
for (int j = 0; j < cd.binds.size(); j++) {
cd.binds.write[j] = r[idx++];
}
+ if (version >= 3) {
+ cd.unbinds = r[idx++];
+ }
}
}
@@ -1380,6 +1383,7 @@ Dictionary SceneState::get_bundled_scene() const {
for (int j = 0; j < cd.binds.size(); j++) {
rconns.push_back(cd.binds[j]);
}
+ rconns.push_back(cd.unbinds);
}
d["conns"] = rconns;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 5a2b917b9a..16cc1c3370 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -1307,7 +1307,8 @@ Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun
}
float error;
- uint32_t index_count = simplify_func((unsigned int *)lod.ptrw(), (unsigned int *)index_array.ptr(), index_array.size(), vertices.ptr(), vertex_array.size(), sizeof(float) * 3, p_target_index_count, p_threshold, &error);
+ const int simplify_options = SIMPLIFY_LOCK_BORDER;
+ uint32_t index_count = simplify_func((unsigned int *)lod.ptrw(), (unsigned int *)index_array.ptr(), index_array.size(), vertices.ptr(), vertex_array.size(), sizeof(float) * 3, p_target_index_count, p_threshold, simplify_options, &error);
ERR_FAIL_COND_V(index_count == 0, lod);
lod.resize(index_count);
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index 00438c4a53..77318bb061 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -74,11 +74,16 @@ public:
SKIN_8_WEIGHTS
};
+ enum {
+ /* Do not move vertices that are located on the topological border (vertices on triangle edges that don't have a paired triangle). Useful for simplifying portions of the larger mesh. */
+ SIMPLIFY_LOCK_BORDER = 1 << 0, // From meshopt_SimplifyLockBorder
+ };
+
typedef void (*OptimizeVertexCacheFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, size_t vertex_count);
static OptimizeVertexCacheFunc optimize_vertex_cache_func;
- typedef size_t (*SimplifyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float *r_error);
+ typedef size_t (*SimplifyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float *r_error);
static SimplifyFunc simplify_func;
- typedef size_t (*SimplifyWithAttribFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, float *result_error, const float *attributes, const float *attribute_weights, size_t attribute_count);
+ typedef size_t (*SimplifyWithAttribFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, unsigned int options, float *result_error, const float *attributes, const float *attribute_weights, size_t attribute_count);
static SimplifyWithAttribFunc simplify_with_attrib_func;
typedef float (*SimplifyScaleFunc)(const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
static SimplifyScaleFunc simplify_scale_func;
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index c18cad48d5..4132972cb3 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2708,6 +2708,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR_INT, "view_index", "VIEW_INDEX" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR_INT, "view_mono_left", "VIEW_MONO_LEFT" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR_INT, "view_right", "VIEW_RIGHT" },
+ { Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR_3D, "eye_offset", "EYE_OFFSET" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR_3D, "node_position_world", "NODE_POSITION_WORLD" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR_3D, "camera_position_world", "CAMERA_POSITION_WORLD" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR_3D, "camera_direction_world", "CAMERA_DIRECTION_WORLD" },
@@ -2742,6 +2743,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR_INT, "view_index", "VIEW_INDEX" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR_INT, "view_mono_left", "VIEW_MONO_LEFT" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR_INT, "view_right", "VIEW_RIGHT" },
+ { Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR_3D, "eye_offset", "EYE_OFFSET" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR_3D, "node_position_world", "NODE_POSITION_WORLD" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR_3D, "camera_position_world", "CAMERA_POSITION_WORLD" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR_3D, "camera_direction_world", "CAMERA_DIRECTION_WORLD" },
@@ -2942,7 +2944,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
{ Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_VECTOR_3D, "world_position", "WORLD_POSITION" },
{ Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_VECTOR_3D, "object_position", "OBJECT_POSITION" },
{ Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_VECTOR_3D, "uvw", "UVW" },
- { Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_VECTOR_3D, "extents", "EXTENTS" },
+ { Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_VECTOR_3D, "size", "SIZE" },
{ Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_SCALAR, "sdf", "SDF" },
{ Shader::MODE_FOG, VisualShader::TYPE_FOG, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 12be0f46a6..0695492e7f 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -6923,15 +6923,34 @@ void VisualShaderNodeSwitch::_bind_methods() { // static
}
String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+ bool use_mix = false;
+ switch (op_type) {
+ case OP_TYPE_FLOAT: {
+ use_mix = true;
+ } break;
+ case OP_TYPE_VECTOR_2D: {
+ use_mix = true;
+ } break;
+ case OP_TYPE_VECTOR_3D: {
+ use_mix = true;
+ } break;
+ case OP_TYPE_VECTOR_4D: {
+ use_mix = true;
+ } break;
+ default: {
+ } break;
+ }
+
String code;
- code += " if(" + p_input_vars[0] + ")\n";
- code += " {\n";
- code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n";
- code += " }\n";
- code += " else\n";
- code += " {\n";
- code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n";
- code += " }\n";
+ if (use_mix) {
+ code += " " + p_output_vars[0] + " = mix(" + p_input_vars[2] + ", " + p_input_vars[1] + ", float(" + p_input_vars[0] + "));\n";
+ } else {
+ code += " if (" + p_input_vars[0] + ") {\n";
+ code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n";
+ code += " } else {\n";
+ code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n";
+ code += " }\n";
+ }
return code;
}
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 2a70139bcb..c7304da358 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -43,6 +43,14 @@ RID World2D::get_canvas() const {
}
RID World2D::get_space() const {
+ if (space.is_null()) {
+ space = PhysicsServer2D::get_singleton()->space_create();
+ PhysicsServer2D::get_singleton()->space_set_active(space, true);
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, GLOBAL_GET("physics/2d/default_gravity"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_GET("physics/2d/default_gravity_vector"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, GLOBAL_GET("physics/2d/default_linear_damp"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_GET("physics/2d/default_angular_damp"));
+ }
return space;
}
@@ -71,19 +79,11 @@ void World2D::_bind_methods() {
}
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
- return PhysicsServer2D::get_singleton()->space_get_direct_state(space);
+ return PhysicsServer2D::get_singleton()->space_get_direct_state(get_space());
}
World2D::World2D() {
canvas = RenderingServer::get_singleton()->canvas_create();
-
- // Create and configure space2D to be more friendly with pixels than meters
- space = PhysicsServer2D::get_singleton()->space_create();
- PhysicsServer2D::get_singleton()->space_set_active(space, true);
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, GLOBAL_DEF_BASIC("physics/2d/default_gravity", 980.0));
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF_BASIC("physics/2d/default_gravity_vector", Vector2(0, 1)));
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), 0.1));
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), 1.0));
}
World2D::~World2D() {
@@ -91,7 +91,9 @@ World2D::~World2D() {
ERR_FAIL_NULL(PhysicsServer2D::get_singleton());
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
RenderingServer::get_singleton()->free(canvas);
- PhysicsServer2D::get_singleton()->free(space);
+ if (space.is_valid()) {
+ PhysicsServer2D::get_singleton()->free(space);
+ }
if (navigation_map.is_valid()) {
NavigationServer2D::get_singleton()->free(navigation_map);
}
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index f02dddd2fe..0b3b9df7dc 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -43,7 +43,7 @@ class World2D : public Resource {
GDCLASS(World2D, Resource);
RID canvas;
- RID space;
+ mutable RID space;
mutable RID navigation_map;
HashSet<Viewport *> viewports;
diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp
index cc4d261c0d..82c056d5ee 100644
--- a/scene/resources/world_3d.cpp
+++ b/scene/resources/world_3d.cpp
@@ -51,6 +51,14 @@ void World3D::_remove_camera(Camera3D *p_camera) {
}
RID World3D::get_space() const {
+ if (space.is_null()) {
+ space = PhysicsServer3D::get_singleton()->space_create();
+ PhysicsServer3D::get_singleton()->space_set_active(space, true);
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY, GLOBAL_GET("physics/3d/default_gravity"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_GET("physics/3d/default_gravity_vector"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, GLOBAL_GET("physics/3d/default_linear_damp"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_GET("physics/3d/default_angular_damp"));
+ }
return space;
}
@@ -121,7 +129,7 @@ Ref<CameraAttributes> World3D::get_camera_attributes() const {
}
PhysicsDirectSpaceState3D *World3D::get_direct_space_state() {
- return PhysicsServer3D::get_singleton()->space_get_direct_state(space);
+ return PhysicsServer3D::get_singleton()->space_get_direct_state(get_space());
}
void World3D::_bind_methods() {
@@ -145,22 +153,18 @@ void World3D::_bind_methods() {
}
World3D::World3D() {
- space = PhysicsServer3D::get_singleton()->space_create();
scenario = RenderingServer::get_singleton()->scenario_create();
-
- PhysicsServer3D::get_singleton()->space_set_active(space, true);
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY, GLOBAL_DEF_BASIC("physics/3d/default_gravity", 9.8));
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF_BASIC("physics/3d/default_gravity_vector", Vector3(0, -1, 0)));
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/default_linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), 0.1));
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/default_angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), 0.1));
}
World3D::~World3D() {
- ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
ERR_FAIL_NULL(RenderingServer::get_singleton());
+ ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
- PhysicsServer3D::get_singleton()->free(space);
+
RenderingServer::get_singleton()->free(scenario);
+ if (space.is_valid()) {
+ PhysicsServer3D::get_singleton()->free(space);
+ }
if (navigation_map.is_valid()) {
NavigationServer3D::get_singleton()->free(navigation_map);
}
diff --git a/scene/resources/world_3d.h b/scene/resources/world_3d.h
index ad17daf466..518fff64e2 100644
--- a/scene/resources/world_3d.h
+++ b/scene/resources/world_3d.h
@@ -45,8 +45,8 @@ class World3D : public Resource {
GDCLASS(World3D, Resource);
private:
- RID space;
RID scenario;
+ mutable RID space;
mutable RID navigation_map;
Ref<Environment> environment;
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 6b4435a991..8c877e4eed 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -144,7 +144,7 @@ int AudioDriver::get_total_channels_by_speaker_mode(AudioDriver::SpeakerMode p_m
ERR_FAIL_V(2);
}
-PackedStringArray AudioDriver::get_device_list() {
+PackedStringArray AudioDriver::get_output_device_list() {
PackedStringArray list;
list.push_back("Default");
@@ -152,11 +152,11 @@ PackedStringArray AudioDriver::get_device_list() {
return list;
}
-String AudioDriver::get_device() {
+String AudioDriver::get_output_device() {
return "Default";
}
-PackedStringArray AudioDriver::capture_get_device_list() {
+PackedStringArray AudioDriver::get_input_device_list() {
PackedStringArray list;
list.push_back("Default");
@@ -238,7 +238,7 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
#endif
if (channel_count != get_channel_count()) {
- // Amount of channels changed due to a device change
+ // Amount of channels changed due to a output_device change
// reinitialize the buses channels and buffers
init_channels_and_buffers();
}
@@ -1632,28 +1632,28 @@ Ref<AudioBusLayout> AudioServer::generate_bus_layout() const {
return state;
}
-PackedStringArray AudioServer::get_device_list() {
- return AudioDriver::get_singleton()->get_device_list();
+PackedStringArray AudioServer::get_output_device_list() {
+ return AudioDriver::get_singleton()->get_output_device_list();
}
-String AudioServer::get_device() {
- return AudioDriver::get_singleton()->get_device();
+String AudioServer::get_output_device() {
+ return AudioDriver::get_singleton()->get_output_device();
}
-void AudioServer::set_device(String device) {
- AudioDriver::get_singleton()->set_device(device);
+void AudioServer::set_output_device(String output_device) {
+ AudioDriver::get_singleton()->set_output_device(output_device);
}
-PackedStringArray AudioServer::capture_get_device_list() {
- return AudioDriver::get_singleton()->capture_get_device_list();
+PackedStringArray AudioServer::get_input_device_list() {
+ return AudioDriver::get_singleton()->get_input_device_list();
}
-String AudioServer::capture_get_device() {
- return AudioDriver::get_singleton()->capture_get_device();
+String AudioServer::get_input_device() {
+ return AudioDriver::get_singleton()->get_input_device();
}
-void AudioServer::capture_set_device(const String &p_name) {
- AudioDriver::get_singleton()->capture_set_device(p_name);
+void AudioServer::set_input_device(const String &p_name) {
+ AudioDriver::get_singleton()->set_input_device(p_name);
}
void AudioServer::set_enable_tagging_used_audio_streams(bool p_enable) {
@@ -1711,17 +1711,17 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_speaker_mode"), &AudioServer::get_speaker_mode);
ClassDB::bind_method(D_METHOD("get_mix_rate"), &AudioServer::get_mix_rate);
- ClassDB::bind_method(D_METHOD("get_device_list"), &AudioServer::get_device_list);
- ClassDB::bind_method(D_METHOD("get_device"), &AudioServer::get_device);
- ClassDB::bind_method(D_METHOD("set_device", "device"), &AudioServer::set_device);
+ ClassDB::bind_method(D_METHOD("get_output_device_list"), &AudioServer::get_output_device_list);
+ ClassDB::bind_method(D_METHOD("get_output_device"), &AudioServer::get_output_device);
+ ClassDB::bind_method(D_METHOD("set_output_device", "output_device"), &AudioServer::set_output_device);
ClassDB::bind_method(D_METHOD("get_time_to_next_mix"), &AudioServer::get_time_to_next_mix);
ClassDB::bind_method(D_METHOD("get_time_since_last_mix"), &AudioServer::get_time_since_last_mix);
ClassDB::bind_method(D_METHOD("get_output_latency"), &AudioServer::get_output_latency);
- ClassDB::bind_method(D_METHOD("capture_get_device_list"), &AudioServer::capture_get_device_list);
- ClassDB::bind_method(D_METHOD("capture_get_device"), &AudioServer::capture_get_device);
- ClassDB::bind_method(D_METHOD("capture_set_device", "name"), &AudioServer::capture_set_device);
+ ClassDB::bind_method(D_METHOD("get_input_device_list"), &AudioServer::get_input_device_list);
+ ClassDB::bind_method(D_METHOD("get_input_device"), &AudioServer::get_input_device);
+ ClassDB::bind_method(D_METHOD("set_input_device", "name"), &AudioServer::set_input_device);
ClassDB::bind_method(D_METHOD("set_bus_layout", "bus_layout"), &AudioServer::set_bus_layout);
ClassDB::bind_method(D_METHOD("generate_bus_layout"), &AudioServer::generate_bus_layout);
@@ -1729,11 +1729,11 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_enable_tagging_used_audio_streams", "enable"), &AudioServer::set_enable_tagging_used_audio_streams);
ADD_PROPERTY(PropertyInfo(Variant::INT, "bus_count"), "set_bus_count", "get_bus_count");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "device"), "set_device", "get_device");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "capture_device"), "capture_set_device", "capture_get_device");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "output_device"), "set_output_device", "get_output_device");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "input_device"), "set_input_device", "get_input_device");
// The default value may be set to an empty string by the platform-specific audio driver.
// Override for class reference generation purposes.
- ADD_PROPERTY_DEFAULT("capture_device", "Default");
+ ADD_PROPERTY_DEFAULT("input_device", "Default");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_speed_scale"), "set_playback_speed_scale", "get_playback_speed_scale");
ADD_SIGNAL(MethodInfo("bus_layout_changed"));
diff --git a/servers/audio_server.h b/servers/audio_server.h
index a369efedf7..d3d87a8400 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -94,18 +94,18 @@ public:
virtual void start() = 0;
virtual int get_mix_rate() const = 0;
virtual SpeakerMode get_speaker_mode() const = 0;
- virtual PackedStringArray get_device_list();
- virtual String get_device();
- virtual void set_device(String device) {}
+ virtual PackedStringArray get_output_device_list();
+ virtual String get_output_device();
+ virtual void set_output_device(String output_device) {}
virtual void lock() = 0;
virtual void unlock() = 0;
virtual void finish() = 0;
virtual Error capture_start() { return FAILED; }
virtual Error capture_stop() { return FAILED; }
- virtual void capture_set_device(const String &p_name) {}
- virtual String capture_get_device() { return "Default"; }
- virtual PackedStringArray capture_get_device_list();
+ virtual void set_input_device(const String &p_name) {}
+ virtual String get_input_device() { return "Default"; }
+ virtual PackedStringArray get_input_device_list();
virtual float get_latency() { return 0; }
@@ -419,13 +419,13 @@ public:
void set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout);
Ref<AudioBusLayout> generate_bus_layout() const;
- PackedStringArray get_device_list();
- String get_device();
- void set_device(String device);
+ PackedStringArray get_output_device_list();
+ String get_output_device();
+ void set_output_device(String output_device);
- PackedStringArray capture_get_device_list();
- String capture_get_device();
- void capture_set_device(const String &p_name);
+ PackedStringArray get_input_device_list();
+ String get_input_device();
+ void set_input_device(const String &p_name);
void set_enable_tagging_used_audio_streams(bool p_enable);
diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp
index 2e4087c1de..85ba8ed431 100644
--- a/servers/navigation_server_2d.cpp
+++ b/servers/navigation_server_2d.cpp
@@ -207,6 +207,30 @@ void NavigationServer2D::set_debug_navigation_enable_edge_connections(const bool
bool NavigationServer2D::get_debug_navigation_enable_edge_connections() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_enable_edge_connections();
}
+
+void NavigationServer2D::set_debug_navigation_agent_path_color(const Color &p_color) {
+ NavigationServer3D::get_singleton()->set_debug_navigation_agent_path_color(p_color);
+}
+
+Color NavigationServer2D::get_debug_navigation_agent_path_color() const {
+ return NavigationServer3D::get_singleton()->get_debug_navigation_agent_path_color();
+}
+
+void NavigationServer2D::set_debug_navigation_enable_agent_paths(const bool p_value) {
+ NavigationServer3D::get_singleton()->set_debug_navigation_enable_agent_paths(p_value);
+}
+
+bool NavigationServer2D::get_debug_navigation_enable_agent_paths() const {
+ return NavigationServer3D::get_singleton()->get_debug_navigation_enable_agent_paths();
+}
+
+void NavigationServer2D::set_debug_navigation_agent_path_point_size(float p_point_size) {
+ NavigationServer3D::get_singleton()->set_debug_navigation_agent_path_point_size(p_point_size);
+}
+
+float NavigationServer2D::get_debug_navigation_agent_path_point_size() const {
+ return NavigationServer3D::get_singleton()->get_debug_navigation_agent_path_point_size();
+}
#endif // DEBUG_ENABLED
void NavigationServer2D::_bind_methods() {
@@ -286,14 +310,26 @@ void NavigationServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer2D::free);
ADD_SIGNAL(MethodInfo("map_changed", PropertyInfo(Variant::RID, "map")));
+
+ ADD_SIGNAL(MethodInfo("navigation_debug_changed"));
}
NavigationServer2D::NavigationServer2D() {
singleton = this;
ERR_FAIL_COND_MSG(!NavigationServer3D::get_singleton(), "The Navigation3D singleton should be initialized before the 2D one.");
NavigationServer3D::get_singleton()->connect("map_changed", callable_mp(this, &NavigationServer2D::_emit_map_changed));
+
+#ifdef DEBUG_ENABLED
+ NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationServer2D::_emit_navigation_debug_changed_signal));
+#endif // DEBUG_ENABLED
}
+#ifdef DEBUG_ENABLED
+void NavigationServer2D::_emit_navigation_debug_changed_signal() {
+ emit_signal(SNAME("navigation_debug_changed"));
+}
+#endif // DEBUG_ENABLED
+
NavigationServer2D::~NavigationServer2D() {
singleton = nullptr;
}
diff --git a/servers/navigation_server_2d.h b/servers/navigation_server_2d.h
index cd18476182..746389404b 100644
--- a/servers/navigation_server_2d.h
+++ b/servers/navigation_server_2d.h
@@ -254,6 +254,20 @@ public:
void set_debug_navigation_enable_edge_connections(const bool p_value);
bool get_debug_navigation_enable_edge_connections() const;
+
+ void set_debug_navigation_agent_path_color(const Color &p_color);
+ Color get_debug_navigation_agent_path_color() const;
+
+ void set_debug_navigation_enable_agent_paths(const bool p_value);
+ bool get_debug_navigation_enable_agent_paths() const;
+
+ void set_debug_navigation_agent_path_point_size(float p_point_size);
+ float get_debug_navigation_agent_path_point_size() const;
+#endif // DEBUG_ENABLED
+
+#ifdef DEBUG_ENABLED
+private:
+ void _emit_navigation_debug_changed_signal();
#endif // DEBUG_ENABLED
};
diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp
index 8f2cff0e04..70897ae75c 100644
--- a/servers/navigation_server_3d.cpp
+++ b/servers/navigation_server_3d.cpp
@@ -159,6 +159,7 @@ NavigationServer3D::NavigationServer3D() {
debug_navigation_geometry_face_disabled_color = GLOBAL_DEF("debug/shapes/navigation/geometry_face_disabled_color", Color(0.5, 0.5, 0.5, 0.4));
debug_navigation_link_connection_color = GLOBAL_DEF("debug/shapes/navigation/link_connection_color", Color(1.0, 0.5, 1.0, 1.0));
debug_navigation_link_connection_disabled_color = GLOBAL_DEF("debug/shapes/navigation/link_connection_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
+ debug_navigation_agent_path_color = GLOBAL_DEF("debug/shapes/navigation/agent_path_color", Color(1.0, 0.0, 0.0, 1.0));
debug_navigation_enable_edge_connections = GLOBAL_DEF("debug/shapes/navigation/enable_edge_connections", true);
debug_navigation_enable_edge_connections_xray = GLOBAL_DEF("debug/shapes/navigation/enable_edge_connections_xray", true);
@@ -168,6 +169,11 @@ NavigationServer3D::NavigationServer3D() {
debug_navigation_enable_link_connections = GLOBAL_DEF("debug/shapes/navigation/enable_link_connections", true);
debug_navigation_enable_link_connections_xray = GLOBAL_DEF("debug/shapes/navigation/enable_link_connections_xray", true);
+ debug_navigation_enable_agent_paths = GLOBAL_DEF("debug/shapes/navigation/enable_agent_paths", true);
+ debug_navigation_enable_agent_paths_xray = GLOBAL_DEF("debug/shapes/navigation/enable_agent_paths_xray", true);
+
+ debug_navigation_agent_path_point_size = GLOBAL_DEF("debug/shapes/navigation/agent_path_point_size", 4.0);
+
if (Engine::get_singleton()->is_editor_hint()) {
// enable NavigationServer3D when in Editor or else navigation mesh edge connections are invisible
// on runtime tests SceneTree has "Visible Navigation" set and main iteration takes care of this
@@ -329,6 +335,42 @@ Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_link_connection
return debug_navigation_link_connections_disabled_material;
}
+Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_agent_path_line_material() {
+ if (debug_navigation_agent_path_line_material.is_valid()) {
+ return debug_navigation_agent_path_line_material;
+ }
+
+ Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ material->set_albedo(debug_navigation_agent_path_color);
+ if (debug_navigation_enable_agent_paths_xray) {
+ material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
+ }
+ material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
+
+ debug_navigation_agent_path_line_material = material;
+ return debug_navigation_agent_path_line_material;
+}
+
+Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_agent_path_point_material() {
+ if (debug_navigation_agent_path_point_material.is_valid()) {
+ return debug_navigation_agent_path_point_material;
+ }
+
+ Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ material->set_albedo(debug_navigation_agent_path_color);
+ material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
+ material->set_point_size(debug_navigation_agent_path_point_size);
+ if (debug_navigation_enable_agent_paths_xray) {
+ material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
+ }
+ material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
+
+ debug_navigation_agent_path_point_material = material;
+ return debug_navigation_agent_path_point_material;
+}
+
void NavigationServer3D::set_debug_navigation_edge_connection_color(const Color &p_color) {
debug_navigation_edge_connection_color = p_color;
if (debug_navigation_edge_connections_material.is_valid()) {
@@ -406,6 +448,31 @@ Color NavigationServer3D::get_debug_navigation_link_connection_disabled_color()
return debug_navigation_link_connection_disabled_color;
}
+void NavigationServer3D::set_debug_navigation_agent_path_point_size(float p_point_size) {
+ debug_navigation_agent_path_point_size = MAX(0.1, p_point_size);
+ if (debug_navigation_agent_path_point_material.is_valid()) {
+ debug_navigation_agent_path_point_material->set_point_size(debug_navigation_agent_path_point_size);
+ }
+}
+
+float NavigationServer3D::get_debug_navigation_agent_path_point_size() const {
+ return debug_navigation_agent_path_point_size;
+}
+
+void NavigationServer3D::set_debug_navigation_agent_path_color(const Color &p_color) {
+ debug_navigation_agent_path_color = p_color;
+ if (debug_navigation_agent_path_line_material.is_valid()) {
+ debug_navigation_agent_path_line_material->set_albedo(debug_navigation_agent_path_color);
+ }
+ if (debug_navigation_agent_path_point_material.is_valid()) {
+ debug_navigation_agent_path_point_material->set_albedo(debug_navigation_agent_path_color);
+ }
+}
+
+Color NavigationServer3D::get_debug_navigation_agent_path_color() const {
+ return debug_navigation_agent_path_color;
+}
+
void NavigationServer3D::set_debug_navigation_enable_edge_connections(const bool p_value) {
debug_navigation_enable_edge_connections = p_value;
debug_dirty = true;
@@ -494,6 +561,37 @@ void NavigationServer3D::set_debug_enabled(bool p_enabled) {
bool NavigationServer3D::get_debug_enabled() const {
return debug_enabled;
}
+
+void NavigationServer3D::set_debug_navigation_enable_agent_paths(const bool p_value) {
+ if (debug_navigation_enable_agent_paths != p_value) {
+ debug_dirty = true;
+ }
+
+ debug_navigation_enable_agent_paths = p_value;
+
+ if (debug_dirty) {
+ call_deferred("_emit_navigation_debug_changed_signal");
+ }
+}
+
+bool NavigationServer3D::get_debug_navigation_enable_agent_paths() const {
+ return debug_navigation_enable_agent_paths;
+}
+
+void NavigationServer3D::set_debug_navigation_enable_agent_paths_xray(const bool p_value) {
+ debug_navigation_enable_agent_paths_xray = p_value;
+ if (debug_navigation_agent_path_line_material.is_valid()) {
+ debug_navigation_agent_path_line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_agent_paths_xray);
+ }
+ if (debug_navigation_agent_path_point_material.is_valid()) {
+ debug_navigation_agent_path_point_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_agent_paths_xray);
+ }
+}
+
+bool NavigationServer3D::get_debug_navigation_enable_agent_paths_xray() const {
+ return debug_navigation_enable_agent_paths_xray;
+}
+
#endif // DEBUG_ENABLED
///////////////////////////////////////////////////////
diff --git a/servers/navigation_server_3d.h b/servers/navigation_server_3d.h
index 9c468d1b10..bc4bdf2a30 100644
--- a/servers/navigation_server_3d.h
+++ b/servers/navigation_server_3d.h
@@ -287,6 +287,9 @@ private:
Color debug_navigation_geometry_face_disabled_color = Color(0.5, 0.5, 0.5, 0.4);
Color debug_navigation_link_connection_color = Color(1.0, 0.5, 1.0, 1.0);
Color debug_navigation_link_connection_disabled_color = Color(0.5, 0.5, 0.5, 1.0);
+ Color debug_navigation_agent_path_color = Color(1.0, 0.0, 0.0, 1.0);
+
+ float debug_navigation_agent_path_point_size = 4.0;
bool debug_navigation_enable_edge_connections = true;
bool debug_navigation_enable_edge_connections_xray = true;
@@ -295,6 +298,8 @@ private:
bool debug_navigation_enable_geometry_face_random_color = true;
bool debug_navigation_enable_link_connections = true;
bool debug_navigation_enable_link_connections_xray = true;
+ bool debug_navigation_enable_agent_paths = true;
+ bool debug_navigation_enable_agent_paths_xray = true;
Ref<StandardMaterial3D> debug_navigation_geometry_edge_material;
Ref<StandardMaterial3D> debug_navigation_geometry_face_material;
@@ -304,6 +309,9 @@ private:
Ref<StandardMaterial3D> debug_navigation_link_connections_material;
Ref<StandardMaterial3D> debug_navigation_link_connections_disabled_material;
+ Ref<StandardMaterial3D> debug_navigation_agent_path_line_material;
+ Ref<StandardMaterial3D> debug_navigation_agent_path_point_material;
+
public:
void set_debug_enabled(bool p_enabled);
bool get_debug_enabled() const;
@@ -329,6 +337,9 @@ public:
void set_debug_navigation_link_connection_disabled_color(const Color &p_color);
Color get_debug_navigation_link_connection_disabled_color() const;
+ void set_debug_navigation_agent_path_color(const Color &p_color);
+ Color get_debug_navigation_agent_path_color() const;
+
void set_debug_navigation_enable_edge_connections(const bool p_value);
bool get_debug_navigation_enable_edge_connections() const;
@@ -350,6 +361,15 @@ public:
void set_debug_navigation_enable_link_connections_xray(const bool p_value);
bool get_debug_navigation_enable_link_connections_xray() const;
+ void set_debug_navigation_enable_agent_paths(const bool p_value);
+ bool get_debug_navigation_enable_agent_paths() const;
+
+ void set_debug_navigation_enable_agent_paths_xray(const bool p_value);
+ bool get_debug_navigation_enable_agent_paths_xray() const;
+
+ void set_debug_navigation_agent_path_point_size(float p_point_size);
+ float get_debug_navigation_agent_path_point_size() const;
+
Ref<StandardMaterial3D> get_debug_navigation_geometry_face_material();
Ref<StandardMaterial3D> get_debug_navigation_geometry_edge_material();
Ref<StandardMaterial3D> get_debug_navigation_geometry_face_disabled_material();
@@ -357,6 +377,9 @@ public:
Ref<StandardMaterial3D> get_debug_navigation_edge_connections_material();
Ref<StandardMaterial3D> get_debug_navigation_link_connections_material();
Ref<StandardMaterial3D> get_debug_navigation_link_connections_disabled_material();
+
+ Ref<StandardMaterial3D> get_debug_navigation_agent_path_line_material();
+ Ref<StandardMaterial3D> get_debug_navigation_agent_path_point_material();
#endif // DEBUG_ENABLED
};
diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp
index 0a5a7c93cc..1beb5336f7 100644
--- a/servers/physics_2d/godot_space_2d.cpp
+++ b/servers/physics_2d/godot_space_2d.cpp
@@ -83,7 +83,7 @@ int GodotPhysicsDirectSpaceState2D::intersect_point(const PointParameters &p_par
continue;
}
- if (p_parameters.canvas_instance_id.is_valid() && col_obj->get_canvas_instance_id() != p_parameters.canvas_instance_id) {
+ if (col_obj->get_canvas_instance_id() != p_parameters.canvas_instance_id) {
continue;
}
@@ -1216,15 +1216,15 @@ GodotPhysicsDirectSpaceState2D *GodotSpace2D::get_direct_state() {
}
GodotSpace2D::GodotSpace2D() {
- body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_linear", 2.0);
- body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_angular", Math::deg_to_rad(8.0));
- body_time_to_sleep = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"), 0.5);
- solver_iterations = GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/2d/solver/solver_iterations", PROPERTY_HINT_RANGE, "1,32,1,or_greater"), 16);
- contact_recycle_radius = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_recycle_radius", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 1.0);
- contact_max_separation = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 1.5);
- contact_max_allowed_penetration = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_allowed_penetration", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 0.3);
- contact_bias = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/default_contact_bias", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.8);
- constraint_bias = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/default_constraint_bias", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.2);
+ body_linear_velocity_sleep_threshold = GLOBAL_GET("physics/2d/sleep_threshold_linear");
+ body_angular_velocity_sleep_threshold = GLOBAL_GET("physics/2d/sleep_threshold_angular");
+ body_time_to_sleep = GLOBAL_GET("physics/2d/time_before_sleep");
+ solver_iterations = GLOBAL_GET("physics/2d/solver/solver_iterations");
+ contact_recycle_radius = GLOBAL_GET("physics/2d/solver/contact_recycle_radius");
+ contact_max_separation = GLOBAL_GET("physics/2d/solver/contact_max_separation");
+ contact_max_allowed_penetration = GLOBAL_GET("physics/2d/solver/contact_max_allowed_penetration");
+ contact_bias = GLOBAL_GET("physics/2d/solver/default_contact_bias");
+ constraint_bias = GLOBAL_GET("physics/2d/solver/default_constraint_bias");
broadphase = GodotBroadPhase2D::create_func();
broadphase->set_pair_callback(_broadphase_pair, this);
diff --git a/servers/physics_3d/godot_space_3d.cpp b/servers/physics_3d/godot_space_3d.cpp
index 93572965d2..35f6fa023d 100644
--- a/servers/physics_3d/godot_space_3d.cpp
+++ b/servers/physics_3d/godot_space_3d.cpp
@@ -1250,14 +1250,14 @@ GodotPhysicsDirectSpaceState3D *GodotSpace3D::get_direct_state() {
}
GodotSpace3D::GodotSpace3D() {
- body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/3d/sleep_threshold_linear", 0.1);
- body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/3d/sleep_threshold_angular", Math::deg_to_rad(8.0));
- body_time_to_sleep = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"), 0.5);
- solver_iterations = GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/3d/solver/solver_iterations", PROPERTY_HINT_RANGE, "1,32,1,or_greater"), 16);
- contact_recycle_radius = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_recycle_radius", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"), 0.01);
- contact_max_separation = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"), 0.05);
- contact_max_allowed_penetration = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_allowed_penetration", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"), 0.01);
- contact_bias = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/default_contact_bias", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.8);
+ body_linear_velocity_sleep_threshold = GLOBAL_GET("physics/3d/sleep_threshold_linear");
+ body_angular_velocity_sleep_threshold = GLOBAL_GET("physics/3d/sleep_threshold_angular");
+ body_time_to_sleep = GLOBAL_GET("physics/3d/time_before_sleep");
+ solver_iterations = GLOBAL_GET("physics/3d/solver/solver_iterations");
+ contact_recycle_radius = GLOBAL_GET("physics/3d/solver/contact_recycle_radius");
+ contact_max_separation = GLOBAL_GET("physics/3d/solver/contact_max_separation");
+ contact_max_allowed_penetration = GLOBAL_GET("physics/3d/solver/contact_max_allowed_penetration");
+ contact_bias = GLOBAL_GET("physics/3d/solver/default_contact_bias");
broadphase = GodotBroadPhase3D::create_func();
broadphase->set_pair_callback(_broadphase_pair, this);
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 15c2749484..f9a8d5f156 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -879,6 +879,23 @@ void PhysicsServer2D::_bind_methods() {
PhysicsServer2D::PhysicsServer2D() {
singleton = this;
+
+ // World2D physics space
+ GLOBAL_DEF_BASIC("physics/2d/default_gravity", 980.0);
+ GLOBAL_DEF_BASIC("physics/2d/default_gravity_vector", Vector2(0, 1));
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), 0.1);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), 1.0);
+
+ // PhysicsServer2D
+ GLOBAL_DEF("physics/2d/sleep_threshold_linear", 2.0);
+ GLOBAL_DEF("physics/2d/sleep_threshold_angular", Math::deg_to_rad(8.0));
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"), 0.5);
+ GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/2d/solver/solver_iterations", PROPERTY_HINT_RANGE, "1,32,1,or_greater"), 16);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_recycle_radius", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 1.0);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 1.5);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/contact_max_allowed_penetration", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 0.3);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/default_contact_bias", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.8);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/2d/solver/default_constraint_bias", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.2);
}
PhysicsServer2D::~PhysicsServer2D() {
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp
index 864774374b..6a163c86d2 100644
--- a/servers/physics_server_3d.cpp
+++ b/servers/physics_server_3d.cpp
@@ -1047,6 +1047,22 @@ void PhysicsServer3D::_bind_methods() {
PhysicsServer3D::PhysicsServer3D() {
singleton = this;
+
+ // World3D physics space
+ GLOBAL_DEF_BASIC("physics/3d/default_gravity", 9.8);
+ GLOBAL_DEF_BASIC("physics/3d/default_gravity_vector", Vector3(0, -1, 0));
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/default_linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), 0.1);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/default_angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), 0.1);
+
+ // PhysicsServer3D
+ GLOBAL_DEF("physics/3d/sleep_threshold_linear", 0.1);
+ GLOBAL_DEF("physics/3d/sleep_threshold_angular", Math::deg_to_rad(8.0));
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"), 0.5);
+ GLOBAL_DEF(PropertyInfo(Variant::INT, "physics/3d/solver/solver_iterations", PROPERTY_HINT_RANGE, "1,32,1,or_greater"), 16);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_recycle_radius", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"), 0.01);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_separation", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"), 0.05);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/contact_max_allowed_penetration", PROPERTY_HINT_RANGE, "0,0.1,0.01,or_greater"), 0.01);
+ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "physics/3d/solver/default_contact_bias", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.8);
}
PhysicsServer3D::~PhysicsServer3D() {
diff --git a/servers/rendering/dummy/environment/fog.h b/servers/rendering/dummy/environment/fog.h
index 5531e2a5d0..10aa242060 100644
--- a/servers/rendering/dummy/environment/fog.h
+++ b/servers/rendering/dummy/environment/fog.h
@@ -44,7 +44,7 @@ public:
virtual void fog_volume_free(RID p_rid) override {}
virtual void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) override {}
- virtual void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) override {}
+ virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) override {}
virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) override {}
virtual AABB fog_volume_get_aabb(RID p_fog_volume) const override { return AABB(); }
virtual RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override { return RS::FOG_VOLUME_SHAPE_BOX; }
diff --git a/servers/rendering/dummy/storage/light_storage.h b/servers/rendering/dummy/storage/light_storage.h
index 99329055a8..9a3918fd86 100644
--- a/servers/rendering/dummy/storage/light_storage.h
+++ b/servers/rendering/dummy/storage/light_storage.h
@@ -101,7 +101,7 @@ public:
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) override {}
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) override {}
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) override {}
- virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) override {}
+ virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) override {}
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) override {}
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) override {}
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) override {}
@@ -114,7 +114,7 @@ public:
virtual AABB reflection_probe_get_aabb(RID p_probe) const override { return AABB(); }
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const override { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; }
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const override { return 0; }
- virtual Vector3 reflection_probe_get_extents(RID p_probe) const override { return Vector3(); }
+ virtual Vector3 reflection_probe_get_size(RID p_probe) const override { return Vector3(); }
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const override { return Vector3(); }
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const override { return 0.0; }
virtual bool reflection_probe_renders_shadows(RID p_probe) const override { return false; }
diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h
index fd36e7ac10..41251b348c 100644
--- a/servers/rendering/dummy/storage/texture_storage.h
+++ b/servers/rendering/dummy/storage/texture_storage.h
@@ -134,7 +134,7 @@ public:
virtual void decal_initialize(RID p_rid) override {}
virtual void decal_free(RID p_rid) override{};
- virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) override {}
+ virtual void decal_set_size(RID p_decal, const Vector3 &p_size) override {}
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) override {}
virtual void decal_set_emission_energy(RID p_decal, float p_energy) override {}
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) override {}
diff --git a/servers/rendering/environment/renderer_fog.h b/servers/rendering/environment/renderer_fog.h
index ac56791711..f5c4134d14 100644
--- a/servers/rendering/environment/renderer_fog.h
+++ b/servers/rendering/environment/renderer_fog.h
@@ -44,7 +44,7 @@ public:
virtual void fog_volume_free(RID p_rid) = 0;
virtual void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) = 0;
- virtual void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) = 0;
+ virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) = 0;
virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) = 0;
virtual AABB fog_volume_get_aabb(RID p_fog_volume) const = 0;
virtual RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const = 0;
diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.h b/servers/rendering/renderer_rd/cluster_builder_rd.h
index a13e6c8172..3ca7af70ca 100644
--- a/servers/rendering/renderer_rd/cluster_builder_rd.h
+++ b/servers/rendering/renderer_rd/cluster_builder_rd.h
@@ -330,7 +330,7 @@ public:
render_element_count++;
}
- _FORCE_INLINE_ void add_box(BoxType p_box_type, const Transform3D &p_transform, const Vector3 &p_half_extents) {
+ _FORCE_INLINE_ void add_box(BoxType p_box_type, const Transform3D &p_transform, const Vector3 &p_half_size) {
if (p_box_type == BOX_TYPE_DECAL && cluster_count_by_type[ELEMENT_TYPE_DECAL] == max_elements_by_type) {
return; // Max number elements reached.
}
@@ -342,7 +342,7 @@ public:
Transform3D xform = view_xform * p_transform;
// Extract scale and scale the matrix by it, makes things simpler.
- Vector3 scale = p_half_extents;
+ Vector3 scale = p_half_size;
for (uint32_t i = 0; i < 3; i++) {
float s = xform.basis.rows[i].length();
scale[i] *= s;
diff --git a/servers/rendering/renderer_rd/environment/fog.cpp b/servers/rendering/renderer_rd/environment/fog.cpp
index 2787693aeb..4253ea8610 100644
--- a/servers/rendering/renderer_rd/environment/fog.cpp
+++ b/servers/rendering/renderer_rd/environment/fog.cpp
@@ -82,11 +82,11 @@ void Fog::fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) {
fog_volume->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
}
-void Fog::fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) {
+void Fog::fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) {
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
ERR_FAIL_COND(!fog_volume);
- fog_volume->extents = p_extents;
+ fog_volume->size = p_size;
fog_volume->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
}
@@ -120,8 +120,8 @@ AABB Fog::fog_volume_get_aabb(RID p_fog_volume) const {
case RS::FOG_VOLUME_SHAPE_CYLINDER:
case RS::FOG_VOLUME_SHAPE_BOX: {
AABB aabb;
- aabb.position = -fog_volume->extents;
- aabb.size = fog_volume->extents * 2;
+ aabb.position = -fog_volume->size / 2;
+ aabb.size = fog_volume->size;
return aabb;
}
default: {
@@ -131,10 +131,10 @@ AABB Fog::fog_volume_get_aabb(RID p_fog_volume) const {
}
}
-Vector3 Fog::fog_volume_get_extents(RID p_fog_volume) const {
+Vector3 Fog::fog_volume_get_size(RID p_fog_volume) const {
const FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
ERR_FAIL_COND_V(!fog_volume, Vector3());
- return fog_volume->extents;
+ return fog_volume->size;
}
////////////////////////////////////////////////////////////////////////////////
@@ -210,7 +210,7 @@ void Fog::init_fog_shader(uint32_t p_max_directional_lights, int p_roughness_lay
actions.renames["WORLD_POSITION"] = "world.xyz";
actions.renames["OBJECT_POSITION"] = "params.position";
actions.renames["UVW"] = "uvw";
- actions.renames["EXTENTS"] = "params.extents";
+ actions.renames["SIZE"] = "params.size";
actions.renames["ALBEDO"] = "albedo";
actions.renames["DENSITY"] = "density";
actions.renames["EMISSION"] = "emission";
@@ -643,7 +643,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
Vector3 position = fog_volume_instance->transform.get_origin();
RS::FogVolumeShape volume_type = RendererRD::Fog::get_singleton()->fog_volume_get_shape(fog_volume);
- Vector3 extents = RendererRD::Fog::get_singleton()->fog_volume_get_extents(fog_volume);
+ Vector3 extents = RendererRD::Fog::get_singleton()->fog_volume_get_size(fog_volume) / 2;
if (volume_type != RS::FOG_VOLUME_SHAPE_WORLD) {
// Local fog volume.
@@ -683,9 +683,9 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
push_constant.position[0] = position.x;
push_constant.position[1] = position.y;
push_constant.position[2] = position.z;
- push_constant.extents[0] = extents.x;
- push_constant.extents[1] = extents.y;
- push_constant.extents[2] = extents.z;
+ push_constant.size[0] = extents.x * 2;
+ push_constant.size[1] = extents.y * 2;
+ push_constant.size[2] = extents.z * 2;
push_constant.corner[0] = min.x;
push_constant.corner[1] = min.y;
push_constant.corner[2] = min.z;
diff --git a/servers/rendering/renderer_rd/environment/fog.h b/servers/rendering/renderer_rd/environment/fog.h
index eb0a2fc7b5..0b6bcc29fb 100644
--- a/servers/rendering/renderer_rd/environment/fog.h
+++ b/servers/rendering/renderer_rd/environment/fog.h
@@ -53,7 +53,7 @@ private:
struct FogVolume {
RID material;
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
RS::FogVolumeShape shape = RS::FOG_VOLUME_SHAPE_BOX;
@@ -83,7 +83,7 @@ private:
float position[3];
float pad;
- float extents[3];
+ float size[3];
float pad2;
int32_t corner[3];
@@ -239,12 +239,12 @@ public:
Dependency *fog_volume_get_dependency(RID p_fog_volume) const;
virtual void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) override;
- virtual void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) override;
+ virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) override;
virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) override;
virtual RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override;
RID fog_volume_get_material(RID p_fog_volume) const;
virtual AABB fog_volume_get_aabb(RID p_fog_volume) const override;
- Vector3 fog_volume_get_extents(RID p_fog_volume) const;
+ Vector3 fog_volume_get_size(RID p_fog_volume) const;
/* FOG VOLUMES INSTANCE */
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index 2e844269e3..59e1f559c7 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -1232,9 +1232,9 @@ void RenderForwardClustered::_update_volumetric_fog(Ref<RenderSceneBuffersRD> p_
/* Lighting */
-void RenderForwardClustered::setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_extents) {
+void RenderForwardClustered::setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_size) {
if (current_cluster_builder != nullptr) {
- current_cluster_builder->add_box(ClusterBuilderRD::BOX_TYPE_REFLECTION_PROBE, p_transform, p_half_extents);
+ current_cluster_builder->add_box(ClusterBuilderRD::BOX_TYPE_REFLECTION_PROBE, p_transform, p_half_size);
}
}
@@ -1244,9 +1244,9 @@ void RenderForwardClustered::setup_added_light(const RS::LightType p_type, const
}
}
-void RenderForwardClustered::setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_extents) {
+void RenderForwardClustered::setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_size) {
if (current_cluster_builder != nullptr) {
- current_cluster_builder->add_box(ClusterBuilderRD::BOX_TYPE_DECAL, p_transform, p_half_extents);
+ current_cluster_builder->add_box(ClusterBuilderRD::BOX_TYPE_DECAL, p_transform, p_half_size);
}
}
@@ -2615,8 +2615,8 @@ void RenderForwardClustered::_render_sdfgi(Ref<RenderSceneBuffersRD> p_render_bu
render_list[RENDER_LIST_SECONDARY].sort_by_key();
_fill_instance_data(RENDER_LIST_SECONDARY);
- Vector3 half_extents = p_bounds.size * 0.5;
- Vector3 center = p_bounds.position + half_extents;
+ Vector3 half_size = p_bounds.size * 0.5;
+ Vector3 center = p_bounds.position + half_size;
Vector<RID> sbs = {
p_albedo_texture,
@@ -2644,16 +2644,16 @@ void RenderForwardClustered::_render_sdfgi(Ref<RenderSceneBuffersRD> p_render_bu
fb_size.x = p_size[right_axis];
fb_size.y = p_size[up_axis];
- scene_data.cam_transform.origin = center + axis * half_extents;
+ scene_data.cam_transform.origin = center + axis * half_size;
scene_data.cam_transform.basis.set_column(0, right);
scene_data.cam_transform.basis.set_column(1, up);
scene_data.cam_transform.basis.set_column(2, axis);
//print_line("pass: " + itos(i) + " xform " + scene_data.cam_transform);
- float h_size = half_extents[right_axis];
- float v_size = half_extents[up_axis];
- float d_size = half_extents[i] * 2.0;
+ float h_size = half_size[right_axis];
+ float v_size = half_size[up_axis];
+ float d_size = half_size[i] * 2.0;
scene_data.cam_projection.set_orthogonal(-h_size, h_size, -v_size, v_size, 0, d_size);
//print_line("pass: " + itos(i) + " cam hsize: " + rtos(h_size) + " vsize: " + rtos(v_size) + " dsize " + rtos(d_size));
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
index 9245f1b13a..8eb17ba6f4 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
@@ -640,9 +640,9 @@ public:
RendererRD::SSEffects *get_ss_effects() { return ss_effects; }
/* callback from updating our lighting UBOs, used to populate cluster builder */
- virtual void setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_extents) override;
+ virtual void setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_size) override;
virtual void setup_added_light(const RS::LightType p_type, const Transform3D &p_transform, float p_radius, float p_spot_aperture) override;
- virtual void setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_extents) override;
+ virtual void setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_size) override;
virtual void base_uniforms_changed() override;
_FORCE_INLINE_ virtual void update_uniform_sets() override {
diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
index 2aaea4288b..d8e77366de 100644
--- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
@@ -625,6 +625,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "0";
actions.renames["VIEW_RIGHT"] = "1";
+ actions.renames["EYE_OFFSET"] = "eye_offset";
//for light
actions.renames["VIEW"] = "view";
diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
index f9eecf4dc7..cc4a7dfa47 100644
--- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
@@ -517,6 +517,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "0";
actions.renames["VIEW_RIGHT"] = "1";
+ actions.renames["EYE_OFFSET"] = "eye_offset";
//for light
actions.renames["VIEW"] = "view";
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
index 6fa2f7a570..7c43021eb0 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
@@ -204,9 +204,9 @@ public:
/* LIGHTING */
- virtual void setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_extents){};
+ virtual void setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_size){};
virtual void setup_added_light(const RS::LightType p_type, const Transform3D &p_transform, float p_radius, float p_spot_aperture){};
- virtual void setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_extents){};
+ virtual void setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_size){};
/* GI */
diff --git a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl
index 4658afd02d..8e4f5762fd 100644
--- a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl
+++ b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl
@@ -37,7 +37,7 @@ layout(push_constant, std430) uniform Params {
vec3 position;
float pad;
- vec3 extents;
+ vec3 size;
float pad2;
ivec3 corner;
@@ -184,36 +184,37 @@ void main() {
vec4 local_pos = params.transform * world;
local_pos.xyz /= local_pos.w;
+ vec3 half_size = params.size / 2.0;
float sdf = -1.0;
if (params.shape == 0) {
// Ellipsoid
// https://www.shadertoy.com/view/tdS3DG
- float k0 = length(local_pos.xyz / params.extents);
- float k1 = length(local_pos.xyz / (params.extents * params.extents));
+ float k0 = length(local_pos.xyz / half_size);
+ float k1 = length(local_pos.xyz / (half_size * half_size));
sdf = k0 * (k0 - 1.0) / k1;
} else if (params.shape == 1) {
// Cone
// https://iquilezles.org/www/articles/distfunctions/distfunctions.htm
- // Compute the cone angle automatically to fit within the volume's extents.
- float inv_height = 1.0 / max(0.001, params.extents.y);
- float radius = 1.0 / max(0.001, (min(params.extents.x, params.extents.z) * 0.5));
+ // Compute the cone angle automatically to fit within the volume's size.
+ float inv_height = 1.0 / max(0.001, half_size.y);
+ float radius = 1.0 / max(0.001, (min(half_size.x, half_size.z) * 0.5));
float hypotenuse = sqrt(radius * radius + inv_height * inv_height);
float rsin = radius / hypotenuse;
float rcos = inv_height / hypotenuse;
vec2 c = vec2(rsin, rcos);
float q = length(local_pos.xz);
- sdf = max(dot(c, vec2(q, local_pos.y - params.extents.y)), -params.extents.y - local_pos.y);
+ sdf = max(dot(c, vec2(q, local_pos.y - half_size.y)), -half_size.y - local_pos.y);
} else if (params.shape == 2) {
// Cylinder
// https://iquilezles.org/www/articles/distfunctions/distfunctions.htm
- vec2 d = abs(vec2(length(local_pos.xz), local_pos.y)) - vec2(min(params.extents.x, params.extents.z), params.extents.y);
+ vec2 d = abs(vec2(length(local_pos.xz), local_pos.y)) - vec2(min(half_size.x, half_size.z), half_size.y);
sdf = min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
} else if (params.shape == 3) {
// Box
// https://iquilezles.org/www/articles/distfunctions/distfunctions.htm
- vec3 q = abs(local_pos.xyz) - params.extents;
+ vec3 q = abs(local_pos.xyz) - half_size;
sdf = length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
@@ -222,7 +223,7 @@ void main() {
#ifndef SDF_USED
cull_mask = 1.0 - smoothstep(-0.1, 0.0, sdf);
#endif
- uvw = clamp((local_pos.xyz + params.extents) / (2.0 * params.extents), 0.0, 1.0);
+ uvw = clamp((local_pos.xyz + half_size) / params.size, 0.0, 1.0);
}
if (cull_mask > 0.0) {
diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl
index c6a3c42e57..21fa7fa148 100644
--- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl
@@ -315,9 +315,11 @@ void vertex_shader(in uint instance_index, in bool is_multimesh, in uint multime
#ifdef USE_MULTIVIEW
mat4 projection_matrix = scene_data.projection_matrix_view[ViewIndex];
mat4 inv_projection_matrix = scene_data.inv_projection_matrix_view[ViewIndex];
+ vec3 eye_offset = scene_data.eye_offset[ViewIndex].xyz;
#else
mat4 projection_matrix = scene_data.projection_matrix;
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;
+ vec3 eye_offset = vec3(0.0, 0.0, 0.0);
#endif //USE_MULTIVIEW
//using world coordinates
@@ -722,8 +724,10 @@ void fragment_shader(in SceneData scene_data) {
//lay out everything, whatever is unused is optimized away anyway
vec3 vertex = vertex_interp;
#ifdef USE_MULTIVIEW
- vec3 view = -normalize(vertex_interp - scene_data.eye_offset[ViewIndex].xyz);
+ vec3 eye_offset = scene_data.eye_offset[ViewIndex].xyz;
+ vec3 view = -normalize(vertex_interp - eye_offset);
#else
+ vec3 eye_offset = vec3(0.0, 0.0, 0.0);
vec3 view = -normalize(vertex_interp);
#endif
vec3 albedo = vec3(1.0);
diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl
index 90e902ca33..a8b28bbd4f 100644
--- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl
+++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl
@@ -314,9 +314,11 @@ void main() {
#ifdef USE_MULTIVIEW
mat4 projection_matrix = scene_data.projection_matrix_view[ViewIndex];
mat4 inv_projection_matrix = scene_data.inv_projection_matrix_view[ViewIndex];
+ vec3 eye_offset = scene_data.eye_offset[ViewIndex].xyz;
#else
mat4 projection_matrix = scene_data.projection_matrix;
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;
+ vec3 eye_offset = vec3(0.0, 0.0, 0.0);
#endif //USE_MULTIVIEW
//using world coordinates
@@ -671,8 +673,10 @@ void main() {
//lay out everything, whatever is unused is optimized away anyway
vec3 vertex = vertex_interp;
#ifdef USE_MULTIVIEW
- vec3 view = -normalize(vertex_interp - scene_data.eye_offset[ViewIndex].xyz);
+ vec3 eye_offset = scene_data.eye_offset[ViewIndex].xyz;
+ vec3 view = -normalize(vertex_interp - eye_offset);
#else
+ vec3 eye_offset = vec3(0.0, 0.0, 0.0);
vec3 view = -normalize(vertex_interp);
#endif
vec3 albedo = vec3(1.0);
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
index f56cee9e12..968f804593 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
@@ -1066,14 +1066,14 @@ void LightStorage::reflection_probe_set_max_distance(RID p_probe, float p_distan
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
}
-void LightStorage::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
+void LightStorage::reflection_probe_set_size(RID p_probe, const Vector3 &p_size) {
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
- if (reflection_probe->extents == p_extents) {
+ if (reflection_probe->size == p_size) {
return;
}
- reflection_probe->extents = p_extents;
+ reflection_probe->size = p_size;
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
}
@@ -1145,8 +1145,8 @@ AABB LightStorage::reflection_probe_get_aabb(RID p_probe) const {
ERR_FAIL_COND_V(!reflection_probe, AABB());
AABB aabb;
- aabb.position = -reflection_probe->extents;
- aabb.size = reflection_probe->extents * 2.0;
+ aabb.position = -reflection_probe->size / 2;
+ aabb.size = reflection_probe->size;
return aabb;
}
@@ -1165,11 +1165,11 @@ uint32_t LightStorage::reflection_probe_get_cull_mask(RID p_probe) const {
return reflection_probe->cull_mask;
}
-Vector3 LightStorage::reflection_probe_get_extents(RID p_probe) const {
+Vector3 LightStorage::reflection_probe_get_size(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
- return reflection_probe->extents;
+ return reflection_probe->size;
}
Vector3 LightStorage::reflection_probe_get_origin_offset(RID p_probe) const {
@@ -1674,7 +1674,7 @@ void LightStorage::update_reflection_probe_buffer(RenderDataRD *p_render_data, c
ReflectionData &reflection_ubo = reflections[i];
- Vector3 extents = probe->extents;
+ Vector3 extents = probe->size / 2;
rpi->cull_mask = probe->cull_mask;
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.h b/servers/rendering/renderer_rd/storage_rd/light_storage.h
index d359219128..68f439ddef 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.h
@@ -226,7 +226,7 @@ private:
Color ambient_color;
float ambient_color_energy = 1.0;
float max_distance = 0;
- Vector3 extents = Vector3(10, 10, 10);
+ Vector3 size = Vector3(20, 20, 20);
Vector3 origin_offset;
bool interior = false;
bool box_projection = false;
@@ -791,7 +791,7 @@ public:
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) override;
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) override;
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) override;
- virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) override;
+ virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) override;
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) override;
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) override;
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) override;
@@ -805,7 +805,7 @@ public:
virtual AABB reflection_probe_get_aabb(RID p_probe) const override;
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const override;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const override;
- virtual Vector3 reflection_probe_get_extents(RID p_probe) const override;
+ virtual Vector3 reflection_probe_get_size(RID p_probe) const override;
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const override;
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const override;
virtual float reflection_probe_get_mesh_lod_threshold(RID p_probe) const override;
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index 9124886764..f65676185c 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -986,7 +986,10 @@ void MeshStorage::update_mesh_instances() {
push_constant.skin_stride = (mi->mesh->surfaces[i]->skin_buffer_size / mi->mesh->surfaces[i]->vertex_count) / 4;
push_constant.skin_weight_offset = (mi->mesh->surfaces[i]->format & RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 4 : 2;
- Transform2D transform = mi->canvas_item_transform_2d.affine_inverse() * sk->base_transform_2d;
+ Transform2D transform = Transform2D();
+ if (sk && sk->use_2d) {
+ transform = mi->canvas_item_transform_2d.affine_inverse() * sk->base_transform_2d;
+ }
push_constant.skeleton_transform_x[0] = transform.columns[0][0];
push_constant.skeleton_transform_x[1] = transform.columns[0][1];
push_constant.skeleton_transform_y[0] = transform.columns[1][0];
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
index 2eaa7824fb..5d845ce510 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
@@ -1853,10 +1853,10 @@ void TextureStorage::decal_free(RID p_rid) {
decal_owner.free(p_rid);
}
-void TextureStorage::decal_set_extents(RID p_decal, const Vector3 &p_extents) {
+void TextureStorage::decal_set_size(RID p_decal, const Vector3 &p_size) {
Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
- decal->extents = p_extents;
+ decal->size = p_size;
decal->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
}
@@ -1949,7 +1949,7 @@ AABB TextureStorage::decal_get_aabb(RID p_decal) const {
Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND_V(!decal, AABB());
- return AABB(-decal->extents, decal->extents * 2.0);
+ return AABB(-decal->size / 2, decal->size);
}
Dependency *TextureStorage::decal_get_dependency(RID p_decal) {
@@ -2312,7 +2312,7 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const
DecalData &dd = decals[i];
- Vector3 decal_extents = decal->extents;
+ Vector3 decal_extents = decal->size / 2;
Transform3D scale_xform;
scale_xform.basis.scale(decal_extents);
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h
index ea0df0b459..aeab3bf3cb 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h
@@ -235,7 +235,7 @@ private:
} decal_atlas;
struct Decal {
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 size = Vector3(2, 2, 2);
RID textures[RS::DECAL_TEXTURE_MAX];
float emission_energy = 1.0;
float albedo_mix = 1.0;
@@ -561,7 +561,7 @@ public:
virtual void decal_initialize(RID p_decal) override;
virtual void decal_free(RID p_rid) override;
- virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) override;
+ virtual void decal_set_size(RID p_decal, const Vector3 &p_size) override;
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) override;
virtual void decal_set_emission_energy(RID p_decal, float p_energy) override;
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) override;
@@ -577,9 +577,9 @@ public:
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;
- _FORCE_INLINE_ Vector3 decal_get_extents(RID p_decal) {
+ _FORCE_INLINE_ Vector3 decal_get_size(RID p_decal) {
const Decal *decal = decal_owner.get_or_null(p_decal);
- return decal->extents;
+ return decal->size;
}
_FORCE_INLINE_ RID decal_get_texture(RID p_decal, RS::DecalTexture p_texture) {
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index 6f4bb115fc..d696955800 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -3396,13 +3396,13 @@ bool RendererSceneCull::_render_reflection_probe_step(Instance *p_instance, int
Vector3(0, -1, 0)
};
- Vector3 extents = RSG::light_storage->reflection_probe_get_extents(p_instance->base);
+ Vector3 probe_size = RSG::light_storage->reflection_probe_get_size(p_instance->base);
Vector3 origin_offset = RSG::light_storage->reflection_probe_get_origin_offset(p_instance->base);
float max_distance = RSG::light_storage->reflection_probe_get_origin_max_distance(p_instance->base);
- float size = RSG::light_storage->reflection_atlas_get_size(scenario->reflection_atlas);
- float mesh_lod_threshold = RSG::light_storage->reflection_probe_get_mesh_lod_threshold(p_instance->base) / size;
+ float atlas_size = RSG::light_storage->reflection_atlas_get_size(scenario->reflection_atlas);
+ float mesh_lod_threshold = RSG::light_storage->reflection_probe_get_mesh_lod_threshold(p_instance->base) / atlas_size;
- Vector3 edge = view_normals[p_step] * extents;
+ Vector3 edge = view_normals[p_step] * probe_size / 2;
float distance = ABS(view_normals[p_step].dot(edge) - view_normals[p_step].dot(origin_offset)); //distance from origin offset to actual view distance limit
max_distance = MAX(max_distance, distance);
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index bcaaba8d65..4f52a63b2f 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -387,7 +387,7 @@ public:
FUNC2(reflection_probe_set_ambient_energy, RID, float)
FUNC2(reflection_probe_set_ambient_mode, RID, ReflectionProbeAmbientMode)
FUNC2(reflection_probe_set_max_distance, RID, float)
- FUNC2(reflection_probe_set_extents, RID, const Vector3 &)
+ FUNC2(reflection_probe_set_size, RID, const Vector3 &)
FUNC2(reflection_probe_set_origin_offset, RID, const Vector3 &)
FUNC2(reflection_probe_set_as_interior, RID, bool)
FUNC2(reflection_probe_set_enable_box_projection, RID, bool)
@@ -428,7 +428,7 @@ public:
FUNCRIDSPLIT(decal)
- FUNC2(decal_set_extents, RID, const Vector3 &)
+ FUNC2(decal_set_size, RID, const Vector3 &)
FUNC3(decal_set_texture, RID, DecalTexture, RID)
FUNC2(decal_set_emission_energy, RID, float)
FUNC2(decal_set_albedo_mix, RID, float)
@@ -540,7 +540,7 @@ public:
FUNCRIDSPLIT(fog_volume)
FUNC2(fog_volume_set_shape, RID, FogVolumeShape)
- FUNC2(fog_volume_set_extents, RID, const Vector3 &)
+ FUNC2(fog_volume_set_size, RID, const Vector3 &)
FUNC2(fog_volume_set_material, RID, RID)
/* VISIBILITY_NOTIFIER */
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index ba39328b2e..56d00fa1bb 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -106,6 +106,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEW_INDEX"] = constt(ShaderLanguage::TYPE_INT);
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEW_MONO_LEFT"] = constt(ShaderLanguage::TYPE_INT);
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEW_RIGHT"] = constt(ShaderLanguage::TYPE_INT);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["EYE_OFFSET"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
@@ -151,6 +152,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW_INDEX"] = constt(ShaderLanguage::TYPE_INT);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW_MONO_LEFT"] = constt(ShaderLanguage::TYPE_INT);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW_RIGHT"] = constt(ShaderLanguage::TYPE_INT);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["EYE_OFFSET"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
@@ -464,7 +466,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["WORLD_POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["OBJECT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["UVW"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["EXTENTS"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["SIZE"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["SDF"] = constt(ShaderLanguage::TYPE_FLOAT);
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["DENSITY"] = ShaderLanguage::TYPE_FLOAT;
diff --git a/servers/rendering/storage/light_storage.h b/servers/rendering/storage/light_storage.h
index 413f06bc5b..9f3f5dd8e4 100644
--- a/servers/rendering/storage/light_storage.h
+++ b/servers/rendering/storage/light_storage.h
@@ -110,7 +110,7 @@ public:
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) = 0;
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) = 0;
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
- virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) = 0;
+ virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) = 0;
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
@@ -121,7 +121,7 @@ public:
virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0;
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0;
- virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0;
+ virtual Vector3 reflection_probe_get_size(RID p_probe) const = 0;
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const = 0;
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const = 0;
virtual bool reflection_probe_renders_shadows(RID p_probe) const = 0;
diff --git a/servers/rendering/storage/texture_storage.h b/servers/rendering/storage/texture_storage.h
index 4c4a84d04e..3a9034ad0d 100644
--- a/servers/rendering/storage/texture_storage.h
+++ b/servers/rendering/storage/texture_storage.h
@@ -107,7 +107,7 @@ public:
virtual void decal_initialize(RID p_rid) = 0;
virtual void decal_free(RID p_rid) = 0;
- virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) = 0;
+ virtual void decal_set_size(RID p_decal, const Vector3 &p_size) = 0;
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) = 0;
virtual void decal_set_emission_energy(RID p_decal, float p_energy) = 0;
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) = 0;
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index cea7912574..1c19b9dcd0 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -1968,7 +1968,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_color", "probe", "color"), &RenderingServer::reflection_probe_set_ambient_color);
ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_ambient_energy);
ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &RenderingServer::reflection_probe_set_extents);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_size", "probe", "size"), &RenderingServer::reflection_probe_set_size);
ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);
ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);
ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);
@@ -1987,7 +1987,7 @@ void RenderingServer::_bind_methods() {
/* DECAL */
ClassDB::bind_method(D_METHOD("decal_create"), &RenderingServer::decal_create);
- ClassDB::bind_method(D_METHOD("decal_set_extents", "decal", "extents"), &RenderingServer::decal_set_extents);
+ ClassDB::bind_method(D_METHOD("decal_set_size", "decal", "size"), &RenderingServer::decal_set_size);
ClassDB::bind_method(D_METHOD("decal_set_texture", "decal", "type", "texture"), &RenderingServer::decal_set_texture);
ClassDB::bind_method(D_METHOD("decal_set_emission_energy", "decal", "energy"), &RenderingServer::decal_set_emission_energy);
ClassDB::bind_method(D_METHOD("decal_set_albedo_mix", "decal", "albedo_mix"), &RenderingServer::decal_set_albedo_mix);
@@ -2147,7 +2147,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("fog_volume_create"), &RenderingServer::fog_volume_create);
ClassDB::bind_method(D_METHOD("fog_volume_set_shape", "fog_volume", "shape"), &RenderingServer::fog_volume_set_shape);
- ClassDB::bind_method(D_METHOD("fog_volume_set_extents", "fog_volume", "extents"), &RenderingServer::fog_volume_set_extents);
+ ClassDB::bind_method(D_METHOD("fog_volume_set_size", "fog_volume", "size"), &RenderingServer::fog_volume_set_size);
ClassDB::bind_method(D_METHOD("fog_volume_set_material", "fog_volume", "material"), &RenderingServer::fog_volume_set_material);
BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_ELLIPSOID);
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index b416ed30e2..1f9bff7c3f 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -541,7 +541,7 @@ public:
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) = 0;
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) = 0;
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
- virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) = 0;
+ virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) = 0;
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
@@ -561,7 +561,7 @@ public:
};
virtual RID decal_create() = 0;
- virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) = 0;
+ virtual void decal_set_size(RID p_decal, const Vector3 &p_size) = 0;
virtual void decal_set_texture(RID p_decal, DecalTexture p_type, RID p_texture) = 0;
virtual void decal_set_emission_energy(RID p_decal, float p_energy) = 0;
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) = 0;
@@ -750,7 +750,7 @@ public:
};
virtual void fog_volume_set_shape(RID p_fog_volume, FogVolumeShape p_shape) = 0;
- virtual void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) = 0;
+ virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) = 0;
virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) = 0;
/* VISIBILITY NOTIFIER API */
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 38001b8782..38ace2c2e3 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -376,7 +376,7 @@ File extracted from upstream release tarball:
## meshoptimizer
- Upstream: https://github.com/zeux/meshoptimizer
-- Version: git (ea4558d1c0f217f1d67ed7fe0b07896ece88ae18, 2022)
+- Version: git (4a287848fd664ae1c3fc8e5e008560534ceeb526, 2022)
- License: MIT
Files extracted from upstream repository:
diff --git a/thirdparty/meshoptimizer/LICENSE.md b/thirdparty/meshoptimizer/LICENSE.md
index 3c52415f62..b673c248b2 100644
--- a/thirdparty/meshoptimizer/LICENSE.md
+++ b/thirdparty/meshoptimizer/LICENSE.md
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2016-2021 Arseny Kapoulkine
+Copyright (c) 2016-2022 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/thirdparty/meshoptimizer/clusterizer.cpp b/thirdparty/meshoptimizer/clusterizer.cpp
index b1f7b359c1..c4672ad606 100644
--- a/thirdparty/meshoptimizer/clusterizer.cpp
+++ b/thirdparty/meshoptimizer/clusterizer.cpp
@@ -283,6 +283,79 @@ static bool appendMeshlet(meshopt_Meshlet& meshlet, unsigned int a, unsigned int
return result;
}
+static unsigned int getNeighborTriangle(const meshopt_Meshlet& meshlet, const Cone* meshlet_cone, unsigned int* meshlet_vertices, const unsigned int* indices, const TriangleAdjacency2& adjacency, const Cone* triangles, const unsigned int* live_triangles, const unsigned char* used, float meshlet_expected_radius, float cone_weight, unsigned int* out_extra)
+{
+ unsigned int best_triangle = ~0u;
+ unsigned int best_extra = 5;
+ float best_score = FLT_MAX;
+
+ for (size_t i = 0; i < meshlet.vertex_count; ++i)
+ {
+ unsigned int index = meshlet_vertices[meshlet.vertex_offset + i];
+
+ unsigned int* neighbors = &adjacency.data[0] + adjacency.offsets[index];
+ size_t neighbors_size = adjacency.counts[index];
+
+ for (size_t j = 0; j < neighbors_size; ++j)
+ {
+ unsigned int triangle = neighbors[j];
+ unsigned int a = indices[triangle * 3 + 0], b = indices[triangle * 3 + 1], c = indices[triangle * 3 + 2];
+
+ unsigned int extra = (used[a] == 0xff) + (used[b] == 0xff) + (used[c] == 0xff);
+
+ // triangles that don't add new vertices to meshlets are max. priority
+ if (extra != 0)
+ {
+ // artificially increase the priority of dangling triangles as they're expensive to add to new meshlets
+ if (live_triangles[a] == 1 || live_triangles[b] == 1 || live_triangles[c] == 1)
+ extra = 0;
+
+ extra++;
+ }
+
+ // since topology-based priority is always more important than the score, we can skip scoring in some cases
+ if (extra > best_extra)
+ continue;
+
+ float score = 0;
+
+ // caller selects one of two scoring functions: geometrical (based on meshlet cone) or topological (based on remaining triangles)
+ if (meshlet_cone)
+ {
+ const Cone& tri_cone = triangles[triangle];
+
+ float distance2 =
+ (tri_cone.px - meshlet_cone->px) * (tri_cone.px - meshlet_cone->px) +
+ (tri_cone.py - meshlet_cone->py) * (tri_cone.py - meshlet_cone->py) +
+ (tri_cone.pz - meshlet_cone->pz) * (tri_cone.pz - meshlet_cone->pz);
+
+ float spread = tri_cone.nx * meshlet_cone->nx + tri_cone.ny * meshlet_cone->ny + tri_cone.nz * meshlet_cone->nz;
+
+ score = getMeshletScore(distance2, spread, cone_weight, meshlet_expected_radius);
+ }
+ else
+ {
+ // each live_triangles entry is >= 1 since it includes the current triangle we're processing
+ score = float(live_triangles[a] + live_triangles[b] + live_triangles[c] - 3);
+ }
+
+ // note that topology-based priority is always more important than the score
+ // this helps maintain reasonable effectiveness of meshlet data and reduces scoring cost
+ if (extra < best_extra || score < best_score)
+ {
+ best_triangle = triangle;
+ best_extra = extra;
+ best_score = score;
+ }
+ }
+ }
+
+ if (out_extra)
+ *out_extra = best_extra;
+
+ return best_triangle;
+}
+
struct KDNode
{
union
@@ -464,13 +537,15 @@ size_t meshopt_buildMeshlets(meshopt_Meshlet* meshlets, unsigned int* meshlet_ve
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
assert(max_vertices >= 3 && max_vertices <= kMeshletMaxVertices);
assert(max_triangles >= 1 && max_triangles <= kMeshletMaxTriangles);
assert(max_triangles % 4 == 0); // ensures the caller will compute output space properly as index data is 4b aligned
+ assert(cone_weight >= 0 && cone_weight <= 1);
+
meshopt_Allocator allocator;
TriangleAdjacency2 adjacency = {};
@@ -511,65 +586,18 @@ size_t meshopt_buildMeshlets(meshopt_Meshlet* meshlets, unsigned int* meshlet_ve
for (;;)
{
- unsigned int best_triangle = ~0u;
- unsigned int best_extra = 5;
- float best_score = FLT_MAX;
-
Cone meshlet_cone = getMeshletCone(meshlet_cone_acc, meshlet.triangle_count);
- for (size_t i = 0; i < meshlet.vertex_count; ++i)
- {
- unsigned int index = meshlet_vertices[meshlet.vertex_offset + i];
-
- unsigned int* neighbours = &adjacency.data[0] + adjacency.offsets[index];
- size_t neighbours_size = adjacency.counts[index];
-
- for (size_t j = 0; j < neighbours_size; ++j)
- {
- unsigned int triangle = neighbours[j];
- assert(!emitted_flags[triangle]);
-
- unsigned int a = indices[triangle * 3 + 0], b = indices[triangle * 3 + 1], c = indices[triangle * 3 + 2];
- assert(a < vertex_count && b < vertex_count && c < vertex_count);
-
- unsigned int extra = (used[a] == 0xff) + (used[b] == 0xff) + (used[c] == 0xff);
-
- // triangles that don't add new vertices to meshlets are max. priority
- if (extra != 0)
- {
- // artificially increase the priority of dangling triangles as they're expensive to add to new meshlets
- if (live_triangles[a] == 1 || live_triangles[b] == 1 || live_triangles[c] == 1)
- extra = 0;
-
- extra++;
- }
-
- // since topology-based priority is always more important than the score, we can skip scoring in some cases
- if (extra > best_extra)
- continue;
-
- const Cone& tri_cone = triangles[triangle];
-
- float distance2 =
- (tri_cone.px - meshlet_cone.px) * (tri_cone.px - meshlet_cone.px) +
- (tri_cone.py - meshlet_cone.py) * (tri_cone.py - meshlet_cone.py) +
- (tri_cone.pz - meshlet_cone.pz) * (tri_cone.pz - meshlet_cone.pz);
-
- float spread = tri_cone.nx * meshlet_cone.nx + tri_cone.ny * meshlet_cone.ny + tri_cone.nz * meshlet_cone.nz;
+ unsigned int best_extra = 0;
+ unsigned int best_triangle = getNeighborTriangle(meshlet, &meshlet_cone, meshlet_vertices, indices, adjacency, triangles, live_triangles, used, meshlet_expected_radius, cone_weight, &best_extra);
- float score = getMeshletScore(distance2, spread, cone_weight, meshlet_expected_radius);
-
- // note that topology-based priority is always more important than the score
- // this helps maintain reasonable effectiveness of meshlet data and reduces scoring cost
- if (extra < best_extra || score < best_score)
- {
- best_triangle = triangle;
- best_extra = extra;
- best_score = score;
- }
- }
+ // if the best triangle doesn't fit into current meshlet, the spatial scoring we've used is not very meaningful, so we re-select using topological scoring
+ if (best_triangle != ~0u && (meshlet.vertex_count + best_extra > max_vertices || meshlet.triangle_count >= max_triangles))
+ {
+ best_triangle = getNeighborTriangle(meshlet, NULL, meshlet_vertices, indices, adjacency, triangles, live_triangles, used, meshlet_expected_radius, 0.f, NULL);
}
+ // when we run out of neighboring triangles we need to switch to spatial search; we currently just pick the closest triangle irrespective of connectivity
if (best_triangle == ~0u)
{
float position[3] = {meshlet_cone.px, meshlet_cone.py, meshlet_cone.pz};
@@ -604,16 +632,16 @@ size_t meshopt_buildMeshlets(meshopt_Meshlet* meshlets, unsigned int* meshlet_ve
{
unsigned int index = indices[best_triangle * 3 + k];
- unsigned int* neighbours = &adjacency.data[0] + adjacency.offsets[index];
- size_t neighbours_size = adjacency.counts[index];
+ unsigned int* neighbors = &adjacency.data[0] + adjacency.offsets[index];
+ size_t neighbors_size = adjacency.counts[index];
- for (size_t i = 0; i < neighbours_size; ++i)
+ for (size_t i = 0; i < neighbors_size; ++i)
{
- unsigned int tri = neighbours[i];
+ unsigned int tri = neighbors[i];
if (tri == best_triangle)
{
- neighbours[i] = neighbours[neighbours_size - 1];
+ neighbors[i] = neighbors[neighbors_size - 1];
adjacency.counts[index]--;
break;
}
@@ -687,7 +715,7 @@ meshopt_Bounds meshopt_computeClusterBounds(const unsigned int* indices, size_t
assert(index_count % 3 == 0);
assert(index_count / 3 <= kMeshletMaxTriangles);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
(void)vertex_count;
@@ -839,7 +867,7 @@ meshopt_Bounds meshopt_computeMeshletBounds(const unsigned int* meshlet_vertices
using namespace meshopt;
assert(triangle_count <= kMeshletMaxTriangles);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
unsigned int indices[kMeshletMaxTriangles * 3];
diff --git a/thirdparty/meshoptimizer/indexgenerator.cpp b/thirdparty/meshoptimizer/indexgenerator.cpp
index f60db0dc4f..cad808a2b1 100644
--- a/thirdparty/meshoptimizer/indexgenerator.cpp
+++ b/thirdparty/meshoptimizer/indexgenerator.cpp
@@ -187,7 +187,7 @@ size_t meshopt_generateVertexRemap(unsigned int* destination, const unsigned int
using namespace meshopt;
assert(indices || index_count == vertex_count);
- assert(index_count % 3 == 0);
+ assert(!indices || index_count % 3 == 0);
assert(vertex_size > 0 && vertex_size <= 256);
meshopt_Allocator allocator;
@@ -412,7 +412,7 @@ void meshopt_generateAdjacencyIndexBuffer(unsigned int* destination, const unsig
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
meshopt_Allocator allocator;
@@ -483,7 +483,7 @@ void meshopt_generateTessellationIndexBuffer(unsigned int* destination, const un
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
meshopt_Allocator allocator;
diff --git a/thirdparty/meshoptimizer/meshoptimizer.h b/thirdparty/meshoptimizer/meshoptimizer.h
index 463fad29da..46d28d3ea3 100644
--- a/thirdparty/meshoptimizer/meshoptimizer.h
+++ b/thirdparty/meshoptimizer/meshoptimizer.h
@@ -1,7 +1,7 @@
/**
- * meshoptimizer - version 0.17
+ * meshoptimizer - version 0.18
*
- * Copyright (C) 2016-2021, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (C) 2016-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://github.com/zeux/meshoptimizer
*
* This library is distributed under the MIT License. See notice at the end of this file.
@@ -12,7 +12,7 @@
#include <stddef.h>
/* Version macro; major * 1000 + minor * 10 + patch */
-#define MESHOPTIMIZER_VERSION 170 /* 0.17 */
+#define MESHOPTIMIZER_VERSION 180 /* 0.18 */
/* If no API is defined, assume default */
#ifndef MESHOPTIMIZER_API
@@ -37,8 +37,8 @@ extern "C" {
#endif
/**
- * Vertex attribute stream, similar to glVertexPointer
- * Each element takes size bytes, with stride controlling the spacing between successive elements.
+ * Vertex attribute stream
+ * Each element takes size bytes, beginning at data, with stride controlling the spacing between successive elements (stride >= size).
*/
struct meshopt_Stream
{
@@ -115,7 +115,7 @@ MESHOPTIMIZER_API void meshopt_generateShadowIndexBufferMulti(unsigned int* dest
* This can be used to implement algorithms like silhouette detection/expansion and other forms of GS-driven rendering.
*
* destination must contain enough space for the resulting index buffer (index_count*2 elements)
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
*/
MESHOPTIMIZER_API void meshopt_generateAdjacencyIndexBuffer(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
@@ -131,7 +131,7 @@ MESHOPTIMIZER_API void meshopt_generateAdjacencyIndexBuffer(unsigned int* destin
* See "Tessellation on Any Budget" (John McDonald, GDC 2011) for implementation details.
*
* destination must contain enough space for the resulting index buffer (index_count*4 elements)
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
*/
MESHOPTIMIZER_API void meshopt_generateTessellationIndexBuffer(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
@@ -171,7 +171,7 @@ MESHOPTIMIZER_API void meshopt_optimizeVertexCacheFifo(unsigned int* destination
*
* destination must contain enough space for the resulting index buffer (index_count elements)
* indices must contain index data that is the result of meshopt_optimizeVertexCache (*not* the original mesh indices!)
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
* threshold indicates how much the overdraw optimizer can degrade vertex cache efficiency (1.05 = up to 5%) to reduce overdraw more efficiently
*/
MESHOPTIMIZER_API void meshopt_optimizeOverdraw(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float threshold);
@@ -313,7 +313,21 @@ MESHOPTIMIZER_EXPERIMENTAL void meshopt_encodeFilterQuat(void* destination, size
MESHOPTIMIZER_EXPERIMENTAL void meshopt_encodeFilterExp(void* destination, size_t count, size_t stride, int bits, const float* data);
/**
- * Experimental: Mesh simplifier
+ * Simplification options
+ */
+enum
+{
+ /* Do not move vertices that are located on the topological border (vertices on triangle edges that don't have a paired triangle). Useful for simplifying portions of the larger mesh. */
+ meshopt_SimplifyLockBorder = 1 << 0,
+};
+
+/**
+ * Experimental: Mesh simplifier with attribute metric; attributes follow xyz position data atm (vertex data must contain 3 + attribute_count floats per vertex)
+ */
+MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error, const float* attributes, const float* attribute_weights, size_t attribute_count);
+
+/**
+ * Mesh simplifier
* Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible
* The algorithm tries to preserve mesh topology and can stop short of the target goal based on topology constraints or target error.
* If not all attributes from the input mesh are required, it's recommended to reindex the mesh using meshopt_generateShadowIndexBuffer prior to simplification.
@@ -322,16 +336,12 @@ MESHOPTIMIZER_EXPERIMENTAL void meshopt_encodeFilterExp(void* destination, size_
* If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
*
* destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
- * target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
+ * target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
+ * options must be a bitmask composed of meshopt_SimplifyX options; 0 is a safe default
* result_error can be NULL; when it's not NULL, it will contain the resulting (relative) error after simplification
*/
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error);
-
-/**
- * Experimental: Mesh simplifier with attribute metric; attributes follow xyz position data atm (vertex data must contain 3 + attribute_count floats per vertex)
- */
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, float* result_error, const float* attributes, const float* attribute_weights, size_t attribute_count);
+MESHOPTIMIZER_API size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error);
/**
* Experimental: Mesh simplifier (sloppy)
@@ -342,8 +352,8 @@ MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyWithAttributes(unsigned int* d
* If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
*
* destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
- * target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
+ * target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
* result_error can be NULL; when it's not NULL, it will contain the resulting (relative) error after simplification
*/
MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifySloppy(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error);
@@ -356,17 +366,17 @@ MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifySloppy(unsigned int* destinati
* If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
*
* destination must contain enough space for the target index buffer (target_vertex_count elements)
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
*/
MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyPoints(unsigned int* destination, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_vertex_count);
/**
- * Experimental: Returns the error scaling factor used by the simplifier to convert between absolute and relative extents
+ * Returns the error scaling factor used by the simplifier to convert between absolute and relative extents
*
* Absolute error must be *divided* by the scaling factor before passing it to meshopt_simplify as target_error
* Relative error returned by meshopt_simplify via result_error must be *multiplied* by the scaling factor to get absolute error.
*/
-MESHOPTIMIZER_EXPERIMENTAL float meshopt_simplifyScale(const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
+MESHOPTIMIZER_API float meshopt_simplifyScale(const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
/**
* Mesh stripifier
@@ -418,7 +428,7 @@ struct meshopt_OverdrawStatistics
* Returns overdraw statistics using a software rasterizer
* Results may not match actual GPU performance
*
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
*/
MESHOPTIMIZER_API struct meshopt_OverdrawStatistics meshopt_analyzeOverdraw(const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
@@ -456,7 +466,7 @@ struct meshopt_Meshlet
* meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound
* meshlet_vertices must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_vertices
* meshlet_triangles must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_triangles * 3
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
* max_vertices and max_triangles must not exceed implementation limits (max_vertices <= 255 - not 256!, max_triangles <= 512)
* cone_weight should be set to 0 when cone culling is not used, and a value between 0 and 1 otherwise to balance between cluster size and cone culling efficiency
*/
@@ -498,7 +508,7 @@ struct meshopt_Bounds
* The formula that uses the apex is slightly more accurate but needs the apex; if you are already using bounding sphere
* to do frustum/occlusion culling, the formula that doesn't use the apex may be preferable.
*
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
* index_count/3 should be less than or equal to 512 (the function assumes clusters of limited size)
*/
MESHOPTIMIZER_API struct meshopt_Bounds meshopt_computeClusterBounds(const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
@@ -518,7 +528,7 @@ MESHOPTIMIZER_EXPERIMENTAL void meshopt_spatialSortRemap(unsigned int* destinati
* Reorders triangles for spatial locality, and generates a new index buffer. The resulting index buffer can be used with other functions like optimizeVertexCache.
*
* destination must contain enough space for the resulting index buffer (index_count elements)
- * vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
*/
MESHOPTIMIZER_EXPERIMENTAL void meshopt_spatialSortTriangles(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
@@ -610,7 +620,7 @@ inline size_t meshopt_encodeIndexSequence(unsigned char* buffer, size_t buffer_s
template <typename T>
inline int meshopt_decodeIndexSequence(T* destination, size_t index_count, const unsigned char* buffer, size_t buffer_size);
template <typename T>
-inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error = 0);
+inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options = 0, float* result_error = 0);
template <typename T>
inline size_t meshopt_simplifySloppy(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error = 0);
template <typename T>
@@ -945,12 +955,12 @@ inline int meshopt_decodeIndexSequence(T* destination, size_t index_count, const
}
template <typename T>
-inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error)
+inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error)
{
meshopt_IndexAdapter<T> in(0, indices, index_count);
meshopt_IndexAdapter<T> out(destination, 0, index_count);
- return meshopt_simplify(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, target_index_count, target_error, result_error);
+ return meshopt_simplify(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, target_index_count, target_error, options, result_error);
}
template <typename T>
@@ -1039,7 +1049,7 @@ inline void meshopt_spatialSortTriangles(T* destination, const T* indices, size_
#endif
/**
- * Copyright (c) 2016-2021 Arseny Kapoulkine
+ * Copyright (c) 2016-2022 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/thirdparty/meshoptimizer/overdrawanalyzer.cpp b/thirdparty/meshoptimizer/overdrawanalyzer.cpp
index 8d5859ba39..8b6f254134 100644
--- a/thirdparty/meshoptimizer/overdrawanalyzer.cpp
+++ b/thirdparty/meshoptimizer/overdrawanalyzer.cpp
@@ -147,7 +147,7 @@ meshopt_OverdrawStatistics meshopt_analyzeOverdraw(const unsigned int* indices,
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
meshopt_Allocator allocator;
diff --git a/thirdparty/meshoptimizer/overdrawoptimizer.cpp b/thirdparty/meshoptimizer/overdrawoptimizer.cpp
index 143656ed76..cc22dbcffc 100644
--- a/thirdparty/meshoptimizer/overdrawoptimizer.cpp
+++ b/thirdparty/meshoptimizer/overdrawoptimizer.cpp
@@ -272,7 +272,7 @@ void meshopt_optimizeOverdraw(unsigned int* destination, const unsigned int* ind
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
meshopt_Allocator allocator;
diff --git a/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch b/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch
index 21daac6eec..5cac985dc5 100644
--- a/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch
+++ b/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch
@@ -1,5 +1,5 @@
diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp
-index 5e92e2dc73..e40c141e76 100644
+index d8d4a67391..3847afc736 100644
--- a/thirdparty/meshoptimizer/simplifier.cpp
+++ b/thirdparty/meshoptimizer/simplifier.cpp
@@ -20,7 +20,7 @@
@@ -11,7 +11,7 @@ index 5e92e2dc73..e40c141e76 100644
// This work is based on:
// Michael Garland and Paul S. Heckbert. Surface simplification using quadric error metrics. 1997
-@@ -453,6 +453,7 @@ struct Collapse
+@@ -458,6 +458,7 @@ struct Collapse
float error;
unsigned int errorui;
};
@@ -19,7 +19,7 @@ index 5e92e2dc73..e40c141e76 100644
};
static float normalize(Vector3& v)
-@@ -533,6 +534,34 @@ static float quadricError(const Quadric& Q, const Vector3& v)
+@@ -538,6 +539,34 @@ static float quadricError(const Quadric& Q, const Vector3& v)
return fabsf(r) * s;
}
@@ -54,7 +54,7 @@ index 5e92e2dc73..e40c141e76 100644
static void quadricFromPlane(Quadric& Q, float a, float b, float c, float d, float w)
{
float aw = a * w;
-@@ -688,7 +717,7 @@ static void quadricUpdateAttributes(Quadric& Q, const Vector3& p0, const Vector3
+@@ -693,7 +722,7 @@ static void quadricUpdateAttributes(Quadric& Q, const Vector3& p0, const Vector3
}
#endif
@@ -63,7 +63,7 @@ index 5e92e2dc73..e40c141e76 100644
{
for (size_t i = 0; i < index_count; i += 3)
{
-@@ -698,6 +727,9 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+@@ -703,6 +732,9 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
Quadric Q;
quadricFromTriangle(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], 1.f);
@@ -73,7 +73,7 @@ index 5e92e2dc73..e40c141e76 100644
#if ATTRIBUTES
quadricUpdateAttributes(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], Q.w);
-@@ -708,7 +740,7 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+@@ -713,7 +745,7 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
}
}
@@ -82,7 +82,7 @@ index 5e92e2dc73..e40c141e76 100644
{
for (size_t i = 0; i < index_count; i += 3)
{
-@@ -752,6 +784,9 @@ static void fillEdgeQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+@@ -757,6 +789,9 @@ static void fillEdgeQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
quadricAdd(vertex_quadrics[remap[i0]], Q);
quadricAdd(vertex_quadrics[remap[i1]], Q);
@@ -92,7 +92,7 @@ index 5e92e2dc73..e40c141e76 100644
}
}
}
-@@ -856,7 +891,7 @@ static size_t pickEdgeCollapses(Collapse* collapses, const unsigned int* indices
+@@ -861,7 +896,7 @@ static size_t pickEdgeCollapses(Collapse* collapses, const unsigned int* indices
return collapse_count;
}
@@ -101,7 +101,7 @@ index 5e92e2dc73..e40c141e76 100644
{
for (size_t i = 0; i < collapse_count; ++i)
{
-@@ -876,10 +911,14 @@ static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const
+@@ -881,10 +916,14 @@ static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const
float ei = quadricError(qi, vertex_positions[i1]);
float ej = quadricError(qj, vertex_positions[j1]);
@@ -116,7 +116,7 @@ index 5e92e2dc73..e40c141e76 100644
}
}
-@@ -976,7 +1015,7 @@ static void sortEdgeCollapses(unsigned int* sort_order, const Collapse* collapse
+@@ -981,7 +1020,7 @@ static void sortEdgeCollapses(unsigned int* sort_order, const Collapse* collapse
}
}
@@ -125,7 +125,7 @@ index 5e92e2dc73..e40c141e76 100644
{
size_t edge_collapses = 0;
size_t triangle_collapses = 0;
-@@ -1038,6 +1077,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
+@@ -1043,6 +1082,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
assert(collapse_remap[r1] == r1);
quadricAdd(vertex_quadrics[r1], vertex_quadrics[r0]);
@@ -133,7 +133,7 @@ index 5e92e2dc73..e40c141e76 100644
if (vertex_kind[i0] == Kind_Complex)
{
-@@ -1075,7 +1115,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
+@@ -1080,7 +1120,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
triangle_collapses += (vertex_kind[i0] == Kind_Border) ? 1 : 2;
edge_collapses++;
@@ -142,7 +142,7 @@ index 5e92e2dc73..e40c141e76 100644
}
#if TRACE
-@@ -1463,9 +1503,11 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
+@@ -1469,9 +1509,11 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
Quadric* vertex_quadrics = allocator.allocate<Quadric>(vertex_count);
memset(vertex_quadrics, 0, vertex_count * sizeof(Quadric));
@@ -156,7 +156,7 @@ index 5e92e2dc73..e40c141e76 100644
if (result != indices)
memcpy(result, indices, index_count * sizeof(unsigned int));
-@@ -1496,7 +1538,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
+@@ -1502,7 +1544,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
if (edge_collapse_count == 0)
break;
@@ -165,7 +165,7 @@ index 5e92e2dc73..e40c141e76 100644
#if TRACE > 1
dumpEdgeCollapses(edge_collapses, edge_collapse_count, vertex_kind);
-@@ -1515,7 +1557,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
+@@ -1521,7 +1563,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
printf("pass %d: ", int(pass_count++));
#endif
diff --git a/thirdparty/meshoptimizer/patches/attribute-aware-simplify.patch b/thirdparty/meshoptimizer/patches/attribute-aware-simplify.patch
index 33a17fe9fa..c065026a7d 100644
--- a/thirdparty/meshoptimizer/patches/attribute-aware-simplify.patch
+++ b/thirdparty/meshoptimizer/patches/attribute-aware-simplify.patch
@@ -1,21 +1,21 @@
diff --git a/thirdparty/meshoptimizer/meshoptimizer.h b/thirdparty/meshoptimizer/meshoptimizer.h
-index be4b765d97..463fad29da 100644
+index d95725dd71..46d28d3ea3 100644
--- a/thirdparty/meshoptimizer/meshoptimizer.h
+++ b/thirdparty/meshoptimizer/meshoptimizer.h
-@@ -328,6 +328,11 @@ MESHOPTIMIZER_EXPERIMENTAL void meshopt_encodeFilterExp(void* destination, size_
- */
- MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error);
+@@ -321,6 +321,11 @@ enum
+ meshopt_SimplifyLockBorder = 1 << 0,
+ };
+/**
+ * Experimental: Mesh simplifier with attribute metric; attributes follow xyz position data atm (vertex data must contain 3 + attribute_count floats per vertex)
+ */
-+MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, float* result_error, const float* attributes, const float* attribute_weights, size_t attribute_count);
++MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error, const float* attributes, const float* attribute_weights, size_t attribute_count);
+
/**
- * Experimental: Mesh simplifier (sloppy)
- * Reduces the number of triangles in the mesh, sacrificing mesh appearance for simplification performance
+ * Mesh simplifier
+ * Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible
diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp
-index a74b08a97d..5e92e2dc73 100644
+index 5f0e9bac31..797329b010 100644
--- a/thirdparty/meshoptimizer/simplifier.cpp
+++ b/thirdparty/meshoptimizer/simplifier.cpp
@@ -20,6 +20,8 @@
@@ -27,7 +27,7 @@ index a74b08a97d..5e92e2dc73 100644
// This work is based on:
// Michael Garland and Paul S. Heckbert. Surface simplification using quadric error metrics. 1997
// Michael Garland. Quadric-based polygonal surface simplification. 1999
-@@ -371,6 +373,10 @@ static void classifyVertices(unsigned char* result, unsigned int* loop, unsigned
+@@ -376,6 +378,10 @@ static void classifyVertices(unsigned char* result, unsigned int* loop, unsigned
struct Vector3
{
float x, y, z;
@@ -38,7 +38,7 @@ index a74b08a97d..5e92e2dc73 100644
};
static float rescalePositions(Vector3* result, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride)
-@@ -427,6 +433,13 @@ struct Quadric
+@@ -432,6 +438,13 @@ struct Quadric
float a10, a20, a21;
float b0, b1, b2, c;
float w;
@@ -52,7 +52,7 @@ index a74b08a97d..5e92e2dc73 100644
};
struct Collapse
-@@ -469,6 +482,16 @@ static void quadricAdd(Quadric& Q, const Quadric& R)
+@@ -474,6 +487,16 @@ static void quadricAdd(Quadric& Q, const Quadric& R)
Q.b2 += R.b2;
Q.c += R.c;
Q.w += R.w;
@@ -69,7 +69,7 @@ index a74b08a97d..5e92e2dc73 100644
}
static float quadricError(const Quadric& Q, const Vector3& v)
-@@ -494,6 +517,17 @@ static float quadricError(const Quadric& Q, const Vector3& v)
+@@ -499,6 +522,17 @@ static float quadricError(const Quadric& Q, const Vector3& v)
r += ry * v.y;
r += rz * v.z;
@@ -87,7 +87,7 @@ index a74b08a97d..5e92e2dc73 100644
float s = Q.w == 0.f ? 0.f : 1.f / Q.w;
return fabsf(r) * s;
-@@ -517,6 +551,13 @@ static void quadricFromPlane(Quadric& Q, float a, float b, float c, float d, flo
+@@ -522,6 +556,13 @@ static void quadricFromPlane(Quadric& Q, float a, float b, float c, float d, flo
Q.b2 = c * dw;
Q.c = d * dw;
Q.w = w;
@@ -101,7 +101,7 @@ index a74b08a97d..5e92e2dc73 100644
}
static void quadricFromPoint(Quadric& Q, float x, float y, float z, float w)
-@@ -569,6 +610,84 @@ static void quadricFromTriangleEdge(Quadric& Q, const Vector3& p0, const Vector3
+@@ -574,6 +615,84 @@ static void quadricFromTriangleEdge(Quadric& Q, const Vector3& p0, const Vector3
quadricFromPlane(Q, normal.x, normal.y, normal.z, -distance, length * weight);
}
@@ -186,7 +186,7 @@ index a74b08a97d..5e92e2dc73 100644
static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap)
{
for (size_t i = 0; i < index_count; i += 3)
-@@ -580,6 +699,9 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+@@ -585,6 +704,9 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
Quadric Q;
quadricFromTriangle(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], 1.f);
@@ -196,29 +196,30 @@ index a74b08a97d..5e92e2dc73 100644
quadricAdd(vertex_quadrics[remap[i0]], Q);
quadricAdd(vertex_quadrics[remap[i1]], Q);
quadricAdd(vertex_quadrics[remap[i2]], Q);
-@@ -1273,13 +1395,19 @@ MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoopBack = 0;
+@@ -1278,14 +1400,20 @@ MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoopBack = 0;
#endif
- size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* out_result_error)
+ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* out_result_error)
+{
-+ return meshopt_simplifyWithAttributes(destination, indices, index_count, vertex_positions_data, vertex_count, vertex_positions_stride, target_index_count, target_error, out_result_error, 0, 0, 0);
++ return meshopt_simplifyWithAttributes(destination, indices, index_count, vertex_positions_data, vertex_count, vertex_positions_stride, target_index_count, target_error, options, out_result_error, 0, 0, 0);
+}
+
-+size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, float* out_result_error, const float* attributes, const float* attribute_weights, size_t attribute_count)
++size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, unsigned int options, float* out_result_error, const float* attributes, const float* attribute_weights, size_t attribute_count)
{
using namespace meshopt;
assert(index_count % 3 == 0);
-- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+- assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
- assert(vertex_positions_stride % sizeof(float) == 0);
-+ assert(vertex_stride > 0 && vertex_stride <= 256);
++ assert(vertex_stride >= 12 && vertex_stride <= 256);
+ assert(vertex_stride % sizeof(float) == 0);
assert(target_index_count <= index_count);
+ assert((options & ~(meshopt_SimplifyLockBorder)) == 0);
+ assert(attribute_count <= ATTRIBUTES);
meshopt_Allocator allocator;
-@@ -1293,7 +1421,7 @@ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices,
+@@ -1299,7 +1427,7 @@ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices,
// build position remap that maps each vertex to the one with identical position
unsigned int* remap = allocator.allocate<unsigned int>(vertex_count);
unsigned int* wedge = allocator.allocate<unsigned int>(vertex_count);
@@ -227,7 +228,7 @@ index a74b08a97d..5e92e2dc73 100644
// classify vertices; vertex kind determines collapse rules, see kCanCollapse
unsigned char* vertex_kind = allocator.allocate<unsigned char>(vertex_count);
-@@ -1317,7 +1445,21 @@ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices,
+@@ -1323,7 +1451,21 @@ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices,
#endif
Vector3* vertex_positions = allocator.allocate<Vector3>(vertex_count);
@@ -250,7 +251,7 @@ index a74b08a97d..5e92e2dc73 100644
Quadric* vertex_quadrics = allocator.allocate<Quadric>(vertex_count);
memset(vertex_quadrics, 0, vertex_count * sizeof(Quadric));
-@@ -1409,7 +1551,9 @@ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices,
+@@ -1415,7 +1557,9 @@ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices,
// result_error is quadratic; we need to remap it back to linear
if (out_result_error)
diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp
index e40c141e76..391a77861a 100644
--- a/thirdparty/meshoptimizer/simplifier.cpp
+++ b/thirdparty/meshoptimizer/simplifier.cpp
@@ -254,7 +254,7 @@ static bool hasEdge(const EdgeAdjacency& adjacency, unsigned int a, unsigned int
return false;
}
-static void classifyVertices(unsigned char* result, unsigned int* loop, unsigned int* loopback, size_t vertex_count, const EdgeAdjacency& adjacency, const unsigned int* remap, const unsigned int* wedge)
+static void classifyVertices(unsigned char* result, unsigned int* loop, unsigned int* loopback, size_t vertex_count, const EdgeAdjacency& adjacency, const unsigned int* remap, const unsigned int* wedge, unsigned int options)
{
memset(loop, -1, vertex_count * sizeof(unsigned int));
memset(loopback, -1, vertex_count * sizeof(unsigned int));
@@ -364,6 +364,11 @@ static void classifyVertices(unsigned char* result, unsigned int* loop, unsigned
}
}
+ if (options & meshopt_SimplifyLockBorder)
+ for (size_t i = 0; i < vertex_count; ++i)
+ if (result[i] == Kind_Border)
+ result[i] = Kind_Locked;
+
#if TRACE
printf("locked: many open edges %d, disconnected seam %d, many seam edges %d, many wedges %d\n",
int(stats[0]), int(stats[1]), int(stats[2]), int(stats[3]));
@@ -1434,19 +1439,20 @@ MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoop = 0;
MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoopBack = 0;
#endif
-size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* out_result_error)
+size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* out_result_error)
{
- return meshopt_simplifyWithAttributes(destination, indices, index_count, vertex_positions_data, vertex_count, vertex_positions_stride, target_index_count, target_error, out_result_error, 0, 0, 0);
+ return meshopt_simplifyWithAttributes(destination, indices, index_count, vertex_positions_data, vertex_count, vertex_positions_stride, target_index_count, target_error, options, out_result_error, 0, 0, 0);
}
-size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, float* out_result_error, const float* attributes, const float* attribute_weights, size_t attribute_count)
+size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, unsigned int options, float* out_result_error, const float* attributes, const float* attribute_weights, size_t attribute_count)
{
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_stride > 0 && vertex_stride <= 256);
+ assert(vertex_stride >= 12 && vertex_stride <= 256);
assert(vertex_stride % sizeof(float) == 0);
assert(target_index_count <= index_count);
+ assert((options & ~(meshopt_SimplifyLockBorder)) == 0);
assert(attribute_count <= ATTRIBUTES);
meshopt_Allocator allocator;
@@ -1467,7 +1473,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
unsigned char* vertex_kind = allocator.allocate<unsigned char>(vertex_count);
unsigned int* loop = allocator.allocate<unsigned int>(vertex_count);
unsigned int* loopback = allocator.allocate<unsigned int>(vertex_count);
- classifyVertices(vertex_kind, loop, loopback, vertex_count, adjacency, remap, wedge);
+ classifyVertices(vertex_kind, loop, loopback, vertex_count, adjacency, remap, wedge, options);
#if TRACE
size_t unique_positions = 0;
@@ -1605,7 +1611,7 @@ size_t meshopt_simplifySloppy(unsigned int* destination, const unsigned int* ind
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
assert(target_index_count <= index_count);
@@ -1736,7 +1742,7 @@ size_t meshopt_simplifyPoints(unsigned int* destination, const float* vertex_pos
{
using namespace meshopt;
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
assert(target_vertex_count <= vertex_count);
@@ -1848,7 +1854,7 @@ float meshopt_simplifyScale(const float* vertex_positions, size_t vertex_count,
{
using namespace meshopt;
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
float extent = rescalePositions(NULL, vertex_positions, vertex_count, vertex_positions_stride);
diff --git a/thirdparty/meshoptimizer/spatialorder.cpp b/thirdparty/meshoptimizer/spatialorder.cpp
index b09f80ac6f..7b1a069450 100644
--- a/thirdparty/meshoptimizer/spatialorder.cpp
+++ b/thirdparty/meshoptimizer/spatialorder.cpp
@@ -113,7 +113,7 @@ void meshopt_spatialSortRemap(unsigned int* destination, const float* vertex_pos
{
using namespace meshopt;
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
meshopt_Allocator allocator;
@@ -144,7 +144,7 @@ void meshopt_spatialSortTriangles(unsigned int* destination, const unsigned int*
using namespace meshopt;
assert(index_count % 3 == 0);
- assert(vertex_positions_stride > 0 && vertex_positions_stride <= 256);
+ assert(vertex_positions_stride >= 12 && vertex_positions_stride <= 256);
assert(vertex_positions_stride % sizeof(float) == 0);
(void)vertex_count;
diff --git a/thirdparty/meshoptimizer/vcacheoptimizer.cpp b/thirdparty/meshoptimizer/vcacheoptimizer.cpp
index fb8ade4b77..ce8fd3a887 100644
--- a/thirdparty/meshoptimizer/vcacheoptimizer.cpp
+++ b/thirdparty/meshoptimizer/vcacheoptimizer.cpp
@@ -110,7 +110,7 @@ static unsigned int getNextVertexDeadEnd(const unsigned int* dead_end, unsigned
return ~0u;
}
-static unsigned int getNextVertexNeighbour(const unsigned int* next_candidates_begin, const unsigned int* next_candidates_end, const unsigned int* live_triangles, const unsigned int* cache_timestamps, unsigned int timestamp, unsigned int cache_size)
+static unsigned int getNextVertexNeighbor(const unsigned int* next_candidates_begin, const unsigned int* next_candidates_end, const unsigned int* live_triangles, const unsigned int* cache_timestamps, unsigned int timestamp, unsigned int cache_size)
{
unsigned int best_candidate = ~0u;
int best_priority = -1;
@@ -281,16 +281,16 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
{
unsigned int index = indices[current_triangle * 3 + k];
- unsigned int* neighbours = &adjacency.data[0] + adjacency.offsets[index];
- size_t neighbours_size = adjacency.counts[index];
+ unsigned int* neighbors = &adjacency.data[0] + adjacency.offsets[index];
+ size_t neighbors_size = adjacency.counts[index];
- for (size_t i = 0; i < neighbours_size; ++i)
+ for (size_t i = 0; i < neighbors_size; ++i)
{
- unsigned int tri = neighbours[i];
+ unsigned int tri = neighbors[i];
if (tri == current_triangle)
{
- neighbours[i] = neighbours[neighbours_size - 1];
+ neighbors[i] = neighbors[neighbors_size - 1];
adjacency.counts[index]--;
break;
}
@@ -314,10 +314,10 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
vertex_scores[index] = score;
// update scores of vertex triangles
- const unsigned int* neighbours_begin = &adjacency.data[0] + adjacency.offsets[index];
- const unsigned int* neighbours_end = neighbours_begin + adjacency.counts[index];
+ const unsigned int* neighbors_begin = &adjacency.data[0] + adjacency.offsets[index];
+ const unsigned int* neighbors_end = neighbors_begin + adjacency.counts[index];
- for (const unsigned int* it = neighbours_begin; it != neighbours_end; ++it)
+ for (const unsigned int* it = neighbors_begin; it != neighbors_end; ++it)
{
unsigned int tri = *it;
assert(!emitted_flags[tri]);
@@ -412,11 +412,11 @@ void meshopt_optimizeVertexCacheFifo(unsigned int* destination, const unsigned i
{
const unsigned int* next_candidates_begin = &dead_end[0] + dead_end_top;
- // emit all vertex neighbours
- const unsigned int* neighbours_begin = &adjacency.data[0] + adjacency.offsets[current_vertex];
- const unsigned int* neighbours_end = neighbours_begin + adjacency.counts[current_vertex];
+ // emit all vertex neighbors
+ const unsigned int* neighbors_begin = &adjacency.data[0] + adjacency.offsets[current_vertex];
+ const unsigned int* neighbors_end = neighbors_begin + adjacency.counts[current_vertex];
- for (const unsigned int* it = neighbours_begin; it != neighbours_end; ++it)
+ for (const unsigned int* it = neighbors_begin; it != neighbors_end; ++it)
{
unsigned int triangle = *it;
@@ -461,7 +461,7 @@ void meshopt_optimizeVertexCacheFifo(unsigned int* destination, const unsigned i
const unsigned int* next_candidates_end = &dead_end[0] + dead_end_top;
// get next vertex
- current_vertex = getNextVertexNeighbour(next_candidates_begin, next_candidates_end, &live_triangles[0], &cache_timestamps[0], timestamp, cache_size);
+ current_vertex = getNextVertexNeighbor(next_candidates_begin, next_candidates_end, &live_triangles[0], &cache_timestamps[0], timestamp, cache_size);
if (current_vertex == ~0u)
{
diff --git a/thirdparty/meshoptimizer/vertexcodec.cpp b/thirdparty/meshoptimizer/vertexcodec.cpp
index 7925ea862c..4bd11121d2 100644
--- a/thirdparty/meshoptimizer/vertexcodec.cpp
+++ b/thirdparty/meshoptimizer/vertexcodec.cpp
@@ -50,6 +50,12 @@
#define SIMD_TARGET
#endif
+// When targeting AArch64/x64, optimize for latency to allow decoding of individual 16-byte groups to overlap
+// We don't do this for 32-bit systems because we need 64-bit math for this and this will hurt in-order CPUs
+#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64)
+#define SIMD_LATENCYOPT
+#endif
+
#endif // !MESHOPTIMIZER_NO_SIMD
#ifdef SIMD_SSE
@@ -472,6 +478,18 @@ static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsi
typedef int unaligned_int;
#endif
+#ifdef SIMD_LATENCYOPT
+ unsigned int data32;
+ memcpy(&data32, data, 4);
+ data32 &= data32 >> 1;
+
+ // arrange bits such that low bits of nibbles of data64 contain all 2-bit elements of data32
+ unsigned long long data64 = ((unsigned long long)data32 << 30) | (data32 & 0x3fffffff);
+
+ // adds all 1-bit nibbles together; the sum fits in 4 bits because datacnt=16 would have used mode 3
+ int datacnt = int(((data64 & 0x1111111111111111ull) * 0x1111111111111111ull) >> 60);
+#endif
+
__m128i sel2 = _mm_cvtsi32_si128(*reinterpret_cast<const unaligned_int*>(data));
__m128i rest = _mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 4));
@@ -490,11 +508,25 @@ static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsi
_mm_storeu_si128(reinterpret_cast<__m128i*>(buffer), result);
+#ifdef SIMD_LATENCYOPT
+ return data + 4 + datacnt;
+#else
return data + 4 + kDecodeBytesGroupCount[mask0] + kDecodeBytesGroupCount[mask1];
+#endif
}
case 2:
{
+#ifdef SIMD_LATENCYOPT
+ unsigned long long data64;
+ memcpy(&data64, data, 8);
+ data64 &= data64 >> 1;
+ data64 &= data64 >> 2;
+
+ // adds all 1-bit nibbles together; the sum fits in 4 bits because datacnt=16 would have used mode 3
+ int datacnt = int(((data64 & 0x1111111111111111ull) * 0x1111111111111111ull) >> 60);
+#endif
+
__m128i sel4 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(data));
__m128i rest = _mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 8));
@@ -512,7 +544,11 @@ static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsi
_mm_storeu_si128(reinterpret_cast<__m128i*>(buffer), result);
+#ifdef SIMD_LATENCYOPT
+ return data + 8 + datacnt;
+#else
return data + 8 + kDecodeBytesGroupCount[mask0] + kDecodeBytesGroupCount[mask1];
+#endif
}
case 3:
@@ -604,24 +640,13 @@ static uint8x16_t shuffleBytes(unsigned char mask0, unsigned char mask1, uint8x8
static void neonMoveMask(uint8x16_t mask, unsigned char& mask0, unsigned char& mask1)
{
- static const unsigned char byte_mask_data[16] = {1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128};
-
- uint8x16_t byte_mask = vld1q_u8(byte_mask_data);
- uint8x16_t masked = vandq_u8(mask, byte_mask);
+ // magic constant found using z3 SMT assuming mask has 8 groups of 0xff or 0x00
+ const uint64_t magic = 0x000103070f1f3f80ull;
-#ifdef __aarch64__
- // aarch64 has horizontal sums; MSVC doesn't expose this via arm64_neon.h so this path is exclusive to clang/gcc
- mask0 = vaddv_u8(vget_low_u8(masked));
- mask1 = vaddv_u8(vget_high_u8(masked));
-#else
- // we need horizontal sums of each half of masked, which can be done in 3 steps (yielding sums of sizes 2, 4, 8)
- uint8x8_t sum1 = vpadd_u8(vget_low_u8(masked), vget_high_u8(masked));
- uint8x8_t sum2 = vpadd_u8(sum1, sum1);
- uint8x8_t sum3 = vpadd_u8(sum2, sum2);
+ uint64x2_t mask2 = vreinterpretq_u64_u8(mask);
- mask0 = vget_lane_u8(sum3, 0);
- mask1 = vget_lane_u8(sum3, 1);
-#endif
+ mask0 = uint8_t((vgetq_lane_u64(mask2, 0) * magic) >> 56);
+ mask1 = uint8_t((vgetq_lane_u64(mask2, 1) * magic) >> 56);
}
static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsigned char* buffer, int bitslog2)
@@ -639,6 +664,18 @@ static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsi
case 1:
{
+#ifdef SIMD_LATENCYOPT
+ unsigned int data32;
+ memcpy(&data32, data, 4);
+ data32 &= data32 >> 1;
+
+ // arrange bits such that low bits of nibbles of data64 contain all 2-bit elements of data32
+ unsigned long long data64 = ((unsigned long long)data32 << 30) | (data32 & 0x3fffffff);
+
+ // adds all 1-bit nibbles together; the sum fits in 4 bits because datacnt=16 would have used mode 3
+ int datacnt = int(((data64 & 0x1111111111111111ull) * 0x1111111111111111ull) >> 60);
+#endif
+
uint8x8_t sel2 = vld1_u8(data);
uint8x8_t sel22 = vzip_u8(vshr_n_u8(sel2, 4), sel2).val[0];
uint8x8x2_t sel2222 = vzip_u8(vshr_n_u8(sel22, 2), sel22);
@@ -655,11 +692,25 @@ static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsi
vst1q_u8(buffer, result);
+#ifdef SIMD_LATENCYOPT
+ return data + 4 + datacnt;
+#else
return data + 4 + kDecodeBytesGroupCount[mask0] + kDecodeBytesGroupCount[mask1];
+#endif
}
case 2:
{
+#ifdef SIMD_LATENCYOPT
+ unsigned long long data64;
+ memcpy(&data64, data, 8);
+ data64 &= data64 >> 1;
+ data64 &= data64 >> 2;
+
+ // adds all 1-bit nibbles together; the sum fits in 4 bits because datacnt=16 would have used mode 3
+ int datacnt = int(((data64 & 0x1111111111111111ull) * 0x1111111111111111ull) >> 60);
+#endif
+
uint8x8_t sel4 = vld1_u8(data);
uint8x8x2_t sel44 = vzip_u8(vshr_n_u8(sel4, 4), vand_u8(sel4, vdup_n_u8(15)));
uint8x16_t sel = vcombine_u8(sel44.val[0], sel44.val[1]);
@@ -675,7 +726,11 @@ static const unsigned char* decodeBytesGroupSimd(const unsigned char* data, unsi
vst1q_u8(buffer, result);
+#ifdef SIMD_LATENCYOPT
+ return data + 8 + datacnt;
+#else
return data + 8 + kDecodeBytesGroupCount[mask0] + kDecodeBytesGroupCount[mask1];
+#endif
}
case 3:
@@ -715,7 +770,6 @@ static void wasmMoveMask(v128_t mask, unsigned char& mask0, unsigned char& mask1
// magic constant found using z3 SMT assuming mask has 8 groups of 0xff or 0x00
const uint64_t magic = 0x000103070f1f3f80ull;
- // TODO: This can use v8x16_bitmask in the future
mask0 = uint8_t((wasm_i64x2_extract_lane(mask, 0) * magic) >> 56);
mask1 = uint8_t((wasm_i64x2_extract_lane(mask, 1) * magic) >> 56);
}
diff --git a/thirdparty/meshoptimizer/vertexfilter.cpp b/thirdparty/meshoptimizer/vertexfilter.cpp
index 606a280aa9..14a73b1ddd 100644
--- a/thirdparty/meshoptimizer/vertexfilter.cpp
+++ b/thirdparty/meshoptimizer/vertexfilter.cpp
@@ -931,7 +931,7 @@ void meshopt_encodeFilterExp(void* destination_, size_t count, size_t stride, in
const float* v = &data[i * stride_float];
unsigned int* d = &destination[i * stride_float];
- // use maximum exponent to encode values; this guarantess that mantissa is [-1, 1]
+ // use maximum exponent to encode values; this guarantees that mantissa is [-1, 1]
int exp = -100;
for (size_t j = 0; j < stride_float; ++j)