summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/config/project_settings.cpp16
-rw-r--r--core/io/file_access_pack.cpp4
-rw-r--r--core/io/resource.cpp4
-rw-r--r--core/io/resource_loader.cpp4
-rw-r--r--core/math/a_star.cpp6
-rw-r--r--core/multiplayer/multiplayer_api.cpp4
-rw-r--r--core/string/translation.cpp12
-rw-r--r--core/string/ustring.h10
-rw-r--r--doc/classes/AnimationNode.xml20
-rw-r--r--doc/classes/AnimationNodeOneShot.xml4
-rw-r--r--doc/classes/EditorFileSystem.xml2
-rw-r--r--doc/classes/PhysicsTestMotionParameters2D.xml4
-rw-r--r--doc/classes/PhysicsTestMotionParameters3D.xml4
-rw-r--r--drivers/gles3/shaders/tonemap.glsl12
-rw-r--r--drivers/gles3/storage/material_storage.cpp24
-rw-r--r--drivers/gles3/storage/mesh_storage.cpp12
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp42
-rw-r--r--editor/animation_bezier_editor.cpp8
-rw-r--r--editor/animation_track_editor.cpp60
-rw-r--r--editor/animation_track_editor.h8
-rw-r--r--editor/create_dialog.cpp4
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp4
-rw-r--r--editor/debugger/editor_debugger_node.cpp4
-rw-r--r--editor/debugger/editor_profiler.cpp24
-rw-r--r--editor/editor_asset_installer.cpp6
-rw-r--r--editor/editor_export.cpp14
-rw-r--r--editor/editor_feature_profile.cpp12
-rw-r--r--editor/editor_file_system.cpp4
-rw-r--r--editor/editor_folding.cpp8
-rw-r--r--editor/editor_node.cpp34
-rw-r--r--editor/editor_resource_picker.cpp16
-rw-r--r--editor/editor_settings.cpp14
-rw-r--r--editor/editor_translation_parser.cpp4
-rw-r--r--editor/import/editor_import_collada.cpp14
-rw-r--r--editor/import/resource_importer_scene.cpp2
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp8
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp4
-rw-r--r--editor/plugins/script_text_editor.cpp18
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp8
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp30
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp86
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp114
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp4
-rw-r--r--editor/pot_generator.cpp8
-rw-r--r--editor/project_manager.cpp12
-rw-r--r--editor/project_settings_editor.cpp4
-rw-r--r--editor/property_editor.cpp8
-rwxr-xr-xeditor/translations/extract.py40
-rw-r--r--main/main.cpp8
-rw-r--r--modules/gdscript/gdscript.cpp12
-rw-r--r--modules/gdscript/gdscript_compiler.cpp45
-rw-r--r--modules/gdscript/gdscript_parser.cpp6
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp4
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.gd16
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.out2
-rw-r--r--modules/gridmap/grid_map.cpp12
-rw-r--r--modules/navigation/nav_map.h6
-rw-r--r--modules/noise/fastnoise_lite.cpp15
-rw-r--r--modules/raycast/lightmap_raycaster.cpp8
-rw-r--r--modules/raycast/raycast_occlusion_cull.cpp6
-rw-r--r--modules/raycast/static_raycaster.cpp8
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp52
-rw-r--r--modules/visual_script/visual_script.cpp118
-rw-r--r--modules/webrtc/webrtc_data_channel.h2
-rw-r--r--platform/android/export/export_plugin.cpp12
-rw-r--r--platform/iphone/export/export_plugin.cpp32
-rw-r--r--scene/2d/audio_listener_2d.cpp2
-rw-r--r--scene/2d/navigation_region_2d.cpp3
-rw-r--r--scene/2d/physics_body_2d.cpp21
-rw-r--r--scene/2d/skeleton_2d.cpp10
-rw-r--r--scene/2d/tile_map.cpp84
-rw-r--r--scene/3d/audio_listener_3d.cpp2
-rw-r--r--scene/3d/collision_object_3d.cpp6
-rw-r--r--scene/3d/mesh_instance_3d.cpp2
-rw-r--r--scene/3d/node_3d.cpp8
-rw-r--r--scene/3d/physics_body_3d.cpp119
-rw-r--r--scene/3d/skeleton_3d.cpp56
-rw-r--r--scene/3d/soft_dynamic_body_3d.cpp9
-rw-r--r--scene/animation/animation_blend_space_1d.cpp6
-rw-r--r--scene/animation/animation_blend_space_1d.h2
-rw-r--r--scene/animation/animation_blend_space_2d.cpp12
-rw-r--r--scene/animation/animation_blend_space_2d.h2
-rw-r--r--scene/animation/animation_blend_tree.cpp89
-rw-r--r--scene/animation/animation_blend_tree.h42
-rw-r--r--scene/animation/animation_node_state_machine.cpp18
-rw-r--r--scene/animation/animation_node_state_machine.h4
-rw-r--r--scene/animation/animation_player.cpp24
-rw-r--r--scene/animation/animation_tree.cpp68
-rw-r--r--scene/animation/animation_tree.h15
-rw-r--r--scene/debugger/scene_debugger.cpp30
-rw-r--r--scene/gui/base_button.cpp20
-rw-r--r--scene/gui/code_edit.cpp8
-rw-r--r--scene/gui/control.h12
-rw-r--r--scene/gui/graph_edit.cpp68
-rw-r--r--scene/gui/grid_container.cpp16
-rw-r--r--scene/gui/range.cpp8
-rw-r--r--scene/gui/text_edit.cpp8
-rw-r--r--scene/main/node.cpp5
-rw-r--r--scene/main/resource_preloader.cpp6
-rw-r--r--scene/main/viewport.cpp40
-rw-r--r--scene/main/window.cpp12
-rw-r--r--scene/multiplayer/scene_cache_interface.cpp10
-rw-r--r--scene/register_scene_types.cpp12
-rw-r--r--scene/resources/concave_polygon_shape_3d.cpp6
-rw-r--r--scene/resources/mesh_library.cpp16
-rw-r--r--scene/resources/navigation_mesh.cpp2
-rw-r--r--scene/resources/polygon_path_finder.cpp70
-rw-r--r--scene/resources/skin.cpp9
-rw-r--r--scene/resources/texture.cpp4
-rw-r--r--scene/resources/theme.cpp100
-rw-r--r--scene/resources/theme.h19
-rw-r--r--scene/resources/tile_set.cpp18
-rw-r--r--scene/resources/visual_shader.cpp10
-rw-r--r--servers/physics_2d/godot_physics_server_2d.cpp18
-rw-r--r--servers/physics_2d/godot_space_2d.cpp2
-rw-r--r--servers/physics_2d/godot_step_2d.cpp4
-rw-r--r--servers/physics_3d/godot_physics_server_3d.cpp18
-rw-r--r--servers/physics_3d/godot_space_3d.cpp2
-rw-r--r--servers/physics_3d/godot_step_3d.cpp8
-rw-r--r--servers/physics_server_2d.cpp18
-rw-r--r--servers/physics_server_2d.h4
-rw-r--r--servers/physics_server_3d.cpp18
-rw-r--r--servers/physics_server_3d.h4
-rw-r--r--servers/rendering/renderer_canvas_cull.cpp16
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp2
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp4
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/tonemap.glsl25
-rw-r--r--servers/rendering/renderer_rd/storage_rd/material_storage.cpp24
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp12
-rw-r--r--servers/rendering/renderer_rd/storage_rd/particles_storage.cpp4
-rw-r--r--servers/rendering/renderer_scene_cull.cpp68
-rw-r--r--servers/rendering/renderer_storage.h8
-rw-r--r--servers/rendering/renderer_viewport.cpp46
-rw-r--r--servers/rendering/shader_compiler.cpp4
-rw-r--r--servers/rendering/shader_language.cpp20
-rw-r--r--servers/rendering/shader_types.cpp62
-rw-r--r--thirdparty/README.md9
-rw-r--r--thirdparty/pcre2/patches/sljit-macos11-conditional.patch31
-rw-r--r--thirdparty/pcre2/src/sljit/sljitExecAllocator.c3
-rw-r--r--thirdparty/rvo2/API.h45
-rw-r--r--thirdparty/rvo2/Agent.cpp590
-rw-r--r--thirdparty/rvo2/Agent.h103
-rw-r--r--thirdparty/rvo2/Definitions.h12
-rw-r--r--thirdparty/rvo2/KdTree.cpp184
-rw-r--r--thirdparty/rvo2/KdTree.h82
-rw-r--r--thirdparty/rvo2/README.md32
-rw-r--r--thirdparty/rvo2/Vector3.h66
-rw-r--r--thirdparty/rvo2/patches/rvo2-godot-changes.patch282
150 files changed, 2256 insertions, 1825 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 4638d70e59..ff5ff83bf8 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -360,8 +360,8 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
vclist.insert(vc);
}
- for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
- String prop_info_name = E->get().name;
+ for (const _VCSort &E : vclist) {
+ String prop_info_name = E.name;
int dot = prop_info_name.find(".");
if (dot != -1 && !custom_prop_info.has(prop_info_name)) {
prop_info_name = prop_info_name.substr(0, dot);
@@ -369,11 +369,11 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
if (custom_prop_info.has(prop_info_name)) {
PropertyInfo pi = custom_prop_info[prop_info_name];
- pi.name = E->get().name;
- pi.usage = E->get().flags;
+ pi.name = E.name;
+ pi.usage = E.flags;
p_list->push_back(pi);
} else {
- p_list->push_back(PropertyInfo(E->get().type, E->get().name, PROPERTY_HINT_NONE, "", E->get().flags));
+ p_list->push_back(PropertyInfo(E.type, E.name, PROPERTY_HINT_NONE, "", E.flags));
}
}
}
@@ -959,9 +959,9 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
RBMap<String, List<String>> props;
- for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
- String category = E->get().name;
- String name = E->get().name;
+ for (const _VCSort &E : vclist) {
+ String category = E.name;
+ String name = E.name;
int div = category.find("/");
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 89efdc4938..595a6e9873 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -406,8 +406,8 @@ Error DirAccessPack::list_dir_begin() {
list_dirs.push_back(E.key);
}
- for (RBSet<String>::Element *E = current->files.front(); E; E = E->next()) {
- list_files.push_back(E->get());
+ for (const String &E : current->files) {
+ list_files.push_back(E);
}
return OK;
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 4a94c17132..ad01eb1083 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -317,8 +317,8 @@ void Resource::unregister_owner(Object *p_owner) {
}
void Resource::notify_change_to_owners() {
- for (RBSet<ObjectID>::Element *E = owners.front(); E; E = E->next()) {
- Object *obj = ObjectDB::get_instance(E->get());
+ for (const ObjectID &E : owners) {
+ Object *obj = ObjectDB::get_instance(E);
ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf
//TODO store string
obj->call("resource_changed", Ref<Resource>(this));
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 9e6330f34b..fb21db1a19 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -391,8 +391,8 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) {
int dep_count = load_task.sub_tasks.size();
if (dep_count > 0) {
float dep_progress = 0;
- for (RBSet<String>::Element *E = load_task.sub_tasks.front(); E; E = E->next()) {
- dep_progress += _dependency_get_progress(E->get());
+ for (const String &E : load_task.sub_tasks) {
+ dep_progress += _dependency_get_progress(E);
}
dep_progress /= float(dep_count);
dep_progress *= 0.5;
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index a3ee259030..29aa959e54 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -293,10 +293,10 @@ Vector3 AStar3D::get_closest_position_in_segment(const Vector3 &p_point) const {
real_t closest_dist = 1e20;
Vector3 closest_point;
- for (const RBSet<Segment>::Element *E = segments.front(); E; E = E->next()) {
+ for (const Segment &E : segments) {
Point *from_point = nullptr, *to_point = nullptr;
- points.lookup(E->get().u, from_point);
- points.lookup(E->get().v, to_point);
+ points.lookup(E.u, from_point);
+ points.lookup(E.v, to_point);
if (!(from_point->enabled && to_point->enabled)) {
continue;
diff --git a/core/multiplayer/multiplayer_api.cpp b/core/multiplayer/multiplayer_api.cpp
index e18c3dd2e4..9605647b3f 100644
--- a/core/multiplayer/multiplayer_api.cpp
+++ b/core/multiplayer/multiplayer_api.cpp
@@ -494,8 +494,8 @@ Vector<int> MultiplayerAPI::get_peer_ids() const {
ERR_FAIL_COND_V_MSG(!multiplayer_peer.is_valid(), Vector<int>(), "No multiplayer peer is assigned. Assume no peers are connected.");
Vector<int> ret;
- for (RBSet<int>::Element *E = connected_peers.front(); E; E = E->next()) {
- ret.push_back(E->get());
+ for (const int &E : connected_peers) {
+ ret.push_back(E);
}
return ret;
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index c64f815563..cba2f09022 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -507,8 +507,8 @@ String TranslationServer::get_locale() const {
Array TranslationServer::get_loaded_locales() const {
Array locales;
- for (const RBSet<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) {
- const Ref<Translation> &t = E->get();
+ for (const Ref<Translation> &E : translations) {
+ const Ref<Translation> &t = E;
ERR_FAIL_COND_V(t.is_null(), Array());
String l = t->get_locale();
@@ -530,8 +530,8 @@ Ref<Translation> TranslationServer::get_translation_object(const String &p_local
Ref<Translation> res;
int best_score = 0;
- for (const RBSet<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) {
- const Ref<Translation> &t = E->get();
+ for (const Ref<Translation> &E : translations) {
+ const Ref<Translation> &t = E;
ERR_FAIL_COND_V(t.is_null(), nullptr);
String l = t->get_locale();
@@ -599,8 +599,8 @@ StringName TranslationServer::_get_message_from_translations(const StringName &p
StringName res;
int best_score = 0;
- for (const RBSet<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) {
- const Ref<Translation> &t = E->get();
+ for (const Ref<Translation> &E : translations) {
+ const Ref<Translation> &t = E;
ERR_FAIL_COND_V(t.is_null(), p_message);
String l = t->get_locale();
diff --git a/core/string/ustring.h b/core/string/ustring.h
index 0d10d4cf10..e4f6c3327a 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -528,6 +528,16 @@ String DTRN(const String &p_text, const String &p_text_plural, int p_n, const St
#define TTRGET(m_value) (m_value)
#endif
+// Use this to mark property names for editor translation.
+// Often for dynamic properties defined in _get_property_list().
+// Property names defined directly inside EDITOR_DEF, GLOBAL_DEF, and ADD_PROPERTY macros don't need this.
+#define PNAME(m_value) (m_value)
+
+// Similar to PNAME, but to mark groups, i.e. properties with PROPERTY_USAGE_GROUP.
+// Groups defined directly inside ADD_GROUP macros don't need this.
+// The arguments are the same as ADD_GROUP. m_prefix is only used for extraction.
+#define GNAME(m_value, m_prefix) (m_value)
+
// Runtime translate for the public node API.
String RTR(const String &p_text, const String &p_context = "");
String RTRN(const String &p_text, const String &p_text_plural, int p_n, const String &p_context = "");
diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml
index 99d21706ee..9026aa6a34 100644
--- a/doc/classes/AnimationNode.xml
+++ b/doc/classes/AnimationNode.xml
@@ -53,6 +53,7 @@
<return type="float" />
<argument index="0" name="time" type="float" />
<argument index="1" name="seek" type="bool" />
+ <argument index="2" name="seek_root" type="bool" />
<description>
User-defined callback called when a custom node is processed. The [code]time[/code] parameter is a relative delta, unless [code]seek[/code] is [code]true[/code], in which case it is absolute.
Here, call the [method blend_input], [method blend_node] or [method blend_animation] functions. You can also use [method get_parameter] and [method set_parameter] to modify local memory.
@@ -72,8 +73,9 @@
<argument index="1" name="time" type="float" />
<argument index="2" name="delta" type="float" />
<argument index="3" name="seeked" type="bool" />
- <argument index="4" name="blend" type="float" />
- <argument index="5" name="pingponged" type="int" default="0" />
+ <argument index="4" name="seek_root" type="bool" />
+ <argument index="5" name="blend" type="float" />
+ <argument index="6" name="pingponged" type="int" default="0" />
<description>
Blend an animation by [code]blend[/code] amount (name must be valid in the linked [AnimationPlayer]). A [code]time[/code] and [code]delta[/code] may be passed, as well as whether [code]seek[/code] happened.
</description>
@@ -83,9 +85,10 @@
<argument index="0" name="input_index" type="int" />
<argument index="1" name="time" type="float" />
<argument index="2" name="seek" type="bool" />
- <argument index="3" name="blend" type="float" />
- <argument index="4" name="filter" type="int" enum="AnimationNode.FilterAction" default="0" />
- <argument index="5" name="optimize" type="bool" default="true" />
+ <argument index="3" name="seek_root" type="bool" />
+ <argument index="4" name="blend" type="float" />
+ <argument index="5" name="filter" type="int" enum="AnimationNode.FilterAction" default="0" />
+ <argument index="6" name="optimize" type="bool" default="true" />
<description>
Blend an input. This is only useful for nodes created for an [AnimationNodeBlendTree]. The [code]time[/code] parameter is a relative delta, unless [code]seek[/code] is [code]true[/code], in which case it is absolute. A filter mode may be optionally passed (see [enum FilterAction] for options).
</description>
@@ -96,9 +99,10 @@
<argument index="1" name="node" type="AnimationNode" />
<argument index="2" name="time" type="float" />
<argument index="3" name="seek" type="bool" />
- <argument index="4" name="blend" type="float" />
- <argument index="5" name="filter" type="int" enum="AnimationNode.FilterAction" default="0" />
- <argument index="6" name="optimize" type="bool" default="true" />
+ <argument index="4" name="seek_root" type="bool" />
+ <argument index="5" name="blend" type="float" />
+ <argument index="6" name="filter" type="int" enum="AnimationNode.FilterAction" default="0" />
+ <argument index="7" name="optimize" type="bool" default="true" />
<description>
Blend another animation node (in case this node contains children animation nodes). This function is only useful if you inherit from [AnimationRootNode] instead, else editors will not display your node for addition.
</description>
diff --git a/doc/classes/AnimationNodeOneShot.xml b/doc/classes/AnimationNodeOneShot.xml
index 727a09e110..de2414cd43 100644
--- a/doc/classes/AnimationNodeOneShot.xml
+++ b/doc/classes/AnimationNodeOneShot.xml
@@ -20,9 +20,9 @@
<member name="autorestart_random_delay" type="float" setter="set_autorestart_random_delay" getter="get_autorestart_random_delay" default="0.0">
If [member autorestart] is [code]true[/code], a random additional delay (in seconds) between 0 and this value will be added to [member autorestart_delay].
</member>
- <member name="fadein_time" type="float" setter="set_fadein_time" getter="get_fadein_time" default="0.1">
+ <member name="fadein_time" type="float" setter="set_fadein_time" getter="get_fadein_time" default="0.0">
</member>
- <member name="fadeout_time" type="float" setter="set_fadeout_time" getter="get_fadeout_time" default="0.1">
+ <member name="fadeout_time" type="float" setter="set_fadeout_time" getter="get_fadeout_time" default="0.0">
</member>
<member name="mix_mode" type="int" setter="set_mix_mode" getter="get_mix_mode" enum="AnimationNodeOneShot.MixMode" default="0">
</member>
diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml
index 60ac499d25..402efba34a 100644
--- a/doc/classes/EditorFileSystem.xml
+++ b/doc/classes/EditorFileSystem.xml
@@ -39,7 +39,7 @@
<method name="is_scanning" qualifiers="const">
<return type="bool" />
<description>
- Returns [code]true[/code] of the filesystem is being scanned.
+ Returns [code]true[/code] if the filesystem is being scanned.
</description>
</method>
<method name="reimport_files">
diff --git a/doc/classes/PhysicsTestMotionParameters2D.xml b/doc/classes/PhysicsTestMotionParameters2D.xml
index c22a49edf7..00f21a2058 100644
--- a/doc/classes/PhysicsTestMotionParameters2D.xml
+++ b/doc/classes/PhysicsTestMotionParameters2D.xml
@@ -28,5 +28,9 @@
<member name="motion" type="Vector2" setter="set_motion" getter="get_motion" default="Vector2(0, 0)">
Motion vector to define the length and direction of the motion to test.
</member>
+ <member name="recovery_as_collision" type="bool" setter="set_recovery_as_collision_enabled" getter="is_recovery_as_collision_enabled" default="false">
+ If set to [code]true[/code], any depenetration from the recovery phase is reported as a collision; this is used e.g. by [method CharacterBody2D.move_and_slide] for improving floor detection when floor snapping is disabled.
+ If set to [code]false[/code], only collisions resulting from the motion are reported; this is used e.g. by [method PhysicsBody2D.move_and_collide].
+ </member>
</members>
</class>
diff --git a/doc/classes/PhysicsTestMotionParameters3D.xml b/doc/classes/PhysicsTestMotionParameters3D.xml
index 4ff07de7aa..5b07796a10 100644
--- a/doc/classes/PhysicsTestMotionParameters3D.xml
+++ b/doc/classes/PhysicsTestMotionParameters3D.xml
@@ -31,5 +31,9 @@
<member name="motion" type="Vector3" setter="set_motion" getter="get_motion" default="Vector3(0, 0, 0)">
Motion vector to define the length and direction of the motion to test.
</member>
+ <member name="recovery_as_collision" type="bool" setter="set_recovery_as_collision_enabled" getter="is_recovery_as_collision_enabled" default="false">
+ If set to [code]true[/code], any depenetration from the recovery phase is reported as a collision; this is used e.g. by [method CharacterBody3D.move_and_slide] for improving floor detection when floor snapping is disabled.
+ If set to [code]false[/code], only collisions resulting from the motion are detected; this is used e.g. by [method PhysicsBody3D.move_and_collide].
+ </member>
</members>
</class>
diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl
index 4f962626a3..a478cf9170 100644
--- a/drivers/gles3/shaders/tonemap.glsl
+++ b/drivers/gles3/shaders/tonemap.glsl
@@ -231,10 +231,10 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) {
}
void main() {
- vec3 color = textureLod(source, uv_interp, 0.0).rgb;
+ vec4 color = textureLod(source, uv_interp, 0.0);
#ifdef USE_FXAA
- color = apply_fxaa(color, uv_interp, pixel_size);
+ color.rgb = apply_fxaa(color.rgb, uv_interp, pixel_size);
#endif
// Glow
@@ -296,18 +296,18 @@ void main() {
#endif //USE_MULTI_TEXTURE_GLOW
glow *= glow_intensity;
- color = apply_glow(color, glow);
+ color.rgb = apply_glow(color.rgb, glow);
#endif
// Additional effects
#ifdef USE_BCS
- color = apply_bcs(color, bcs);
+ color.rgb = apply_bcs(color.rgb, bcs);
#endif
#ifdef USE_COLOR_CORRECTION
- color = apply_color_correction(color, color_correction);
+ color.rgb = apply_color_correction(color.rgb, color_correction);
#endif
- frag_color = vec4(color, 1.0);
+ frag_color = color;
}
diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp
index e93c503396..7b18376a2a 100644
--- a/drivers/gles3/storage/material_storage.cpp
+++ b/drivers/gles3/storage/material_storage.cpp
@@ -2091,8 +2091,8 @@ void MaterialStorage::global_variable_set(const StringName &p_name, const Varian
} else {
//texture
MaterialStorage *material_storage = MaterialStorage::get_singleton();
- for (RBSet<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_storage->get_material(E->get());
+ for (const RID &E : gv.texture_materials) {
+ Material *material = material_storage->get_material(E);
ERR_CONTINUE(!material);
material_storage->_material_queue_update(material, false, true);
}
@@ -2123,8 +2123,8 @@ void MaterialStorage::global_variable_set_override(const StringName &p_name, con
} else {
//texture
MaterialStorage *material_storage = MaterialStorage::get_singleton();
- for (RBSet<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_storage->get_material(E->get());
+ for (const RID &E : gv.texture_materials) {
+ Material *material = material_storage->get_material(E);
ERR_CONTINUE(!material);
material_storage->_material_queue_update(material, false, true);
}
@@ -2421,8 +2421,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->data = nullptr;
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
material->shader_mode = new_mode;
if (material->data) {
memdelete(material->data);
@@ -2438,8 +2438,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->mode = RS::SHADER_MAX; //invalid
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
if (shader->data) {
material->data = material_data_request_func[new_mode](shader->data);
material->data->self = material->self;
@@ -2462,8 +2462,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->data->set_code(p_code);
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
material->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MATERIAL);
_material_queue_update(material, true, true);
}
@@ -2504,8 +2504,8 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin
if (shader->data) {
shader->data->set_default_texture_param(p_name, p_texture, p_index);
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
_material_queue_update(material, false, true);
}
}
diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp
index 5739a63cac..3be1792868 100644
--- a/drivers/gles3/storage/mesh_storage.cpp
+++ b/drivers/gles3/storage/mesh_storage.cpp
@@ -68,8 +68,8 @@ void MeshStorage::mesh_free(RID p_rid) {
ERR_PRINT("deleting mesh with active instances");
}
if (mesh->shadow_owners.size()) {
- for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) {
- Mesh *shadow_owner = E->get();
+ for (Mesh *E : mesh->shadow_owners) {
+ Mesh *shadow_owner = E;
shadow_owner->shadow_mesh = RID();
shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
}
@@ -268,8 +268,8 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
- for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) {
- Mesh *shadow_owner = E->get();
+ for (Mesh *E : mesh->shadow_owners) {
+ Mesh *shadow_owner = E;
shadow_owner->shadow_mesh = RID();
shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
}
@@ -610,8 +610,8 @@ void MeshStorage::mesh_clear(RID p_mesh) {
mesh->has_bone_weights = false;
mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
- for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) {
- Mesh *shadow_owner = E->get();
+ for (Mesh *E : mesh->shadow_owners) {
+ Mesh *shadow_owner = E;
shadow_owner->shadow_mesh = RID();
shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
}
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 23c2d764b8..1a60ca0647 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -159,8 +159,8 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
E = reverse_dependency_map.find(p_id);
if (E) {
- for (RBSet<RID>::Element *F = E->value.front(); F; F = F->next()) {
- HashMap<RID, RBSet<RID>>::Iterator G = dependency_map.find(F->get());
+ for (const RID &F : E->value) {
+ HashMap<RID, RBSet<RID>>::Iterator G = dependency_map.find(F);
ERR_CONTINUE(!G);
ERR_CONTINUE(!G->value.has(p_id));
G->value.erase(p_id);
@@ -5473,9 +5473,9 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a
DescriptorPool *pool = nullptr;
- for (RBSet<DescriptorPool *>::Element *E = descriptor_pools[p_key].front(); E; E = E->next()) {
- if (E->get()->usage < max_descriptors_per_pool) {
- pool = E->get();
+ for (DescriptorPool *E : descriptor_pools[p_key]) {
+ if (E->usage < max_descriptors_per_pool) {
+ pool = E;
break;
}
}
@@ -8349,31 +8349,31 @@ void RenderingDeviceVulkan::compute_list_end(uint32_t p_post_barrier) {
uint32_t barrier_idx = 0;
- for (RBSet<Texture *>::Element *E = compute_list->state.textures_to_sampled_layout.front(); E; E = E->next()) {
+ for (Texture *E : compute_list->state.textures_to_sampled_layout) {
VkImageMemoryBarrier &image_memory_barrier = image_barriers[barrier_idx++];
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
image_memory_barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
image_memory_barrier.dstAccessMask = access_flags;
- image_memory_barrier.oldLayout = E->get()->layout;
+ image_memory_barrier.oldLayout = E->layout;
image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- image_memory_barrier.image = E->get()->image;
- image_memory_barrier.subresourceRange.aspectMask = E->get()->read_aspect_mask;
- image_memory_barrier.subresourceRange.baseMipLevel = E->get()->base_mipmap;
- image_memory_barrier.subresourceRange.levelCount = E->get()->mipmaps;
- image_memory_barrier.subresourceRange.baseArrayLayer = E->get()->base_layer;
- image_memory_barrier.subresourceRange.layerCount = E->get()->layers;
-
- E->get()->layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
-
- if (E->get()->used_in_frame != frames_drawn) {
- E->get()->used_in_transfer = false;
- E->get()->used_in_raster = false;
- E->get()->used_in_compute = false;
- E->get()->used_in_frame = frames_drawn;
+ image_memory_barrier.image = E->image;
+ image_memory_barrier.subresourceRange.aspectMask = E->read_aspect_mask;
+ image_memory_barrier.subresourceRange.baseMipLevel = E->base_mipmap;
+ image_memory_barrier.subresourceRange.levelCount = E->mipmaps;
+ image_memory_barrier.subresourceRange.baseArrayLayer = E->base_layer;
+ image_memory_barrier.subresourceRange.layerCount = E->layers;
+
+ E->layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+
+ if (E->used_in_frame != frames_drawn) {
+ E->used_in_transfer = false;
+ E->used_in_raster = false;
+ E->used_in_compute = false;
+ E->used_in_frame = frames_drawn;
}
}
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index ff8b72274c..c5f800b17a 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -747,8 +747,8 @@ void AnimationBezierTrackEdit::_update_locked_tracks_after(int p_track) {
}
Vector<int> updated_locked_tracks;
- for (RBSet<int>::Element *E = locked_tracks.front(); E; E = E->next()) {
- updated_locked_tracks.push_back(E->get());
+ for (const int &E : locked_tracks) {
+ updated_locked_tracks.push_back(E);
}
locked_tracks.clear();
for (int i = 0; i < updated_locked_tracks.size(); ++i) {
@@ -766,8 +766,8 @@ void AnimationBezierTrackEdit::_update_hidden_tracks_after(int p_track) {
}
Vector<int> updated_hidden_tracks;
- for (RBSet<int>::Element *E = hidden_tracks.front(); E; E = E->next()) {
- updated_hidden_tracks.push_back(E->get());
+ for (const int &E : hidden_tracks) {
+ updated_hidden_tracks.push_back(E);
}
hidden_tracks.clear();
for (int i = 0; i < updated_hidden_tracks.size(); ++i) {
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 7d8197bead..ad4b7b7d95 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -560,30 +560,30 @@ public:
if (use_fps && animation->get_step() > 0) {
float max_frame = animation->get_length() / animation->get_step();
- p_list->push_back(PropertyInfo(Variant::FLOAT, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("frame"), PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1"));
} else {
- p_list->push_back(PropertyInfo(Variant::FLOAT, "time", PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("time"), PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01"));
}
switch (animation->track_get_type(track)) {
case Animation::TYPE_POSITION_3D: {
- p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, PNAME("position")));
} break;
case Animation::TYPE_ROTATION_3D: {
- p_list->push_back(PropertyInfo(Variant::QUATERNION, "rotation"));
+ p_list->push_back(PropertyInfo(Variant::QUATERNION, PNAME("rotation")));
} break;
case Animation::TYPE_SCALE_3D: {
- p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, PNAME("scale")));
} break;
case Animation::TYPE_BLEND_SHAPE: {
- p_list->push_back(PropertyInfo(Variant::FLOAT, "value"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("value")));
} break;
case Animation::TYPE_VALUE: {
Variant v = animation->track_get_key_value(track, key);
if (hint.type != Variant::NIL) {
PropertyInfo pi = hint;
- pi.name = "value";
+ pi.name = PNAME("value");
p_list->push_back(pi);
} else {
PropertyHint val_hint = PROPERTY_HINT_NONE;
@@ -599,14 +599,14 @@ public:
}
if (v.get_type() != Variant::NIL) {
- p_list->push_back(PropertyInfo(v.get_type(), "value", val_hint, val_hint_string));
+ p_list->push_back(PropertyInfo(v.get_type(), PNAME("value"), val_hint, val_hint_string));
}
}
} break;
case Animation::TYPE_METHOD: {
- p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name"));
- p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,32,1,or_greater"));
+ p_list->push_back(PropertyInfo(Variant::STRING_NAME, PNAME("name")));
+ p_list->push_back(PropertyInfo(Variant::INT, PNAME("arg_count"), PROPERTY_HINT_RANGE, "0,32,1,or_greater"));
Dictionary d = animation->track_get_key_value(track, key);
ERR_FAIL_COND(!d.has("args"));
@@ -620,24 +620,24 @@ public:
}
for (int i = 0; i < args.size(); i++) {
- p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes));
+ p_list->push_back(PropertyInfo(Variant::INT, vformat("%s/%d/%s", PNAME("args"), i, PNAME("type")), PROPERTY_HINT_ENUM, vtypes));
if (args[i].get_type() != Variant::NIL) {
- p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value"));
+ p_list->push_back(PropertyInfo(args[i].get_type(), vformat("%s/%d/%s", PNAME("args"), i, PNAME("value"))));
}
}
} break;
case Animation::TYPE_BEZIER: {
- p_list->push_back(PropertyInfo(Variant::FLOAT, "value"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle"));
- p_list->push_back(PropertyInfo(Variant::INT, "handle_mode", PROPERTY_HINT_ENUM, "Free,Balanced"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("value")));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, PNAME("in_handle")));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, PNAME("out_handle")));
+ p_list->push_back(PropertyInfo(Variant::INT, PNAME("handle_mode"), PROPERTY_HINT_ENUM, "Free,Balanced"));
} break;
case Animation::TYPE_AUDIO: {
- p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("stream"), PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("start_offset"), PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("end_offset"), PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
} break;
case Animation::TYPE_ANIMATION: {
@@ -663,13 +663,13 @@ public:
}
animations += "[stop]";
- p_list->push_back(PropertyInfo(Variant::STRING_NAME, "animation", PROPERTY_HINT_ENUM, animations));
+ p_list->push_back(PropertyInfo(Variant::STRING_NAME, PNAME("animation"), PROPERTY_HINT_ENUM, animations));
} break;
}
if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
- p_list->push_back(PropertyInfo(Variant::FLOAT, "easing", PROPERTY_HINT_EXP_EASING));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("easing"), PROPERTY_HINT_EXP_EASING));
}
}
@@ -1417,14 +1417,14 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
void AnimationTimelineEdit::_anim_loop_pressed() {
undo_redo->create_action(TTR("Change Animation Loop"));
switch (animation->get_loop_mode()) {
- case Animation::LoopMode::LOOP_NONE: {
- undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LoopMode::LOOP_LINEAR);
+ case Animation::LOOP_NONE: {
+ undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_LINEAR);
} break;
- case Animation::LoopMode::LOOP_LINEAR: {
- undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LoopMode::LOOP_PINGPONG);
+ case Animation::LOOP_LINEAR: {
+ undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_PINGPONG);
} break;
- case Animation::LoopMode::LOOP_PINGPONG: {
- undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LoopMode::LOOP_NONE);
+ case Animation::LOOP_PINGPONG: {
+ undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_NONE);
} break;
default:
break;
@@ -1724,15 +1724,15 @@ void AnimationTimelineEdit::update_values() {
}
switch (animation->get_loop_mode()) {
- case Animation::LoopMode::LOOP_NONE: {
+ case Animation::LOOP_NONE: {
loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons")));
loop->set_pressed(false);
} break;
- case Animation::LoopMode::LOOP_LINEAR: {
+ case Animation::LOOP_LINEAR: {
loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons")));
loop->set_pressed(true);
} break;
- case Animation::LoopMode::LOOP_PINGPONG: {
+ case Animation::LOOP_PINGPONG: {
loop->set_icon(get_theme_icon(SNAME("PingPongLoop"), SNAME("EditorIcons")));
loop->set_pressed(true);
} break;
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 07c3ed9990..55c3bd922a 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -478,10 +478,10 @@ class AnimationTrackEditor : public VBoxContainer {
struct TrackClipboard {
NodePath full_path;
NodePath base_path;
- Animation::TrackType track_type = Animation::TrackType::TYPE_ANIMATION;
- Animation::InterpolationType interp_type = Animation::InterpolationType::INTERPOLATION_CUBIC;
- Animation::UpdateMode update_mode = Animation::UpdateMode::UPDATE_CAPTURE;
- Animation::LoopMode loop_mode = Animation::LoopMode::LOOP_LINEAR;
+ Animation::TrackType track_type = Animation::TYPE_ANIMATION;
+ Animation::InterpolationType interp_type = Animation::INTERPOLATION_CUBIC;
+ Animation::UpdateMode update_mode = Animation::UPDATE_CAPTURE;
+ Animation::LoopMode loop_mode = Animation::LOOP_LINEAR;
bool loop_wrap = false;
bool enabled = false;
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index fb908ea573..3469e96a0a 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -138,8 +138,8 @@ bool CreateDialog::_should_hide_type(const String &p_type) const {
return true; // Wrong inheritance.
}
- for (RBSet<StringName>::Element *E = type_blacklist.front(); E; E = E->next()) {
- if (ClassDB::is_parent_class(p_type, E->get())) {
+ for (const StringName &E : type_blacklist) {
+ if (ClassDB::is_parent_class(p_type, E)) {
return true; // Parent type is blacklisted.
}
}
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index 6d7f3f4ae2..0dd7b44b68 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -193,8 +193,8 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) {
//only some may have changed, if so, then update those, if exist
- for (RBSet<String>::Element *E = changed.front(); E; E = E->next()) {
- emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E->get());
+ for (const String &E : changed) {
+ emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E);
}
} else {
//full update, because props were added or removed
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index de26b56ab6..bc28b11a71 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -118,8 +118,8 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
}
if (!debugger_plugins.is_empty()) {
- for (RBSet<Ref<Script>>::Element *i = debugger_plugins.front(); i; i = i->next()) {
- node->add_debugger_plugin(i->get());
+ for (const Ref<Script> &i : debugger_plugins) {
+ node->add_debugger_plugin(i);
}
}
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index 55c3c7af78..9899e91c5a 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -198,13 +198,13 @@ void EditorProfiler::_update_plot() {
for (int i = 0; i < total_metrics; i++) {
const Metric &m = _get_frame_metric(i);
- for (RBSet<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) {
- HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E->get());
+ for (const StringName &E : plot_sigs) {
+ HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E);
if (F) {
highest = MAX(F->value->total_time, highest);
}
- HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E->get());
+ HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E);
if (G) {
if (use_self) {
highest = MAX(G->value->self, highest);
@@ -234,17 +234,17 @@ void EditorProfiler::_update_plot() {
int current = i * frame_metrics.size() / w;
- for (RBSet<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) {
+ for (const StringName &E : plot_sigs) {
const Metric &m = _get_frame_metric(current);
float value = 0;
- HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E->get());
+ HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E);
if (F) {
value = F->value->total_time;
}
- HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E->get());
+ HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E);
if (G) {
if (use_self) {
value = G->value->self;
@@ -256,12 +256,12 @@ void EditorProfiler::_update_plot() {
int plot_pos = CLAMP(int(value * h / highest), 0, h - 1);
int prev_plot = plot_pos;
- HashMap<StringName, int>::Iterator H = prev_plots.find(E->get());
+ HashMap<StringName, int>::Iterator H = prev_plots.find(E);
if (H) {
prev_plot = H->value;
H->value = plot_pos;
} else {
- prev_plots[E->get()] = plot_pos;
+ prev_plots[E] = plot_pos;
}
plot_pos = h - plot_pos - 1;
@@ -271,7 +271,7 @@ void EditorProfiler::_update_plot() {
SWAP(prev_plot, plot_pos);
}
- Color col = _get_color_from_signature(E->get());
+ Color col = _get_color_from_signature(E);
for (int j = prev_plot; j <= plot_pos; j++) {
column[j * 4 + 0] += Math::fast_ftoi(CLAMP(col.r * 255, 0, 255));
@@ -534,9 +534,9 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
Vector<String> signatures;
signatures.resize(possible_signatures.size());
int sig_index = 0;
- for (const RBSet<StringName>::Element *E = possible_signatures.front(); E; E = E->next()) {
- signatures.write[sig_index] = E->get();
- sig_map[E->get()] = sig_index;
+ for (const StringName &E : possible_signatures) {
+ signatures.write[sig_index] = E;
+ sig_map[E] = sig_index;
sig_index++;
}
res.push_back(signatures);
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index 93b155bcd2..b696bc3ac6 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -154,8 +154,8 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
int num_file_conflicts = 0;
- for (RBSet<String>::Element *E = files_sorted.front(); E; E = E->next()) {
- String path = E->get();
+ for (const String &E : files_sorted) {
+ String path = E;
int depth = p_depth;
bool skip = false;
while (depth > 0) {
@@ -224,7 +224,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
ti->set_metadata(0, res_path);
}
- status_map[E->get()] = ti;
+ status_map[E] = ti;
}
if (num_file_conflicts >= 1) {
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index f0eea50d3a..586ffa418c 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -95,9 +95,9 @@ Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
void EditorExportPreset::update_files_to_export() {
Vector<String> to_remove;
- for (RBSet<String>::Element *E = selected_files.front(); E; E = E->next()) {
- if (!FileAccess::exists(E->get())) {
- to_remove.push_back(E->get());
+ for (const String &E : selected_files) {
+ if (!FileAccess::exists(E)) {
+ to_remove.push_back(E);
}
}
for (int i = 0; i < to_remove.size(); ++i) {
@@ -107,8 +107,8 @@ void EditorExportPreset::update_files_to_export() {
Vector<String> EditorExportPreset::get_files_to_export() const {
Vector<String> files;
- for (RBSet<String>::Element *E = selected_files.front(); E; E = E->next()) {
- files.push_back(E->get());
+ for (const String &E : selected_files) {
+ files.push_back(E);
}
return files;
}
@@ -879,8 +879,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
int idx = 0;
int total = paths.size();
- for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) {
- String path = E->get();
+ for (const String &E : paths) {
+ String path = E;
String type = ResourceLoader::get_resource_type(path);
if (FileAccess::exists(path + ".import")) {
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index 7eb5aec5d0..670f193326 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -166,15 +166,15 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
Dictionary data;
data["type"] = "feature_profile";
Array dis_classes;
- for (RBSet<StringName>::Element *E = disabled_classes.front(); E; E = E->next()) {
- dis_classes.push_back(String(E->get()));
+ for (const StringName &E : disabled_classes) {
+ dis_classes.push_back(String(E));
}
dis_classes.sort();
data["disabled_classes"] = dis_classes;
Array dis_editors;
- for (RBSet<StringName>::Element *E = disabled_editors.front(); E; E = E->next()) {
- dis_editors.push_back(String(E->get()));
+ for (const StringName &E : disabled_editors) {
+ dis_editors.push_back(String(E));
}
dis_editors.sort();
data["disabled_editors"] = dis_editors;
@@ -182,8 +182,8 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
Array dis_props;
for (KeyValue<StringName, RBSet<StringName>> &E : disabled_properties) {
- for (RBSet<StringName>::Element *F = E.value.front(); F; F = F->next()) {
- dis_props.push_back(String(E.key) + ":" + String(F->get()));
+ for (const StringName &F : E.value) {
+ dis_props.push_back(String(E.key) + ":" + String(F));
}
}
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 56edb03184..e37bfa32bc 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1458,8 +1458,8 @@ void EditorFileSystem::_save_late_updated_files() {
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4");
Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE);
ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions.");
- for (RBSet<String>::Element *E = late_update_files.front(); E; E = E->next()) {
- f->store_line(E->get());
+ for (const String &E : late_update_files) {
+ f->store_line(E);
}
}
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp
index 39dc253429..ad8aaf324c 100644
--- a/editor/editor_folding.cpp
+++ b/editor/editor_folding.cpp
@@ -40,8 +40,8 @@ Vector<String> EditorFolding::_get_unfolds(const Object *p_object) {
if (sections.size()) {
String *w = sections.ptrw();
int idx = 0;
- for (const RBSet<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) {
- w[idx++] = E->get();
+ for (const String &E : p_object->editor_get_section_folding()) {
+ w[idx++] = E;
}
}
@@ -270,8 +270,8 @@ void EditorFolding::_do_object_unfolds(Object *p_object, RBSet<Ref<Resource>> &r
}
}
- for (RBSet<String>::Element *E = unfold_group.front(); E; E = E->next()) {
- p_object->editor_set_section_unfold(E->get(), true);
+ for (const String &E : unfold_group) {
+ p_object->editor_set_section_unfold(E, true);
}
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 0b96900053..f2baaf8b5c 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -231,8 +231,8 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto
RBSet<int> iset = index_sets[i];
while (iset.size() > 1) {
// Append the parent folder to each scene name.
- for (RBSet<int>::Element *E = iset.front(); E; E = E->next()) {
- int set_idx = E->get();
+ for (const int &E : iset) {
+ int set_idx = E;
String scene_name = r_filenames[set_idx];
String full_path = p_full_paths[set_idx];
@@ -270,11 +270,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto
while (E) {
String scene_name = r_filenames[E->get()];
bool duplicate_found = false;
- for (RBSet<int>::Element *F = iset.front(); F; F = F->next()) {
- if (E->get() == F->get()) {
+ for (const int &F : iset) {
+ if (E->get() == F) {
continue;
}
- String other_scene_name = r_filenames[F->get()];
+ String other_scene_name = r_filenames[F];
if (other_scene_name == scene_name) {
duplicate_found = true;
break;
@@ -907,12 +907,12 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) {
}
void EditorNode::_fs_changed() {
- for (RBSet<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) {
- E->get()->invalidate();
+ for (FileDialog *E : file_dialogs) {
+ E->invalidate();
}
- for (RBSet<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) {
- E->get()->invalidate();
+ for (EditorFileDialog *E : editor_file_dialogs) {
+ E->invalidate();
}
_mark_unsaved_scenes();
@@ -1185,8 +1185,8 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) {
Vector<String> errors;
- for (RBSet<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) {
- errors.push_back(E->get());
+ for (const String &E : dependency_errors[p_resource]) {
+ errors.push_back(E);
}
dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors);
dependency_errors.erase(p_resource);
@@ -1677,8 +1677,8 @@ int EditorNode::_save_external_resources() {
// Clear later, because user may have put the same subresource in two different resources,
// which will be shared until the next reload.
- for (RBSet<Ref<Resource>>::Element *E = edited_subresources.front(); E; E = E->next()) {
- Ref<Resource> res = E->get();
+ for (const Ref<Resource> &E : edited_subresources) {
+ Ref<Resource> res = E;
res->set_edited(false);
}
@@ -3663,8 +3663,8 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (!p_ignore_broken_deps && dependency_errors.has(lpath)) {
current_menu_option = -1;
Vector<String> errors;
- for (RBSet<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) {
- errors.push_back(E->get());
+ for (const String &E : dependency_errors[lpath]) {
+ errors.push_back(E);
}
dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors);
opening_prev = false;
@@ -3680,8 +3680,8 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
for (KeyValue<String, RBSet<String>> &E : dependency_errors) {
String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E.key) + "\n";
- for (RBSet<String>::Element *F = E.value.front(); F; F = F->next()) {
- txt += "\t" + F->get() + "\n";
+ for (const String &F : E.value) {
+ txt += "\t" + F + "\n";
}
add_io_error(txt);
}
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 41d769ad1f..cb3000ee88 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -253,8 +253,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
}
file_dialog->clear_filters();
- for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
- file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
+ for (const String &E : valid_extensions) {
+ file_dialog->add_filter("*." + E + " ; " + E.to_upper());
}
file_dialog->popup_file_dialog();
@@ -417,8 +417,8 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"];
}
- for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) {
- const String &t = E->get();
+ for (const String &E : allowed_types) {
+ const String &t = E;
bool is_custom_resource = false;
Ref<Texture2D> icon;
@@ -599,8 +599,8 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const {
}
bool EditorResourcePicker::_is_type_valid(const String p_type_name, RBSet<String> p_allowed_types) const {
- for (RBSet<String>::Element *E = p_allowed_types.front(); E; E = E->next()) {
- String at = E->get().strip_edges();
+ for (const String &E : p_allowed_types) {
+ String at = E.strip_edges();
if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) {
return true;
}
@@ -651,8 +651,8 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
// If the accepted dropped resource is from the extended list, it requires conversion.
if (!_is_type_valid(dropped_resource->get_class(), allowed_types)) {
- for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) {
- String at = E->get().strip_edges();
+ for (const String &E : allowed_types) {
+ String at = E.strip_edges();
if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) {
// Use existing resource if possible and only replace its data.
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index e251a66610..5160492e51 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -268,25 +268,25 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
vclist.insert(vc);
}
- for (RBSet<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) {
+ for (const _EVCSort &E : vclist) {
uint32_t pusage = PROPERTY_USAGE_NONE;
- if (E->get().save || !optimize_save) {
+ if (E.save || !optimize_save) {
pusage |= PROPERTY_USAGE_STORAGE;
}
- if (!E->get().name.begins_with("_") && !E->get().name.begins_with("projects/")) {
+ if (!E.name.begins_with("_") && !E.name.begins_with("projects/")) {
pusage |= PROPERTY_USAGE_EDITOR;
} else {
pusage |= PROPERTY_USAGE_STORAGE; //hiddens must always be saved
}
- PropertyInfo pi(E->get().type, E->get().name);
+ PropertyInfo pi(E.type, E.name);
pi.usage = pusage;
- if (hints.has(E->get().name)) {
- pi = hints[E->get().name];
+ if (hints.has(E.name)) {
+ pi = hints[E.name];
}
- if (E->get().restart_if_changed) {
+ if (E.restart_if_changed) {
pi.usage |= PROPERTY_USAGE_RESTART_IF_CHANGED;
}
diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp
index 13dff08c14..ddb084e19b 100644
--- a/editor/editor_translation_parser.cpp
+++ b/editor/editor_translation_parser.cpp
@@ -96,8 +96,8 @@ void EditorTranslationParser::get_recognized_extensions(List<String> *r_extensio
for (int i = 0; i < temp.size(); i++) {
extensions.insert(temp[i]);
}
- for (RBSet<String>::Element *E = extensions.front(); E; E = E->next()) {
- r_extensions->push_back(E->get());
+ for (const String &E : extensions) {
+ r_extensions->push_back(E);
}
}
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 8ee47cb6f4..03fda0a1c3 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -875,8 +875,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
Vector<Collada::Vertex> vertex_array; //there we go, vertex array
vertex_array.resize(vertex_set.size());
- for (RBSet<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) {
- vertex_array.write[F->get().idx] = F->get();
+ for (Collada::Vertex &F : vertex_set) {
+ vertex_array.write[F.idx] = F;
}
if (has_weights) {
@@ -1507,14 +1507,14 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
bool tracks_found = false;
- for (RBSet<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) {
+ for (const String &E : valid_animated_nodes) {
// take snapshots
- if (!collada.state.scene_map.has(E->get())) {
+ if (!collada.state.scene_map.has(E)) {
continue;
}
- NodeMap &nm = node_map[E->get()];
+ NodeMap &nm = node_map[E];
String path = scene->get_path_to(nm.node);
if (nm.bone >= 0) {
@@ -1525,7 +1525,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
bool found_anim = false;
- Collada::Node *cn = collada.state.scene_map[E->get()];
+ Collada::Node *cn = collada.state.scene_map[E];
if (cn->ignore_anim) {
continue;
}
@@ -1665,7 +1665,7 @@ void ColladaImport::create_animation(int p_clip, bool p_import_value_tracks) {
if (nm.bone >= 0) {
if (found_anim) {
- bones_with_animation[E->get()] = true;
+ bones_with_animation[E] = true;
}
}
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 647eb1344b..4f666730d5 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -466,7 +466,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<R
static const char *loop_strings[loop_string_count] = { "loop_mode", "loop", "cycle" };
for (int i = 0; i < loop_string_count; i++) {
if (_teststr(animname, loop_strings[i])) {
- anim->set_loop_mode(Animation::LoopMode::LOOP_LINEAR);
+ anim->set_loop_mode(Animation::LOOP_LINEAR);
animname = _fixstr(animname, loop_strings[i]);
Ref<AnimationLibrary> library = ap->get_animation_library(ap->find_animation_library(anim));
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 08df704f44..715b1725e0 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -603,8 +603,8 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
HashMap<String, TreeItem *> parenthood;
- for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) {
- NodePath path = E->get();
+ for (const String &E : paths) {
+ NodePath path = E;
TreeItem *ti = nullptr;
String accum;
for (int i = 0; i < path.get_name_count(); i++) {
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 581dab84b4..57cf13d298 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -1338,7 +1338,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
float pos = cpos + step_off * anim->get_step();
- bool valid = anim->get_loop_mode() != Animation::LoopMode::LOOP_NONE || (pos >= 0 && pos <= anim->get_length());
+ bool valid = anim->get_loop_mode() != Animation::LOOP_NONE || (pos >= 0 && pos <= anim->get_length());
onion.captures_valid.write[cidx] = valid;
if (valid) {
player->seek(pos, true);
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 1d85e80331..10c63afa02 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -6710,8 +6710,8 @@ RBSet<RID> _get_physics_bodies_rid(Node *node) {
rids.insert(pb->get_rid());
}
RBSet<PhysicsBody3D *> child_nodes = _get_child_nodes<PhysicsBody3D>(node);
- for (RBSet<PhysicsBody3D *>::Element *I = child_nodes.front(); I; I = I->next()) {
- rids.insert(I->get()->get_rid());
+ for (const PhysicsBody3D *I : child_nodes) {
+ rids.insert(I->get_rid());
}
return rids;
@@ -6755,8 +6755,8 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
}
if (!found_valid_shape && vi.size()) {
AABB aabb = vi.front()->get()->get_transformed_aabb();
- for (RBSet<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) {
- aabb.merge_with(I->get()->get_transformed_aabb());
+ for (const VisualInstance3D *I : vi) {
+ aabb.merge_with(I->get_transformed_aabb());
}
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
from = aabb.position + size;
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index b632b0d641..bebc0e9d54 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -83,8 +83,8 @@ void EditorPropertyRootMotion::_node_assign() {
HashMap<String, TreeItem *> parenthood;
- for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) {
- NodePath path = E->get();
+ for (const String &E : paths) {
+ NodePath path = E;
TreeItem *ti = nullptr;
String accum;
for (int i = 0; i < path.get_name_count(); i++) {
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index ee8767e6a6..f666ac0649 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -693,8 +693,8 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
_find_changed_scripts_for_external_editor(base, base, scripts);
}
- for (RBSet<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) {
- Ref<Script> script = E->get();
+ for (const Ref<Script> &E : scripts) {
+ Ref<Script> script = E;
if (p_for_script.is_valid() && p_for_script != script) {
continue;
@@ -1568,7 +1568,12 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
continue;
}
- String path = sn->get_path_to(node);
+ String path;
+ if (node->is_unique_name_in_owner()) {
+ path = "%" + node->get_name();
+ } else {
+ path = sn->get_path_to(node);
+ }
for (const String &segment : path.split("/")) {
if (!segment.is_valid_identifier()) {
path = path.c_escape().quote(quote_style);
@@ -1595,7 +1600,12 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
continue;
}
- String path = sn->get_path_to(node);
+ String path;
+ if (node->is_unique_name_in_owner()) {
+ path = "%" + node->get_name();
+ } else {
+ path = sn->get_path_to(node);
+ }
for (const String &segment : path.split("/")) {
if (!segment.is_valid_identifier()) {
path = path.c_escape().quote(quote_style);
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index cb8d59dfe4..8a40ffbe38 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -125,8 +125,8 @@ void SpriteFramesEditor::_sheet_preview_draw() {
Color accent = get_theme_color("accent_color", "Editor");
- for (RBSet<int>::Element *E = frames_selected.front(); E; E = E->next()) {
- const int idx = E->get();
+ for (const int &E : frames_selected) {
+ const int idx = E;
const int x = idx % frame_count.x;
const int y = idx / frame_count.x;
const Point2 pos = draw_offset + Point2(x, y) * (draw_frame_size + draw_sep);
@@ -248,8 +248,8 @@ void SpriteFramesEditor::_sheet_add_frames() {
int fc = frames->get_frame_count(edited_anim);
- for (RBSet<int>::Element *E = frames_selected.front(); E; E = E->next()) {
- int idx = E->get();
+ for (const int &E : frames_selected) {
+ int idx = E;
const Point2 frame_coords(idx % frame_count.x, idx / frame_count.x);
Ref<AtlasTexture> at;
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index eda05b1005..244c718ebe 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -897,8 +897,8 @@ void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_
}
}
- for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
- Vector2i coords = E->get().get_atlas_coords();
+ for (const TileMapCell &E : edited) {
+ Vector2i coords = E.get_atlas_coords();
p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false);
}
p_canvas_item->draw_set_transform_matrix(Transform2D());
@@ -1755,8 +1755,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas
}
}
- for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
- Vector2i coords = E->get().get_atlas_coords();
+ for (const TileMapCell &E : edited) {
+ Vector2i coords = E.get_atlas_coords();
p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false);
}
p_canvas_item->draw_set_transform_matrix(Transform2D());
@@ -1800,8 +1800,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas
p_canvas_item->draw_set_transform_matrix(p_transform);
- for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
- Vector2i coords = E->get().get_atlas_coords();
+ for (const TileMapCell &E : edited) {
+ Vector2i coords = E.get_atlas_coords();
Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
Vector2i position = texture_region.get_center() + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
@@ -2133,15 +2133,15 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t
}
}
undo_redo->create_action(TTR("Painting Terrain Set"));
- for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
- Vector2i coords = E->get().get_atlas_coords();
+ for (const TileMapCell &E : edited) {
+ Vector2i coords = E.get_atlas_coords();
TileData *tile_data = p_tile_set_atlas_source->get_tile_data(coords, 0);
- undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->get().alternative_tile), tile_data->get_terrain_set());
- undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->get().alternative_tile), drag_painted_value);
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.alternative_tile), tile_data->get_terrain_set());
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.alternative_tile), drag_painted_value);
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
if (tile_data->is_valid_peering_bit_terrain(bit)) {
- undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), tile_data->get_peering_bit_terrain(bit));
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), tile_data->get_peering_bit_terrain(bit));
}
}
}
@@ -2220,8 +2220,8 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t
mouse_pos_rect_polygon.push_back(Vector2(drag_start_pos.x, mb->get_position().y));
undo_redo->create_action(TTR("Painting Terrain"));
- for (RBSet<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
- Vector2i coords = E->get().get_atlas_coords();
+ for (const TileMapCell &E : edited) {
+ Vector2i coords = E.get_atlas_coords();
TileData *tile_data = p_tile_set_atlas_source->get_tile_data(coords, 0);
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
@@ -2236,8 +2236,8 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t
}
if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).is_empty()) {
// Draw bit.
- undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), terrain);
- undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), tile_data->get_peering_bit_terrain(bit));
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), terrain);
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), tile_data->get_peering_bit_terrain(bit));
}
}
}
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 12e1f10750..6c39244f80 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -501,8 +501,8 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
if (!tile_map_selection.is_empty()) {
tile_map_clipboard.instantiate();
TypedArray<Vector2i> coords_array;
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- coords_array.push_back(E->get());
+ for (const Vector2i &E : tile_map_selection) {
+ coords_array.push_back(E);
}
tile_map_clipboard = tile_map->get_pattern(tile_map_layer, coords_array);
}
@@ -511,9 +511,9 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
// Delete selected tiles.
if (!tile_map_selection.is_empty()) {
undo_redo->create_action(TTR("Delete tiles"));
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
- undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->get(), tile_map->get_cell_source_id(tile_map_layer, E->get()), tile_map->get_cell_atlas_coords(tile_map_layer, E->get()), tile_map->get_cell_alternative_tile(tile_map_layer, E->get()));
+ for (const Vector2i &E : tile_map_selection) {
+ undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
+ undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E, tile_map->get_cell_source_id(tile_map_layer, E), tile_map->get_cell_atlas_coords(tile_map_layer, E), tile_map->get_cell_alternative_tile(tile_map_layer, E));
}
undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection());
tile_map_selection.clear();
@@ -542,9 +542,9 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
// Delete selected tiles.
if (!tile_map_selection.is_empty()) {
undo_redo->create_action(TTR("Delete tiles"));
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
- undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->get(), tile_map->get_cell_source_id(tile_map_layer, E->get()), tile_map->get_cell_atlas_coords(tile_map_layer, E->get()), tile_map->get_cell_alternative_tile(tile_map_layer, E->get()));
+ for (const Vector2i &E : tile_map_selection) {
+ undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
+ undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E, tile_map->get_cell_source_id(tile_map_layer, E), tile_map->get_cell_atlas_coords(tile_map_layer, E), tile_map->get_cell_alternative_tile(tile_map_layer, E));
}
undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection());
tile_map_selection.clear();
@@ -628,8 +628,8 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
_update_selection_pattern_from_tilemap_selection(); // Make sure the pattern is up to date before moving.
drag_type = DRAG_TYPE_MOVE;
drag_modified.clear();
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- Vector2i coords = E->get();
+ for (const Vector2i &E : tile_map_selection) {
+ Vector2i coords = E;
drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords));
tile_map->set_cell(tile_map_layer, coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
}
@@ -785,8 +785,8 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over
if (!tile_map_selection.is_empty()) {
top_left = tile_map_selection.front()->get();
}
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- top_left = top_left.min(E->get());
+ for (const Vector2i &E : tile_map_selection) {
+ top_left = top_left.min(E);
}
Vector2i offset = drag_start_mouse_pos - tile_map->map_to_world(top_left);
offset = tile_map->world_to_map(drag_last_mouse_pos - offset) - tile_map->world_to_map(drag_start_mouse_pos - offset);
@@ -1278,8 +1278,8 @@ void TileMapEditorTilesPlugin::_stop_dragging() {
if (!tile_map_selection.is_empty()) {
top_left = tile_map_selection.front()->get();
}
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- top_left = top_left.min(E->get());
+ for (const Vector2i &E : tile_map_selection) {
+ top_left = top_left.min(E);
}
// Get the offset from the mouse.
@@ -1534,8 +1534,8 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection(
selection_pattern.instantiate();
TypedArray<Vector2i> coords_array;
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- coords_array.push_back(E->get());
+ for (const Vector2i &E : tile_map_selection) {
+ coords_array.push_back(E);
}
selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array);
}
@@ -1559,8 +1559,8 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sele
// Group per source.
HashMap<int, List<const TileMapCell *>> per_source;
- for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) {
- per_source[E->get().source_id].push_back(&(E->get()));
+ for (const TileMapCell &E : tile_set_selection) {
+ per_source[E.source_id].push_back(&(E));
}
int vertical_offset = 0;
@@ -1680,14 +1680,14 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() {
// Draw the selection.
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
- for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) {
- if (E->get().source_id == source_id && E->get().alternative_tile == 0) {
- for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E->get().get_atlas_coords()); frame++) {
+ for (const TileMapCell &E : tile_set_selection) {
+ if (E.source_id == source_id && E.alternative_tile == 0) {
+ for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E.get_atlas_coords()); frame++) {
Color color = selection_color;
if (frame > 0) {
color.a *= 0.3;
}
- tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get().get_atlas_coords(), frame), color, false);
+ tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E.get_atlas_coords(), frame), color, false);
}
}
}
@@ -1721,8 +1721,8 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() {
}
}
Color selection_rect_color = selection_color.lightened(0.2);
- for (RBSet<Vector2i>::Element *E = to_draw.front(); E; E = E->next()) {
- tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get()), selection_rect_color, false);
+ for (const Vector2i &E : to_draw) {
+ tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E), selection_rect_color, false);
}
}
}
@@ -1868,9 +1868,9 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() {
}
// Draw the selection.
- for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) {
- if (E->get().source_id == source_id && E->get().get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E->get().alternative_tile > 0) {
- Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().get_atlas_coords(), E->get().alternative_tile);
+ for (const TileMapCell &E : tile_set_selection) {
+ if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E.alternative_tile > 0) {
+ Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), E.alternative_tile);
if (rect != Rect2i()) {
alternative_tiles_control->draw_rect(rect, Color(0.2, 0.2, 1.0), false);
}
@@ -1972,8 +1972,8 @@ void TileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArray<Vector2i
TypedArray<Vector2i> TileMapEditorTilesPlugin::_get_tile_map_selection() const {
TypedArray<Vector2i> output;
- for (RBSet<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
- output.push_back(E->get());
+ for (const Vector2i &E : tile_map_selection) {
+ output.push_back(E);
}
return output;
}
@@ -2341,8 +2341,8 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const
TileSet::TerrainsPattern terrains_pattern = E_to_paint.value;
RBSet<TileMap::TerrainConstraint> cell_constraints = tile_map->get_terrain_constraints_from_added_tile(coords, p_terrain_set, terrains_pattern);
- for (RBSet<TileMap::TerrainConstraint>::Element *E = cell_constraints.front(); E; E = E->next()) {
- added_tiles_constraints_set.insert(E->get());
+ for (const TileMap::TerrainConstraint &E : cell_constraints) {
+ added_tiles_constraints_set.insert(E);
}
}
@@ -2377,18 +2377,18 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const
// Filter the sources to make sure they are in the potential_to_replace.
RBMap<TileMap::TerrainConstraint, RBSet<Vector2i>> per_constraint_tiles;
- for (RBSet<TileMap::TerrainConstraint>::Element *E = removed_cells_constraints_set.front(); E; E = E->next()) {
- HashMap<Vector2i, TileSet::CellNeighbor> sources_of_constraint = E->get().get_overlapping_coords_and_peering_bits();
+ for (const TileMap::TerrainConstraint &E : removed_cells_constraints_set) {
+ HashMap<Vector2i, TileSet::CellNeighbor> sources_of_constraint = E.get_overlapping_coords_and_peering_bits();
for (const KeyValue<Vector2i, TileSet::CellNeighbor> &E_source_tile_of_constraint : sources_of_constraint) {
if (potential_to_replace.has(E_source_tile_of_constraint.key)) {
- per_constraint_tiles[E->get()].insert(E_source_tile_of_constraint.key);
+ per_constraint_tiles[E].insert(E_source_tile_of_constraint.key);
}
}
}
to_replace_modified = false;
- for (RBSet<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) {
- TileMap::TerrainConstraint c = E->get();
+ for (const TileMap::TerrainConstraint &E : added_tiles_constraints_set) {
+ TileMap::TerrainConstraint c = E;
// Check if we have a conflict in constraints.
if (removed_cells_constraints_set.has(c) && removed_cells_constraints_set.find(c)->get().get_terrain() != c.get_terrain()) {
// If we do, we search for a neighbor to remove.
@@ -2409,8 +2409,8 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const
// Combine all constraints together.
RBSet<TileMap::TerrainConstraint> constraints = removed_cells_constraints_set;
- for (RBSet<TileMap::TerrainConstraint>::Element *E = added_tiles_constraints_set.front(); E; E = E->next()) {
- constraints.insert(E->get());
+ for (const TileMap::TerrainConstraint &E : added_tiles_constraints_set) {
+ constraints.insert(E);
}
// Remove the central tiles from the ones to replace.
@@ -3194,22 +3194,22 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() {
// Sort the items in a map by the number of corresponding terrains.
RBMap<int, RBSet<TileSet::TerrainsPattern>> sorted;
- for (RBSet<TileSet::TerrainsPattern>::Element *E = per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id].front(); E; E = E->next()) {
+ for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id]) {
// Count the number of matching sides/terrains.
int count = 0;
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
- if (tile_set->is_valid_peering_bit_terrain(selected_terrain_set, bit) && E->get().get_terrain(bit) == selected_terrain_id) {
+ if (tile_set->is_valid_peering_bit_terrain(selected_terrain_set, bit) && E.get_terrain(bit) == selected_terrain_id) {
count++;
}
}
- sorted[count].insert(E->get());
+ sorted[count].insert(E);
}
for (RBMap<int, RBSet<TileSet::TerrainsPattern>>::Element *E_set = sorted.back(); E_set; E_set = E_set->prev()) {
- for (RBSet<TileSet::TerrainsPattern>::Element *E = E_set->get().front(); E; E = E->next()) {
- TileSet::TerrainsPattern terrains_pattern = E->get();
+ for (const TileSet::TerrainsPattern &E : E_set->get()) {
+ TileSet::TerrainsPattern terrains_pattern = E;
// Get the icon.
Ref<Texture2D> icon;
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index dc3fa87565..b87aedcf60 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -270,9 +270,9 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na
// Other properties.
bool any_valid = false;
- for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
- const Vector2i &coords = E->get().tile;
- const int &alternative = E->get().alternative;
+ for (const TileSelection &E : tiles) {
+ const Vector2i &coords = E.tile;
+ const int &alternative = E.alternative;
bool valid = false;
TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative);
@@ -354,11 +354,11 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na
}
}
- for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
+ for (const TileSelection &E : tiles) {
// Return the first tile with a property matching the name.
// Note: It's a little bit annoying, but the behavior is the same the one in MultiNodeEdit.
- const Vector2i &coords = E->get().tile;
- const int &alternative = E->get().alternative;
+ const Vector2i &coords = E.tile;
+ const int &alternative = E.alternative;
TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative);
ERR_FAIL_COND_V(!tile_data, false);
@@ -429,9 +429,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro
RBMap<PropertyId, PLData> usage;
List<PLData *> data_list;
- for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
- const Vector2i &coords = E->get().tile;
- const int &alternative = E->get().alternative;
+ for (const TileSelection &E : tiles) {
+ const Vector2i &coords = E.tile;
+ const int &alternative = E.alternative;
TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative);
ERR_FAIL_COND(!tile_data);
@@ -476,15 +476,15 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro
void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_tile_set_atlas_source, RBSet<TileSelection> p_tiles) {
ERR_FAIL_COND(!p_tile_set_atlas_source);
ERR_FAIL_COND(p_tiles.is_empty());
- for (RBSet<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
- ERR_FAIL_COND(E->get().tile == TileSetSource::INVALID_ATLAS_COORDS);
- ERR_FAIL_COND(E->get().alternative < 0);
+ for (const TileSelection &E : p_tiles) {
+ ERR_FAIL_COND(E.tile == TileSetSource::INVALID_ATLAS_COORDS);
+ ERR_FAIL_COND(E.alternative < 0);
}
// Disconnect to changes.
- for (RBSet<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
- const Vector2i &coords = E->get().tile;
- const int &alternative = E->get().alternative;
+ for (const TileSelection &E : tiles) {
+ const Vector2i &coords = E.tile;
+ const int &alternative = E.alternative;
if (tile_set_atlas_source && tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative);
@@ -498,9 +498,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_
tiles = RBSet<TileSelection>(p_tiles);
// Connect to changes.
- for (RBSet<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
- const Vector2i &coords = E->get().tile;
- const int &alternative = E->get().alternative;
+ for (const TileSelection &E : p_tiles) {
+ const Vector2i &coords = E.tile;
+ const int &alternative = E.alternative;
if (tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
TileData *tile_data = tile_set_atlas_source->get_tile_data(coords, alternative);
@@ -1313,9 +1313,9 @@ void TileSetAtlasSourceEditor::_end_dragging() {
switch (drag_type) {
case DRAG_TYPE_CREATE_TILES:
undo_redo->create_action(TTR("Create tiles"));
- for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) {
- undo_redo->add_do_method(tile_set_atlas_source, "create_tile", E->get());
- undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", E->get());
+ for (const Vector2i &E : drag_modified_tiles) {
+ undo_redo->add_do_method(tile_set_atlas_source, "create_tile", E);
+ undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", E);
}
undo_redo->commit_action(false);
break;
@@ -1330,8 +1330,8 @@ void TileSetAtlasSourceEditor::_end_dragging() {
tile_set_atlas_source->get_property_list(&list);
HashMap<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source);
undo_redo->create_action(TTR("Remove tiles"));
- for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) {
- Vector2i coords = E->get();
+ for (const Vector2i &E : drag_modified_tiles) {
+ Vector2i coords = E;
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords);
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords);
if (per_tile.has(coords)) {
@@ -1384,8 +1384,8 @@ void TileSetAtlasSourceEditor::_end_dragging() {
undo_redo->create_action(TTR("Remove tiles"));
undo_redo->add_do_method(this, "_set_selection_from_array", Array());
- for (RBSet<Vector2i>::Element *E = to_delete.front(); E; E = E->next()) {
- Vector2i coords = E->get();
+ for (const Vector2i &E : to_delete) {
+ Vector2i coords = E;
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords);
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords);
if (per_tile.has(coords)) {
@@ -1549,8 +1549,8 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) {
// Remove tiles
RBSet<Vector2i> removed;
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- TileSelection selected = E->get();
+ for (const TileSelection &E : selection) {
+ TileSelection selected = E;
if (selected.alternative == 0) {
// Remove a tile.
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", selected.tile);
@@ -1569,8 +1569,8 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) {
}
// Remove alternatives
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- TileSelection selected = E->get();
+ for (const TileSelection &E : selection) {
+ TileSelection selected = E;
if (selected.alternative > 0 && !removed.has(selected.tile)) {
// Remove an alternative tile.
undo_redo->add_do_method(tile_set_atlas_source, "remove_alternative_tile", selected.tile, selected.alternative);
@@ -1608,13 +1608,13 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) {
case TILE_CREATE_ALTERNATIVE: {
undo_redo->create_action(TTR("Create tile alternatives"));
Array array;
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- if (E->get().alternative == 0) {
- int next_id = tile_set_atlas_source->get_next_alternative_tile_id(E->get().tile);
- undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", E->get().tile, next_id);
- array.push_back(E->get().tile);
+ for (const TileSelection &E : selection) {
+ if (E.alternative == 0) {
+ int next_id = tile_set_atlas_source->get_next_alternative_tile_id(E.tile);
+ undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", E.tile, next_id);
+ array.push_back(E.tile);
array.push_back(next_id);
- undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", E->get().tile, next_id);
+ undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", E.tile, next_id);
}
}
undo_redo->add_do_method(this, "_set_selection_from_array", array);
@@ -1658,9 +1658,9 @@ void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
Array TileSetAtlasSourceEditor::_get_selection_as_array() {
Array output;
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- output.push_back(E->get().tile);
- output.push_back(E->get().alternative);
+ for (const TileSelection &E : selection) {
+ output.push_back(E.tile);
+ output.push_back(E.alternative);
}
return output;
}
@@ -1672,8 +1672,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
// Draw the selected tile.
if (tools_button_group->get_pressed_button() == tool_select_button) {
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- TileSelection selected = E->get();
+ for (const TileSelection &E : selection) {
+ TileSelection selected = E;
if (selected.alternative == 0) {
// Draw the rect.
for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(selected.tile); frame++) {
@@ -1722,9 +1722,9 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
if (drag_type == DRAG_TYPE_REMOVE_TILES) {
// Draw the tiles to be removed.
- for (RBSet<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) {
- for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(E->get()); frame++) {
- tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(E->get(), frame), Color(0.0, 0.0, 0.0), false);
+ for (const Vector2i &E : drag_modified_tiles) {
+ for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(E); frame++) {
+ tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(E, frame), Color(0.0, 0.0, 0.0), false);
}
}
} else if (drag_type == DRAG_TYPE_RECT_SELECT || drag_type == DRAG_TYPE_REMOVE_TILES_USING_RECT) {
@@ -1749,8 +1749,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
}
}
- for (RBSet<Vector2i>::Element *E = to_paint.front(); E; E = E->next()) {
- Vector2i coords = E->get();
+ for (const Vector2i &E : to_paint) {
+ Vector2i coords = E;
tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(coords), color, false);
}
} else if (drag_type == DRAG_TYPE_CREATE_TILES_USING_RECT) {
@@ -1837,19 +1837,19 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
// Draw the selection on top of other.
if (tools_button_group->get_pressed_button() == tool_select_button) {
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- if (E->get().alternative != 0) {
+ for (const TileSelection &E : selection) {
+ if (E.alternative != 0) {
continue;
}
- Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(E->get().tile);
- Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_effective_texture_offset(E->get().tile, 0);
+ Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(E.tile);
+ Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_effective_texture_offset(E.tile, 0);
Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
xform.translate(position);
TileMapCell cell;
cell.source_id = tile_set_atlas_source_id;
- cell.set_atlas_coords(E->get().tile);
+ cell.set_atlas_coords(E.tile);
cell.alternative_tile = 0;
current_tile_data_editor->draw_over_tile(tile_atlas_control_unscaled, xform, cell, true);
}
@@ -1962,8 +1962,8 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
}
// Draw selected tile.
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- TileSelection selected = E->get();
+ for (const TileSelection &E : selection) {
+ TileSelection selected = E;
if (selected.alternative >= 1) {
Rect2i rect = tile_atlas_view->get_alternative_tile_rect(selected.tile, selected.alternative);
if (rect != Rect2i()) {
@@ -2005,11 +2005,11 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
// Draw the selection on top of other.
if (tools_button_group->get_pressed_button() == tool_select_button) {
- for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
- if (E->get().alternative == 0) {
+ for (const TileSelection &E : selection) {
+ if (E.alternative == 0) {
continue;
}
- Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().tile, E->get().alternative);
+ Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.tile, E.alternative);
Vector2 position = rect.get_center();
Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
@@ -2017,8 +2017,8 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
TileMapCell cell;
cell.source_id = tile_set_atlas_source_id;
- cell.set_atlas_coords(E->get().tile);
- cell.alternative_tile = E->get().alternative;
+ cell.set_atlas_coords(E.tile);
+ cell.alternative_tile = E.alternative;
current_tile_data_editor->draw_over_tile(alternative_tiles_control_unscaled, xform, cell, true);
}
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index c5669f3eda..0595357926 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -3215,8 +3215,8 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
const RBSet<int> &current_set = p_vice_versa ? selected_uniforms : selected_constants;
RBSet<String> deleted_names;
- for (RBSet<int>::Element *E = current_set.front(); E; E = E->next()) {
- int node_id = E->get();
+ for (const int &E : current_set) {
+ int node_id = E;
Ref<VisualShaderNode> node = visual_shader->get_node(type_id, node_id);
bool caught = false;
Variant var;
diff --git a/editor/pot_generator.cpp b/editor/pot_generator.cpp
index c46a4f5a86..bfc58db2ad 100644
--- a/editor/pot_generator.cpp
+++ b/editor/pot_generator.cpp
@@ -46,8 +46,8 @@ void POTGenerator::_print_all_translation_strings() {
print_line("msgid: " + E.key());
print_line("context: " + v_md[i].ctx);
print_line("msgid_plural: " + v_md[i].plural);
- for (RBSet<String>::Element *F = v_md[i].locations.front(); F; F = F->next()) {
- print_line("location: " + F->get());
+ for (const String &F : v_md[i].locations) {
+ print_line("location: " + F);
}
}
}
@@ -133,8 +133,8 @@ void POTGenerator::_write_to_pot(const String &p_file) {
file->store_line("");
// Write file locations.
- for (RBSet<String>::Element *E = locations.front(); E; E = E->next()) {
- file->store_line("#: " + E->get().trim_prefix("res://"));
+ for (const String &E : locations) {
+ file->store_line("#: " + E.trim_prefix("res://"));
}
// Write context.
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index d74cfe4ec0..967cb5a932 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -2099,8 +2099,8 @@ void ProjectManager::_open_selected_projects() {
const RBSet<String> &selected_list = _project_list->get_selected_project_keys();
- for (const RBSet<String>::Element *E = selected_list.front(); E; E = E->next()) {
- const String &selected = E->get();
+ for (const String &E : selected_list) {
+ const String &selected = E;
String path = EditorSettings::get_singleton()->get("projects/" + selected);
String conf = path.plus_file("project.godot");
@@ -2327,8 +2327,8 @@ void ProjectManager::_rename_project() {
return;
}
- for (RBSet<String>::Element *E = selected_list.front(); E; E = E->next()) {
- const String &selected = E->get();
+ for (const String &E : selected_list) {
+ const String &selected = E;
String path = EditorSettings::get_singleton()->get("projects/" + selected);
npdialog->set_project_path(path);
npdialog->set_mode(ProjectDialog::MODE_RENAME);
@@ -2412,8 +2412,8 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) {
}
if (folders_set.size() > 0) {
PackedStringArray folders;
- for (RBSet<String>::Element *E = folders_set.front(); E; E = E->next()) {
- folders.push_back(E->get());
+ for (const String &E : folders_set) {
+ folders.push_back(E);
}
bool confirm = true;
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index bd0affbcc3..5367306f1a 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -292,8 +292,8 @@ void ProjectSettingsEditor::_add_feature_overrides() {
feature_box->clear();
feature_box->add_item(TTR("(All)"), 0); // So it is always on top.
int id = 1;
- for (RBSet<String>::Element *E = presets.front(); E; E = E->next()) {
- feature_box->add_item(E->get(), id++);
+ for (const String &E : presets) {
+ feature_box->add_item(E, id++);
}
}
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 71cdcc2580..d541b26cc9 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -143,8 +143,8 @@ void CustomPropertyEditor::_menu_option(int p_which) {
}
file->clear_filters();
- for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
- file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
+ for (const String &E : valid_extensions) {
+ file->add_filter("*." + E + " ; " + E.to_upper());
}
file->popup_file_dialog();
@@ -890,8 +890,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
E = E->next();
}
- for (RBSet<String>::Element *j = valid_inheritors.front(); j; j = j->next()) {
- const String &t = j->get();
+ for (const String &j : valid_inheritors) {
+ const String &t = j;
bool is_custom_resource = false;
Ref<Texture2D> icon;
diff --git a/editor/translations/extract.py b/editor/translations/extract.py
index bd32fc01c7..7f3da400e7 100755
--- a/editor/translations/extract.py
+++ b/editor/translations/extract.py
@@ -100,6 +100,7 @@ class ExtractType(enum.IntEnum):
TEXT = 1
PROPERTY_PATH = 2
GROUP = 3
+ SUBGROUP = 4
# Regex "(?P<name>([^"\\]|\\.)*)" creates a group named `name` that matches a string.
@@ -115,19 +116,23 @@ message_patterns = {
): ExtractType.TEXT,
re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
re.compile(r'GLOBAL_DEF(_RST)?(_NOVAL)?(_BASIC)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
- re.compile(r'GLOBAL_DEF_BASIC\(vformat\("(?P<message>layer_names/\w+)/layer_%d"'): ExtractType.PROPERTY_PATH,
re.compile(r'EDITOR_DEF(_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
re.compile(
r'EDITOR_SETTING(_USAGE)?\(Variant::[_A-Z0-9]+, [_A-Z0-9]+, "(?P<message>[^"]+?)",'
): ExtractType.PROPERTY_PATH,
re.compile(
- r'(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]'
+ r"(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\("
+ + r"Variant::[_A-Z0-9]+" # Name
+ + r', "(?P<message>[^"]+)"' # Type
+ + r'(, [_A-Z0-9]+(, "([^"\\]|\\.)*"(, (?P<usage>[_A-Z0-9]+))?)?|\))' # [, hint[, hint string[, usage]]].
): ExtractType.PROPERTY_PATH,
- re.compile(
- r"(?!#define )LIMPL_PROPERTY(_RANGE)?\(Variant::[_A-Z0-9]+, (?P<message>[^,]+?),"
- ): ExtractType.PROPERTY_PATH,
- re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP,
- re.compile(r'#define WRTC_\w+ "(?P<message>[^"]+?)"'): ExtractType.PROPERTY_PATH,
+ re.compile(r'ADD_ARRAY\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH,
+ re.compile(r'ADD_ARRAY_COUNT(_WITH_USAGE_FLAGS)?\("(?P<message>[^"]+)", '): ExtractType.TEXT,
+ re.compile(r'(ADD_GROUP|GNAME)\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)"\)'): ExtractType.GROUP,
+ re.compile(r'ADD_GROUP_INDENT\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)", '): ExtractType.GROUP,
+ re.compile(r'ADD_SUBGROUP\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)"\)'): ExtractType.SUBGROUP,
+ re.compile(r'ADD_SUBGROUP_INDENT\("(?P<message>[^"]+)", "(?P<prefix>[^"]*)", '): ExtractType.GROUP,
+ re.compile(r'PNAME\("(?P<message>[^"]+)"\)'): ExtractType.PROPERTY_PATH,
}
theme_property_patterns = {
re.compile(r'set_(constant|font|font_size|stylebox|color|icon)\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH,
@@ -203,6 +208,7 @@ def process_file(f, fname):
is_block_translator_comment = False
translator_comment = ""
current_group = ""
+ current_subgroup = ""
patterns = message_patterns
if os.path.basename(fname) == "default_theme.cpp":
@@ -239,11 +245,25 @@ def process_file(f, fname):
if extract_type == ExtractType.TEXT:
_add_message(msg, msg_plural, msgctx, location, translator_comment)
elif extract_type == ExtractType.PROPERTY_PATH:
- if current_group:
+ if captures.get("usage") == "PROPERTY_USAGE_NO_EDITOR":
+ continue
+
+ if current_subgroup:
+ if msg.startswith(current_subgroup):
+ msg = msg[len(current_subgroup) :]
+ elif current_subgroup.startswith(msg):
+ pass # Keep this as-is. See EditorInspector::update_tree().
+ else:
+ current_subgroup = ""
+ elif current_group:
if msg.startswith(current_group):
msg = msg[len(current_group) :]
+ elif current_group.startswith(msg):
+ pass # Keep this as-is. See EditorInspector::update_tree().
else:
current_group = ""
+ current_subgroup = ""
+
if "." in msg: # Strip feature tag.
msg = msg.split(".", 1)[0]
for part in msg.split("/"):
@@ -251,6 +271,10 @@ def process_file(f, fname):
elif extract_type == ExtractType.GROUP:
_add_message(msg, msg_plural, msgctx, location, translator_comment)
current_group = captures["prefix"]
+ current_subgroup = ""
+ elif extract_type == ExtractType.SUBGROUP:
+ _add_message(msg, msg_plural, msgctx, location, translator_comment)
+ current_subgroup = captures["prefix"]
translator_comment = ""
l = f.readline()
diff --git a/main/main.cpp b/main/main.cpp
index 191f4d684f..4d4173b2ee 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2189,10 +2189,10 @@ bool Main::start() {
print_line("Merging docs...");
doc.merge_from(docsrc);
- for (RBSet<String>::Element *E = checked_paths.front(); E; E = E->next()) {
- print_line("Erasing old docs at: " + E->get());
- err = DocTools::erase_classes(E->get());
- ERR_FAIL_COND_V_MSG(err != OK, false, "Error erasing old docs at: " + E->get() + ": " + itos(err));
+ for (const String &E : checked_paths) {
+ print_line("Erasing old docs at: " + E);
+ err = DocTools::erase_classes(E);
+ ERR_FAIL_COND_V_MSG(err != OK, false, "Error erasing old docs at: " + E + ": " + itos(err));
}
print_line("Generating new docs...");
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index e400d0bf94..25f4823d92 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -764,8 +764,8 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc
_update_exports_values(values, propnames);
if (changed) {
- for (RBSet<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
- E->get()->update(propnames, values);
+ for (PlaceHolderScriptInstance *E : placeholders) {
+ E->update(propnames, values);
}
} else {
p_instance_to_update->update(propnames, values);
@@ -790,8 +790,8 @@ void GDScript::update_exports() {
RBSet<ObjectID> copy = inheriters_cache; //might get modified
- for (RBSet<ObjectID>::Element *E = copy.front(); E; E = E->next()) {
- Object *id = ObjectDB::get_instance(E->get());
+ for (const ObjectID &E : copy) {
+ Object *id = ObjectDB::get_instance(E);
GDScript *s = Object::cast_to<GDScript>(id);
if (!s) {
continue;
@@ -939,8 +939,8 @@ void GDScript::get_constants(HashMap<StringName, Variant> *p_constants) {
void GDScript::get_members(RBSet<StringName> *p_members) {
if (p_members) {
- for (RBSet<StringName>::Element *E = members.front(); E; E = E->next()) {
- p_members->insert(E->get());
+ for (const StringName &E : members) {
+ p_members->insert(E);
}
}
}
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index cb389fd86a..478fafc930 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -108,11 +108,15 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
result.native_type = result.script_type->get_instance_base_type();
} break;
case GDScriptParser::DataType::CLASS: {
- // Locate class by constructing the path to it and following that path
+ // Locate class by constructing the path to it and following that path.
GDScriptParser::ClassNode *class_type = p_datatype.class_type;
if (class_type) {
- const bool is_inner_by_path = (!main_script->path.is_empty()) && (class_type->fqcn.split("::")[0] == main_script->path);
- const bool is_inner_by_name = (!main_script->name.is_empty()) && (class_type->fqcn.split("::")[0] == main_script->name);
+ result.kind = GDScriptDataType::GDSCRIPT;
+ result.builtin_type = p_datatype.builtin_type;
+
+ String class_name = class_type->fqcn.split("::")[0];
+ const bool is_inner_by_path = (!main_script->path.is_empty()) && (class_name == main_script->path);
+ const bool is_inner_by_name = (!main_script->name.is_empty()) && (class_name == main_script->name);
if (is_inner_by_path || is_inner_by_name) {
// Local class.
List<StringName> names;
@@ -131,16 +135,41 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
script = script->subclasses[names.back()->get()];
names.pop_back();
}
- result.kind = GDScriptDataType::GDSCRIPT;
result.script_type = script.ptr();
result.native_type = script->get_instance_base_type();
- result.builtin_type = p_datatype.builtin_type;
} else {
- result.kind = GDScriptDataType::GDSCRIPT;
- result.script_type_ref = GDScriptCache::get_shallow_script(p_datatype.script_path, main_script->path);
+ // Inner class.
+ PackedStringArray classes = class_type->fqcn.split("::");
+ if (!classes.is_empty()) {
+ for (GDScript *script : parsed_classes) {
+ // Checking of inheritance structure of inner class to find a correct script link.
+ if (script->name == classes[classes.size() - 1]) {
+ PackedStringArray classes2 = script->fully_qualified_name.split("::");
+ bool valid = true;
+ if (classes.size() != classes2.size()) {
+ valid = false;
+ } else {
+ for (int i = 0; i < classes.size(); i++) {
+ if (classes[i] != classes2[i]) {
+ valid = false;
+ break;
+ }
+ }
+ }
+ if (!valid) {
+ continue;
+ }
+ result.script_type_ref = Ref<GDScript>(script);
+ break;
+ }
+ }
+ }
+ if (result.script_type_ref.is_null()) {
+ result.script_type_ref = GDScriptCache::get_shallow_script(p_datatype.script_path, main_script->path);
+ }
+
result.script_type = result.script_type_ref.ptr();
result.native_type = p_datatype.native_type;
- result.builtin_type = p_datatype.builtin_type;
}
}
} break;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 8563f2b432..96d1f68f60 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -1808,7 +1808,6 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
#ifdef DEBUG_ENABLED
bool all_have_return = true;
bool have_wildcard = false;
- bool wildcard_has_return = false;
bool have_wildcard_without_continue = false;
#endif
@@ -1826,9 +1825,6 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
if (branch->has_wildcard) {
have_wildcard = true;
- if (branch->block->has_return) {
- wildcard_has_return = true;
- }
if (!branch->block->has_continue) {
have_wildcard_without_continue = true;
}
@@ -1843,7 +1839,7 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
consume(GDScriptTokenizer::Token::DEDENT, R"(Expected an indented block after "match" statement.)");
#ifdef DEBUG_ENABLED
- if (wildcard_has_return || (all_have_return && have_wildcard)) {
+ if (all_have_return && have_wildcard) {
current_suite->has_return = true;
}
#endif
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index d9de112bb0..ffd3cfa907 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -794,7 +794,7 @@ GDScriptWorkspace::~GDScriptWorkspace() {
cached_parsers.insert(E.key);
}
- for (RBSet<String>::Element *E = cached_parsers.front(); E; E = E->next()) {
- remove_cache_parser(E->get());
+ for (const String &E : cached_parsers) {
+ remove_cache_parser(E);
}
}
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.gd b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.gd
new file mode 100644
index 0000000000..d00d483a73
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.gd
@@ -0,0 +1,16 @@
+func test():
+ var foo := "bar"
+ match foo:
+ "baz":
+ return
+ _:
+ pass
+ match foo:
+ "baz":
+ return
+ match foo:
+ "bar":
+ pass
+ _:
+ return
+ print("reached")
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.out b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.out
new file mode 100644
index 0000000000..47db6b631b
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return_bug_55154.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+reached
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 9da137f9d5..c70a8121e8 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -483,15 +483,15 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
HashMap<int, List<Pair<Transform3D, IndexKey>>> multimesh_items;
- for (RBSet<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) {
- ERR_CONTINUE(!cell_map.has(E->get()));
- const Cell &c = cell_map[E->get()];
+ for (const IndexKey &E : g.cells) {
+ ERR_CONTINUE(!cell_map.has(E));
+ const Cell &c = cell_map[E];
if (!mesh_library.is_valid() || !mesh_library->has_item(c.item)) {
continue;
}
- Vector3 cellpos = Vector3(E->get().x, E->get().y, E->get().z);
+ Vector3 cellpos = Vector3(E.x, E.y, E.z);
Vector3 ofs = _get_offset();
Transform3D xform;
@@ -507,7 +507,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
Pair<Transform3D, IndexKey> p;
p.first = xform * mesh_library->get_item_mesh_transform(c.item);
- p.second = E->get();
+ p.second = E;
multimesh_items[c.item].push_back(p);
}
}
@@ -540,7 +540,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
nm.region = region;
}
- g.navmesh_ids[E->get()] = nm;
+ g.navmesh_ids[E] = nm;
}
}
diff --git a/modules/navigation/nav_map.h b/modules/navigation/nav_map.h
index 0ebdea30e1..f58a78d4ca 100644
--- a/modules/navigation/nav_map.h
+++ b/modules/navigation/nav_map.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RVO_SPACE_H
-#define RVO_SPACE_H
+#ifndef NAV_MAP_H
+#define NAV_MAP_H
#include "nav_rid.h"
@@ -141,4 +141,4 @@ private:
void clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const;
};
-#endif // RVO_SPACE_H
+#endif // NAV_MAP_H
diff --git a/modules/noise/fastnoise_lite.cpp b/modules/noise/fastnoise_lite.cpp
index 914cdec24c..b21e3247d7 100644
--- a/modules/noise/fastnoise_lite.cpp
+++ b/modules/noise/fastnoise_lite.cpp
@@ -300,6 +300,12 @@ real_t FastNoiseLite::get_domain_warp_fractal_gain() const {
// Noise interface functions.
real_t FastNoiseLite::get_noise_1d(real_t p_x) const {
+ p_x += offset.x;
+ if (domain_warp_enabled) {
+ // Needed since DomainWarp expects a reference.
+ real_t y_dummy = 0;
+ _domain_warp_noise.DomainWarp(p_x, y_dummy);
+ }
return get_noise_2d(p_x, 0.0);
}
@@ -308,10 +314,12 @@ real_t FastNoiseLite::get_noise_2dv(Vector2 p_v) const {
}
real_t FastNoiseLite::get_noise_2d(real_t p_x, real_t p_y) const {
+ p_x += offset.x;
+ p_y += offset.y;
if (domain_warp_enabled) {
_domain_warp_noise.DomainWarp(p_x, p_y);
}
- return _noise.GetNoise(p_x + offset.x, p_y + offset.y);
+ return _noise.GetNoise(p_x, p_y);
}
real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
@@ -319,10 +327,13 @@ real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
}
real_t FastNoiseLite::get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const {
+ p_x += offset.x;
+ p_y += offset.y;
+ p_z += offset.z;
if (domain_warp_enabled) {
_domain_warp_noise.DomainWarp(p_x, p_y, p_z);
}
- return _noise.GetNoise(p_x + offset.x, p_y + offset.y, p_z + offset.z);
+ return _noise.GetNoise(p_x, p_y, p_z);
}
void FastNoiseLite::_changed() {
diff --git a/modules/raycast/lightmap_raycaster.cpp b/modules/raycast/lightmap_raycaster.cpp
index 7e7c3f9067..fc9ac416b7 100644
--- a/modules/raycast/lightmap_raycaster.cpp
+++ b/modules/raycast/lightmap_raycaster.cpp
@@ -153,16 +153,16 @@ void LightmapRaycasterEmbree::commit() {
}
void LightmapRaycasterEmbree::set_mesh_filter(const RBSet<int> &p_mesh_ids) {
- for (RBSet<int>::Element *E = p_mesh_ids.front(); E; E = E->next()) {
- rtcDisableGeometry(rtcGetGeometry(embree_scene, E->get()));
+ for (const int &E : p_mesh_ids) {
+ rtcDisableGeometry(rtcGetGeometry(embree_scene, E));
}
rtcCommitScene(embree_scene);
filter_meshes = p_mesh_ids;
}
void LightmapRaycasterEmbree::clear_mesh_filter() {
- for (RBSet<int>::Element *E = filter_meshes.front(); E; E = E->next()) {
- rtcEnableGeometry(rtcGetGeometry(embree_scene, E->get()));
+ for (const int &E : filter_meshes) {
+ rtcEnableGeometry(rtcGetGeometry(embree_scene, E));
}
rtcCommitScene(embree_scene);
filter_meshes.clear();
diff --git a/modules/raycast/raycast_occlusion_cull.cpp b/modules/raycast/raycast_occlusion_cull.cpp
index c165354c7b..89e75f774e 100644
--- a/modules/raycast/raycast_occlusion_cull.cpp
+++ b/modules/raycast/raycast_occlusion_cull.cpp
@@ -223,9 +223,9 @@ void RaycastOcclusionCull::occluder_set_mesh(RID p_occluder, const PackedVector3
occluder->vertices = p_vertices;
occluder->indices = p_indices;
- for (RBSet<InstanceID>::Element *E = occluder->users.front(); E; E = E->next()) {
- RID scenario_rid = E->get().scenario;
- RID instance_rid = E->get().instance;
+ for (const InstanceID &E : occluder->users) {
+ RID scenario_rid = E.scenario;
+ RID instance_rid = E.instance;
ERR_CONTINUE(!scenarios.has(scenario_rid));
Scenario &scenario = scenarios[scenario_rid];
ERR_CONTINUE(!scenario.instances.has(instance_rid));
diff --git a/modules/raycast/static_raycaster.cpp b/modules/raycast/static_raycaster.cpp
index f2e944a82d..5d2dedf1a4 100644
--- a/modules/raycast/static_raycaster.cpp
+++ b/modules/raycast/static_raycaster.cpp
@@ -95,16 +95,16 @@ void StaticRaycasterEmbree::commit() {
}
void StaticRaycasterEmbree::set_mesh_filter(const RBSet<int> &p_mesh_ids) {
- for (RBSet<int>::Element *E = p_mesh_ids.front(); E; E = E->next()) {
- rtcDisableGeometry(rtcGetGeometry(embree_scene, E->get()));
+ for (const int &E : p_mesh_ids) {
+ rtcDisableGeometry(rtcGetGeometry(embree_scene, E));
}
rtcCommitScene(embree_scene);
filter_meshes = p_mesh_ids;
}
void StaticRaycasterEmbree::clear_mesh_filter() {
- for (RBSet<int>::Element *E = filter_meshes.front(); E; E = E->next()) {
- rtcEnableGeometry(rtcGetGeometry(embree_scene, E->get()));
+ for (const int &E : filter_meshes) {
+ rtcEnableGeometry(rtcGetGeometry(embree_scene, E));
}
rtcCommitScene(embree_scene);
filter_meshes.clear();
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 4847b24f61..012e0229f3 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -1625,8 +1625,8 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
undo_redo->add_do_method(this, "_update_graph", p_id);
for (const KeyValue<int, RBSet<int>> &E : conn_map) {
- for (const RBSet<int>::Element *F = E.value.front(); F; F = F->next()) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E.key, F->get());
+ for (const int &F : E.value) {
+ undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E.key, F);
}
}
@@ -1813,14 +1813,14 @@ void VisualScriptEditor::_on_nodes_paste() {
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
}
- for (RBSet<VisualScript::SequenceConnection>::Element *E = clipboard->sequence_connections.front(); E; E = E->next()) {
- undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
- undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
+ for (const VisualScript::SequenceConnection &E : clipboard->sequence_connections) {
+ undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]);
+ undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", remap[E.from_node], E.from_output, remap[E.to_node]);
}
- for (RBSet<VisualScript::DataConnection>::Element *E = clipboard->data_connections.front(); E; E = E->next()) {
- undo_redo->add_do_method(script.ptr(), "data_connect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
- undo_redo->add_undo_method(script.ptr(), "data_disconnect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
+ for (const VisualScript::DataConnection &E : clipboard->data_connections) {
+ undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port);
+ undo_redo->add_undo_method(script.ptr(), "data_disconnect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port);
}
undo_redo->add_do_method(this, "_update_graph");
@@ -1910,17 +1910,17 @@ void VisualScriptEditor::_on_nodes_duplicate() {
RBSet<int> to_select;
HashMap<int, int> remap;
- for (RBSet<int>::Element *F = to_duplicate.front(); F; F = F->next()) {
+ for (const int &F : to_duplicate) {
// Duplicate from the specific function but place it into the default func as it would lack the connections.
- Ref<VisualScriptNode> node = script->get_node(F->get());
+ Ref<VisualScriptNode> node = script->get_node(F);
Ref<VisualScriptNode> dupe = node->duplicate(true);
int new_id = idc++;
- remap.insert(F->get(), new_id);
+ remap.insert(F, new_id);
to_select.insert(new_id);
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, dupe, script->get_node_position(F->get()) + Vector2(20, 20));
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, dupe, script->get_node_position(F) + Vector2(20, 20));
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
}
@@ -4201,9 +4201,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
// If we still don't have a start node then,
// run through the nodes and select the first tree node,
// i.e. node without any input sequence but output sequence.
- for (RBSet<int>::Element *E = nodes_from.front(); E; E = E->next()) {
- if (!nodes_to.has(E->get())) {
- start_node = E->get();
+ for (const int &E : nodes_from) {
+ if (!nodes_to.has(E)) {
+ start_node = E;
}
}
}
@@ -4272,13 +4272,13 @@ void VisualScriptEditor::_menu_option(int p_what) {
// Move the nodes.
// Handles reconnection of sequence connections on undo, start here in case of issues.
- for (RBSet<VisualScript::SequenceConnection>::Element *E = seqext.front(); E; E = E->next()) {
- undo_redo->add_do_method(script.ptr(), "sequence_disconnect", E->get().from_node, E->get().from_output, E->get().to_node);
- undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node);
+ for (const VisualScript::SequenceConnection &E : seqext) {
+ undo_redo->add_do_method(script.ptr(), "sequence_disconnect", E.from_node, E.from_output, E.to_node);
+ undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node);
}
- for (RBSet<VisualScript::DataConnection>::Element *E = dataext.front(); E; E = E->next()) {
- undo_redo->add_do_method(script.ptr(), "data_disconnect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
- undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ for (const VisualScript::DataConnection &E : dataext) {
+ undo_redo->add_do_method(script.ptr(), "data_disconnect", E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port);
}
// I don't really think we need support for non sequenced functions at this moment.
@@ -4286,24 +4286,24 @@ void VisualScriptEditor::_menu_option(int p_what) {
// Could fail with the new changes, start here when searching for bugs in create function shortcut.
int m = 1;
- for (RBSet<int>::Element *G = end_nodes.front(); G; G = G->next()) {
+ for (const int &G : end_nodes) {
Ref<VisualScriptReturn> ret_node;
ret_node.instantiate();
int ret_id = fn_id + (m++);
selections.insert(ret_id);
- Vector2 posi = _get_available_pos(false, script->get_node_position(G->get()) + Vector2(80, -100));
+ Vector2 posi = _get_available_pos(false, script->get_node_position(G) + Vector2(80, -100));
undo_redo->add_do_method(script.ptr(), "add_node", ret_id, ret_node, posi);
undo_redo->add_undo_method(script.ptr(), "remove_node", ret_id);
- undo_redo->add_do_method(script.ptr(), "sequence_connect", G->get(), 0, ret_id);
+ undo_redo->add_do_method(script.ptr(), "sequence_connect", G, 0, ret_id);
// Add data outputs from each of the end_nodes.
- Ref<VisualScriptNode> vsn = script->get_node(G->get());
+ Ref<VisualScriptNode> vsn = script->get_node(G);
if (vsn.is_valid() && vsn->get_output_value_port_count() > 0) {
ret_node->set_enable_return_value(true);
// Use the zeroth data port cause that's the likely one that is planned to be used.
ret_node->set_return_type(vsn->get_output_value_port_info(0).type);
- undo_redo->add_do_method(script.ptr(), "data_connect", G->get(), 0, ret_id, 0);
+ undo_redo->add_do_method(script.ptr(), "data_connect", G, 0, ret_id, 0);
}
}
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index a287b8e69f..7c15651fa2 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -230,12 +230,12 @@ void VisualScript::_node_ports_changed(int p_id) {
{
List<SequenceConnection> to_remove;
- for (RBSet<SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) {
- if (E->get().from_node == p_id && E->get().from_output >= vsn->get_output_sequence_port_count()) {
- to_remove.push_back(E->get());
+ for (const SequenceConnection &E : sequence_connections) {
+ if (E.from_node == p_id && E.from_output >= vsn->get_output_sequence_port_count()) {
+ to_remove.push_back(E);
}
- if (E->get().to_node == p_id && !vsn->has_input_sequence_port()) {
- to_remove.push_back(E->get());
+ if (E.to_node == p_id && !vsn->has_input_sequence_port()) {
+ to_remove.push_back(E);
}
}
@@ -248,12 +248,12 @@ void VisualScript::_node_ports_changed(int p_id) {
{
List<DataConnection> to_remove;
- for (RBSet<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- if (E->get().from_node == p_id && E->get().from_port >= vsn->get_output_value_port_count()) {
- to_remove.push_back(E->get());
+ for (const DataConnection &E : data_connections) {
+ if (E.from_node == p_id && E.from_port >= vsn->get_output_value_port_count()) {
+ to_remove.push_back(E);
}
- if (E->get().to_node == p_id && E->get().to_port >= vsn->get_input_value_port_count()) {
- to_remove.push_back(E->get());
+ if (E.to_node == p_id && E.to_port >= vsn->get_input_value_port_count()) {
+ to_remove.push_back(E);
}
}
@@ -292,9 +292,9 @@ void VisualScript::remove_node(int p_id) {
{
List<SequenceConnection> to_remove;
- for (RBSet<SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) {
- if (E->get().from_node == p_id || E->get().to_node == p_id) {
- to_remove.push_back(E->get());
+ for (const SequenceConnection &E : sequence_connections) {
+ if (E.from_node == p_id || E.to_node == p_id) {
+ to_remove.push_back(E);
}
}
@@ -307,9 +307,9 @@ void VisualScript::remove_node(int p_id) {
{
List<DataConnection> to_remove;
- for (RBSet<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- if (E->get().from_node == p_id || E->get().to_node == p_id) {
- to_remove.push_back(E->get());
+ for (const DataConnection &E : data_connections) {
+ if (E.from_node == p_id || E.to_node == p_id) {
+ to_remove.push_back(E);
}
}
@@ -384,8 +384,8 @@ bool VisualScript::has_sequence_connection(int p_from_node, int p_from_output, i
}
void VisualScript::get_sequence_connection_list(List<SequenceConnection> *r_connection) const {
- for (const RBSet<SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) {
- r_connection->push_back(E->get());
+ for (const SequenceConnection &E : sequence_connections) {
+ r_connection->push_back(E);
}
}
@@ -426,8 +426,8 @@ bool VisualScript::has_data_connection(int p_from_node, int p_from_port, int p_t
}
bool VisualScript::is_input_value_port_connected(int p_node, int p_port) const {
- for (const RBSet<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- if (E->get().to_node == p_node && E->get().to_port == p_port) {
+ for (const DataConnection &E : data_connections) {
+ if (E.to_node == p_node && E.to_port == p_port) {
return true;
}
}
@@ -435,10 +435,10 @@ bool VisualScript::is_input_value_port_connected(int p_node, int p_port) const {
}
bool VisualScript::get_input_value_port_connection_source(int p_node, int p_port, int *r_node, int *r_port) const {
- for (const RBSet<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- if (E->get().to_node == p_node && E->get().to_port == p_port) {
- *r_node = E->get().from_node;
- *r_port = E->get().from_port;
+ for (const DataConnection &E : data_connections) {
+ if (E.to_node == p_node && E.to_port == p_port) {
+ *r_node = E.from_node;
+ *r_port = E.from_port;
return true;
}
}
@@ -446,8 +446,8 @@ bool VisualScript::get_input_value_port_connection_source(int p_node, int p_port
}
void VisualScript::get_data_connection_list(List<DataConnection> *r_connection) const {
- for (const RBSet<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- r_connection->push_back(E->get());
+ for (const DataConnection &E : data_connections) {
+ r_connection->push_back(E);
}
}
@@ -764,8 +764,8 @@ void VisualScript::_update_placeholders() {
values[p.name] = variables[E.key].default_value;
}
- for (RBSet<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
- E->get()->update(pinfo, values);
+ for (PlaceHolderScriptInstance *E : placeholders) {
+ E->update(pinfo, values);
}
}
@@ -1078,19 +1078,19 @@ Dictionary VisualScript::_get_data() const {
d["nodes"] = nds;
Array seqconns;
- for (const RBSet<SequenceConnection>::Element *F = sequence_connections.front(); F; F = F->next()) {
- seqconns.push_back(F->get().from_node);
- seqconns.push_back(F->get().from_output);
- seqconns.push_back(F->get().to_node);
+ for (const SequenceConnection &F : sequence_connections) {
+ seqconns.push_back(F.from_node);
+ seqconns.push_back(F.from_output);
+ seqconns.push_back(F.to_node);
}
d["sequence_connections"] = seqconns;
Array dataconns;
- for (const RBSet<DataConnection>::Element *F = data_connections.front(); F; F = F->next()) {
- dataconns.push_back(F->get().from_node);
- dataconns.push_back(F->get().from_port);
- dataconns.push_back(F->get().to_node);
- dataconns.push_back(F->get().to_port);
+ for (const DataConnection &F : data_connections) {
+ dataconns.push_back(F.from_node);
+ dataconns.push_back(F.from_port);
+ dataconns.push_back(F.to_node);
+ dataconns.push_back(F.to_port);
}
d["data_connections"] = dataconns;
@@ -1869,23 +1869,23 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
List<int> nd_queue;
nd_queue.push_back(function.node);
while (!nd_queue.is_empty()) {
- for (const RBSet<VisualScript::SequenceConnection>::Element *F = script->sequence_connections.front(); F; F = F->next()) {
- if (nd_queue.front()->get() == F->get().from_node && !node_ids.has(F->get().to_node)) {
- nd_queue.push_back(F->get().to_node);
- node_ids.insert(F->get().to_node);
+ for (const VisualScript::SequenceConnection &F : script->sequence_connections) {
+ if (nd_queue.front()->get() == F.from_node && !node_ids.has(F.to_node)) {
+ nd_queue.push_back(F.to_node);
+ node_ids.insert(F.to_node);
}
- if (nd_queue.front()->get() == F->get().from_node && !seqconns.has(F->get())) {
- seqconns.insert(F->get());
+ if (nd_queue.front()->get() == F.from_node && !seqconns.has(F)) {
+ seqconns.insert(F);
}
}
nd_queue.pop_front();
}
HashMap<int, HashMap<int, Pair<int, int>>> dc_lut; // :: to -> to_port -> (from, from_port)
- for (const RBSet<VisualScript::DataConnection>::Element *F = script->data_connections.front(); F; F = F->next()) {
- dc_lut[F->get().to_node][F->get().to_port] = Pair<int, int>(F->get().from_node, F->get().from_port);
+ for (const VisualScript::DataConnection &F : script->data_connections) {
+ dc_lut[F.to_node][F.to_port] = Pair<int, int>(F.from_node, F.from_port);
}
- for (const RBSet<int>::Element *F = node_ids.front(); F; F = F->next()) {
- nd_queue.push_back(F->get());
+ for (const int &F : node_ids) {
+ nd_queue.push_back(F);
}
List<int> dc_keys;
while (!nd_queue.is_empty()) {
@@ -1907,15 +1907,15 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
//Multiple passes are required to set up this complex thing..
//First create the nodes.
- for (const RBSet<int>::Element *F = node_ids.front(); F; F = F->next()) {
- Ref<VisualScriptNode> node = script->nodes[F->get()].node;
+ for (const int &F : node_ids) {
+ Ref<VisualScriptNode> node = script->nodes[F].node;
VisualScriptNodeInstance *instance = node->instantiate(this); // Create instance.
ERR_FAIL_COND(!instance);
instance->base = node.ptr();
- instance->id = F->get();
+ instance->id = F;
instance->input_port_count = node->get_input_value_port_count();
instance->input_ports = nullptr;
instance->output_port_count = node->get_output_value_port_count();
@@ -1975,14 +1975,14 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
max_input_args = MAX(max_input_args, instance->input_port_count);
max_output_args = MAX(max_output_args, instance->output_port_count);
- instances[F->get()] = instance;
+ instances[F] = instance;
}
function.trash_pos = function.max_stack++; // create pos for trash
// Second pass, do data connections.
- for (const RBSet<VisualScript::DataConnection>::Element *F = dataconns.front(); F; F = F->next()) {
- VisualScript::DataConnection dc = F->get();
+ for (const VisualScript::DataConnection &F : dataconns) {
+ VisualScript::DataConnection dc = F;
ERR_CONTINUE(!instances.has(dc.from_node));
VisualScriptNodeInstance *from = instances[dc.from_node];
ERR_CONTINUE(!instances.has(dc.to_node));
@@ -2008,8 +2008,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
}
// Third pass, do sequence connections.
- for (const RBSet<VisualScript::SequenceConnection>::Element *F = seqconns.front(); F; F = F->next()) {
- VisualScript::SequenceConnection sc = F->get();
+ for (const VisualScript::SequenceConnection &F : seqconns) {
+ VisualScript::SequenceConnection sc = F;
ERR_CONTINUE(!instances.has(sc.from_node));
VisualScriptNodeInstance *from = instances[sc.from_node];
ERR_CONTINUE(!instances.has(sc.to_node));
@@ -2022,11 +2022,11 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
//fourth pass:
// 1) unassigned input ports to default values
// 2) connect unassigned output ports to trash
- for (const RBSet<int>::Element *F = node_ids.front(); F; F = F->next()) {
- ERR_CONTINUE(!instances.has(F->get()));
+ for (const int &F : node_ids) {
+ ERR_CONTINUE(!instances.has(F));
- Ref<VisualScriptNode> node = script->nodes[F->get()].node;
- VisualScriptNodeInstance *instance = instances[F->get()];
+ Ref<VisualScriptNode> node = script->nodes[F].node;
+ VisualScriptNodeInstance *instance = instances[F];
// Connect to default values.
for (int i = 0; i < instance->input_port_count; i++) {
diff --git a/modules/webrtc/webrtc_data_channel.h b/modules/webrtc/webrtc_data_channel.h
index eac8f85a84..75e29283ec 100644
--- a/modules/webrtc/webrtc_data_channel.h
+++ b/modules/webrtc/webrtc_data_channel.h
@@ -33,7 +33,7 @@
#include "core/io/packet_peer.h"
-#define WRTC_IN_BUF "network/limits/webrtc/max_channel_in_buffer_kb"
+#define WRTC_IN_BUF PNAME("network/limits/webrtc/max_channel_in_buffer_kb")
class WebRTCDataChannel : public PacketPeer {
GDCLASS(WebRTCDataChannel, PacketPeer);
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index a893571e54..18f037ed56 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -207,9 +207,9 @@ static const char *SPLASH_CONFIG_PATH = "res://android/build/res/drawable/splash
static const char *GDNATIVE_LIBS_PATH = "res://android/build/libs/gdnativelibs.json";
static const int icon_densities_count = 6;
-static const char *launcher_icon_option = "launcher_icons/main_192x192";
-static const char *launcher_adaptive_icon_foreground_option = "launcher_icons/adaptive_foreground_432x432";
-static const char *launcher_adaptive_icon_background_option = "launcher_icons/adaptive_background_432x432";
+static const char *launcher_icon_option = PNAME("launcher_icons/main_192x192");
+static const char *launcher_adaptive_icon_foreground_option = PNAME("launcher_icons/adaptive_foreground_432x432");
+static const char *launcher_adaptive_icon_background_option = PNAME("launcher_icons/adaptive_background_432x432");
static const LauncherIcon launcher_icons[icon_densities_count] = {
{ "res/mipmap-xxxhdpi-v4/icon.png", 192 },
@@ -1697,7 +1697,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
Vector<PluginConfigAndroid> plugins_configs = get_plugins();
for (int i = 0; i < plugins_configs.size(); i++) {
print_verbose("Found Android plugin " + plugins_configs[i].name);
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + plugins_configs[i].name), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("%s/%s", PNAME("plugins"), plugins_configs[i].name)), false));
}
plugins_changed.clear();
@@ -1707,7 +1707,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
// All Android devices supporting Vulkan run 64-bit Android,
// so there is usually no point in exporting for 32-bit Android.
const bool is_default = abi == "arm64-v8a";
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + abi), is_default));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("%s/%s", PNAME("architectures"), abi)), is_default));
}
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/debug", PROPERTY_HINT_GLOBAL_FILE, "*.keystore,*.jks"), ""));
@@ -1758,7 +1758,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
const char **perms = android_perms;
while (*perms) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "permissions/" + String(*perms).to_lower()), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("%s/%s", PNAME("permissions"), String(*perms).to_lower())), false));
perms++;
}
}
diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp
index 09191c958d..f28d014c07 100644
--- a/platform/iphone/export/export_plugin.cpp
+++ b/platform/iphone/export/export_plugin.cpp
@@ -58,18 +58,18 @@ struct LoadingScreenInfo {
};
static const LoadingScreenInfo loading_screen_infos[] = {
- { "landscape_launch_screens/iphone_2436x1125", "Default-Landscape-X.png", 2436, 1125, false },
- { "landscape_launch_screens/iphone_2208x1242", "Default-Landscape-736h@3x.png", 2208, 1242, false },
- { "landscape_launch_screens/ipad_1024x768", "Default-Landscape.png", 1024, 768, false },
- { "landscape_launch_screens/ipad_2048x1536", "Default-Landscape@2x.png", 2048, 1536, false },
-
- { "portrait_launch_screens/iphone_640x960", "Default-480h@2x.png", 640, 960, true },
- { "portrait_launch_screens/iphone_640x1136", "Default-568h@2x.png", 640, 1136, true },
- { "portrait_launch_screens/iphone_750x1334", "Default-667h@2x.png", 750, 1334, true },
- { "portrait_launch_screens/iphone_1125x2436", "Default-Portrait-X.png", 1125, 2436, true },
- { "portrait_launch_screens/ipad_768x1024", "Default-Portrait.png", 768, 1024, true },
- { "portrait_launch_screens/ipad_1536x2048", "Default-Portrait@2x.png", 1536, 2048, true },
- { "portrait_launch_screens/iphone_1242x2208", "Default-Portrait-736h@3x.png", 1242, 2208, true }
+ { PNAME("landscape_launch_screens/iphone_2436x1125"), "Default-Landscape-X.png", 2436, 1125, false },
+ { PNAME("landscape_launch_screens/iphone_2208x1242"), "Default-Landscape-736h@3x.png", 2208, 1242, false },
+ { PNAME("landscape_launch_screens/ipad_1024x768"), "Default-Landscape.png", 1024, 768, false },
+ { PNAME("landscape_launch_screens/ipad_2048x1536"), "Default-Landscape@2x.png", 2048, 1536, false },
+
+ { PNAME("portrait_launch_screens/iphone_640x960"), "Default-480h@2x.png", 640, 960, true },
+ { PNAME("portrait_launch_screens/iphone_640x1136"), "Default-568h@2x.png", 640, 1136, true },
+ { PNAME("portrait_launch_screens/iphone_750x1334"), "Default-667h@2x.png", 750, 1334, true },
+ { PNAME("portrait_launch_screens/iphone_1125x2436"), "Default-Portrait-X.png", 1125, 2436, true },
+ { PNAME("portrait_launch_screens/ipad_768x1024"), "Default-Portrait.png", 768, 1024, true },
+ { PNAME("portrait_launch_screens/ipad_1536x2048"), "Default-Portrait@2x.png", 1536, 2048, true },
+ { PNAME("portrait_launch_screens/iphone_1242x2208"), "Default-Portrait-736h@3x.png", 1242, 2208, true }
};
void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) {
@@ -78,7 +78,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
Vector<ExportArchitecture> architectures = _get_supported_architectures();
for (int i = 0; i < architectures.size(); ++i) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + architectures[i].name), architectures[i].is_default));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("%s/%s", PNAME("architectures"), architectures[i].name)), architectures[i].is_default));
}
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/app_store_team_id"), ""));
@@ -99,7 +99,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
Vector<PluginConfigIOS> found_plugins = get_plugins();
for (int i = 0; i < found_plugins.size(); i++) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + found_plugins[i].name), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("%s/%s", PNAME("plugins"), found_plugins[i].name)), false));
}
RBSet<String> plist_keys;
@@ -1350,8 +1350,8 @@ Error EditorExportPlatformIOS::_export_ios_plugins(const Ref<EditorExportPreset>
// Update Linker Flag Values
{
String result_linker_flags = " ";
- for (RBSet<String>::Element *E = plugin_linker_flags.front(); E; E = E->next()) {
- const String &flag = E->get();
+ for (const String &E : plugin_linker_flags) {
+ const String &flag = E;
if (flag.length() == 0) {
continue;
diff --git a/scene/2d/audio_listener_2d.cpp b/scene/2d/audio_listener_2d.cpp
index eb463864e1..f7dd20d7c0 100644
--- a/scene/2d/audio_listener_2d.cpp
+++ b/scene/2d/audio_listener_2d.cpp
@@ -57,7 +57,7 @@ bool AudioListener2D::_get(const StringName &p_name, Variant &r_ret) const {
}
void AudioListener2D::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, PNAME("current")));
}
void AudioListener2D::_notification(int p_what) {
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index f46453283c..260faf1d68 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -509,6 +509,9 @@ void NavigationRegion2D::_navpoly_changed() {
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) {
update();
}
+ if (navpoly.is_valid()) {
+ NavigationServer2D::get_singleton()->region_set_navpoly(region, navpoly);
+ }
}
void NavigationRegion2D::_map_changed(RID p_map) {
if (enabled && get_world_2d()->get_navigation_map() == p_map) {
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index f345d8c3c9..9d9db0d6b4 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -56,13 +56,11 @@ PhysicsBody2D::~PhysicsBody2D() {
Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_distance, bool p_test_only, real_t p_margin) {
PhysicsServer2D::MotionParameters parameters(get_global_transform(), p_distance, p_margin);
+ parameters.recovery_as_collision = false; // Don't report collisions generated only from recovery.
PhysicsServer2D::MotionResult result;
- bool collided = move_and_collide(parameters, result, p_test_only);
-
- // Don't report collision when the whole motion is done.
- if (collided && result.collision_safe_fraction < 1) {
+ if (move_and_collide(parameters, result, p_test_only)) {
// Create a new instance when the cached reference is invalid or still in use in script.
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
motion_cache.instantiate();
@@ -143,15 +141,9 @@ bool PhysicsBody2D::test_move(const Transform2D &p_from, const Vector2 &p_distan
}
PhysicsServer2D::MotionParameters parameters(p_from, p_distance, p_margin);
+ parameters.recovery_as_collision = false; // Don't report collisions generated only from recovery.
- bool colliding = PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), parameters, r);
-
- if (colliding) {
- // Don't report collision when the whole motion is done.
- return (r->collision_safe_fraction < 1.0);
- } else {
- return false;
- }
+ return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), parameters, r);
}
TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() {
@@ -1145,6 +1137,7 @@ bool CharacterBody2D::move_and_slide() {
if (!current_platform_velocity.is_equal_approx(Vector2())) {
PhysicsServer2D::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.exclude_bodies.insert(platform_rid);
if (platform_object_id.is_valid()) {
parameters.exclude_objects.insert(platform_object_id);
@@ -1203,6 +1196,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
for (int iteration = 0; iteration < max_slides; ++iteration) {
PhysicsServer2D::MotionParameters parameters(get_global_transform(), motion, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
Vector2 prev_position = parameters.from.columns[2];
@@ -1359,6 +1353,7 @@ void CharacterBody2D::_move_and_slide_floating(double p_delta) {
bool first_slide = true;
for (int iteration = 0; iteration < max_slides; ++iteration) {
PhysicsServer2D::MotionParameters parameters(get_global_transform(), motion, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
PhysicsServer2D::MotionResult result;
bool collided = move_and_collide(parameters, result, false, false);
@@ -1405,6 +1400,7 @@ void CharacterBody2D::_snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_
real_t length = MAX(floor_snap_length, margin);
PhysicsServer2D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
PhysicsServer2D::MotionResult result;
@@ -1440,6 +1436,7 @@ bool CharacterBody2D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_f
real_t length = MAX(floor_snap_length, margin);
PhysicsServer2D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
PhysicsServer2D::MotionResult result;
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp
index aa039e07ee..377d51cad7 100644
--- a/scene/2d/skeleton_2d.cpp
+++ b/scene/2d/skeleton_2d.cpp
@@ -81,14 +81,14 @@ bool Bone2D::_get(const StringName &p_path, Variant &r_ret) const {
}
void Bone2D::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::BOOL, "auto_calculate_length_and_angle", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT));
+ p_list->push_back(PropertyInfo(Variant::BOOL, PNAME("auto_calculate_length_and_angle"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT));
if (!autocalculate_length_and_angle) {
- p_list->push_back(PropertyInfo(Variant::FLOAT, "length", PROPERTY_HINT_RANGE, "1, 1024, 1", PROPERTY_USAGE_DEFAULT));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "bone_angle", PROPERTY_HINT_RANGE, "-360, 360, 0.01", PROPERTY_USAGE_DEFAULT));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("length"), PROPERTY_HINT_RANGE, "1, 1024, 1", PROPERTY_USAGE_DEFAULT));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("bone_angle"), PROPERTY_HINT_RANGE, "-360, 360, 0.01", PROPERTY_USAGE_DEFAULT));
}
#ifdef TOOLS_ENABLED
- p_list->push_back(PropertyInfo(Variant::BOOL, "editor_settings/show_bone_gizmo", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT));
+ p_list->push_back(PropertyInfo(Variant::BOOL, PNAME("editor_settings/show_bone_gizmo"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT));
#endif // TOOLS_ENABLED
}
@@ -560,7 +560,7 @@ bool Skeleton2D::_get(const StringName &p_path, Variant &r_ret) const {
void Skeleton2D::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(
- PropertyInfo(Variant::OBJECT, "modification_stack",
+ PropertyInfo(Variant::OBJECT, PNAME("modification_stack"),
PROPERTY_HINT_RESOURCE_TYPE,
"SkeletonModificationStack2D",
PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE));
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 19c341c1e1..c4b923ff34 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -810,8 +810,8 @@ void TileMap::_update_dirty_quadrants() {
for (SelfList<TileMapQuadrant> *q = dirty_quadrant_list.first(); q; q = q->next()) {
q->self()->map_to_world.clear();
q->self()->world_to_map.clear();
- for (RBSet<Vector2i>::Element *E = q->self()->cells.front(); E; E = E->next()) {
- Vector2i pk = E->get();
+ for (const Vector2i &E : q->self()->cells) {
+ Vector2i pk = E;
Vector2i pk_world_coords = map_to_world(pk);
q->self()->map_to_world[pk] = pk_world_coords;
q->self()->world_to_map[pk_world_coords] = pk;
@@ -1250,8 +1250,8 @@ void TileMap::_rendering_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
// Draw a placeholder for scenes needing one.
RenderingServer *rs = RenderingServer::get_singleton();
Vector2 quadrant_pos = map_to_world(p_quadrant->coords * get_effective_quadrant_size(p_quadrant->layer));
- for (RBSet<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) {
- const TileMapCell &c = get_cell(p_quadrant->layer, E_cell->get(), true);
+ for (const Vector2i &E_cell : p_quadrant->cells) {
+ const TileMapCell &c = get_cell(p_quadrant->layer, E_cell, true);
TileSetSource *source;
if (tile_set->has_source(c.source_id)) {
@@ -1281,7 +1281,7 @@ void TileMap::_rendering_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
// Draw a placeholder tile.
Transform2D xform;
- xform.set_origin(map_to_world(E_cell->get()) - quadrant_pos);
+ xform.set_origin(map_to_world(E_cell) - quadrant_pos);
rs->canvas_item_add_set_transform(p_quadrant->debug_canvas_item, xform);
rs->canvas_item_add_circle(p_quadrant->debug_canvas_item, Vector2(), MIN(tile_set->get_tile_size().x, tile_set->get_tile_size().y) / 4.0, color);
}
@@ -1464,8 +1464,8 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
q.bodies.clear();
// Recreate bodies and shapes.
- for (RBSet<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) {
- TileMapCell c = get_cell(q.layer, E_cell->get(), true);
+ for (const Vector2i &E_cell : q.cells) {
+ TileMapCell c = get_cell(q.layer, E_cell, true);
TileSetSource *source;
if (tile_set->has_source(c.source_id)) {
@@ -1478,8 +1478,8 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
if (atlas_source) {
const TileData *tile_data;
- if (q.runtime_tile_data_cache.has(E_cell->get())) {
- tile_data = q.runtime_tile_data_cache[E_cell->get()];
+ if (q.runtime_tile_data_cache.has(E_cell)) {
+ tile_data = q.runtime_tile_data_cache[E_cell];
} else {
tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
}
@@ -1490,12 +1490,12 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
// Create the body.
RID body = ps->body_create();
- bodies_coords[body] = E_cell->get();
+ bodies_coords[body] = E_cell;
ps->body_set_mode(body, collision_animatable ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC);
ps->body_set_space(body, space);
Transform2D xform;
- xform.set_origin(map_to_world(E_cell->get()));
+ xform.set_origin(map_to_world(E_cell));
xform = global_transform * xform;
ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
@@ -1661,8 +1661,8 @@ void TileMap::_navigation_update_dirty_quadrants(SelfList<TileMapQuadrant>::List
q.navigation_regions.clear();
// Get the navigation polygons and create regions.
- for (RBSet<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) {
- TileMapCell c = get_cell(q.layer, E_cell->get(), true);
+ for (const Vector2i &E_cell : q.cells) {
+ TileMapCell c = get_cell(q.layer, E_cell, true);
TileSetSource *source;
if (tile_set->has_source(c.source_id)) {
@@ -1675,12 +1675,12 @@ void TileMap::_navigation_update_dirty_quadrants(SelfList<TileMapQuadrant>::List
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
if (atlas_source) {
const TileData *tile_data;
- if (q.runtime_tile_data_cache.has(E_cell->get())) {
- tile_data = q.runtime_tile_data_cache[E_cell->get()];
+ if (q.runtime_tile_data_cache.has(E_cell)) {
+ tile_data = q.runtime_tile_data_cache[E_cell];
} else {
tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
}
- q.navigation_regions[E_cell->get()].resize(tile_set->get_navigation_layers_count());
+ q.navigation_regions[E_cell].resize(tile_set->get_navigation_layers_count());
for (int layer_index = 0; layer_index < tile_set->get_navigation_layers_count(); layer_index++) {
Ref<NavigationPolygon> navpoly;
@@ -1688,13 +1688,13 @@ void TileMap::_navigation_update_dirty_quadrants(SelfList<TileMapQuadrant>::List
if (navpoly.is_valid()) {
Transform2D tile_transform;
- tile_transform.set_origin(map_to_world(E_cell->get()));
+ tile_transform.set_origin(map_to_world(E_cell));
RID region = NavigationServer2D::get_singleton()->region_create();
NavigationServer2D::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map());
NavigationServer2D::get_singleton()->region_set_transform(region, tilemap_xform * tile_transform);
NavigationServer2D::get_singleton()->region_set_navpoly(region, navpoly);
- q.navigation_regions[E_cell->get()].write[layer_index] = region;
+ q.navigation_regions[E_cell].write[layer_index] = region;
}
}
}
@@ -1750,8 +1750,8 @@ void TileMap::_navigation_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
Vector2 quadrant_pos = map_to_world(p_quadrant->coords * get_effective_quadrant_size(p_quadrant->layer));
- for (RBSet<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) {
- TileMapCell c = get_cell(p_quadrant->layer, E_cell->get(), true);
+ for (const Vector2i &E_cell : p_quadrant->cells) {
+ TileMapCell c = get_cell(p_quadrant->layer, E_cell, true);
TileSetSource *source;
if (tile_set->has_source(c.source_id)) {
@@ -1764,14 +1764,14 @@ void TileMap::_navigation_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
if (atlas_source) {
const TileData *tile_data;
- if (p_quadrant->runtime_tile_data_cache.has(E_cell->get())) {
- tile_data = p_quadrant->runtime_tile_data_cache[E_cell->get()];
+ if (p_quadrant->runtime_tile_data_cache.has(E_cell)) {
+ tile_data = p_quadrant->runtime_tile_data_cache[E_cell];
} else {
tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
}
Transform2D xform;
- xform.set_origin(map_to_world(E_cell->get()) - quadrant_pos);
+ xform.set_origin(map_to_world(E_cell) - quadrant_pos);
rs->canvas_item_add_set_transform(p_quadrant->debug_canvas_item, xform);
for (int layer_index = 0; layer_index < tile_set->get_navigation_layers_count(); layer_index++) {
@@ -1825,8 +1825,8 @@ void TileMap::_scenes_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r_
q.scenes.clear();
// Recreate the scenes.
- for (RBSet<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) {
- const TileMapCell &c = get_cell(q.layer, E_cell->get(), true);
+ for (const Vector2i &E_cell : q.cells) {
+ const TileMapCell &c = get_cell(q.layer, E_cell, true);
TileSetSource *source;
if (tile_set->has_source(c.source_id)) {
@@ -1845,13 +1845,13 @@ void TileMap::_scenes_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r_
Control *scene_as_control = Object::cast_to<Control>(scene);
Node2D *scene_as_node2d = Object::cast_to<Node2D>(scene);
if (scene_as_control) {
- scene_as_control->set_position(map_to_world(E_cell->get()) + scene_as_control->get_position());
+ scene_as_control->set_position(map_to_world(E_cell) + scene_as_control->get_position());
} else if (scene_as_node2d) {
Transform2D xform;
- xform.set_origin(map_to_world(E_cell->get()));
+ xform.set_origin(map_to_world(E_cell));
scene_as_node2d->set_transform(xform * scene_as_node2d->get_transform());
}
- q.scenes[E_cell->get()] = scene->get_name();
+ q.scenes[E_cell] = scene->get_name();
}
}
}
@@ -1883,8 +1883,8 @@ void TileMap::_scenes_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
// Draw a placeholder for scenes needing one.
RenderingServer *rs = RenderingServer::get_singleton();
Vector2 quadrant_pos = map_to_world(p_quadrant->coords * get_effective_quadrant_size(p_quadrant->layer));
- for (RBSet<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) {
- const TileMapCell &c = get_cell(p_quadrant->layer, E_cell->get(), true);
+ for (const Vector2i &E_cell : p_quadrant->cells) {
+ const TileMapCell &c = get_cell(p_quadrant->layer, E_cell, true);
TileSetSource *source;
if (tile_set->has_source(c.source_id)) {
@@ -1912,7 +1912,7 @@ void TileMap::_scenes_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
// Draw a placeholder tile.
Transform2D xform;
- xform.set_origin(map_to_world(E_cell->get()) - quadrant_pos);
+ xform.set_origin(map_to_world(E_cell) - quadrant_pos);
rs->canvas_item_add_set_transform(p_quadrant->debug_canvas_item, xform);
rs->canvas_item_add_circle(p_quadrant->debug_canvas_item, Vector2(), MIN(tile_set->get_tile_size().x, tile_set->get_tile_size().y) / 4.0, color);
}
@@ -2189,19 +2189,19 @@ RBSet<TileMap::TerrainConstraint> TileMap::get_terrain_constraints_from_removed_
// Build a set of dummy constraints get the constrained points.
RBSet<TerrainConstraint> dummy_constraints;
- for (RBSet<Vector2i>::Element *E = p_to_replace.front(); E; E = E->next()) {
+ for (const Vector2i &E : p_to_replace) {
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { // Iterates over sides.
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
if (tile_set->is_valid_peering_bit_terrain(p_terrain_set, bit)) {
- dummy_constraints.insert(TerrainConstraint(this, E->get(), bit, -1));
+ dummy_constraints.insert(TerrainConstraint(this, E, bit, -1));
}
}
}
// For each constrained point, we get all overlapping tiles, and select the most adequate terrain for it.
RBSet<TerrainConstraint> constraints;
- for (RBSet<TerrainConstraint>::Element *E = dummy_constraints.front(); E; E = E->next()) {
- TerrainConstraint c = E->get();
+ for (const TerrainConstraint &E : dummy_constraints) {
+ TerrainConstraint c = E;
HashMap<int, int> terrain_count;
@@ -2348,8 +2348,8 @@ HashMap<Vector2i, TileSet::TerrainsPattern> TileMap::terrain_wave_function_colla
// Add the new constraints from the added tiles.
RBSet<TerrainConstraint> new_constraints = get_terrain_constraints_from_added_tile(selected_cell_to_replace, p_terrain_set, selected_terrain_tile_pattern);
- for (RBSet<TerrainConstraint>::Element *E_constraint = new_constraints.front(); E_constraint; E_constraint = E_constraint->next()) {
- constraints.insert(E_constraint->get());
+ for (const TerrainConstraint &E_constraint : new_constraints) {
+ constraints.insert(E_constraint);
}
// Compute valid tiles again for neighbors.
@@ -2425,8 +2425,8 @@ void TileMap::fix_invalid_tiles() {
coords.insert(E.key);
}
}
- for (RBSet<Vector2i>::Element *E = coords.front(); E; E = E->next()) {
- set_cell(i, E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
+ for (const Vector2i &E : coords) {
+ set_cell(i, E, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
}
}
}
@@ -3524,11 +3524,11 @@ void TileMap::draw_cells_outline(Control *p_control, RBSet<Vector2i> p_cells, Co
Vector<Vector2> polygon = tile_set->get_tile_shape_polygon();
TileSet::TileShape shape = tile_set->get_tile_shape();
- for (RBSet<Vector2i>::Element *E = p_cells.front(); E; E = E->next()) {
- Vector2 center = map_to_world(E->get());
+ for (const Vector2i &E : p_cells) {
+ Vector2 center = map_to_world(E);
#define DRAW_SIDE_IF_NEEDED(side, polygon_index_from, polygon_index_to) \
- if (!p_cells.has(get_neighbor_cell(E->get(), side))) { \
+ if (!p_cells.has(get_neighbor_cell(E, side))) { \
Vector2 from = p_transform.xform(center + polygon[polygon_index_from] * tile_size); \
Vector2 to = p_transform.xform(center + polygon[polygon_index_to] * tile_size); \
p_control->draw_line(from, to, p_color); \
diff --git a/scene/3d/audio_listener_3d.cpp b/scene/3d/audio_listener_3d.cpp
index 1ead9bb384..4f3f403ab7 100644
--- a/scene/3d/audio_listener_3d.cpp
+++ b/scene/3d/audio_listener_3d.cpp
@@ -68,7 +68,7 @@ bool AudioListener3D::_get(const StringName &p_name, Variant &r_ret) const {
}
void AudioListener3D::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, PNAME("current")));
}
void AudioListener3D::_update_listener() {
diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp
index 70cab77eda..a36357555a 100644
--- a/scene/3d/collision_object_3d.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -345,9 +345,9 @@ void CollisionObject3D::_update_debug_shapes() {
return;
}
- for (RBSet<uint32_t>::Element *shapedata_idx = debug_shapes_to_update.front(); shapedata_idx; shapedata_idx = shapedata_idx->next()) {
- if (shapes.has(shapedata_idx->get())) {
- ShapeData &shapedata = shapes[shapedata_idx->get()];
+ for (const uint32_t &shapedata_idx : debug_shapes_to_update) {
+ if (shapes.has(shapedata_idx)) {
+ ShapeData &shapedata = shapes[shapedata_idx];
ShapeData::ShapeBase *shapes = shapedata.shapes.ptrw();
for (int i = 0; i < shapedata.shapes.size(); i++) {
ShapeData::ShapeBase &s = shapes[i];
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp
index 189ab7fc3b..31993f898d 100644
--- a/scene/3d/mesh_instance_3d.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -97,7 +97,7 @@ void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
if (mesh.is_valid()) {
for (int i = 0; i < mesh->get_surface_count(); i++) {
- p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_material_override/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, vformat("%s/%d", PNAME("surface_material_override"), i), PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE));
}
}
}
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index bbc977647e..ad1ba83c9d 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -180,7 +180,7 @@ void Node3D::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
- get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
}
#endif
} break;
@@ -418,7 +418,7 @@ void Node3D::update_gizmos() {
}
if (data.gizmos.is_empty()) {
- get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
return;
}
if (data.gizmos_dirty) {
@@ -436,7 +436,7 @@ void Node3D::set_subgizmo_selection(Ref<Node3DGizmo> p_gizmo, int p_id, Transfor
}
if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
- get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_set_subgizmo_selection, this, p_gizmo, p_id, p_transform);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_set_subgizmo_selection, this, p_gizmo, p_id, p_transform);
}
#endif
}
@@ -452,7 +452,7 @@ void Node3D::clear_subgizmo_selection() {
}
if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
- get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_clear_subgizmo_selection, this);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFERRED, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_clear_subgizmo_selection, this);
}
#endif
}
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 94cd5400db..370ffef19d 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -94,13 +94,11 @@ void PhysicsBody3D::remove_collision_exception_with(Node *p_node) {
Ref<KinematicCollision3D> PhysicsBody3D::_move(const Vector3 &p_distance, bool p_test_only, real_t p_margin, int p_max_collisions) {
PhysicsServer3D::MotionParameters parameters(get_global_transform(), p_distance, p_margin);
parameters.max_collisions = p_max_collisions;
+ parameters.recovery_as_collision = false; // Don't report collisions generated only from recovery.
PhysicsServer3D::MotionResult result;
- bool collided = move_and_collide(parameters, result, p_test_only);
-
- // Don't report collision when the whole motion is done.
- if (collided && result.collision_safe_fraction < 1) {
+ if (move_and_collide(parameters, result, p_test_only)) {
// Create a new instance when the cached reference is invalid or still in use in script.
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
motion_cache.instantiate();
@@ -184,15 +182,9 @@ bool PhysicsBody3D::test_move(const Transform3D &p_from, const Vector3 &p_distan
}
PhysicsServer3D::MotionParameters parameters(p_from, p_distance, p_margin);
+ parameters.recovery_as_collision = false; // Don't report collisions generated only from recovery.
- bool colliding = PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), parameters, r);
-
- if (colliding) {
- // Don't report collision when the whole motion is done.
- return (r->collision_safe_fraction < 1.0);
- } else {
- return false;
- }
+ return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), parameters, r);
}
void PhysicsBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) {
@@ -1214,6 +1206,8 @@ bool CharacterBody3D::move_and_slide() {
if (!current_platform_velocity.is_equal_approx(Vector3())) {
PhysicsServer3D::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
+
parameters.exclude_bodies.insert(platform_rid);
if (platform_object_id.is_valid()) {
parameters.exclude_objects.insert(platform_object_id);
@@ -1277,6 +1271,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
for (int iteration = 0; iteration < max_slides; ++iteration) {
PhysicsServer3D::MotionParameters parameters(get_global_transform(), motion, margin);
parameters.max_collisions = 4;
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
PhysicsServer3D::MotionResult result;
bool collided = move_and_collide(parameters, result, false, !sliding_enabled);
@@ -1521,6 +1516,7 @@ void CharacterBody3D::_move_and_slide_floating(double p_delta) {
bool first_slide = true;
for (int iteration = 0; iteration < max_slides; ++iteration) {
PhysicsServer3D::MotionParameters parameters(get_global_transform(), motion, margin);
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
PhysicsServer3D::MotionResult result;
bool collided = move_and_collide(parameters, result, false, false);
@@ -1575,6 +1571,7 @@ void CharacterBody3D::_snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_
PhysicsServer3D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
parameters.max_collisions = 4;
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
PhysicsServer3D::MotionResult result;
@@ -1610,6 +1607,7 @@ bool CharacterBody3D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_f
PhysicsServer3D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
parameters.max_collisions = 4;
+ parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
PhysicsServer3D::MotionResult result;
@@ -2263,9 +2261,9 @@ bool PhysicalBone3D::PinJointData::_get(const StringName &p_name, Variant &r_ret
void PhysicalBone3D::PinJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/damping", PROPERTY_HINT_RANGE, "0.01,8.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/impulse_clamp", PROPERTY_HINT_RANGE, "0.0,64.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/bias"), PROPERTY_HINT_RANGE, "0.01,0.99,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/damping"), PROPERTY_HINT_RANGE, "0.01,8.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/impulse_clamp"), PROPERTY_HINT_RANGE, "0.0,64.0,0.01"));
}
bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
@@ -2335,11 +2333,11 @@ bool PhysicalBone3D::ConeJointData::_get(const StringName &p_name, Variant &r_re
void PhysicalBone3D::ConeJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/swing_span", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/twist_span", PROPERTY_HINT_RANGE, "-40000,40000,0.1,or_lesser,or_greater"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/bias", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/relaxation", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/swing_span"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/twist_span"), PROPERTY_HINT_RANGE, "-40000,40000,0.1,or_lesser,or_greater"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/bias"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/softness"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/relaxation"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
}
bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
@@ -2417,12 +2415,12 @@ bool PhysicalBone3D::HingeJointData::_get(const StringName &p_name, Variant &r_r
void PhysicalBone3D::HingeJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
- p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/angular_limit_enabled"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_upper", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_lower", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_relaxation", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, PNAME("joint_constraints/angular_limit_enabled")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_upper"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_lower"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_bias"), PROPERTY_HINT_RANGE, "0.01,0.99,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_softness"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_relaxation"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
}
bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
@@ -2532,17 +2530,17 @@ bool PhysicalBone3D::SliderJointData::_get(const StringName &p_name, Variant &r_
void PhysicalBone3D::SliderJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/linear_limit_upper"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/linear_limit_lower"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/linear_limit_softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/linear_limit_restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/linear_limit_damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/linear_limit_upper")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/linear_limit_lower")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/linear_limit_softness"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/linear_limit_restitution"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/linear_limit_damping"), PROPERTY_HINT_RANGE, "0,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_upper", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_lower", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_upper"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_lower"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_softness"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_restitution"), PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("joint_constraints/angular_limit_damping"), PROPERTY_HINT_RANGE, "0,16.0,0.01"));
}
bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
@@ -2782,29 +2780,30 @@ bool PhysicalBone3D::SixDOFJointData::_get(const StringName &p_name, Variant &r_
}
void PhysicalBone3D::SixDOFJointData::_get_property_list(List<PropertyInfo> *p_list) const {
- const StringName axis_names[] = { "x", "y", "z" };
+ const StringName axis_names[] = { PNAME("x"), PNAME("y"), PNAME("z") };
for (int i = 0; i < 3; ++i) {
- p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/" + axis_names[i] + "/linear_limit_enabled"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_limit_upper"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_limit_lower"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_limit_softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/" + axis_names[i] + "/linear_spring_enabled"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_spring_stiffness"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_spring_damping"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_equilibrium_point"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/linear_damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/" + axis_names[i] + "/angular_limit_enabled"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_limit_upper", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_limit_lower", PROPERTY_HINT_RANGE, "-180,180,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_limit_softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/erp"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/" + axis_names[i] + "/angular_spring_enabled"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_spring_stiffness"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_spring_damping"));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/" + axis_names[i] + "/angular_equilibrium_point"));
+ const String prefix = vformat("%s/%s/", PNAME("joint_constraints"), axis_names[i]);
+ p_list->push_back(PropertyInfo(Variant::BOOL, prefix + PNAME("linear_limit_enabled")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_limit_upper")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_limit_lower")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_limit_softness"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prefix + PNAME("linear_spring_enabled")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_spring_stiffness")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_spring_damping")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_equilibrium_point")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_restitution"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("linear_damping"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prefix + PNAME("angular_limit_enabled")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_limit_upper"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_limit_lower"), PROPERTY_HINT_RANGE, "-180,180,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_limit_softness"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_restitution"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_damping"), PROPERTY_HINT_RANGE, "0.01,16,0.01"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("erp")));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prefix + PNAME("angular_spring_enabled")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_spring_stiffness")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_spring_damping")));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, prefix + PNAME("angular_equilibrium_point")));
}
}
@@ -2851,9 +2850,9 @@ void PhysicalBone3D::_get_property_list(List<PropertyInfo> *p_list) const {
names += parent->get_bone_name(i);
}
- p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name", PROPERTY_HINT_ENUM, names));
+ p_list->push_back(PropertyInfo(Variant::STRING_NAME, PNAME("bone_name"), PROPERTY_HINT_ENUM, names));
} else {
- p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name"));
+ p_list->push_back(PropertyInfo(Variant::STRING_NAME, PNAME("bone_name")));
}
if (joint_data) {
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index f4a7767c44..ba2029788e 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -153,14 +153,14 @@ bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < bones.size(); i++) {
- String prep = "bones/" + itos(i) + "/";
- p_list->push_back(PropertyInfo(Variant::STRING, prep + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
- p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1", PROPERTY_USAGE_NO_EDITOR));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prep + "rest", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
- p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
- p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + "position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
- p_list->push_back(PropertyInfo(Variant::QUATERNION, prep + "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
- p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
+ const String prep = vformat("%s/%d/", PNAME("bones"), i);
+ p_list->push_back(PropertyInfo(Variant::STRING, prep + PNAME("name"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, prep + PNAME("parent"), PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1", PROPERTY_USAGE_NO_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prep + PNAME("rest"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prep + PNAME("enabled"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + PNAME("position"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::QUATERNION, prep + PNAME("rotation"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + PNAME("scale"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
}
#ifndef _3D_DISABLED
@@ -263,19 +263,19 @@ void Skeleton3D::_notification(int p_what) {
force_update_all_bone_transforms();
// Update skins.
- for (RBSet<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
- const Skin *skin = E->get()->skin.operator->();
- RID skeleton = E->get()->skeleton;
+ for (SkinReference *E : skin_bindings) {
+ const Skin *skin = E->skin.operator->();
+ RID skeleton = E->skeleton;
uint32_t bind_count = skin->get_bind_count();
- if (E->get()->bind_count != bind_count) {
+ if (E->bind_count != bind_count) {
RS::get_singleton()->skeleton_allocate_data(skeleton, bind_count);
- E->get()->bind_count = bind_count;
- E->get()->skin_bone_indices.resize(bind_count);
- E->get()->skin_bone_indices_ptrs = E->get()->skin_bone_indices.ptrw();
+ E->bind_count = bind_count;
+ E->skin_bone_indices.resize(bind_count);
+ E->skin_bone_indices_ptrs = E->skin_bone_indices.ptrw();
}
- if (E->get()->skeleton_version != version) {
+ if (E->skeleton_version != version) {
for (uint32_t i = 0; i < bind_count; i++) {
StringName bind_name = skin->get_bind_name(i);
@@ -284,7 +284,7 @@ void Skeleton3D::_notification(int p_what) {
bool found = false;
for (int j = 0; j < len; j++) {
if (bonesptr[j].name == bind_name) {
- E->get()->skin_bone_indices_ptrs[i] = j;
+ E->skin_bone_indices_ptrs[i] = j;
found = true;
break;
}
@@ -292,27 +292,27 @@ void Skeleton3D::_notification(int p_what) {
if (!found) {
ERR_PRINT("Skin bind #" + itos(i) + " contains named bind '" + String(bind_name) + "' but Skeleton3D has no bone by that name.");
- E->get()->skin_bone_indices_ptrs[i] = 0;
+ E->skin_bone_indices_ptrs[i] = 0;
}
} else if (skin->get_bind_bone(i) >= 0) {
int bind_index = skin->get_bind_bone(i);
if (bind_index >= len) {
ERR_PRINT("Skin bind #" + itos(i) + " contains bone index bind: " + itos(bind_index) + " , which is greater than the skeleton bone count: " + itos(len) + ".");
- E->get()->skin_bone_indices_ptrs[i] = 0;
+ E->skin_bone_indices_ptrs[i] = 0;
} else {
- E->get()->skin_bone_indices_ptrs[i] = bind_index;
+ E->skin_bone_indices_ptrs[i] = bind_index;
}
} else {
ERR_PRINT("Skin bind #" + itos(i) + " does not contain a name nor a bone index.");
- E->get()->skin_bone_indices_ptrs[i] = 0;
+ E->skin_bone_indices_ptrs[i] = 0;
}
}
- E->get()->skeleton_version = version;
+ E->skeleton_version = version;
}
for (uint32_t i = 0; i < bind_count; i++) {
- uint32_t bone_index = E->get()->skin_bone_indices_ptrs[i];
+ uint32_t bone_index = E->skin_bone_indices_ptrs[i];
ERR_CONTINUE(bone_index >= (uint32_t)len);
rs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i));
}
@@ -1000,9 +1000,9 @@ Ref<Skin> Skeleton3D::create_skin_from_rest_transforms() {
Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
ERR_FAIL_COND_V(p_skin.is_null(), Ref<SkinReference>());
- for (RBSet<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
- if (E->get()->skin == p_skin) {
- return Ref<SkinReference>(E->get());
+ for (const SkinReference *E : skin_bindings) {
+ if (E->skin == p_skin) {
+ return Ref<SkinReference>(E);
}
}
@@ -1303,7 +1303,7 @@ Skeleton3D::Skeleton3D() {
Skeleton3D::~Skeleton3D() {
// Some skins may remain bound.
- for (RBSet<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
- E->get()->skeleton_node = nullptr;
+ for (SkinReference *E : skin_bindings) {
+ E->skeleton_node = nullptr;
}
}
diff --git a/scene/3d/soft_dynamic_body_3d.cpp b/scene/3d/soft_dynamic_body_3d.cpp
index 7d786a41bf..5816c0650f 100644
--- a/scene/3d/soft_dynamic_body_3d.cpp
+++ b/scene/3d/soft_dynamic_body_3d.cpp
@@ -162,12 +162,13 @@ bool SoftDynamicBody3D::_get(const StringName &p_name, Variant &r_ret) const {
void SoftDynamicBody3D::_get_property_list(List<PropertyInfo> *p_list) const {
const int pinned_points_indices_size = pinned_points.size();
- p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "pinned_points"));
+ p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, PNAME("pinned_points")));
for (int i = 0; i < pinned_points_indices_size; ++i) {
- p_list->push_back(PropertyInfo(Variant::INT, "attachments/" + itos(i) + "/point_index"));
- p_list->push_back(PropertyInfo(Variant::NODE_PATH, "attachments/" + itos(i) + "/spatial_attachment_path"));
- p_list->push_back(PropertyInfo(Variant::VECTOR3, "attachments/" + itos(i) + "/offset"));
+ const String prefix = vformat("%s/%d", PNAME("attachments"), i);
+ p_list->push_back(PropertyInfo(Variant::INT, prefix + PNAME("point_index")));
+ p_list->push_back(PropertyInfo(Variant::NODE_PATH, prefix + PNAME("spatial_attachment_path")));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, prefix + PNAME("offset")));
}
}
diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp
index 849316c568..594f98410e 100644
--- a/scene/animation/animation_blend_space_1d.cpp
+++ b/scene/animation/animation_blend_space_1d.cpp
@@ -219,14 +219,14 @@ void AnimationNodeBlendSpace1D::_add_blend_point(int p_index, const Ref<Animatio
}
}
-double AnimationNodeBlendSpace1D::process(double p_time, bool p_seek) {
+double AnimationNodeBlendSpace1D::process(double p_time, bool p_seek, bool p_seek_root) {
if (blend_points_used == 0) {
return 0.0;
}
if (blend_points_used == 1) {
// only one point available, just play that animation
- return blend_node(blend_points[0].name, blend_points[0].node, p_time, p_seek, 1.0, FILTER_IGNORE, false);
+ return blend_node(blend_points[0].name, blend_points[0].node, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, false);
}
double blend_pos = get_parameter(blend_position);
@@ -295,7 +295,7 @@ double AnimationNodeBlendSpace1D::process(double p_time, bool p_seek) {
double max_time_remaining = 0.0;
for (int i = 0; i < blend_points_used; i++) {
- double remaining = blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, weights[i], FILTER_IGNORE, false);
+ double remaining = blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, p_seek_root, weights[i], FILTER_IGNORE, false);
max_time_remaining = MAX(max_time_remaining, remaining);
}
diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h
index 7038cece06..b2075c8c93 100644
--- a/scene/animation/animation_blend_space_1d.h
+++ b/scene/animation/animation_blend_space_1d.h
@@ -93,7 +93,7 @@ public:
void set_value_label(const String &p_label);
String get_value_label() const;
- double process(double p_time, bool p_seek) override;
+ double process(double p_time, bool p_seek, bool p_seek_root) override;
String get_caption() const override;
Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index a3aa3f6cc8..acdce2d7de 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -432,7 +432,7 @@ void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vect
r_weights[2] = w;
}
-double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek) {
+double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek, bool p_seek_root) {
_update_triangles();
Vector2 blend_pos = get_parameter(blend_position);
@@ -502,7 +502,7 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek) {
for (int j = 0; j < 3; j++) {
if (i == triangle_points[j]) {
//blend with the given weight
- double t = blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, blend_weights[j], FILTER_IGNORE, false);
+ double t = blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, p_seek_root, blend_weights[j], FILTER_IGNORE, false);
if (first || t < mind) {
mind = t;
first = false;
@@ -514,7 +514,7 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek) {
if (!found) {
//ignore
- blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, 0, FILTER_IGNORE, false);
+ blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, p_seek_root, 0, FILTER_IGNORE, false);
}
}
} else {
@@ -539,16 +539,16 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek) {
na_n->set_backward(na_c->is_backward());
}
//see how much animation remains
- from = length_internal - blend_node(blend_points[closest].name, blend_points[closest].node, p_time, false, 0.0, FILTER_IGNORE, false);
+ from = length_internal - blend_node(blend_points[closest].name, blend_points[closest].node, p_time, false, p_seek_root, 0.0, FILTER_IGNORE, false);
}
- mind = blend_node(blend_points[new_closest].name, blend_points[new_closest].node, from, true, 1.0, FILTER_IGNORE, false);
+ mind = blend_node(blend_points[new_closest].name, blend_points[new_closest].node, from, true, p_seek_root, 1.0, FILTER_IGNORE, false);
length_internal = from + mind;
closest = new_closest;
} else {
- mind = blend_node(blend_points[closest].name, blend_points[closest].node, p_time, p_seek, 1.0, FILTER_IGNORE, false);
+ mind = blend_node(blend_points[closest].name, blend_points[closest].node, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, false);
}
}
diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h
index 1356656bf8..01f53ed25a 100644
--- a/scene/animation/animation_blend_space_2d.h
+++ b/scene/animation/animation_blend_space_2d.h
@@ -126,7 +126,7 @@ public:
void set_y_label(const String &p_label);
String get_y_label() const;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
virtual String get_caption() const override;
Vector2 get_closest_point(const Vector2 &p_point);
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 433f21f91f..17a99ed034 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -64,7 +64,7 @@ void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
}
}
-double AnimationNodeAnimation::process(double p_time, bool p_seek) {
+double AnimationNodeAnimation::process(double p_time, bool p_seek, bool p_seek_root) {
AnimationPlayer *ap = state->player;
ERR_FAIL_COND_V(!ap, 0);
@@ -101,8 +101,8 @@ double AnimationNodeAnimation::process(double p_time, bool p_seek) {
}
}
- if (anim->get_loop_mode() == Animation::LoopMode::LOOP_PINGPONG) {
- if (anim_size) {
+ if (anim->get_loop_mode() == Animation::LOOP_PINGPONG) {
+ if (!Math::is_zero_approx(anim_size)) {
if ((int)Math::floor(abs(time - prev_time) / anim_size) % 2 == 0) {
if (prev_time > 0 && time <= 0) {
backward = !backward;
@@ -116,22 +116,24 @@ double AnimationNodeAnimation::process(double p_time, bool p_seek) {
time = Math::pingpong(time, anim_size);
}
} else {
- if (anim->get_loop_mode() == Animation::LoopMode::LOOP_LINEAR) {
- if (anim_size) {
+ if (anim->get_loop_mode() == Animation::LOOP_LINEAR) {
+ if (!Math::is_zero_approx(anim_size)) {
time = Math::fposmod(time, anim_size);
}
} else if (time < 0) {
+ step += time;
time = 0;
} else if (time > anim_size) {
+ step += anim_size - time;
time = anim_size;
}
backward = false;
}
if (play_mode == PLAY_MODE_FORWARD) {
- blend_animation(animation, time, step, p_seek, 1.0, pingponged);
+ blend_animation(animation, time, step, p_seek, p_seek_root, 1.0, pingponged);
} else {
- blend_animation(animation, anim_size - time, -step, p_seek, 1.0, pingponged);
+ blend_animation(animation, anim_size - time, -step, p_seek, p_seek_root, 1.0, pingponged);
}
set_parameter(this->time, time);
@@ -251,7 +253,7 @@ bool AnimationNodeOneShot::has_filter() const {
return true;
}
-double AnimationNodeOneShot::process(double p_time, bool p_seek) {
+double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_root) {
bool active = get_parameter(this->active);
bool prev_active = get_parameter(this->prev_active);
double time = get_parameter(this->time);
@@ -274,7 +276,7 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek) {
}
if (!active) {
- return blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
+ return blend_input(0, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, !sync);
}
}
@@ -311,12 +313,12 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek) {
double main_rem;
if (mix == MIX_MODE_ADD) {
- main_rem = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
+ main_rem = blend_input(0, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, !sync);
} else {
- main_rem = blend_input(0, p_time, p_seek, 1.0 - blend, FILTER_BLEND, !sync);
+ main_rem = blend_input(0, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_BLEND, !sync);
}
- double os_rem = blend_input(1, os_seek ? time : p_time, os_seek, blend, FILTER_PASS, false);
+ double os_rem = blend_input(1, os_seek ? time : p_time, os_seek, p_seek_root, blend, FILTER_PASS, false);
if (do_start) {
remaining = os_rem;
@@ -420,10 +422,10 @@ bool AnimationNodeAdd2::has_filter() const {
return true;
}
-double AnimationNodeAdd2::process(double p_time, bool p_seek) {
+double AnimationNodeAdd2::process(double p_time, bool p_seek, bool p_seek_root) {
double amount = get_parameter(add_amount);
- double rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
- blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);
+ double rem0 = blend_input(0, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, !sync);
+ blend_input(1, p_time, p_seek, p_seek_root, amount, FILTER_PASS, !sync);
return rem0;
}
@@ -466,11 +468,11 @@ bool AnimationNodeAdd3::has_filter() const {
return true;
}
-double AnimationNodeAdd3::process(double p_time, bool p_seek) {
+double AnimationNodeAdd3::process(double p_time, bool p_seek, bool p_seek_root) {
double amount = get_parameter(add_amount);
- blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_PASS, !sync);
- double rem0 = blend_input(1, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
- blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_PASS, !sync);
+ blend_input(0, p_time, p_seek, p_seek_root, MAX(0, -amount), FILTER_PASS, !sync);
+ double rem0 = blend_input(1, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, !sync);
+ blend_input(2, p_time, p_seek, p_seek_root, MAX(0, amount), FILTER_PASS, !sync);
return rem0;
}
@@ -502,11 +504,11 @@ String AnimationNodeBlend2::get_caption() const {
return "Blend2";
}
-double AnimationNodeBlend2::process(double p_time, bool p_seek) {
+double AnimationNodeBlend2::process(double p_time, bool p_seek, bool p_seek_root) {
double amount = get_parameter(blend_amount);
- double rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync);
- double rem1 = blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);
+ double rem0 = blend_input(0, p_time, p_seek, p_seek_root, 1.0 - amount, FILTER_BLEND, !sync);
+ double rem1 = blend_input(1, p_time, p_seek, p_seek_root, amount, FILTER_PASS, !sync);
return amount > 0.5 ? rem1 : rem0; //hacky but good enough
}
@@ -557,11 +559,11 @@ bool AnimationNodeBlend3::is_using_sync() const {
return sync;
}
-double AnimationNodeBlend3::process(double p_time, bool p_seek) {
+double AnimationNodeBlend3::process(double p_time, bool p_seek, bool p_seek_root) {
double amount = get_parameter(blend_amount);
- double rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync);
- double rem1 = blend_input(1, p_time, p_seek, 1.0 - ABS(amount), FILTER_IGNORE, !sync);
- double rem2 = blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_IGNORE, !sync);
+ double rem0 = blend_input(0, p_time, p_seek, p_seek_root, MAX(0, -amount), FILTER_IGNORE, !sync);
+ double rem1 = blend_input(1, p_time, p_seek, p_seek_root, 1.0 - ABS(amount), FILTER_IGNORE, !sync);
+ double rem2 = blend_input(2, p_time, p_seek, p_seek_root, MAX(0, amount), FILTER_IGNORE, !sync);
return amount > 0.5 ? rem2 : (amount < -0.5 ? rem0 : rem1); //hacky but good enough
}
@@ -574,7 +576,6 @@ void AnimationNodeBlend3::_bind_methods() {
}
AnimationNodeBlend3::AnimationNodeBlend3() {
- blend_amount = "blend_amount";
add_input("-blend");
add_input("in");
add_input("+blend");
@@ -595,12 +596,12 @@ String AnimationNodeTimeScale::get_caption() const {
return "TimeScale";
}
-double AnimationNodeTimeScale::process(double p_time, bool p_seek) {
+double AnimationNodeTimeScale::process(double p_time, bool p_seek, bool p_seek_root) {
double scale = get_parameter(this->scale);
if (p_seek) {
- return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
+ return blend_input(0, p_time, true, p_seek_root, 1.0, FILTER_IGNORE, false);
} else {
- return blend_input(0, p_time * scale, false, 1.0, FILTER_IGNORE, false);
+ return blend_input(0, p_time * scale, false, p_seek_root, 1.0, FILTER_IGNORE, false);
}
}
@@ -625,16 +626,16 @@ String AnimationNodeTimeSeek::get_caption() const {
return "Seek";
}
-double AnimationNodeTimeSeek::process(double p_time, bool p_seek) {
+double AnimationNodeTimeSeek::process(double p_time, bool p_seek, bool p_seek_root) {
double seek_pos = get_parameter(this->seek_pos);
if (p_seek) {
- return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
+ return blend_input(0, p_time, true, p_seek_root, 1.0, FILTER_IGNORE, false);
} else if (seek_pos >= 0) {
- double ret = blend_input(0, seek_pos, true, 1.0, FILTER_IGNORE, false);
+ double ret = blend_input(0, seek_pos, true, true, 1.0, FILTER_IGNORE, false);
set_parameter(this->seek_pos, -1.0); //reset
return ret;
} else {
- return blend_input(0, p_time, false, 1.0, FILTER_IGNORE, false);
+ return blend_input(0, p_time, false, p_seek_root, 1.0, FILTER_IGNORE, false);
}
}
@@ -726,7 +727,7 @@ float AnimationNodeTransition::get_cross_fade_time() const {
return xfade;
}
-double AnimationNodeTransition::process(double p_time, bool p_seek) {
+double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_seek_root) {
int current = get_parameter(this->current);
int prev = get_parameter(this->prev);
int prev_current = get_parameter(this->prev_current);
@@ -754,7 +755,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek) {
if (prev < 0) { // process current animation, check for transition
- rem = blend_input(current, p_time, p_seek, 1.0, FILTER_IGNORE, false);
+ rem = blend_input(current, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, false);
if (p_seek) {
time = p_time;
@@ -772,16 +773,16 @@ double AnimationNodeTransition::process(double p_time, bool p_seek) {
if (!p_seek && switched) { //just switched, seek to start of current
- rem = blend_input(current, 0, true, 1.0 - blend, FILTER_IGNORE, false);
+ rem = blend_input(current, 0, true, p_seek_root, 1.0 - blend, FILTER_IGNORE, false);
} else {
- rem = blend_input(current, p_time, p_seek, 1.0 - blend, FILTER_IGNORE, false);
+ rem = blend_input(current, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_IGNORE, false);
}
if (p_seek) { // don't seek prev animation
- blend_input(prev, 0, false, blend, FILTER_IGNORE, false);
+ blend_input(prev, 0, false, p_seek_root, blend, FILTER_IGNORE, false);
time = p_time;
} else {
- blend_input(prev, p_time, false, blend, FILTER_IGNORE, false);
+ blend_input(prev, p_time, false, p_seek_root, blend, FILTER_IGNORE, false);
time += p_time;
prev_xfading -= p_time;
if (prev_xfading < 0) {
@@ -844,8 +845,8 @@ String AnimationNodeOutput::get_caption() const {
return "Output";
}
-double AnimationNodeOutput::process(double p_time, bool p_seek) {
- return blend_input(0, p_time, p_seek, 1.0);
+double AnimationNodeOutput::process(double p_time, bool p_seek, bool p_seek_root) {
+ return blend_input(0, p_time, p_seek, p_seek_root, 1.0);
}
AnimationNodeOutput::AnimationNodeOutput() {
@@ -1057,9 +1058,9 @@ String AnimationNodeBlendTree::get_caption() const {
return "BlendTree";
}
-double AnimationNodeBlendTree::process(double p_time, bool p_seek) {
+double AnimationNodeBlendTree::process(double p_time, bool p_seek, bool p_seek_root) {
Ref<AnimationNodeOutput> output = nodes[SceneStringNames::get_singleton()->output].node;
- return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, 1.0);
+ return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, p_seek_root, 1.0);
}
void AnimationNodeBlendTree::get_node_list(List<StringName> *r_list) {
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 73bde633cb..0a2305b8d6 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -53,7 +53,7 @@ public:
static Vector<String> (*get_editable_animation_list)();
virtual String get_caption() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
void set_animation(const StringName &p_name);
StringName get_animation() const;
@@ -87,8 +87,8 @@ public:
};
private:
- float fade_in = 0.1;
- float fade_out = 0.1;
+ float fade_in = 0.0;
+ float fade_out = 0.0;
bool autorestart = false;
float autorestart_delay = 1.0;
@@ -102,7 +102,7 @@ private:
float time;
float remaining;*/
- StringName active = "active";
+ StringName active = PNAME("active");
StringName prev_active = "prev_active";
StringName time = "time";
StringName remaining = "remaining";
@@ -138,7 +138,7 @@ public:
bool is_using_sync() const;
virtual bool has_filter() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeOneShot();
};
@@ -148,7 +148,7 @@ VARIANT_ENUM_CAST(AnimationNodeOneShot::MixMode)
class AnimationNodeAdd2 : public AnimationNode {
GDCLASS(AnimationNodeAdd2, AnimationNode);
- StringName add_amount = "add_amount";
+ StringName add_amount = PNAME("add_amount");
bool sync = false;
protected:
@@ -164,7 +164,7 @@ public:
bool is_using_sync() const;
virtual bool has_filter() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeAdd2();
};
@@ -172,7 +172,7 @@ public:
class AnimationNodeAdd3 : public AnimationNode {
GDCLASS(AnimationNodeAdd3, AnimationNode);
- StringName add_amount = "add_amount";
+ StringName add_amount = PNAME("add_amount");
bool sync = false;
protected:
@@ -188,7 +188,7 @@ public:
bool is_using_sync() const;
virtual bool has_filter() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeAdd3();
};
@@ -196,7 +196,7 @@ public:
class AnimationNodeBlend2 : public AnimationNode {
GDCLASS(AnimationNodeBlend2, AnimationNode);
- StringName blend_amount = "blend_amount";
+ StringName blend_amount = PNAME("blend_amount");
bool sync = false;
protected:
@@ -207,7 +207,7 @@ public:
virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
virtual String get_caption() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
@@ -219,7 +219,7 @@ public:
class AnimationNodeBlend3 : public AnimationNode {
GDCLASS(AnimationNodeBlend3, AnimationNode);
- StringName blend_amount;
+ StringName blend_amount = PNAME("blend_amount");
bool sync;
protected:
@@ -234,14 +234,14 @@ public:
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- double process(double p_time, bool p_seek) override;
+ double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeBlend3();
};
class AnimationNodeTimeScale : public AnimationNode {
GDCLASS(AnimationNodeTimeScale, AnimationNode);
- StringName scale = "scale";
+ StringName scale = PNAME("scale");
protected:
static void _bind_methods();
@@ -252,7 +252,7 @@ public:
virtual String get_caption() const override;
- double process(double p_time, bool p_seek) override;
+ double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeTimeScale();
};
@@ -260,7 +260,7 @@ public:
class AnimationNodeTimeSeek : public AnimationNode {
GDCLASS(AnimationNodeTimeSeek, AnimationNode);
- StringName seek_pos = "seek_position";
+ StringName seek_pos = PNAME("seek_position");
protected:
static void _bind_methods();
@@ -271,7 +271,7 @@ public:
virtual String get_caption() const override;
- double process(double p_time, bool p_seek) override;
+ double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeTimeSeek();
};
@@ -300,7 +300,7 @@ class AnimationNodeTransition : public AnimationNode {
StringName prev_xfading = "prev_xfading";
StringName prev = "prev";
StringName time = "time";
- StringName current = "current";
+ StringName current = PNAME("current");
StringName prev_current = "prev_current";
float xfade = 0.0;
@@ -329,7 +329,7 @@ public:
void set_cross_fade_time(float p_fade);
float get_cross_fade_time() const;
- double process(double p_time, bool p_seek) override;
+ double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeTransition();
};
@@ -339,7 +339,7 @@ class AnimationNodeOutput : public AnimationNode {
public:
virtual String get_caption() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
AnimationNodeOutput();
};
@@ -408,7 +408,7 @@ public:
void get_node_connections(List<NodeConnection> *r_connections) const;
virtual String get_caption() const override;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
void get_node_list(List<StringName> *r_list);
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index 81df12791c..39849a0b00 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -292,7 +292,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
return true;
}
-double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, double p_time, bool p_seek) {
+double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, double p_time, bool p_seek, bool p_seek_root) {
//if not playing and it can restart, then restart
if (!playing && start_request == StringName()) {
if (!stop_request && p_state_machine->start_node) {
@@ -356,7 +356,7 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s
current = p_state_machine->start_node;
}
- len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false);
+ len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, p_seek_root, 1.0, AnimationNode::FILTER_IGNORE, false);
pos_current = 0;
}
@@ -381,10 +381,10 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s
}
}
- float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false);
+ float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, p_seek_root, fade_blend, AnimationNode::FILTER_IGNORE, false);
if (fading_from != StringName()) {
- p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false);
+ p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, p_seek_root, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false);
}
//guess playback position
@@ -538,12 +538,12 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s
}
current = next;
if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_SYNC) {
- len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
+ len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, p_seek_root, 0, AnimationNode::FILTER_IGNORE, false);
pos_current = MIN(pos_current, len_current);
- p_state_machine->blend_node(current, p_state_machine->states[current].node, pos_current, true, 0, AnimationNode::FILTER_IGNORE, false);
+ p_state_machine->blend_node(current, p_state_machine->states[current].node, pos_current, true, p_seek_root, 0, AnimationNode::FILTER_IGNORE, false);
} else {
- len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
+ len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, p_seek_root, 0, AnimationNode::FILTER_IGNORE, false);
pos_current = 0;
}
@@ -1071,11 +1071,11 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const {
return graph_offset;
}
-double AnimationNodeStateMachine::process(double p_time, bool p_seek) {
+double AnimationNodeStateMachine::process(double p_time, bool p_seek, bool p_seek_root) {
Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback);
ERR_FAIL_COND_V(playback.is_null(), 0.0);
- return playback->process(this, p_time, p_seek);
+ return playback->process(this, p_time, p_seek, p_seek_root);
}
String AnimationNodeStateMachine::get_caption() const {
diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h
index 07d0579533..9eeac6a183 100644
--- a/scene/animation/animation_node_state_machine.h
+++ b/scene/animation/animation_node_state_machine.h
@@ -120,7 +120,7 @@ class AnimationNodeStateMachinePlayback : public Resource {
bool _travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel);
- double process(AnimationNodeStateMachine *p_state_machine, double p_time, bool p_seek);
+ double process(AnimationNodeStateMachine *p_state_machine, double p_time, bool p_seek, bool p_seek_root);
bool _check_advance_condition(const Ref<AnimationNodeStateMachine> p_state_machine, const Ref<AnimationNodeStateMachineTransition> p_transition) const;
@@ -226,7 +226,7 @@ public:
void set_graph_offset(const Vector2 &p_offset);
Vector2 get_graph_offset() const;
- virtual double process(double p_time, bool p_seek) override;
+ virtual double process(double p_time, bool p_seek, bool p_seek_root) override;
virtual String get_caption() const override;
virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 9ace6db505..921a06b73c 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -832,7 +832,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
nc->audio_start = p_time;
}
} else if (nc->audio_playing) {
- bool loop = a->get_loop_mode() != Animation::LoopMode::LOOP_NONE;
+ bool loop = a->get_loop_mode() != Animation::LOOP_NONE;
bool stop = false;
@@ -883,15 +883,15 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
double at_anim_pos = 0.0;
switch (anim->get_loop_mode()) {
- case Animation::LoopMode::LOOP_NONE: {
+ case Animation::LOOP_NONE: {
at_anim_pos = MIN((double)anim->get_length(), p_time - pos); //seek to end
} break;
- case Animation::LoopMode::LOOP_LINEAR: {
+ case Animation::LOOP_LINEAR: {
at_anim_pos = Math::fposmod(p_time - pos, (double)anim->get_length()); //seek to loop
} break;
- case Animation::LoopMode::LOOP_PINGPONG: {
+ case Animation::LOOP_PINGPONG: {
at_anim_pos = Math::pingpong(p_time - pos, (double)anim->get_length());
} break;
@@ -944,7 +944,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, double p_delta,
int pingponged = 0;
switch (cd.from->animation->get_loop_mode()) {
- case Animation::LoopMode::LOOP_NONE: {
+ case Animation::LOOP_NONE: {
if (next_pos < 0) {
next_pos = 0;
} else if (next_pos > len) {
@@ -969,7 +969,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, double p_delta,
}
} break;
- case Animation::LoopMode::LOOP_LINEAR: {
+ case Animation::LOOP_LINEAR: {
double looped_next_pos = Math::fposmod(next_pos, (double)len);
if (looped_next_pos == 0 && next_pos != 0) {
// Loop multiples of the length to it, rather than 0
@@ -980,7 +980,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, double p_delta,
}
} break;
- case Animation::LoopMode::LOOP_PINGPONG: {
+ case Animation::LOOP_PINGPONG: {
if ((int)Math::floor(abs(next_pos - cd.pos) / len) % 2 == 0) {
if (next_pos < 0 && cd.pos >= 0) {
cd.speed_scale *= -1.0;
@@ -1766,12 +1766,12 @@ void AnimationPlayer::_animation_changed() {
}
void AnimationPlayer::_stop_playing_caches() {
- for (RBSet<TrackNodeCache *>::Element *E = playing_caches.front(); E; E = E->next()) {
- if (E->get()->node && E->get()->audio_playing) {
- E->get()->node->call(SNAME("stop"));
+ for (TrackNodeCache *E : playing_caches) {
+ if (E->node && E->audio_playing) {
+ E->node->call(SNAME("stop"));
}
- if (E->get()->node && E->get()->animation_playing) {
- AnimationPlayer *player = Object::cast_to<AnimationPlayer>(E->get()->node);
+ if (E->node && E->animation_playing) {
+ AnimationPlayer *player = Object::cast_to<AnimationPlayer>(E->node);
if (!player) {
continue;
}
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 92af15d5d3..d34e8db093 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -88,7 +88,7 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
}
}
-void AnimationNode::blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, real_t p_blend, int p_pingponged) {
+void AnimationNode::blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, bool p_seek_root, real_t p_blend, int p_pingponged) {
ERR_FAIL_COND(!state);
ERR_FAIL_COND(!state->player->has_animation(p_animation));
@@ -115,17 +115,18 @@ void AnimationNode::blend_animation(const StringName &p_animation, double p_time
anim_state.animation = animation;
anim_state.seeked = p_seeked;
anim_state.pingponged = p_pingponged;
+ anim_state.seek_root = p_seek_root;
state->animation_states.push_back(anim_state);
}
-double AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, const Vector<StringName> &p_connections) {
+double AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, bool p_seek_root, const Vector<StringName> &p_connections) {
base_path = p_base_path;
parent = p_parent;
connections = p_connections;
state = p_state;
- double t = process(p_time, p_seek);
+ double t = process(p_time, p_seek, p_seek_root);
state = nullptr;
parent = nullptr;
@@ -144,7 +145,7 @@ void AnimationNode::make_invalid(const String &p_reason) {
state->invalid_reasons += String::utf8("• ") + p_reason;
}
-double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) {
+double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, bool p_seek_root, real_t p_blend, FilterAction p_filter, bool p_optimize) {
ERR_FAIL_INDEX_V(p_input, inputs.size(), 0);
ERR_FAIL_COND_V(!state, 0);
@@ -163,7 +164,7 @@ double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, real_
//inputs.write[p_input].last_pass = state->last_pass;
real_t activity = 0.0;
- double ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);
+ double ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_seek_root, p_blend, p_filter, p_optimize, &activity);
Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path);
@@ -174,11 +175,11 @@ double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, real_
return ret;
}
-double AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) {
- return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize);
+double AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_seek_root, real_t p_blend, FilterAction p_filter, bool p_optimize) {
+ return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_seek_root, p_blend, p_filter, p_optimize);
}
-double AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize, real_t *r_max) {
+double AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_seek_root, real_t p_blend, FilterAction p_filter, bool p_optimize, real_t *r_max) {
ERR_FAIL_COND_V(!p_node.is_valid(), 0);
ERR_FAIL_COND_V(!state, 0);
@@ -286,9 +287,9 @@ double AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Stri
}
if (!p_seek && p_optimize && !any_valid) {
- return p_node->_pre_process(new_path, new_parent, state, 0, p_seek, p_connections);
+ return p_node->_pre_process(new_path, new_parent, state, 0, p_seek, p_seek_root, p_connections);
}
- return p_node->_pre_process(new_path, new_parent, state, p_time, p_seek, p_connections);
+ return p_node->_pre_process(new_path, new_parent, state, p_time, p_seek, p_seek_root, p_connections);
}
int AnimationNode::get_input_count() const {
@@ -332,9 +333,9 @@ void AnimationNode::remove_input(int p_index) {
emit_changed();
}
-double AnimationNode::process(double p_time, bool p_seek) {
+double AnimationNode::process(double p_time, bool p_seek, bool p_seek_root) {
double ret;
- if (GDVIRTUAL_CALL(_process, p_time, p_seek, ret)) {
+ if (GDVIRTUAL_CALL(_process, p_time, p_seek, p_seek_root, ret)) {
return ret;
}
@@ -418,9 +419,9 @@ void AnimationNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_filters", "filters"), &AnimationNode::_set_filters);
ClassDB::bind_method(D_METHOD("_get_filters"), &AnimationNode::_get_filters);
- ClassDB::bind_method(D_METHOD("blend_animation", "animation", "time", "delta", "seeked", "blend", "pingponged"), &AnimationNode::blend_animation, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("blend_node", "name", "node", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_node, DEFVAL(FILTER_IGNORE), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("blend_input", "input_index", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_input, DEFVAL(FILTER_IGNORE), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("blend_animation", "animation", "time", "delta", "seeked", "seek_root", "blend", "pingponged"), &AnimationNode::blend_animation, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("blend_node", "name", "node", "time", "seek", "seek_root", "blend", "filter", "optimize"), &AnimationNode::blend_node, DEFVAL(FILTER_IGNORE), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("blend_input", "input_index", "time", "seek", "seek_root", "blend", "filter", "optimize"), &AnimationNode::blend_input, DEFVAL(FILTER_IGNORE), DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_parameter", "name", "value"), &AnimationNode::set_parameter);
ClassDB::bind_method(D_METHOD("get_parameter", "name"), &AnimationNode::get_parameter);
@@ -432,7 +433,7 @@ void AnimationNode::_bind_methods() {
GDVIRTUAL_BIND(_get_parameter_list);
GDVIRTUAL_BIND(_get_child_by_name, "name");
GDVIRTUAL_BIND(_get_parameter_default_value, "parameter");
- GDVIRTUAL_BIND(_process, "time", "seek");
+ GDVIRTUAL_BIND(_process, "time", "seek", "seek_root");
GDVIRTUAL_BIND(_get_caption);
GDVIRTUAL_BIND(_has_filter);
@@ -486,9 +487,9 @@ void AnimationTree::set_active(bool p_active) {
}
if (!active && is_inside_tree()) {
- for (RBSet<TrackCache *>::Element *E = playing_caches.front(); E; E = E->next()) {
- if (ObjectDB::get_instance(E->get()->object_id)) {
- E->get()->object->call(SNAME("stop"));
+ for (const TrackCache *E : playing_caches) {
+ if (ObjectDB::get_instance(E->object_id)) {
+ E->object->call(SNAME("stop"));
}
}
@@ -859,7 +860,6 @@ void AnimationTree::_process_graph(double p_delta) {
_update_properties(); //if properties need updating, update them
//check all tracks, see if they need modification
-
root_motion_transform = Transform3D();
if (!root.is_valid()) {
@@ -938,11 +938,11 @@ void AnimationTree::_process_graph(double p_delta) {
{
if (started) {
//if started, seek
- root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, Vector<StringName>());
+ root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, false, Vector<StringName>());
started = false;
}
- root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, p_delta, false, Vector<StringName>());
+ root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, p_delta, false, false, Vector<StringName>());
}
if (!state.valid) {
@@ -962,6 +962,7 @@ void AnimationTree::_process_graph(double p_delta) {
int pingponged = as.pingponged;
#ifndef _3D_DISABLED
bool backward = signbit(delta);
+ bool calc_root = !seeked || as.seek_root;
#endif // _3D_DISABLED
for (int i = 0; i < a->get_track_count(); i++) {
@@ -990,7 +991,7 @@ void AnimationTree::_process_graph(double p_delta) {
case Animation::TYPE_POSITION_3D: {
#ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
- if (track->root_motion) {
+ if (track->root_motion && calc_root) {
if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3(0, 0, 0);
@@ -1052,7 +1053,7 @@ void AnimationTree::_process_graph(double p_delta) {
}
a->position_track_interpolate(i, 0, &loc[1]);
t->loc += (loc[1] - loc[0]) * blend;
- prev_time = 0;
+ prev_time = (double)a->get_length();
}
}
@@ -1086,7 +1087,7 @@ void AnimationTree::_process_graph(double p_delta) {
case Animation::TYPE_ROTATION_3D: {
#ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
- if (track->root_motion) {
+ if (track->root_motion && calc_root) {
if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3(0, 0, 0);
@@ -1148,7 +1149,7 @@ void AnimationTree::_process_graph(double p_delta) {
}
a->rotation_track_interpolate(i, 0, &rot[1]);
t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
- prev_time = 0;
+ prev_time = (double)a->get_length();
}
}
@@ -1182,7 +1183,7 @@ void AnimationTree::_process_graph(double p_delta) {
case Animation::TYPE_SCALE_3D: {
#ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
- if (track->root_motion) {
+ if (track->root_motion && calc_root) {
if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3(0, 0, 0);
@@ -1244,7 +1245,7 @@ void AnimationTree::_process_graph(double p_delta) {
}
a->scale_track_interpolate(i, 0, &scale[1]);
t->scale += (scale[1] - scale[0]) * blend;
- prev_time = 0;
+ prev_time = (double)a->get_length();
}
}
@@ -1301,8 +1302,7 @@ void AnimationTree::_process_graph(double p_delta) {
Animation::UpdateMode update_mode = a->value_track_get_update_mode(i);
- if (update_mode == Animation::UPDATE_CONTINUOUS || update_mode == Animation::UPDATE_CAPTURE) { //delta == 0 means seek
-
+ if (update_mode == Animation::UPDATE_CONTINUOUS || update_mode == Animation::UPDATE_CAPTURE) {
Variant value = a->value_track_interpolate(i, time);
if (value == Variant()) {
@@ -1443,7 +1443,7 @@ void AnimationTree::_process_graph(double p_delta) {
t->start = time;
}
} else if (t->playing) {
- bool loop = a->get_loop_mode() != Animation::LoopMode::LOOP_NONE;
+ bool loop = a->get_loop_mode() != Animation::LOOP_NONE;
bool stop = false;
@@ -1512,13 +1512,13 @@ void AnimationTree::_process_graph(double p_delta) {
double at_anim_pos = 0.0;
switch (anim->get_loop_mode()) {
- case Animation::LoopMode::LOOP_NONE: {
+ case Animation::LOOP_NONE: {
at_anim_pos = MAX((double)anim->get_length(), time - pos); //seek to end
} break;
- case Animation::LoopMode::LOOP_LINEAR: {
+ case Animation::LOOP_LINEAR: {
at_anim_pos = Math::fposmod(time - pos, (double)anim->get_length()); //seek to loop
} break;
- case Animation::LoopMode::LOOP_PINGPONG: {
+ case Animation::LOOP_PINGPONG: {
at_anim_pos = Math::pingpong(time - pos, (double)a->get_length());
} break;
default:
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index d40d4ccbbd..37cd22568a 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -68,6 +68,7 @@ public:
const Vector<real_t> *track_blends = nullptr;
real_t blend = 0.0;
bool seeked = false;
+ bool seek_root = false;
int pingponged = 0;
};
@@ -85,7 +86,7 @@ public:
Vector<real_t> blends;
State *state = nullptr;
- double _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, const Vector<StringName> &p_connections);
+ double _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, bool p_seek_root, const Vector<StringName> &p_connections);
//all this is temporary
StringName base_path;
@@ -98,12 +99,12 @@ public:
Array _get_filters() const;
void _set_filters(const Array &p_filters);
friend class AnimationNodeBlendTree;
- double _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, real_t *r_max = nullptr);
+ double _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_seek_root, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, real_t *r_max = nullptr);
protected:
- void blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, real_t p_blend, int p_pingponged = 0);
- double blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
- double blend_input(int p_input, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
+ void blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, bool p_seek_root, real_t p_blend, int p_pingponged = 0);
+ double blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_seek_root, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
+ double blend_input(int p_input, double p_time, bool p_seek, bool p_seek_root, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
void make_invalid(const String &p_reason);
@@ -115,7 +116,7 @@ protected:
GDVIRTUAL0RC(Array, _get_parameter_list)
GDVIRTUAL1RC(Ref<AnimationNode>, _get_child_by_name, StringName)
GDVIRTUAL1RC(Variant, _get_parameter_default_value, StringName)
- GDVIRTUAL2RC(double, _process, double, bool)
+ GDVIRTUAL3RC(double, _process, double, bool, bool)
GDVIRTUAL0RC(String, _get_caption)
GDVIRTUAL0RC(bool, _has_filter)
@@ -133,7 +134,7 @@ public:
virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
- virtual double process(double p_time, bool p_seek);
+ virtual double process(double p_time, bool p_seek, bool p_seek_root);
virtual String get_caption() const;
int get_input_count() const;
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index b792b11dbc..dfad91ecd5 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -436,11 +436,11 @@ void SceneDebuggerObject::_parse_script_properties(Script *p_script, ScriptInsta
// Members
for (KeyValue<const Script *, RBSet<StringName>> sm : members) {
- for (RBSet<StringName>::Element *E = sm.value.front(); E; E = E->next()) {
+ for (const StringName &E : sm.value) {
Variant m;
- if (p_instance->get(E->get(), m)) {
+ if (p_instance->get(E, m)) {
String script_path = sm.key == p_script ? "" : sm.key->get_path().get_file() + "/";
- PropertyInfo pi(m.get_type(), "Members/" + script_path + E->get());
+ PropertyInfo pi(m.get_type(), "Members/" + script_path + E);
properties.push_back(SceneDebuggerProperty(pi, m));
}
}
@@ -629,8 +629,8 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian
return; //scene not editable
}
- for (RBSet<Node *>::Element *F = E->value.front(); F; F = F->next()) {
- Node *n = F->get();
+ for (Node *F : E->value) {
+ Node *n = F;
if (base && !base->is_ancestor_of(n)) {
continue;
@@ -673,8 +673,8 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, const Var
return; //scene not editable
}
- for (RBSet<Node *>::Element *F = E->value.front(); F; F = F->next()) {
- Node *n = F->get();
+ for (Node *F : E->value) {
+ Node *n = F;
if (base && !base->is_ancestor_of(n)) {
continue;
@@ -758,8 +758,8 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ
return; //scene not editable
}
- for (RBSet<Node *>::Element *F = E->value.front(); F; F = F->next()) {
- Node *n = F->get();
+ for (Node *F : E->value) {
+ Node *n = F;
if (base && !base->is_ancestor_of(n)) {
continue;
@@ -802,8 +802,8 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p
return; //scene not editable
}
- for (RBSet<Node *>::Element *F = E->value.front(); F; F = F->next()) {
- Node *n = F->get();
+ for (Node *F : E->value) {
+ Node *n = F;
if (base && !base->is_ancestor_of(n)) {
continue;
@@ -968,8 +968,8 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_
return; //scene not editable
}
- for (RBSet<Node *>::Element *F = E->value.front(); F; F = F->next()) {
- Node *n = F->get();
+ for (Node *F : E->value) {
+ Node *n = F;
if (base && !base->is_ancestor_of(n)) {
continue;
@@ -1007,8 +1007,8 @@ void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new
return; //scene not editable
}
- for (RBSet<Node *>::Element *F = E->value.front(); F; F = F->next()) {
- Node *n = F->get();
+ for (Node *F : E->value) {
+ Node *n = F;
if (base && !base->is_ancestor_of(n)) {
continue;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 595f0cbea7..776623f7ce 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -43,12 +43,12 @@ void BaseButton::_unpress_group() {
status.pressed = true;
}
- for (RBSet<BaseButton *>::Element *E = button_group->buttons.front(); E; E = E->next()) {
- if (E->get() == this) {
+ for (BaseButton *E : button_group->buttons) {
+ if (E == this) {
continue;
}
- E->get()->set_pressed(false);
+ E->set_pressed(false);
}
}
@@ -485,24 +485,24 @@ BaseButton::~BaseButton() {
}
void ButtonGroup::get_buttons(List<BaseButton *> *r_buttons) {
- for (RBSet<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
- r_buttons->push_back(E->get());
+ for (BaseButton *E : buttons) {
+ r_buttons->push_back(E);
}
}
Array ButtonGroup::_get_buttons() {
Array btns;
- for (RBSet<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
- btns.push_back(E->get());
+ for (const BaseButton *E : buttons) {
+ btns.push_back(E);
}
return btns;
}
BaseButton *ButtonGroup::get_pressed_button() {
- for (RBSet<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
- if (E->get()->is_pressed()) {
- return E->get();
+ for (BaseButton *E : buttons) {
+ if (E->is_pressed()) {
+ return E;
}
}
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 197c9005c3..22e9763929 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -740,8 +740,8 @@ void CodeEdit::set_auto_indent_prefixes(const TypedArray<String> &p_prefixes) {
TypedArray<String> CodeEdit::get_auto_indent_prefixes() const {
TypedArray<String> prefixes;
- for (const RBSet<char32_t>::Element *E = auto_indent_prefixes.front(); E; E = E->next()) {
- prefixes.push_back(String::chr(E->get()));
+ for (const char32_t &E : auto_indent_prefixes) {
+ prefixes.push_back(String::chr(E));
}
return prefixes;
}
@@ -1752,8 +1752,8 @@ void CodeEdit::set_code_completion_prefixes(const TypedArray<String> &p_prefixes
TypedArray<String> CodeEdit::get_code_completion_prefixes() const {
TypedArray<String> prefixes;
- for (const RBSet<char32_t>::Element *E = code_completion_prefixes.front(); E; E = E->next()) {
- prefixes.push_back(String::chr(E->get()));
+ for (const char32_t &E : code_completion_prefixes) {
+ prefixes.push_back(String::chr(E));
}
return prefixes;
}
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 43d49da055..f18dd99bff 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -217,12 +217,12 @@ private:
NodePath focus_prev;
bool bulk_theme_override = false;
- HashMap<StringName, Ref<Texture2D>> icon_override;
- HashMap<StringName, Ref<StyleBox>> style_override;
- HashMap<StringName, Ref<Font>> font_override;
- HashMap<StringName, int> font_size_override;
- HashMap<StringName, Color> color_override;
- HashMap<StringName, int> constant_override;
+ Theme::ThemeIconMap icon_override;
+ Theme::ThemeStyleMap style_override;
+ Theme::ThemeFontMap font_override;
+ Theme::ThemeFontSizeMap font_size_override;
+ Theme::ThemeColorMap color_override;
+ Theme::ThemeConstantMap constant_override;
} data;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0ed9a4e989..ccf7e2828a 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -1699,8 +1699,8 @@ void GraphEdit::set_warped_panning(bool p_warped) {
int GraphEdit::_set_operations(SET_OPERATIONS p_operation, RBSet<StringName> &r_u, const RBSet<StringName> &r_v) {
switch (p_operation) {
case GraphEdit::IS_EQUAL: {
- for (RBSet<StringName>::Element *E = r_u.front(); E; E = E->next()) {
- if (!r_v.has(E->get())) {
+ for (const StringName &E : r_u) {
+ if (!r_v.has(E)) {
return 0;
}
}
@@ -1710,8 +1710,8 @@ int GraphEdit::_set_operations(SET_OPERATIONS p_operation, RBSet<StringName> &r_
if (r_u.size() == r_v.size() && !r_u.size()) {
return 1;
}
- for (RBSet<StringName>::Element *E = r_u.front(); E; E = E->next()) {
- if (!r_v.has(E->get())) {
+ for (const StringName &E : r_u) {
+ if (!r_v.has(E)) {
return 0;
}
}
@@ -1726,9 +1726,9 @@ int GraphEdit::_set_operations(SET_OPERATIONS p_operation, RBSet<StringName> &r_
return r_u.size();
} break;
case GraphEdit::UNION: {
- for (RBSet<StringName>::Element *E = r_v.front(); E; E = E->next()) {
- if (!r_u.has(E->get())) {
- r_u.insert(E->get());
+ for (const StringName &E : r_v) {
+ if (!r_u.has(E)) {
+ r_u.insert(E);
}
}
return r_u.size();
@@ -1748,11 +1748,11 @@ HashMap<int, Vector<StringName>> GraphEdit::_layering(const RBSet<StringName> &r
while (!_set_operations(GraphEdit::IS_EQUAL, q, u)) {
_set_operations(GraphEdit::DIFFERENCE, p, u);
- for (const RBSet<StringName>::Element *E = p.front(); E; E = E->next()) {
- RBSet<StringName> n = r_upper_neighbours[E->get()];
+ for (const StringName &E : p) {
+ RBSet<StringName> n = r_upper_neighbours[E];
if (_set_operations(GraphEdit::IS_SUBSET, n, z)) {
Vector<StringName> t;
- t.push_back(E->get());
+ t.push_back(E);
if (!l.has(current_layer)) {
l.insert(current_layer, Vector<StringName>{});
}
@@ -1760,7 +1760,7 @@ HashMap<int, Vector<StringName>> GraphEdit::_layering(const RBSet<StringName> &r
t.append_array(l[current_layer]);
l.insert(current_layer, t);
RBSet<StringName> V;
- V.insert(E->get());
+ V.insert(E);
_set_operations(GraphEdit::UNION, u, V);
}
}
@@ -1802,9 +1802,9 @@ Vector<StringName> GraphEdit::_split(const Vector<StringName> &r_layer, const Ha
}
void GraphEdit::_horizontal_alignment(Dictionary &r_root, Dictionary &r_align, const HashMap<int, Vector<StringName>> &r_layers, const HashMap<StringName, RBSet<StringName>> &r_upper_neighbours, const RBSet<StringName> &r_selected_nodes) {
- for (const RBSet<StringName>::Element *E = r_selected_nodes.front(); E; E = E->next()) {
- r_root[E->get()] = E->get();
- r_align[E->get()] = E->get();
+ for (const StringName &E : r_selected_nodes) {
+ r_root[E] = E;
+ r_align[E] = E;
}
if (r_layers.size() == 1) {
@@ -1880,9 +1880,9 @@ void GraphEdit::_crossing_minimisation(HashMap<int, Vector<StringName>> &r_layer
}
void GraphEdit::_calculate_inner_shifts(Dictionary &r_inner_shifts, const Dictionary &r_root, const Dictionary &r_node_names, const Dictionary &r_align, const RBSet<StringName> &r_block_heads, const HashMap<StringName, Pair<int, int>> &r_port_info) {
- for (const RBSet<StringName>::Element *E = r_block_heads.front(); E; E = E->next()) {
+ for (const StringName &E : r_block_heads) {
real_t left = 0;
- StringName u = E->get();
+ StringName u = E;
StringName v = r_align[u];
while (u != v && (StringName)r_root[u] != v) {
String _connection = String(u) + " " + String(v);
@@ -1903,11 +1903,11 @@ void GraphEdit::_calculate_inner_shifts(Dictionary &r_inner_shifts, const Dictio
v = (StringName)r_align[v];
}
- u = E->get();
+ u = E;
do {
r_inner_shifts[u] = (real_t)r_inner_shifts[u] - left;
u = (StringName)r_align[u];
- } while (u != E->get());
+ } while (u != E);
}
}
@@ -2117,33 +2117,33 @@ void GraphEdit::arrange_nodes() {
Dictionary inner_shift;
RBSet<StringName> block_heads;
- for (const RBSet<StringName>::Element *E = selected_nodes.front(); E; E = E->next()) {
- inner_shift[E->get()] = 0.0f;
- sink[E->get()] = E->get();
- shift[E->get()] = FLT_MAX;
- new_positions.insert(E->get(), default_position);
- if ((StringName)root[E->get()] == E->get()) {
- block_heads.insert(E->get());
+ for (const StringName &E : selected_nodes) {
+ inner_shift[E] = 0.0f;
+ sink[E] = E;
+ shift[E] = FLT_MAX;
+ new_positions.insert(E, default_position);
+ if ((StringName)root[E] == E) {
+ block_heads.insert(E);
}
}
_calculate_inner_shifts(inner_shift, root, node_names, align, block_heads, port_info);
- for (const RBSet<StringName>::Element *E = block_heads.front(); E; E = E->next()) {
- _place_block(E->get(), gap_v, layers, root, align, node_names, inner_shift, sink, shift, new_positions);
+ for (const StringName &E : block_heads) {
+ _place_block(E, gap_v, layers, root, align, node_names, inner_shift, sink, shift, new_positions);
}
origin.y = Object::cast_to<GraphNode>(node_names[layers[0][0]])->get_position_offset().y - (new_positions[layers[0][0]].y + (float)inner_shift[layers[0][0]]);
origin.x = Object::cast_to<GraphNode>(node_names[layers[0][0]])->get_position_offset().x;
- for (const RBSet<StringName>::Element *E = block_heads.front(); E; E = E->next()) {
- StringName u = E->get();
- float start_from = origin.y + new_positions[E->get()].y;
+ for (const StringName &E : block_heads) {
+ StringName u = E;
+ float start_from = origin.y + new_positions[E].y;
do {
Vector2 cal_pos;
cal_pos.y = start_from + (real_t)inner_shift[u];
new_positions.insert(u, cal_pos);
u = align[u];
- } while (u != E->get());
+ } while (u != E);
}
// Compute horizontal coordinates individually for layers to get uniform gap.
@@ -2181,10 +2181,10 @@ void GraphEdit::arrange_nodes() {
}
emit_signal(SNAME("begin_node_move"));
- for (const RBSet<StringName>::Element *E = selected_nodes.front(); E; E = E->next()) {
- GraphNode *gn = Object::cast_to<GraphNode>(node_names[E->get()]);
+ for (const StringName &E : selected_nodes) {
+ GraphNode *gn = Object::cast_to<GraphNode>(node_names[E]);
gn->set_drag(true);
- Vector2 pos = (new_positions[E->get()]);
+ Vector2 pos = (new_positions[E]);
if (is_using_snap()) {
const int snap = get_snap();
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index ec33018da0..5d9484806b 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -104,11 +104,11 @@ void GridContainer::_notification(int p_what) {
// Check if all minwidth constraints are OK if we use the remaining space.
can_fit = true;
int max_index = col_expanded.front()->get();
- for (RBSet<int>::Element *E = col_expanded.front(); E; E = E->next()) {
- if (col_minw[E->get()] > col_minw[max_index]) {
- max_index = E->get();
+ for (const int &E : col_expanded) {
+ if (col_minw[E] > col_minw[max_index]) {
+ max_index = E;
}
- if (can_fit && (remaining_space.width / col_expanded.size()) < col_minw[E->get()]) {
+ if (can_fit && (remaining_space.width / col_expanded.size()) < col_minw[E]) {
can_fit = false;
}
}
@@ -125,11 +125,11 @@ void GridContainer::_notification(int p_what) {
// Check if all minheight constraints are OK if we use the remaining space.
can_fit = true;
int max_index = row_expanded.front()->get();
- for (RBSet<int>::Element *E = row_expanded.front(); E; E = E->next()) {
- if (row_minh[E->get()] > row_minh[max_index]) {
- max_index = E->get();
+ for (const int &E : row_expanded) {
+ if (row_minh[E] > row_minh[max_index]) {
+ max_index = E;
}
- if (can_fit && (remaining_space.height / row_expanded.size()) < row_minh[E->get()]) {
+ if (can_fit && (remaining_space.height / row_expanded.size()) < row_minh[E]) {
can_fit = false;
}
}
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 73f19a8eda..fae6688452 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -50,8 +50,8 @@ void Range::_value_changed_notify() {
}
void Range::Shared::emit_value_changed() {
- for (RBSet<Range *>::Element *E = owners.front(); E; E = E->next()) {
- Range *r = E->get();
+ for (Range *E : owners) {
+ Range *r = E;
if (!r->is_inside_tree()) {
continue;
}
@@ -70,8 +70,8 @@ void Range::_validate_values() {
}
void Range::Shared::emit_changed(const char *p_what) {
- for (RBSet<Range *>::Element *E = owners.front(); E; E = E->next()) {
- Range *r = E->get();
+ for (Range *E : owners) {
+ Range *r = E;
if (!r->is_inside_tree()) {
continue;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 315ffbd419..050c510a96 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4756,9 +4756,7 @@ void TextEdit::add_gutter(int p_at) {
gutters.insert(p_at, GutterInfo());
}
- for (int i = 0; i < text.size() + 1; i++) {
- text.add_gutter(p_at);
- }
+ text.add_gutter(p_at);
emit_signal(SNAME("gutter_added"));
update();
}
@@ -4768,9 +4766,7 @@ void TextEdit::remove_gutter(int p_gutter) {
gutters.remove_at(p_gutter);
- for (int i = 0; i < text.size() + 1; i++) {
- text.remove_gutter(p_gutter);
- }
+ text.remove_gutter(p_gutter);
emit_signal(SNAME("gutter_removed"));
update();
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 0c1a62c667..bd791dff2a 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2528,9 +2528,10 @@ Node *Node::get_node_and_resource(const NodePath &p_path, Ref<Resource> &r_res,
int j = 0;
// If not p_last_is_property, we shouldn't consider the last one as part of the resource
for (; j < p_path.get_subname_count() - (int)p_last_is_property; j++) {
- Variant new_res_v = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
+ bool is_valid = false;
+ Variant new_res_v = j == 0 ? node->get(p_path.get_subname(j), &is_valid) : r_res->get(p_path.get_subname(j), &is_valid);
- if (new_res_v.get_type() == Variant::NIL) { // Found nothing on that path
+ if (!is_valid) { // Found nothing on that path
return nullptr;
}
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index b3595c6227..71e62fe804 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -62,9 +62,9 @@ Array ResourcePreloader::_get_resources() const {
}
int i = 0;
- for (RBSet<String>::Element *E = sorted_names.front(); E; E = E->next()) {
- names.set(i, E->get());
- arr[i] = resources[E->get()];
+ for (const String &E : sorted_names) {
+ names.set(i, E);
+ arr[i] = resources[E];
i++;
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 0be4216e99..590c73de0b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -412,9 +412,9 @@ void Viewport::_notification(int p_what) {
#ifndef _3D_DISABLED
if (audio_listener_3d_set.size() && !audio_listener_3d) {
AudioListener3D *first = nullptr;
- for (RBSet<AudioListener3D *>::Element *E = audio_listener_3d_set.front(); E; E = E->next()) {
- if (first == nullptr || first->is_greater_than(E->get())) {
- first = E->get();
+ for (AudioListener3D *E : audio_listener_3d_set) {
+ if (first == nullptr || first->is_greater_than(E)) {
+ first = E;
}
}
@@ -426,9 +426,9 @@ void Viewport::_notification(int p_what) {
if (camera_3d_set.size() && !camera_3d) {
// There are cameras but no current camera, pick first in tree and make it current.
Camera3D *first = nullptr;
- for (RBSet<Camera3D *>::Element *E = camera_3d_set.front(); E; E = E->next()) {
- if (first == nullptr || first->is_greater_than(E->get())) {
- first = E->get();
+ for (Camera3D *E : camera_3d_set) {
+ if (first == nullptr || first->is_greater_than(E)) {
+ first = E;
}
}
@@ -647,13 +647,13 @@ void Viewport::_process_picking() {
uint64_t frame = get_tree()->get_frame();
PhysicsDirectSpaceState2D::ShapeResult res[64];
- for (RBSet<CanvasLayer *>::Element *E = canvas_layers.front(); E; E = E->next()) {
+ for (const CanvasLayer *E : canvas_layers) {
Transform2D canvas_transform;
ObjectID canvas_layer_id;
- if (E->get()) {
+ if (E) {
// A descendant CanvasLayer.
- canvas_transform = E->get()->get_transform();
- canvas_layer_id = E->get()->get_instance_id();
+ canvas_transform = E->get_transform();
+ canvas_layer_id = E->get_instance_id();
} else {
// This Viewport's builtin canvas.
canvas_transform = get_canvas_transform();
@@ -3202,18 +3202,18 @@ void Viewport::_audio_listener_3d_remove(AudioListener3D *p_listener) {
void Viewport::_audio_listener_3d_make_next_current(AudioListener3D *p_exclude) {
if (audio_listener_3d_set.size() > 0) {
- for (RBSet<AudioListener3D *>::Element *E = audio_listener_3d_set.front(); E; E = E->next()) {
- if (p_exclude == E->get()) {
+ for (AudioListener3D *E : audio_listener_3d_set) {
+ if (p_exclude == E) {
continue;
}
- if (!E->get()->is_inside_tree()) {
+ if (!E->is_inside_tree()) {
continue;
}
if (audio_listener_3d != nullptr) {
return;
}
- E->get()->make_current();
+ E->make_current();
}
} else {
// Attempt to reset listener to the camera position.
@@ -3290,18 +3290,18 @@ void Viewport::_camera_3d_remove(Camera3D *p_camera) {
}
void Viewport::_camera_3d_make_next_current(Camera3D *p_exclude) {
- for (RBSet<Camera3D *>::Element *E = camera_3d_set.front(); E; E = E->next()) {
- if (p_exclude == E->get()) {
+ for (Camera3D *E : camera_3d_set) {
+ if (p_exclude == E) {
continue;
}
- if (!E->get()->is_inside_tree()) {
+ if (!E->is_inside_tree()) {
continue;
}
if (camera_3d != nullptr) {
return;
}
- E->get()->make_current();
+ E->make_current();
}
}
@@ -3936,8 +3936,8 @@ Viewport::Viewport() {
Viewport::~Viewport() {
// Erase itself from viewport textures.
- for (RBSet<ViewportTexture *>::Element *E = viewport_textures.front(); E; E = E->next()) {
- E->get()->vp = nullptr;
+ for (ViewportTexture *E : viewport_textures) {
+ E->vp = nullptr;
}
RenderingServer::get_singleton()->free(viewport);
}
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index d8264e7d33..193f18c075 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -263,9 +263,9 @@ void Window::_make_window() {
DisplayServer::get_singleton()->window_set_transient(window_id, transient_parent->window_id);
}
- for (RBSet<Window *>::Element *E = transient_children.front(); E; E = E->next()) {
- if (E->get()->window_id != DisplayServer::INVALID_WINDOW_ID) {
- DisplayServer::get_singleton()->window_set_transient(E->get()->window_id, transient_parent->window_id);
+ for (const Window *E : transient_children) {
+ if (E->window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(E->window_id, transient_parent->window_id);
}
}
@@ -290,9 +290,9 @@ void Window::_clear_window() {
DisplayServer::get_singleton()->window_set_transient(window_id, DisplayServer::INVALID_WINDOW_ID);
}
- for (RBSet<Window *>::Element *E = transient_children.front(); E; E = E->next()) {
- if (E->get()->window_id != DisplayServer::INVALID_WINDOW_ID) {
- DisplayServer::get_singleton()->window_set_transient(E->get()->window_id, DisplayServer::INVALID_WINDOW_ID);
+ for (const Window *E : transient_children) {
+ if (E->window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(E->window_id, DisplayServer::INVALID_WINDOW_ID);
}
}
diff --git a/scene/multiplayer/scene_cache_interface.cpp b/scene/multiplayer/scene_cache_interface.cpp
index a7e84b6bca..7c271341db 100644
--- a/scene/multiplayer/scene_cache_interface.cpp
+++ b/scene/multiplayer/scene_cache_interface.cpp
@@ -214,17 +214,17 @@ bool SceneCacheInterface::send_object_cache(Object *p_obj, NodePath p_path, int
}
} else {
// Long and painful.
- for (const RBSet<int>::Element *E = multiplayer->get_connected_peers().front(); E; E = E->next()) {
- if (p_peer_id < 0 && E->get() == -p_peer_id) {
+ for (const int &E : multiplayer->get_connected_peers()) {
+ if (p_peer_id < 0 && E == -p_peer_id) {
continue; // Continue, excluded.
}
- if (p_peer_id > 0 && E->get() != p_peer_id) {
+ if (p_peer_id > 0 && E != p_peer_id) {
continue; // Continue, not for this peer.
}
- HashMap<int, bool>::Iterator F = psc->confirmed_peers.find(E->get());
+ HashMap<int, bool>::Iterator F = psc->confirmed_peers.find(E);
if (!F) {
- peers_to_add.push_back(E->get()); // Need to also be notified.
+ peers_to_add.push_back(E); // Need to also be notified.
has_all_peers = false;
} else if (!F->value) {
has_all_peers = false;
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 6bce957d80..f70d57291f 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -1077,15 +1077,15 @@ void register_scene_types() {
OS::get_singleton()->yield(); // may take time to init
for (int i = 0; i < 20; i++) {
- GLOBAL_DEF_BASIC(vformat("layer_names/2d_render/layer_%d", i + 1), "");
- GLOBAL_DEF_BASIC(vformat("layer_names/3d_render/layer_%d", i + 1), "");
+ GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/2d_render"), i + 1), "");
+ GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/3d_render"), i + 1), "");
}
for (int i = 0; i < 32; i++) {
- GLOBAL_DEF_BASIC(vformat("layer_names/2d_physics/layer_%d", i + 1), "");
- GLOBAL_DEF_BASIC(vformat("layer_names/2d_navigation/layer_%d", i + 1), "");
- GLOBAL_DEF_BASIC(vformat("layer_names/3d_physics/layer_%d", i + 1), "");
- GLOBAL_DEF_BASIC(vformat("layer_names/3d_navigation/layer_%d", i + 1), "");
+ GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/2d_physics"), i + 1), "");
+ GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/2d_navigation"), i + 1), "");
+ GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/3d_physics"), i + 1), "");
+ GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/3d_navigation"), i + 1), "");
}
if (RenderingServer::get_singleton()) {
diff --git a/scene/resources/concave_polygon_shape_3d.cpp b/scene/resources/concave_polygon_shape_3d.cpp
index ab2c1da327..081271c2fc 100644
--- a/scene/resources/concave_polygon_shape_3d.cpp
+++ b/scene/resources/concave_polygon_shape_3d.cpp
@@ -50,9 +50,9 @@ Vector<Vector3> ConcavePolygonShape3D::get_debug_mesh_lines() const {
Vector<Vector3> points;
points.resize(edges.size() * 2);
int idx = 0;
- for (RBSet<DrawEdge>::Element *E = edges.front(); E; E = E->next()) {
- points.write[idx + 0] = E->get().a;
- points.write[idx + 1] = E->get().b;
+ for (const DrawEdge &E : edges) {
+ points.write[idx + 0] = E.a;
+ points.write[idx + 1] = E.b;
idx += 2;
}
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 5168bf83eb..a90999bf07 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -100,14 +100,14 @@ bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const {
void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
for (const KeyValue<int, Item> &E : item_map) {
- String name = "item/" + itos(E.key) + "/";
- p_list->push_back(PropertyInfo(Variant::STRING, name + "name"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, name + "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, name + "mesh_transform"));
- p_list->push_back(PropertyInfo(Variant::ARRAY, name + "shapes"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, name + "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, name + "navmesh_transform"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
+ String name = vformat("%s/%d/", PNAME("item"), E.key);
+ p_list->push_back(PropertyInfo(Variant::STRING, name + PNAME("name")));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + PNAME("mesh"), PROPERTY_HINT_RESOURCE_TYPE, "Mesh"));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, name + PNAME("mesh_transform")));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, name + PNAME("shapes")));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + PNAME("navmesh"), PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, name + PNAME("navmesh_transform")));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + PNAME("preview"), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
}
}
diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp
index 7813de94ca..dd0a8472a4 100644
--- a/scene/resources/navigation_mesh.cpp
+++ b/scene/resources/navigation_mesh.cpp
@@ -38,6 +38,7 @@ void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
+ WARN_PRINT("A mesh surface was skipped when creating a NavigationMesh due to wrong primitive type in the source mesh. Mesh surface must be made out of triangles.");
continue;
}
Array arr = p_mesh->surface_get_arrays(i);
@@ -46,6 +47,7 @@ void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
Vector<Vector3> varr = arr[Mesh::ARRAY_VERTEX];
Vector<int> iarr = arr[Mesh::ARRAY_INDEX];
if (varr.size() == 0 || iarr.size() == 0) {
+ WARN_PRINT("A mesh surface was skipped when creating a NavigationMesh due to an empty vertex or index array.");
continue;
}
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 155a8522cf..6b0c22d720 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -34,8 +34,8 @@
bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
int crosses = 0;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
@@ -105,8 +105,8 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int>
bool valid = true;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
if (e.points[0] == i || e.points[1] == i || e.points[0] == j || e.points[1] == j) {
continue;
}
@@ -140,8 +140,8 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
float closest_dist = 1e20f;
Vector2 closest_point;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
@@ -151,7 +151,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
float d = from.distance_squared_to(closest);
if (d < closest_dist) {
- ignore_from_edge = E->get();
+ ignore_from_edge = E;
closest_dist = d;
closest_point = closest;
}
@@ -164,8 +164,8 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
float closest_dist = 1e20f;
Vector2 closest_point;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
@@ -175,7 +175,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
float d = to.distance_squared_to(closest);
if (d < closest_dist) {
- ignore_to_edge = E->get();
+ ignore_to_edge = E;
closest_dist = d;
closest_point = closest;
}
@@ -188,8 +188,8 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
{
bool can_see_eachother = true;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
if (e.points[0] == ignore_from_edge.points[0] && e.points[1] == ignore_from_edge.points[1]) {
continue;
}
@@ -240,8 +240,8 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
valid_b = false;
}
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
if (e.points[0] == i || e.points[1] == i) {
continue;
@@ -293,10 +293,10 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
points.write[aidx].distance = 0;
points.write[aidx].prev = aidx;
- for (RBSet<int>::Element *E = points[aidx].connections.front(); E; E = E->next()) {
- open_list.insert(E->get());
- points.write[E->get()].distance = from.distance_to(points[E->get()].pos);
- points.write[E->get()].prev = aidx;
+ for (const int &E : points[aidx].connections) {
+ open_list.insert(E);
+ points.write[E].distance = from.distance_to(points[E].pos);
+ points.write[E].prev = aidx;
}
bool found_route = false;
@@ -312,14 +312,14 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
float least_cost = 1e30;
//this could be faster (cache previous results)
- for (RBSet<int>::Element *E = open_list.front(); E; E = E->next()) {
- const Point &p = points[E->get()];
+ for (const int &E : open_list) {
+ const Point &p = points[E];
float cost = p.distance;
cost += p.pos.distance_to(to);
cost += p.penalty;
if (cost < least_cost) {
- least_cost_point = E->get();
+ least_cost_point = E;
least_cost = cost;
}
}
@@ -327,8 +327,8 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
const Point &np = points[least_cost_point];
//open the neighbours for search
- for (RBSet<int>::Element *E = np.connections.front(); E; E = E->next()) {
- Point &p = points.write[E->get()];
+ for (const int &E : np.connections) {
+ Point &p = points.write[E];
float distance = np.pos.distance_to(p.pos) + np.distance;
if (p.prev != -1) {
@@ -343,9 +343,9 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
p.prev = least_cost_point;
p.distance = distance;
- open_list.insert(E->get());
+ open_list.insert(E);
- if (E->get() == bidx) {
+ if (E == bidx) {
//oh my reached end! stop algorithm
found_route = true;
break;
@@ -459,8 +459,8 @@ Dictionary PolygonPathFinder::_get_data() const {
{
int *cw = c.ptrw();
int idx = 0;
- for (RBSet<int>::Element *E = points[i].connections.front(); E; E = E->next()) {
- cw[idx++] = E->get();
+ for (const int &E : points[i].connections) {
+ cw[idx++] = E;
}
}
connections[i] = c;
@@ -469,9 +469,9 @@ Dictionary PolygonPathFinder::_get_data() const {
{
int *iw = ind.ptrw();
int idx = 0;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- iw[idx++] = E->get().points[0];
- iw[idx++] = E->get().points[1];
+ for (const Edge &E : edges) {
+ iw[idx++] = E.points[0];
+ iw[idx++] = E.points[1];
}
}
@@ -492,8 +492,8 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
float closest_dist = 1e20f;
Vector2 closest_point;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge &e = E->get();
+ for (const Edge &E : edges) {
+ const Edge &e = E;
Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
@@ -516,9 +516,9 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2 &p_from, const Vector2 &p_to) const {
Vector<Vector2> inters;
- for (RBSet<Edge>::Element *E = edges.front(); E; E = E->next()) {
- Vector2 a = points[E->get().points[0]].pos;
- Vector2 b = points[E->get().points[1]].pos;
+ for (const Edge &E : edges) {
+ Vector2 a = points[E.points[0]].pos;
+ Vector2 b = points[E.points[1]].pos;
Vector2 res;
if (Geometry2D::segment_intersects_segment(a, b, p_from, p_to, &res)) {
diff --git a/scene/resources/skin.cpp b/scene/resources/skin.cpp
index 54ed71999c..1c04ba0cd4 100644
--- a/scene/resources/skin.cpp
+++ b/scene/resources/skin.cpp
@@ -130,11 +130,12 @@ bool Skin::_get(const StringName &p_name, Variant &r_ret) const {
}
void Skin::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::INT, "bind_count", PROPERTY_HINT_RANGE, "0,16384,1,or_greater"));
+ p_list->push_back(PropertyInfo(Variant::INT, PNAME("bind_count"), PROPERTY_HINT_RANGE, "0,16384,1,or_greater"));
for (int i = 0; i < get_bind_count(); i++) {
- p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bind/" + itos(i) + "/name"));
- p_list->push_back(PropertyInfo(Variant::INT, "bind/" + itos(i) + "/bone", PROPERTY_HINT_RANGE, "0,16384,1,or_greater", get_bind_name(i) != StringName() ? PROPERTY_USAGE_NO_EDITOR : PROPERTY_USAGE_DEFAULT));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, "bind/" + itos(i) + "/pose"));
+ const String prefix = vformat("%s/%d/", PNAME("bind"), i);
+ p_list->push_back(PropertyInfo(Variant::STRING_NAME, prefix + PNAME("name")));
+ p_list->push_back(PropertyInfo(Variant::INT, prefix + PNAME("bone"), PROPERTY_HINT_RANGE, "0,16384,1,or_greater", get_bind_name(i) != StringName() ? PROPERTY_USAGE_NO_EDITOR : PROPERTY_USAGE_DEFAULT));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prefix + PNAME("pose")));
}
}
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 5850d253e3..9442a58ac1 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -175,8 +175,8 @@ bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
}
void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("image"), PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, PNAME("size"), PROPERTY_HINT_NONE, ""));
}
void ImageTexture::create_from_image(const Ref<Image> &p_image) {
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 1e57933000..2981f38766 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -129,42 +129,42 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
}
// Icons.
- for (const KeyValue<StringName, HashMap<StringName, Ref<Texture2D>>> &E : icon_map) {
+ for (const KeyValue<StringName, ThemeIconMap> &E : icon_map) {
for (const KeyValue<StringName, Ref<Texture2D>> &F : E.value) {
list.push_back(PropertyInfo(Variant::OBJECT, String() + E.key + "/icons/" + F.key, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
// Styles.
- for (const KeyValue<StringName, HashMap<StringName, Ref<StyleBox>>> &E : style_map) {
+ for (const KeyValue<StringName, ThemeStyleMap> &E : style_map) {
for (const KeyValue<StringName, Ref<StyleBox>> &F : E.value) {
list.push_back(PropertyInfo(Variant::OBJECT, String() + E.key + "/styles/" + F.key, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
// Fonts.
- for (const KeyValue<StringName, HashMap<StringName, Ref<Font>>> &E : font_map) {
+ for (const KeyValue<StringName, ThemeFontMap> &E : font_map) {
for (const KeyValue<StringName, Ref<Font>> &F : E.value) {
list.push_back(PropertyInfo(Variant::OBJECT, String() + E.key + "/fonts/" + F.key, PROPERTY_HINT_RESOURCE_TYPE, "Font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
// Font sizes.
- for (const KeyValue<StringName, HashMap<StringName, int>> &E : font_size_map) {
+ for (const KeyValue<StringName, ThemeFontSizeMap> &E : font_size_map) {
for (const KeyValue<StringName, int> &F : E.value) {
list.push_back(PropertyInfo(Variant::INT, String() + E.key + "/font_sizes/" + F.key, PROPERTY_HINT_RANGE, "0,256,1,or_greater"));
}
}
// Colors.
- for (const KeyValue<StringName, HashMap<StringName, Color>> &E : color_map) {
+ for (const KeyValue<StringName, ThemeColorMap> &E : color_map) {
for (const KeyValue<StringName, Color> &F : E.value) {
- list.push_back(PropertyInfo(Variant::INT, String() + E.key + "/colors/" + F.key));
+ list.push_back(PropertyInfo(Variant::COLOR, String() + E.key + "/colors/" + F.key));
}
}
// Constants.
- for (const KeyValue<StringName, HashMap<StringName, int>> &E : constant_map) {
+ for (const KeyValue<StringName, ThemeConstantMap> &E : constant_map) {
for (const KeyValue<StringName, int> &F : E.value) {
list.push_back(PropertyInfo(Variant::INT, String() + E.key + "/constants/" + F.key));
}
@@ -407,7 +407,7 @@ void Theme::add_icon_type(const StringName &p_theme_type) {
if (icon_map.has(p_theme_type)) {
return;
}
- icon_map[p_theme_type] = HashMap<StringName, Ref<Texture2D>>();
+ icon_map[p_theme_type] = ThemeIconMap();
}
void Theme::remove_icon_type(const StringName &p_theme_type) {
@@ -432,7 +432,7 @@ void Theme::remove_icon_type(const StringName &p_theme_type) {
void Theme::get_icon_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- for (const KeyValue<StringName, HashMap<StringName, Ref<Texture2D>>> &E : icon_map) {
+ for (const KeyValue<StringName, ThemeIconMap> &E : icon_map) {
p_list->push_back(E.key);
}
}
@@ -517,7 +517,7 @@ void Theme::add_stylebox_type(const StringName &p_theme_type) {
if (style_map.has(p_theme_type)) {
return;
}
- style_map[p_theme_type] = HashMap<StringName, Ref<StyleBox>>();
+ style_map[p_theme_type] = ThemeStyleMap();
}
void Theme::remove_stylebox_type(const StringName &p_theme_type) {
@@ -542,7 +542,7 @@ void Theme::remove_stylebox_type(const StringName &p_theme_type) {
void Theme::get_stylebox_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- for (const KeyValue<StringName, HashMap<StringName, Ref<StyleBox>>> &E : style_map) {
+ for (const KeyValue<StringName, ThemeStyleMap> &E : style_map) {
p_list->push_back(E.key);
}
}
@@ -629,7 +629,7 @@ void Theme::add_font_type(const StringName &p_theme_type) {
if (font_map.has(p_theme_type)) {
return;
}
- font_map[p_theme_type] = HashMap<StringName, Ref<Font>>();
+ font_map[p_theme_type] = ThemeFontMap();
}
void Theme::remove_font_type(const StringName &p_theme_type) {
@@ -654,7 +654,7 @@ void Theme::remove_font_type(const StringName &p_theme_type) {
void Theme::get_font_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- for (const KeyValue<StringName, HashMap<StringName, Ref<Font>>> &E : font_map) {
+ for (const KeyValue<StringName, ThemeFontMap> &E : font_map) {
p_list->push_back(E.key);
}
}
@@ -728,7 +728,7 @@ void Theme::add_font_size_type(const StringName &p_theme_type) {
if (font_size_map.has(p_theme_type)) {
return;
}
- font_size_map[p_theme_type] = HashMap<StringName, int>();
+ font_size_map[p_theme_type] = ThemeFontSizeMap();
}
void Theme::remove_font_size_type(const StringName &p_theme_type) {
@@ -742,7 +742,7 @@ void Theme::remove_font_size_type(const StringName &p_theme_type) {
void Theme::get_font_size_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- for (const KeyValue<StringName, HashMap<StringName, int>> &E : font_size_map) {
+ for (const KeyValue<StringName, ThemeFontSizeMap> &E : font_size_map) {
p_list->push_back(E.key);
}
}
@@ -814,7 +814,7 @@ void Theme::add_color_type(const StringName &p_theme_type) {
if (color_map.has(p_theme_type)) {
return;
}
- color_map[p_theme_type] = HashMap<StringName, Color>();
+ color_map[p_theme_type] = ThemeColorMap();
}
void Theme::remove_color_type(const StringName &p_theme_type) {
@@ -828,7 +828,7 @@ void Theme::remove_color_type(const StringName &p_theme_type) {
void Theme::get_color_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- for (const KeyValue<StringName, HashMap<StringName, Color>> &E : color_map) {
+ for (const KeyValue<StringName, ThemeColorMap> &E : color_map) {
p_list->push_back(E.key);
}
}
@@ -900,7 +900,7 @@ void Theme::add_constant_type(const StringName &p_theme_type) {
if (constant_map.has(p_theme_type)) {
return;
}
- constant_map[p_theme_type] = HashMap<StringName, int>();
+ constant_map[p_theme_type] = ThemeConstantMap();
}
void Theme::remove_constant_type(const StringName &p_theme_type) {
@@ -914,7 +914,7 @@ void Theme::remove_constant_type(const StringName &p_theme_type) {
void Theme::get_constant_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- for (const KeyValue<StringName, HashMap<StringName, int>> &E : constant_map) {
+ for (const KeyValue<StringName, ThemeConstantMap> &E : constant_map) {
p_list->push_back(E.key);
}
}
@@ -1272,12 +1272,44 @@ void Theme::remove_type(const StringName &p_theme_type) {
void Theme::get_type_list(List<StringName> *p_list) const {
ERR_FAIL_NULL(p_list);
- get_icon_type_list(p_list);
- get_stylebox_type_list(p_list);
- get_font_type_list(p_list);
- get_font_size_type_list(p_list);
- get_color_type_list(p_list);
- get_constant_type_list(p_list);
+ // This Set guarantees uniqueness.
+ // Because each map can have the same type defined, but for this method
+ // we only want one occurrence of each type.
+ RBSet<StringName> types;
+
+ // Icons.
+ for (const KeyValue<StringName, ThemeIconMap> &E : icon_map) {
+ types.insert(E.key);
+ }
+
+ // Styles.
+ for (const KeyValue<StringName, ThemeStyleMap> &E : style_map) {
+ types.insert(E.key);
+ }
+
+ // Fonts.
+ for (const KeyValue<StringName, ThemeFontMap> &E : font_map) {
+ types.insert(E.key);
+ }
+
+ // Font sizes.
+ for (const KeyValue<StringName, ThemeFontSizeMap> &E : font_size_map) {
+ types.insert(E.key);
+ }
+
+ // Colors.
+ for (const KeyValue<StringName, ThemeColorMap> &E : color_map) {
+ types.insert(E.key);
+ }
+
+ // Constants.
+ for (const KeyValue<StringName, ThemeConstantMap> &E : constant_map) {
+ types.insert(E.key);
+ }
+
+ for (const StringName &E : types) {
+ p_list->push_back(E);
+ }
}
void Theme::get_type_dependencies(const StringName &p_base_type, const StringName &p_type_variation, List<StringName> *p_list) {
@@ -1588,7 +1620,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
// Colors.
{
- for (const KeyValue<StringName, HashMap<StringName, Color>> &E : p_other->color_map) {
+ for (const KeyValue<StringName, ThemeColorMap> &E : p_other->color_map) {
for (const KeyValue<StringName, Color> &F : E.value) {
set_color(F.key, E.key, F.value);
}
@@ -1597,7 +1629,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
// Constants.
{
- for (const KeyValue<StringName, HashMap<StringName, int>> &E : p_other->constant_map) {
+ for (const KeyValue<StringName, ThemeConstantMap> &E : p_other->constant_map) {
for (const KeyValue<StringName, int> &F : E.value) {
set_constant(F.key, E.key, F.value);
}
@@ -1606,7 +1638,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
// Fonts.
{
- for (const KeyValue<StringName, HashMap<StringName, Ref<Font>>> &E : p_other->font_map) {
+ for (const KeyValue<StringName, ThemeFontMap> &E : p_other->font_map) {
for (const KeyValue<StringName, Ref<Font>> &F : E.value) {
set_font(F.key, E.key, F.value);
}
@@ -1615,7 +1647,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
// Font sizes.
{
- for (const KeyValue<StringName, HashMap<StringName, int>> &E : p_other->font_size_map) {
+ for (const KeyValue<StringName, ThemeFontSizeMap> &E : p_other->font_size_map) {
for (const KeyValue<StringName, int> &F : E.value) {
set_font_size(F.key, E.key, F.value);
}
@@ -1624,7 +1656,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
// Icons.
{
- for (const KeyValue<StringName, HashMap<StringName, Ref<Texture2D>>> &E : p_other->icon_map) {
+ for (const KeyValue<StringName, ThemeIconMap> &E : p_other->icon_map) {
for (const KeyValue<StringName, Ref<Texture2D>> &F : E.value) {
set_icon(F.key, E.key, F.value);
}
@@ -1633,7 +1665,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
// Styleboxes.
{
- for (const KeyValue<StringName, HashMap<StringName, Ref<StyleBox>>> &E : p_other->style_map) {
+ for (const KeyValue<StringName, ThemeStyleMap> &E : p_other->style_map) {
for (const KeyValue<StringName, Ref<StyleBox>> &F : E.value) {
set_stylebox(F.key, E.key, F.value);
}
@@ -1653,7 +1685,7 @@ void Theme::merge_with(const Ref<Theme> &p_other) {
void Theme::clear() {
// These items need disconnecting.
{
- for (const KeyValue<StringName, HashMap<StringName, Ref<Texture2D>>> &E : icon_map) {
+ for (const KeyValue<StringName, ThemeIconMap> &E : icon_map) {
for (const KeyValue<StringName, Ref<Texture2D>> &F : E.value) {
if (F.value.is_valid()) {
Ref<Texture2D> icon = F.value;
@@ -1664,7 +1696,7 @@ void Theme::clear() {
}
{
- for (const KeyValue<StringName, HashMap<StringName, Ref<StyleBox>>> &E : style_map) {
+ for (const KeyValue<StringName, ThemeStyleMap> &E : style_map) {
for (const KeyValue<StringName, Ref<StyleBox>> &F : E.value) {
if (F.value.is_valid()) {
Ref<StyleBox> style = F.value;
@@ -1675,7 +1707,7 @@ void Theme::clear() {
}
{
- for (const KeyValue<StringName, HashMap<StringName, Ref<Font>>> &E : font_map) {
+ for (const KeyValue<StringName, ThemeFontMap> &E : font_map) {
for (const KeyValue<StringName, Ref<Font>> &F : E.value) {
if (F.value.is_valid()) {
Ref<Font> font = F.value;
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index f8f1e95634..87d7d2fdea 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -47,6 +47,13 @@ class Theme : public Resource {
#endif
public:
+ using ThemeIconMap = HashMap<StringName, Ref<Texture2D>>;
+ using ThemeStyleMap = HashMap<StringName, Ref<StyleBox>>;
+ using ThemeFontMap = HashMap<StringName, Ref<Font>>;
+ using ThemeFontSizeMap = HashMap<StringName, int>;
+ using ThemeColorMap = HashMap<StringName, Color>;
+ using ThemeConstantMap = HashMap<StringName, int>;
+
enum DataType {
DATA_TYPE_COLOR,
DATA_TYPE_CONSTANT,
@@ -62,12 +69,12 @@ private:
void _emit_theme_changed(bool p_notify_list_changed = false);
- HashMap<StringName, HashMap<StringName, Ref<Texture2D>>> icon_map;
- HashMap<StringName, HashMap<StringName, Ref<StyleBox>>> style_map;
- HashMap<StringName, HashMap<StringName, Ref<Font>>> font_map;
- HashMap<StringName, HashMap<StringName, int>> font_size_map;
- HashMap<StringName, HashMap<StringName, Color>> color_map;
- HashMap<StringName, HashMap<StringName, int>> constant_map;
+ HashMap<StringName, ThemeIconMap> icon_map;
+ HashMap<StringName, ThemeStyleMap> style_map;
+ HashMap<StringName, ThemeFontMap> font_map;
+ HashMap<StringName, ThemeFontSizeMap> font_size_map;
+ HashMap<StringName, ThemeColorMap> color_map;
+ HashMap<StringName, ThemeConstantMap> constant_map;
HashMap<StringName, StringName> variation_map;
HashMap<StringName, List<StringName>> variation_base_map;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index cee3f85c32..e22b8efaae 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -1369,12 +1369,12 @@ TileMapCell TileSet::get_random_tile_from_terrains_pattern(int p_terrain_set, Ti
// Count the sum of probabilities.
double sum = 0.0;
RBSet<TileMapCell> set = per_terrain_pattern_tiles[p_terrain_set][p_terrain_tile_pattern];
- for (RBSet<TileMapCell>::Element *E = set.front(); E; E = E->next()) {
- if (E->get().source_id >= 0) {
- Ref<TileSetSource> source = sources[E->get().source_id];
+ for (const TileMapCell &E : set) {
+ if (E.source_id >= 0) {
+ Ref<TileSetSource> source = sources[E.source_id];
Ref<TileSetAtlasSource> atlas_source = source;
if (atlas_source.is_valid()) {
- TileData *tile_data = atlas_source->get_tile_data(E->get().get_atlas_coords(), E->get().alternative_tile);
+ TileData *tile_data = atlas_source->get_tile_data(E.get_atlas_coords(), E.alternative_tile);
sum += tile_data->get_probability();
} else {
sum += 1.0;
@@ -1389,13 +1389,13 @@ TileMapCell TileSet::get_random_tile_from_terrains_pattern(int p_terrain_set, Ti
double picked = Math::random(0.0, sum);
// Pick the tile.
- for (RBSet<TileMapCell>::Element *E = set.front(); E; E = E->next()) {
- if (E->get().source_id >= 0) {
- Ref<TileSetSource> source = sources[E->get().source_id];
+ for (const TileMapCell &E : set) {
+ if (E.source_id >= 0) {
+ Ref<TileSetSource> source = sources[E.source_id];
Ref<TileSetAtlasSource> atlas_source = source;
if (atlas_source.is_valid()) {
- TileData *tile_data = atlas_source->get_tile_data(E->get().get_atlas_coords(), E->get().alternative_tile);
+ TileData *tile_data = atlas_source->get_tile_data(E.get_atlas_coords(), E.alternative_tile);
count += tile_data->get_probability();
} else {
count += 1.0;
@@ -1405,7 +1405,7 @@ TileMapCell TileSet::get_random_tile_from_terrains_pattern(int p_terrain_set, Ti
}
if (count >= picked) {
- return E->get();
+ return E;
}
}
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 8e7824665f..d361aa876b 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -1547,7 +1547,7 @@ void VisualShader::reset_state() {
}
void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
//mode
- p_list->push_back(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Node3D,CanvasItem,Particles,Sky,Fog"));
+ p_list->push_back(PropertyInfo(Variant::INT, PNAME("mode"), PROPERTY_HINT_ENUM, "Node3D,CanvasItem,Particles,Sky,Fog"));
//render modes
HashMap<String, String> blend_mode_enums;
@@ -1576,15 +1576,15 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
}
for (const KeyValue<String, String> &E : blend_mode_enums) {
- p_list->push_back(PropertyInfo(Variant::INT, "modes/" + E.key, PROPERTY_HINT_ENUM, E.value));
+ p_list->push_back(PropertyInfo(Variant::INT, vformat("%s/%s", PNAME("modes"), E.key), PROPERTY_HINT_ENUM, E.value));
}
- for (RBSet<String>::Element *E = toggles.front(); E; E = E->next()) {
- p_list->push_back(PropertyInfo(Variant::BOOL, "flags/" + E->get()));
+ for (const String &E : toggles) {
+ p_list->push_back(PropertyInfo(Variant::BOOL, vformat("%s/%s", PNAME("flags"), E)));
}
for (const KeyValue<String, Varying> &E : varyings) {
- p_list->push_back(PropertyInfo(Variant::STRING, "varyings/" + E.key));
+ p_list->push_back(PropertyInfo(Variant::STRING, vformat("%s/%s", PNAME("varyings"), E.key)));
}
for (int i = 0; i < TYPE_MAX; i++) {
diff --git a/servers/physics_2d/godot_physics_server_2d.cpp b/servers/physics_2d/godot_physics_server_2d.cpp
index f82f2533f3..cb829e5d91 100644
--- a/servers/physics_2d/godot_physics_server_2d.cpp
+++ b/servers/physics_2d/godot_physics_server_2d.cpp
@@ -1250,11 +1250,11 @@ void GodotPhysicsServer2D::step(real_t p_step) {
island_count = 0;
active_objects = 0;
collision_pairs = 0;
- for (RBSet<const GodotSpace2D *>::Element *E = active_spaces.front(); E; E = E->next()) {
- stepper->step(const_cast<GodotSpace2D *>(E->get()), p_step);
- island_count += E->get()->get_island_count();
- active_objects += E->get()->get_active_objects();
- collision_pairs += E->get()->get_collision_pairs();
+ for (const GodotSpace2D *E : active_spaces) {
+ stepper->step(const_cast<GodotSpace2D *>(E), p_step);
+ island_count += E->get_island_count();
+ active_objects += E->get_active_objects();
+ collision_pairs += E->get_collision_pairs();
}
}
@@ -1271,8 +1271,8 @@ void GodotPhysicsServer2D::flush_queries() {
uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
- for (RBSet<const GodotSpace2D *>::Element *E = active_spaces.front(); E; E = E->next()) {
- GodotSpace2D *space = const_cast<GodotSpace2D *>(E->get());
+ for (const GodotSpace2D *E : active_spaces) {
+ GodotSpace2D *space = const_cast<GodotSpace2D *>(E);
space->call_queries();
}
@@ -1292,9 +1292,9 @@ void GodotPhysicsServer2D::flush_queries() {
total_time[i] = 0;
}
- for (RBSet<const GodotSpace2D *>::Element *E = active_spaces.front(); E; E = E->next()) {
+ for (const GodotSpace2D *E : active_spaces) {
for (int i = 0; i < GodotSpace2D::ELAPSED_TIME_MAX; i++) {
- total_time[i] += E->get()->get_elapsed_time(GodotSpace2D::ElapsedTime(i));
+ total_time[i] += E->get_elapsed_time(GodotSpace2D::ElapsedTime(i));
}
}
diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp
index 731eab2dfe..0a7859d86a 100644
--- a/servers/physics_2d/godot_space_2d.cpp
+++ b/servers/physics_2d/godot_space_2d.cpp
@@ -874,7 +874,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
bool collided = false;
- if (recovered || (safe < 1)) {
+ if ((p_parameters.recovery_as_collision && recovered) || (safe < 1)) {
if (safe >= 1) {
best_shape = -1; //no best shape with cast, reset to -1
}
diff --git a/servers/physics_2d/godot_step_2d.cpp b/servers/physics_2d/godot_step_2d.cpp
index 0df5c1aabc..551fd9329f 100644
--- a/servers/physics_2d/godot_step_2d.cpp
+++ b/servers/physics_2d/godot_step_2d.cpp
@@ -168,8 +168,8 @@ void GodotStep2D::step(GodotSpace2D *p_space, real_t p_delta) {
const SelfList<GodotArea2D>::List &aml = p_space->get_moved_area_list();
while (aml.first()) {
- for (const RBSet<GodotConstraint2D *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) {
- GodotConstraint2D *constraint = E->get();
+ for (GodotConstraint2D *E : aml.first()->self()->get_constraints()) {
+ GodotConstraint2D *constraint = E;
if (constraint->get_island_step() == _step) {
continue;
}
diff --git a/servers/physics_3d/godot_physics_server_3d.cpp b/servers/physics_3d/godot_physics_server_3d.cpp
index cb4988757c..b3a384ba8f 100644
--- a/servers/physics_3d/godot_physics_server_3d.cpp
+++ b/servers/physics_3d/godot_physics_server_3d.cpp
@@ -1611,11 +1611,11 @@ void GodotPhysicsServer3D::step(real_t p_step) {
island_count = 0;
active_objects = 0;
collision_pairs = 0;
- for (RBSet<const GodotSpace3D *>::Element *E = active_spaces.front(); E; E = E->next()) {
- stepper->step(const_cast<GodotSpace3D *>(E->get()), p_step);
- island_count += E->get()->get_island_count();
- active_objects += E->get()->get_active_objects();
- collision_pairs += E->get()->get_collision_pairs();
+ for (const GodotSpace3D *E : active_spaces) {
+ stepper->step(const_cast<GodotSpace3D *>(E), p_step);
+ island_count += E->get_island_count();
+ active_objects += E->get_active_objects();
+ collision_pairs += E->get_collision_pairs();
}
#endif
}
@@ -1635,8 +1635,8 @@ void GodotPhysicsServer3D::flush_queries() {
uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
- for (RBSet<const GodotSpace3D *>::Element *E = active_spaces.front(); E; E = E->next()) {
- GodotSpace3D *space = const_cast<GodotSpace3D *>(E->get());
+ for (const GodotSpace3D *E : active_spaces) {
+ GodotSpace3D *space = const_cast<GodotSpace3D *>(E);
space->call_queries();
}
@@ -1656,9 +1656,9 @@ void GodotPhysicsServer3D::flush_queries() {
total_time[i] = 0;
}
- for (RBSet<const GodotSpace3D *>::Element *E = active_spaces.front(); E; E = E->next()) {
+ for (const GodotSpace3D *E : active_spaces) {
for (int i = 0; i < GodotSpace3D::ELAPSED_TIME_MAX; i++) {
- total_time[i] += E->get()->get_elapsed_time(GodotSpace3D::ElapsedTime(i));
+ total_time[i] += E->get_elapsed_time(GodotSpace3D::ElapsedTime(i));
}
}
diff --git a/servers/physics_3d/godot_space_3d.cpp b/servers/physics_3d/godot_space_3d.cpp
index 9c051b23f6..2bdaf581a1 100644
--- a/servers/physics_3d/godot_space_3d.cpp
+++ b/servers/physics_3d/godot_space_3d.cpp
@@ -906,7 +906,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::
}
bool collided = false;
- if (recovered || (safe < 1)) {
+ if ((p_parameters.recovery_as_collision && recovered) || (safe < 1)) {
if (safe >= 1) {
best_shape = -1; //no best shape with cast, reset to -1
}
diff --git a/servers/physics_3d/godot_step_3d.cpp b/servers/physics_3d/godot_step_3d.cpp
index b46436ba39..99656d01a0 100644
--- a/servers/physics_3d/godot_step_3d.cpp
+++ b/servers/physics_3d/godot_step_3d.cpp
@@ -87,8 +87,8 @@ void GodotStep3D::_populate_island(GodotBody3D *p_body, LocalVector<GodotBody3D
void GodotStep3D::_populate_island_soft_body(GodotSoftBody3D *p_soft_body, LocalVector<GodotBody3D *> &p_body_island, LocalVector<GodotConstraint3D *> &p_constraint_island) {
p_soft_body->set_island_step(_step);
- for (RBSet<GodotConstraint3D *>::Element *E = p_soft_body->get_constraints().front(); E; E = E->next()) {
- GodotConstraint3D *constraint = const_cast<GodotConstraint3D *>(E->get());
+ for (const GodotConstraint3D *E : p_soft_body->get_constraints()) {
+ GodotConstraint3D *constraint = const_cast<GodotConstraint3D *>(E);
if (constraint->get_island_step() == _step) {
continue; // Already processed.
}
@@ -236,8 +236,8 @@ void GodotStep3D::step(GodotSpace3D *p_space, real_t p_delta) {
const SelfList<GodotArea3D>::List &aml = p_space->get_moved_area_list();
while (aml.first()) {
- for (const RBSet<GodotConstraint3D *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) {
- GodotConstraint3D *constraint = E->get();
+ for (GodotConstraint3D *E : aml.first()->self()->get_constraints()) {
+ GodotConstraint3D *constraint = E;
if (constraint->get_island_step() == _step) {
continue;
}
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 4aeaa7497f..41aae36785 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -158,8 +158,8 @@ Vector<RID> PhysicsRayQueryParameters2D::get_exclude() const {
Vector<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
- for (RBSet<RID>::Element *E = parameters.exclude.front(); E; E = E->next()) {
- ret.write[idx++] = E->get();
+ for (const RID &E : parameters.exclude) {
+ ret.write[idx++] = E;
}
return ret;
}
@@ -208,8 +208,8 @@ Vector<RID> PhysicsPointQueryParameters2D::get_exclude() const {
Vector<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
- for (RBSet<RID>::Element *E = parameters.exclude.front(); E; E = E->next()) {
- ret.write[idx++] = E->get();
+ for (const RID &E : parameters.exclude) {
+ ret.write[idx++] = E;
}
return ret;
}
@@ -267,8 +267,8 @@ Vector<RID> PhysicsShapeQueryParameters2D::get_exclude() const {
Vector<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
- for (RBSet<RID>::Element *E = parameters.exclude.front(); E; E = E->next()) {
- ret.write[idx++] = E->get();
+ for (const RID &E : parameters.exclude) {
+ ret.write[idx++] = E;
}
return ret;
}
@@ -505,12 +505,16 @@ void PhysicsTestMotionParameters2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_exclude_objects"), &PhysicsTestMotionParameters2D::get_exclude_objects);
ClassDB::bind_method(D_METHOD("set_exclude_objects", "exclude_list"), &PhysicsTestMotionParameters2D::set_exclude_objects);
+ ClassDB::bind_method(D_METHOD("is_recovery_as_collision_enabled"), &PhysicsTestMotionParameters2D::is_recovery_as_collision_enabled);
+ ClassDB::bind_method(D_METHOD("set_recovery_as_collision_enabled", "enabled"), &PhysicsTestMotionParameters2D::set_recovery_as_collision_enabled);
+
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "from"), "set_from", "get_from");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "set_motion", "get_motion");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_separation_ray"), "set_collide_separation_ray_enabled", "is_collide_separation_ray_enabled");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_bodies", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude_bodies", "get_exclude_bodies");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_objects"), "set_exclude_objects", "get_exclude_objects");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recovery_as_collision"), "set_recovery_as_collision_enabled", "is_recovery_as_collision_enabled");
}
///////////////////////////////
@@ -857,7 +861,7 @@ PhysicsServer2D::~PhysicsServer2D() {
Vector<PhysicsServer2DManager::ClassInfo> PhysicsServer2DManager::physics_2d_servers;
int PhysicsServer2DManager::default_server_id = -1;
int PhysicsServer2DManager::default_server_priority = -1;
-const String PhysicsServer2DManager::setting_property_name("physics/2d/physics_engine");
+const String PhysicsServer2DManager::setting_property_name(PNAME("physics/2d/physics_engine"));
void PhysicsServer2DManager::on_servers_changed() {
String physics_servers("DEFAULT");
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index bd53764932..745ee38ee1 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -485,6 +485,7 @@ public:
bool collide_separation_ray = false;
RBSet<RID> exclude_bodies;
RBSet<ObjectID> exclude_objects;
+ bool recovery_as_collision = false;
MotionParameters() {}
@@ -727,6 +728,9 @@ public:
Array get_exclude_objects() const;
void set_exclude_objects(const Array &p_exclude);
+
+ bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
+ void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
};
class PhysicsTestMotionResult2D : public RefCounted {
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp
index d05f5128b2..a606d055f7 100644
--- a/servers/physics_server_3d.cpp
+++ b/servers/physics_server_3d.cpp
@@ -177,8 +177,8 @@ Vector<RID> PhysicsRayQueryParameters3D::get_exclude() const {
Vector<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
- for (RBSet<RID>::Element *E = parameters.exclude.front(); E; E = E->next()) {
- ret.write[idx++] = E->get();
+ for (const RID &E : parameters.exclude) {
+ ret.write[idx++] = E;
}
return ret;
}
@@ -231,8 +231,8 @@ Vector<RID> PhysicsPointQueryParameters3D::get_exclude() const {
Vector<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
- for (RBSet<RID>::Element *E = parameters.exclude.front(); E; E = E->next()) {
- ret.write[idx++] = E->get();
+ for (const RID &E : parameters.exclude) {
+ ret.write[idx++] = E;
}
return ret;
}
@@ -286,8 +286,8 @@ Vector<RID> PhysicsShapeQueryParameters3D::get_exclude() const {
Vector<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
- for (RBSet<RID>::Element *E = parameters.exclude.front(); E; E = E->next()) {
- ret.write[idx++] = E->get();
+ for (const RID &E : parameters.exclude) {
+ ret.write[idx++] = E;
}
return ret;
}
@@ -527,6 +527,9 @@ void PhysicsTestMotionParameters3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_exclude_objects"), &PhysicsTestMotionParameters3D::get_exclude_objects);
ClassDB::bind_method(D_METHOD("set_exclude_objects", "exclude_list"), &PhysicsTestMotionParameters3D::set_exclude_objects);
+ ClassDB::bind_method(D_METHOD("is_recovery_as_collision_enabled"), &PhysicsTestMotionParameters3D::is_recovery_as_collision_enabled);
+ ClassDB::bind_method(D_METHOD("set_recovery_as_collision_enabled", "enabled"), &PhysicsTestMotionParameters3D::set_recovery_as_collision_enabled);
+
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "from"), "set_from", "get_from");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "motion"), "set_motion", "get_motion");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
@@ -534,6 +537,7 @@ void PhysicsTestMotionParameters3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_separation_ray"), "set_collide_separation_ray_enabled", "is_collide_separation_ray_enabled");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_bodies", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude_bodies", "get_exclude_bodies");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_objects"), "set_exclude_objects", "get_exclude_objects");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recovery_as_collision"), "set_recovery_as_collision_enabled", "is_recovery_as_collision_enabled");
}
///////////////////////////////
@@ -1029,7 +1033,7 @@ PhysicsServer3D::~PhysicsServer3D() {
Vector<PhysicsServer3DManager::ClassInfo> PhysicsServer3DManager::physics_servers;
int PhysicsServer3DManager::default_server_id = -1;
int PhysicsServer3DManager::default_server_priority = -1;
-const String PhysicsServer3DManager::setting_property_name("physics/3d/physics_engine");
+const String PhysicsServer3DManager::setting_property_name(PNAME("physics/3d/physics_engine"));
void PhysicsServer3DManager::on_servers_changed() {
String physics_servers2("DEFAULT");
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h
index c707f621b4..6a721f75a3 100644
--- a/servers/physics_server_3d.h
+++ b/servers/physics_server_3d.h
@@ -522,6 +522,7 @@ public:
bool collide_separation_ray = false;
RBSet<RID> exclude_bodies;
RBSet<ObjectID> exclude_objects;
+ bool recovery_as_collision = false;
MotionParameters() {}
@@ -941,6 +942,9 @@ public:
Array get_exclude_objects() const;
void set_exclude_objects(const Array &p_exclude);
+
+ bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
+ void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
};
class PhysicsTestMotionResult3D : public RefCounted {
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp
index 46bc22ad54..9291a89333 100644
--- a/servers/rendering/renderer_canvas_cull.cpp
+++ b/servers/rendering/renderer_canvas_cull.cpp
@@ -1831,8 +1831,8 @@ void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygo
RSG::canvas_render->occluder_polygon_set_shape(occluder_poly->occluder, p_shape, p_closed);
- for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
- E->get()->aabb_cache = occluder_poly->aabb;
+ for (RendererCanvasRender::LightOccluderInstance *E : occluder_poly->owners) {
+ E->aabb_cache = occluder_poly->aabb;
}
}
@@ -1841,8 +1841,8 @@ void RendererCanvasCull::canvas_occluder_polygon_set_cull_mode(RID p_occluder_po
ERR_FAIL_COND(!occluder_poly);
occluder_poly->cull_mode = p_mode;
RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode);
- for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
- E->get()->cull_cache = p_mode;
+ for (RendererCanvasRender::LightOccluderInstance *E : occluder_poly->owners) {
+ E->cull_cache = p_mode;
}
}
@@ -1942,12 +1942,12 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas->child_items[i].item->parent = RID();
}
- for (RBSet<RendererCanvasRender::Light *>::Element *E = canvas->lights.front(); E; E = E->next()) {
- E->get()->canvas = RID();
+ for (RendererCanvasRender::Light *E : canvas->lights) {
+ E->canvas = RID();
}
- for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *E = canvas->occluders.front(); E; E = E->next()) {
- E->get()->canvas = RID();
+ for (RendererCanvasRender::LightOccluderInstance *E : canvas->occluders) {
+ E->canvas = RID();
}
canvas_owner.free(p_rid);
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 0eb981d51b..7b92e92f8c 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -1523,7 +1523,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
Vector<Color> c;
{
Color cc = clear_color.srgb_to_linear();
- if (using_separate_specular) {
+ if (using_separate_specular || render_buffer) {
cc.a = 0; //subsurf scatter must be 0
}
c.push_back(cc);
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index e3bf2e3dda..3f3b087edb 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -5464,8 +5464,8 @@ bool RendererSceneRenderRD::free(RID p_rid) {
LightInstance *light_instance = light_instance_owner.get_or_null(p_rid);
//remove from shadow atlases..
- for (RBSet<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(E->get());
+ for (const RID &E : light_instance->shadow_atlases) {
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(E);
ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
uint32_t key = shadow_atlas->shadow_owners[p_rid];
uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
diff --git a/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl b/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl
index 5a238452c0..a8ccdea60b 100644
--- a/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl
@@ -426,12 +426,13 @@ vec3 screen_space_dither(vec2 frag_coord) {
void main() {
#ifdef SUBPASS
// SUBPASS and MULTIVIEW can be combined but in that case we're already reading from the correct layer
- vec3 color = subpassLoad(input_color).rgb * params.luminance_multiplier;
+ vec4 color = subpassLoad(input_color);
#elif defined(MULTIVIEW)
- vec3 color = textureLod(source_color, vec3(uv_interp, ViewIndex), 0.0f).rgb * params.luminance_multiplier;
+ vec4 color = textureLod(source_color, vec3(uv_interp, ViewIndex), 0.0f);
#else
- vec3 color = textureLod(source_color, uv_interp, 0.0f).rgb * params.luminance_multiplier;
+ vec4 color = textureLod(source_color, uv_interp, 0.0f);
#endif
+ color.rgb *= params.luminance_multiplier;
// Exposure
@@ -443,7 +444,7 @@ void main() {
}
#endif
- color *= exposure;
+ color.rgb *= exposure;
// Early Tonemap & SRGB Conversion
#ifndef SUBPASS
@@ -456,19 +457,19 @@ void main() {
}
if (params.use_fxaa) {
- color = do_fxaa(color, exposure, uv_interp);
+ color.rgb = do_fxaa(color.rgb, exposure, uv_interp);
}
#endif
if (params.use_debanding) {
// For best results, debanding should be done before tonemapping.
// Otherwise, we're adding noise to an already-quantized image.
- color += screen_space_dither(gl_FragCoord.xy);
+ color.rgb += screen_space_dither(gl_FragCoord.xy);
}
- color = apply_tonemapping(color, params.white);
+ color.rgb = apply_tonemapping(color.rgb, params.white);
- color = linear_to_srgb(color); // regular linear -> SRGB conversion
+ color.rgb = linear_to_srgb(color.rgb); // regular linear -> SRGB conversion
#ifndef SUBPASS
// Glow
@@ -482,19 +483,19 @@ void main() {
glow = apply_tonemapping(glow, params.white);
glow = linear_to_srgb(glow);
- color = apply_glow(color, glow);
+ color.rgb = apply_glow(color.rgb, glow);
}
#endif
// Additional effects
if (params.use_bcs) {
- color = apply_bcs(color, params.bcs);
+ color.rgb = apply_bcs(color.rgb, params.bcs);
}
if (params.use_color_correction) {
- color = apply_color_correction(color);
+ color.rgb = apply_color_correction(color.rgb);
}
- frag_color = vec4(color, 1.0f);
+ frag_color = color;
}
diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp
index 27f0c5f273..93f1f4e0d9 100644
--- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp
@@ -1979,8 +1979,8 @@ void MaterialStorage::global_variable_set(const StringName &p_name, const Varian
} else {
//texture
MaterialStorage *material_storage = MaterialStorage::get_singleton();
- for (RBSet<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_storage->get_material(E->get());
+ for (const RID &E : gv.texture_materials) {
+ Material *material = material_storage->get_material(E);
ERR_CONTINUE(!material);
material_storage->_material_queue_update(material, false, true);
}
@@ -2011,8 +2011,8 @@ void MaterialStorage::global_variable_set_override(const StringName &p_name, con
} else {
//texture
MaterialStorage *material_storage = MaterialStorage::get_singleton();
- for (RBSet<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_storage->get_material(E->get());
+ for (const RID &E : gv.texture_materials) {
+ Material *material = material_storage->get_material(E);
ERR_CONTINUE(!material);
material_storage->_material_queue_update(material, false, true);
}
@@ -2305,8 +2305,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->data = nullptr;
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
material->shader_type = new_type;
if (material->data) {
memdelete(material->data);
@@ -2322,8 +2322,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->type = SHADER_TYPE_MAX; //invalid
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
if (shader->data) {
material->data = material_get_data_request_function(new_type)(shader->data);
material->data->self = material->self;
@@ -2346,8 +2346,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->data->set_code(p_code);
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
material->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MATERIAL);
_material_queue_update(material, true, true);
}
@@ -2388,8 +2388,8 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin
if (shader->data) {
shader->data->set_default_texture_param(p_name, p_texture, p_index);
}
- for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
- Material *material = E->get();
+ for (Material *E : shader->owners) {
+ Material *material = E;
_material_queue_update(material, false, true);
}
}
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index fa051c92ed..1e0d67f269 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -215,8 +215,8 @@ void MeshStorage::mesh_free(RID p_rid) {
ERR_PRINT("deleting mesh with active instances");
}
if (mesh->shadow_owners.size()) {
- for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) {
- Mesh *shadow_owner = E->get();
+ for (Mesh *E : mesh->shadow_owners) {
+ Mesh *shadow_owner = E;
shadow_owner->shadow_mesh = RID();
shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
}
@@ -431,8 +431,8 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
- for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) {
- Mesh *shadow_owner = E->get();
+ for (Mesh *E : mesh->shadow_owners) {
+ Mesh *shadow_owner = E;
shadow_owner->shadow_mesh = RID();
shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
}
@@ -742,8 +742,8 @@ void MeshStorage::mesh_clear(RID p_mesh) {
mesh->has_bone_weights = false;
mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
- for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) {
- Mesh *shadow_owner = E->get();
+ for (Mesh *E : mesh->shadow_owners) {
+ Mesh *shadow_owner = E;
shadow_owner->shadow_mesh = RID();
shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH);
}
diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
index 1701b56b0b..e15d3e13a9 100644
--- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
@@ -838,8 +838,8 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
}
uint32_t collision_3d_textures_used = 0;
- for (const RBSet<RID>::Element *E = p_particles->collisions.front(); E; E = E->next()) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(E->get());
+ for (const RID &E : p_particles->collisions) {
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(E);
if (!pci || !pci->active) {
continue;
}
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index 37bbab86ff..89bd12ea3d 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -653,8 +653,8 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
scene_render->geometry_instance_set_lightmap_capture(geom->geometry_instance, instance->lightmap_sh.ptr());
}
- for (RBSet<Instance *>::Element *E = instance->visibility_dependencies.front(); E; E = E->next()) {
- Instance *dep_instance = E->get();
+ for (Instance *E : instance->visibility_dependencies) {
+ Instance *dep_instance = E;
ERR_CONTINUE(dep_instance->array_index == -1);
ERR_CONTINUE(dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index != -1);
dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = instance->array_index;
@@ -1299,8 +1299,8 @@ bool RendererSceneCull::_update_instance_visibility_depth(Instance *p_instance)
while (instance) {
if (!instance->visibility_dependencies.is_empty()) {
uint32_t depth = 0;
- for (RBSet<Instance *>::Element *E = instance->visibility_dependencies.front(); E; E = E->next()) {
- depth = MAX(depth, E->get()->visibility_dependencies_depth);
+ for (const Instance *E : instance->visibility_dependencies) {
+ depth = MAX(depth, E->visibility_dependencies_depth);
}
instance->visibility_dependencies_depth = depth + 1;
} else {
@@ -1559,8 +1559,8 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(p_instance->base_data);
//erase dependencies, since no longer a lightmap
- for (RBSet<Instance *>::Element *E = lightmap_data->geometries.front(); E; E = E->next()) {
- Instance *geom = E->get();
+ for (Instance *E : lightmap_data->geometries) {
+ Instance *geom = E;
_instance_queue_update(geom, true, false);
}
}
@@ -1574,8 +1574,8 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
//make sure lights are updated if it casts shadow
if (geom->can_cast_shadows) {
- for (RBSet<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) {
- InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
+ for (const Instance *E : geom->lights) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->base_data);
light->shadow_dirty = true;
}
}
@@ -1632,8 +1632,8 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
idata.parent_array_index = p_instance->visibility_parent ? p_instance->visibility_parent->array_index : -1;
idata.visibility_index = p_instance->visibility_index;
- for (RBSet<Instance *>::Element *E = p_instance->visibility_dependencies.front(); E; E = E->next()) {
- Instance *dep_instance = E->get();
+ for (Instance *E : p_instance->visibility_dependencies) {
+ Instance *dep_instance = E;
if (dep_instance->array_index != -1) {
dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = p_instance->array_index;
}
@@ -1800,8 +1800,8 @@ void RendererSceneCull::_unpair_instance(Instance *p_instance) {
swapped_instance->scenario->instance_visibility[swapped_instance->visibility_index].array_index = swapped_instance->array_index;
}
- for (RBSet<Instance *>::Element *E = swapped_instance->visibility_dependencies.front(); E; E = E->next()) {
- Instance *dep_instance = E->get();
+ for (Instance *E : swapped_instance->visibility_dependencies) {
+ Instance *dep_instance = E;
if (dep_instance != p_instance && dep_instance->array_index != -1) {
dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = swapped_instance->array_index;
}
@@ -1824,8 +1824,8 @@ void RendererSceneCull::_unpair_instance(Instance *p_instance) {
scene_render->geometry_instance_pair_voxel_gi_instances(geom->geometry_instance, nullptr, 0);
}
- for (RBSet<Instance *>::Element *E = p_instance->visibility_dependencies.front(); E; E = E->next()) {
- Instance *dep_instance = E->get();
+ for (Instance *E : p_instance->visibility_dependencies) {
+ Instance *dep_instance = E;
if (dep_instance->array_index != -1) {
dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = -1;
if ((1 << dep_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
@@ -1923,8 +1923,8 @@ void RendererSceneCull::_update_instance_lightmap_captures(Instance *p_instance)
float accum_blend = 0.0;
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
- for (RBSet<Instance *>::Element *E = geom->lightmap_captures.front(); E; E = E->next()) {
- Instance *lightmap = E->get();
+ for (Instance *E : geom->lightmap_captures) {
+ Instance *lightmap = E;
bool interior = RSG::light_storage->lightmap_is_interior(lightmap->base);
@@ -2744,8 +2744,8 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data);
uint32_t idx = 0;
- for (RBSet<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) {
- InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
+ for (const Instance *E : geom->lights) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->base_data);
instance_pair_buffer[idx++] = light->instance;
if (idx == MAX_INSTANCE_PAIRS) {
break;
@@ -2767,8 +2767,8 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data);
uint32_t idx = 0;
- for (RBSet<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) {
- InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->get()->base_data);
+ for (const Instance *E : geom->reflection_probes) {
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->base_data);
instance_pair_buffer[idx++] = reflection_probe->instance;
if (idx == MAX_INSTANCE_PAIRS) {
@@ -2784,8 +2784,8 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data);
uint32_t idx = 0;
- for (RBSet<Instance *>::Element *E = geom->decals.front(); E; E = E->next()) {
- InstanceDecalData *decal = static_cast<InstanceDecalData *>(E->get()->base_data);
+ for (const Instance *E : geom->decals) {
+ InstanceDecalData *decal = static_cast<InstanceDecalData *>(E->base_data);
instance_pair_buffer[idx++] = decal->instance;
if (idx == MAX_INSTANCE_PAIRS) {
@@ -2799,8 +2799,8 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
if (idata.flags & InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY) {
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data);
uint32_t idx = 0;
- for (RBSet<Instance *>::Element *E = geom->voxel_gi_instances.front(); E; E = E->next()) {
- InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(E->get()->base_data);
+ for (const Instance *E : geom->voxel_gi_instances) {
+ InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(E->base_data);
instance_pair_buffer[idx++] = voxel_gi->probe_instance;
if (idx == MAX_INSTANCE_PAIRS) {
@@ -3420,8 +3420,8 @@ void RendererSceneCull::render_probes() {
const RID *instance_caches = probe->light_instances.ptr();
int idx = 0; //must count visible lights
- for (RBSet<Instance *>::Element *E = probe->lights.front(); E; E = E->next()) {
- Instance *instance = E->get();
+ for (Instance *E : probe->lights) {
+ Instance *instance = E;
InstanceLightData *instance_light = (InstanceLightData *)instance->base_data;
if (!instance->visible) {
continue;
@@ -3502,8 +3502,8 @@ void RendererSceneCull::render_probes() {
RID *instance_caches = probe->light_instances.ptrw();
int idx = 0; //must count visible lights
- for (RBSet<Instance *>::Element *E = probe->lights.front(); E; E = E->next()) {
- Instance *instance = E->get();
+ for (Instance *E : probe->lights) {
+ Instance *instance = E;
InstanceLightData *instance_light = (InstanceLightData *)instance->base_data;
if (!instance->visible) {
continue;
@@ -3557,8 +3557,8 @@ void RendererSceneCull::render_probes() {
RID instance_pair_buffer[MAX_INSTANCE_PAIRS];
- for (RBSet<Instance *>::Element *E = probe->dynamic_geometries.front(); E; E = E->next()) {
- Instance *ins = E->get();
+ for (Instance *E : probe->dynamic_geometries) {
+ Instance *ins = E;
if (!ins->visible) {
continue;
}
@@ -3566,8 +3566,8 @@ void RendererSceneCull::render_probes() {
if (ins->scenario && ins->array_index >= 0 && (ins->scenario->instance_data[ins->array_index].flags & InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY)) {
uint32_t idx = 0;
- for (RBSet<Instance *>::Element *F = geom->voxel_gi_instances.front(); F; F = F->next()) {
- InstanceVoxelGIData *voxel_gi2 = static_cast<InstanceVoxelGIData *>(F->get()->base_data);
+ for (const Instance *F : geom->voxel_gi_instances) {
+ InstanceVoxelGIData *voxel_gi2 = static_cast<InstanceVoxelGIData *>(F->base_data);
instance_pair_buffer[idx++] = voxel_gi2->probe_instance;
if (idx == MAX_INSTANCE_PAIRS) {
@@ -3823,8 +3823,8 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) {
if (can_cast_shadows != geom->can_cast_shadows) {
//ability to cast shadows change, let lights now
- for (RBSet<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) {
- InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
+ for (const Instance *E : geom->lights) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->base_data);
light->shadow_dirty = true;
}
diff --git a/servers/rendering/renderer_storage.h b/servers/rendering/renderer_storage.h
index 7f35d2ca99..672fd4e4f1 100644
--- a/servers/rendering/renderer_storage.h
+++ b/servers/rendering/renderer_storage.h
@@ -85,8 +85,8 @@ public:
void update_end() { //call after updating dependencies
List<Pair<Dependency *, DependencyTracker *>> to_clean_up;
- for (RBSet<Dependency *>::Element *E = dependencies.front(); E; E = E->next()) {
- Dependency *dep = E->get();
+ for (Dependency *E : dependencies) {
+ Dependency *dep = E;
HashMap<DependencyTracker *, uint32_t>::Iterator F = dep->instances.find(this);
ERR_CONTINUE(!F);
if (F->value != instance_version) {
@@ -105,8 +105,8 @@ public:
}
void clear() { // clear all dependencies
- for (RBSet<Dependency *>::Element *E = dependencies.front(); E; E = E->next()) {
- Dependency *dep = E->get();
+ for (Dependency *E : dependencies) {
+ Dependency *dep = E;
dep->instances.erase(this);
}
dependencies.clear();
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index d612fb4aa7..7c2d7a1e1d 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -247,15 +247,15 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
- for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
- if (!F->get()->enabled) {
+ for (RendererCanvasRender::LightOccluderInstance *F : canvas->occluders) {
+ if (!F->enabled) {
continue;
}
- F->get()->xform_cache = xf * F->get()->xform;
+ F->xform_cache = xf * F->xform;
- if (sdf_rect.intersects_transformed(F->get()->xform_cache, F->get()->aabb_cache)) {
- F->get()->next = occluders;
- occluders = F->get();
+ if (sdf_rect.intersects_transformed(F->xform_cache, F->aabb_cache)) {
+ F->next = occluders;
+ occluders = F;
}
}
}
@@ -281,8 +281,8 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
// Find lights in canvas.
- for (RBSet<RendererCanvasRender::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) {
- RendererCanvasRender::Light *cl = F->get();
+ for (RendererCanvasRender::Light *F : canvas->lights) {
+ RendererCanvasRender::Light *cl = F;
if (cl->enabled && cl->texture.is_valid()) {
//not super efficient..
Size2 tsize = RSG::texture_storage->texture_size_with_proxy(cl->texture);
@@ -313,8 +313,8 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
}
}
- for (RBSet<RendererCanvasRender::Light *>::Element *F = canvas->directional_lights.front(); F; F = F->next()) {
- RendererCanvasRender::Light *cl = F->get();
+ for (RendererCanvasRender::Light *F : canvas->directional_lights) {
+ RendererCanvasRender::Light *cl = F;
if (cl->enabled) {
cl->filter_next_ptr = directional_lights;
directional_lights = cl;
@@ -349,14 +349,14 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
- for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
- if (!F->get()->enabled) {
+ for (RendererCanvasRender::LightOccluderInstance *F : canvas->occluders) {
+ if (!F->enabled) {
continue;
}
- F->get()->xform_cache = xf * F->get()->xform;
- if (shadow_rect.intersects_transformed(F->get()->xform_cache, F->get()->aabb_cache)) {
- F->get()->next = occluders;
- occluders = F->get();
+ F->xform_cache = xf * F->xform;
+ if (shadow_rect.intersects_transformed(F->xform_cache, F->aabb_cache)) {
+ F->next = occluders;
+ occluders = F;
}
}
}
@@ -429,19 +429,19 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
- for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
- if (!F->get()->enabled) {
+ for (RendererCanvasRender::LightOccluderInstance *F : canvas->occluders) {
+ if (!F->enabled) {
continue;
}
- F->get()->xform_cache = xf * F->get()->xform;
- Transform2D localizer = F->get()->xform_cache.affine_inverse();
+ F->xform_cache = xf * F->xform;
+ Transform2D localizer = F->xform_cache.affine_inverse();
for (int j = 0; j < point_count; j++) {
xf_points[j] = localizer.xform(points[j]);
}
- if (F->get()->aabb_cache.intersects_filled_polygon(xf_points, point_count)) {
- F->get()->next = occluders;
- occluders = F->get();
+ if (F->aabb_cache.intersects_filled_polygon(xf_points, point_count)) {
+ F->next = occluders;
+ occluders = F;
}
}
}
diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp
index c88d9e8222..662016e6f4 100644
--- a/servers/rendering/shader_compiler.cpp
+++ b/servers/rendering/shader_compiler.cpp
@@ -303,8 +303,8 @@ void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const Str
Vector<StringName> uses_functions;
- for (RBSet<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) {
- uses_functions.push_back(E->get());
+ for (const StringName &E : p_node->functions[fidx].uses_function) {
+ uses_functions.push_back(E);
}
uses_functions.sort_custom<StringName::AlphCompare>(); //ensure order is deterministic so the same shader is always produced
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 8a3ab92714..d2e188a9a7 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -4036,8 +4036,8 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
idx++;
}
- for (RBSet<String>::Element *E = kws.front(); E; E = E->next()) {
- r_keywords->push_back(E->get());
+ for (const String &E : kws) {
+ r_keywords->push_back(E);
}
}
@@ -4066,8 +4066,8 @@ void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
idx++;
}
- for (RBSet<String>::Element *E = kws.front(); E; E = E->next()) {
- r_keywords->push_back(E->get());
+ for (const String &E : kws) {
+ r_keywords->push_back(E);
}
}
@@ -4341,8 +4341,8 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringNam
arg->tex_argument_filter = p_filter;
arg->tex_argument_repeat = p_repeat;
for (KeyValue<StringName, RBSet<int>> &E : arg->tex_argument_connect) {
- for (RBSet<int>::Element *F = E.value.front(); F; F = F->next()) {
- if (!_propagate_function_call_sampler_uniform_settings(E.key, F->get(), p_filter, p_repeat)) {
+ for (const int &F : E.value) {
+ if (!_propagate_function_call_sampler_uniform_settings(E.key, F, p_filter, p_repeat)) {
return false;
}
}
@@ -4375,8 +4375,8 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa
arg->tex_builtin = p_builtin;
for (KeyValue<StringName, RBSet<int>> &E : arg->tex_argument_connect) {
- for (RBSet<int>::Element *F = E.value.front(); F; F = F->next()) {
- if (!_propagate_function_call_sampler_builtin_reference(E.key, F->get(), p_builtin)) {
+ for (const int &F : E.value) {
+ if (!_propagate_function_call_sampler_builtin_reference(E.key, F, p_builtin)) {
return false;
}
}
@@ -7568,12 +7568,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
String ShaderLanguage::_get_shader_type_list(const RBSet<String> &p_shader_types) const {
// Return a list of shader types as an human-readable string
String valid_types;
- for (const RBSet<String>::Element *E = p_shader_types.front(); E; E = E->next()) {
+ for (const String &E : p_shader_types) {
if (!valid_types.is_empty()) {
valid_types += ", ";
}
- valid_types += "'" + E->get() + "'";
+ valid_types += "'" + E + "'";
}
return valid_types;
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index 98c7f0d7aa..05700e7ff9 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -192,26 +192,26 @@ ShaderTypes::ShaderTypes() {
// spatial render modes
{
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "blend", "mix", "add", "sub", "mul" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "depth_draw", "opaque", "always", "never" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "depth_prepass_alpha" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "depth_test_disabled" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "sss_mode_skin" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "cull", "back", "front", "disabled" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "unshaded" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "wireframe" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "diffuse", "lambert", "lambert_wrap", "burley", "toon" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "specular", "schlick_ggx", "toon", "disabled" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "skip_vertex_transform" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "world_vertex_coords" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "ensure_correct_normals" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "shadows_disabled" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "ambient_light_disabled" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "shadow_to_opacity" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "vertex_lighting" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "particle_trails" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "alpha_to_coverage" });
- shader_modes[RS::SHADER_SPATIAL].modes.push_back({ "alpha_to_coverage_and_one" });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("blend"), "mix", "add", "sub", "mul" });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_draw"), "opaque", "always", "never" });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_prepass_alpha") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_test_disabled") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("sss_mode_skin") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("cull"), "back", "front", "disabled" });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("unshaded") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("wireframe") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("diffuse"), "lambert", "lambert_wrap", "burley", "toon" });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("specular"), "schlick_ggx", "toon", "disabled" });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("skip_vertex_transform") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("world_vertex_coords") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("ensure_correct_normals") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("shadows_disabled") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("ambient_light_disabled") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("shadow_to_opacity") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("vertex_lighting") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("particle_trails") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("alpha_to_coverage") });
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("alpha_to_coverage_and_one") });
}
/************ CANVAS ITEM **************************/
@@ -299,10 +299,10 @@ ShaderTypes::ShaderTypes() {
// canvasitem render modes
{
- shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ "skip_vertex_transform" });
- shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ "blend", "mix", "add", "sub", "mul", "premul_alpha", "disabled" });
- shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ "unshaded" });
- shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ "light_only" });
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("skip_vertex_transform") });
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("blend"), "mix", "add", "sub", "mul", "premul_alpha", "disabled" });
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("unshaded") });
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("light_only") });
}
/************ PARTICLES **************************/
@@ -380,10 +380,10 @@ ShaderTypes::ShaderTypes() {
// particles render modes
{
- shader_modes[RS::SHADER_PARTICLES].modes.push_back({ "collision_use_scale" });
- shader_modes[RS::SHADER_PARTICLES].modes.push_back({ "disable_force" });
- shader_modes[RS::SHADER_PARTICLES].modes.push_back({ "disable_velocity" });
- shader_modes[RS::SHADER_PARTICLES].modes.push_back({ "keep_data" });
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("collision_use_scale") });
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("disable_force") });
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("disable_velocity") });
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("keep_data") });
}
/************ SKY **************************/
@@ -430,9 +430,9 @@ ShaderTypes::ShaderTypes() {
// sky render modes
{
- shader_modes[RS::SHADER_SKY].modes.push_back({ "use_half_res_pass" });
- shader_modes[RS::SHADER_SKY].modes.push_back({ "use_quarter_res_pass" });
- shader_modes[RS::SHADER_SKY].modes.push_back({ "disable_fog" });
+ shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_half_res_pass") });
+ shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_quarter_res_pass") });
+ shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("disable_fog") });
}
/************ FOG **************************/
diff --git a/thirdparty/README.md b/thirdparty/README.md
index ab59d4fc18..0047f1c66c 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -547,6 +547,9 @@ Files extracted from upstream source:
- src/sljit/
- AUTHORS and LICENCE
+A sljit patch from upstream was backported to fix macOS < 11.0 compilation
+in 10.40, it can be found in the `patches` folder.
+
## recastnavigation
@@ -563,17 +566,17 @@ Files extracted from upstream source:
## rvo2
- Upstream: https://github.com/snape/RVO2-3D
-- Version: 1.0.1 (e3883f288a9e55ecfed3633a01af3e12778c6acf, 2016)
+- Version: git (bfc048670a4e85066e86a1f923d8ea92e3add3b2, 2021)
- License: Apache 2.0
Files extracted from upstream source:
-- All .cpp and .h files in the `src/` folder except for RVO.h, RVOSimulator.cpp and RVOSimulator.h
+- All .cpp and .h files in the `src/` folder except for Export.h, RVO.h, RVOSimulator.cpp and RVOSimulator.h
- LICENSE
Important: Some files have Godot-made changes; so to enrich the features
originally proposed by this library and better integrate this library with
-Godot. Please check the file to know what's new.
+Godot. See the patch in the `patches` folder for details.
## spirv-reflect
diff --git a/thirdparty/pcre2/patches/sljit-macos11-conditional.patch b/thirdparty/pcre2/patches/sljit-macos11-conditional.patch
new file mode 100644
index 0000000000..def1207a3d
--- /dev/null
+++ b/thirdparty/pcre2/patches/sljit-macos11-conditional.patch
@@ -0,0 +1,31 @@
+From de8fc816bc6698ab97316ed954e133e7e5098262 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@gmail.com>
+Date: Thu, 21 Apr 2022 21:01:12 -0700
+Subject: [PATCH] macos: somehow allow building with a target below 11.0
+
+While building for macOS older than 11 in Apple Silicon makes no
+sense, some build systems lack the flexibility to set a target per
+architecture while aiming to support multi architecture binaries.
+
+Allow an option in those cases by using the slower runtime checks
+if the toolchain allows it.
+
+Fixes: PCRE2Project/pcre2#109
+---
+ sljit_src/sljitExecAllocator.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/sljit_src/sljitExecAllocator.c b/sljit_src/sljitExecAllocator.c
+index 92d940dd..6359848c 100644
+--- a/sljit_src/sljitExecAllocator.c
++++ b/sljit_src/sljitExecAllocator.c
+@@ -152,6 +152,9 @@ static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec)
+ {
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
+ pthread_jit_write_protect_np(enable_exec);
++#elif defined(__clang__)
++ if (__builtin_available(macOS 11.0, *))
++ pthread_jit_write_protect_np(enable_exec);
+ #else
+ #error "Must target Big Sur or newer"
+ #endif /* BigSur */
diff --git a/thirdparty/pcre2/src/sljit/sljitExecAllocator.c b/thirdparty/pcre2/src/sljit/sljitExecAllocator.c
index 92d940ddc2..6359848cd5 100644
--- a/thirdparty/pcre2/src/sljit/sljitExecAllocator.c
+++ b/thirdparty/pcre2/src/sljit/sljitExecAllocator.c
@@ -152,6 +152,9 @@ static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec)
{
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
pthread_jit_write_protect_np(enable_exec);
+#elif defined(__clang__)
+ if (__builtin_available(macOS 11.0, *))
+ pthread_jit_write_protect_np(enable_exec);
#else
#error "Must target Big Sur or newer"
#endif /* BigSur */
diff --git a/thirdparty/rvo2/API.h b/thirdparty/rvo2/API.h
deleted file mode 100644
index c64efb452c..0000000000
--- a/thirdparty/rvo2/API.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * API.h
- * RVO2-3D Library
- *
- * Copyright 2008 University of North Carolina at Chapel Hill
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Please send all bug reports to <geom@cs.unc.edu>.
- *
- * The authors may be contacted via:
- *
- * Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, Dinesh Manocha
- * Dept. of Computer Science
- * 201 S. Columbia St.
- * Frederick P. Brooks, Jr. Computer Science Bldg.
- * Chapel Hill, N.C. 27599-3175
- * United States of America
- *
- * <http://gamma.cs.unc.edu/RVO2/>
- */
-
-/**
- * \file API.h
- * \brief Contains definitions related to Microsoft Windows.
- */
-
-#ifndef RVO_API_H_
-#define RVO_API_H_
-
-// -- GODOT start --
-#define RVO_API
-// -- GODOT end --
-
-#endif /* RVO_API_H_ */
diff --git a/thirdparty/rvo2/Agent.cpp b/thirdparty/rvo2/Agent.cpp
index 851d780758..b35eee9c12 100644
--- a/thirdparty/rvo2/Agent.cpp
+++ b/thirdparty/rvo2/Agent.cpp
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,40 +27,40 @@
* Chapel Hill, N.C. 27599-3175
* United States of America
*
- * <http://gamma.cs.unc.edu/RVO2/>
+ * <https://gamma.cs.unc.edu/RVO2/>
*/
#include "Agent.h"
-#include <algorithm>
#include <cmath>
+#include <algorithm>
#include "Definitions.h"
#include "KdTree.h"
namespace RVO {
-/**
+ /**
* \brief A sufficiently small positive number.
*/
-const float RVO_EPSILON = 0.00001f;
+ const float RVO3D_EPSILON = 0.00001f;
-/**
+ /**
* \brief Defines a directed line.
*/
-class Line {
-public:
- /**
+ class Line {
+ public:
+ /**
* \brief The direction of the directed line.
*/
- Vector3 direction;
+ Vector3 direction;
- /**
+ /**
* \brief A point on the directed line.
*/
- Vector3 point;
-};
+ Vector3 point;
+ };
-/**
+ /**
* \brief Solves a one-dimensional linear program on a specified line subject to linear constraints defined by planes and a spherical constraint.
* \param planes Planes defining the linear constraints.
* \param planeNo The plane on which the line lies.
@@ -71,9 +71,9 @@ public:
* \param result A reference to the result of the linear program.
* \return True if successful.
*/
-bool linearProgram1(const std::vector<Plane> &planes, size_t planeNo, const Line &line, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result);
+ bool linearProgram1(const std::vector<Plane> &planes, size_t planeNo, const Line &line, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result);
-/**
+ /**
* \brief Solves a two-dimensional linear program on a specified plane subject to linear constraints defined by planes and a spherical constraint.
* \param planes Planes defining the linear constraints.
* \param planeNo The plane on which the 2-d linear program is solved
@@ -83,9 +83,9 @@ bool linearProgram1(const std::vector<Plane> &planes, size_t planeNo, const Line
* \param result A reference to the result of the linear program.
* \return True if successful.
*/
-bool linearProgram2(const std::vector<Plane> &planes, size_t planeNo, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result);
+ bool linearProgram2(const std::vector<Plane> &planes, size_t planeNo, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result);
-/**
+ /**
* \brief Solves a three-dimensional linear program subject to linear constraints defined by planes and a spherical constraint.
* \param planes Planes defining the linear constraints.
* \param radius The radius of the spherical constraint.
@@ -94,332 +94,352 @@ bool linearProgram2(const std::vector<Plane> &planes, size_t planeNo, float radi
* \param result A reference to the result of the linear program.
* \return The number of the plane it fails on, and the number of planes if successful.
*/
-size_t linearProgram3(const std::vector<Plane> &planes, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result);
+ size_t linearProgram3(const std::vector<Plane> &planes, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result);
-/**
+ /**
* \brief Solves a four-dimensional linear program subject to linear constraints defined by planes and a spherical constraint.
* \param planes Planes defining the linear constraints.
* \param beginPlane The plane on which the 3-d linear program failed.
* \param radius The radius of the spherical constraint.
* \param result A reference to the result of the linear program.
*/
-void linearProgram4(const std::vector<Plane> &planes, size_t beginPlane, float radius, Vector3 &result);
+ void linearProgram4(const std::vector<Plane> &planes, size_t beginPlane, float radius, Vector3 &result);
-Agent::Agent() :
- id_(0), maxNeighbors_(0), maxSpeed_(0.0f), neighborDist_(0.0f), radius_(0.0f), timeHorizon_(0.0f), ignore_y_(false) {}
+ Agent::Agent() : id_(0), maxNeighbors_(0), maxSpeed_(0.0f), neighborDist_(0.0f), radius_(0.0f), timeHorizon_(0.0f), ignore_y_(false) { }
-void Agent::computeNeighbors(KdTree *kdTree_) {
- agentNeighbors_.clear();
- if (maxNeighbors_ > 0) {
- kdTree_->computeAgentNeighbors(this, neighborDist_ * neighborDist_);
- }
-}
+ void Agent::computeNeighbors(KdTree *kdTree_)
+ {
+ agentNeighbors_.clear();
+ if (maxNeighbors_ > 0) {
+ kdTree_->computeAgentNeighbors(this, neighborDist_ * neighborDist_);
+ }
+ }
+ void Agent::computeNewVelocity(float timeStep)
+ {
+ orcaPlanes_.clear();
+ const float invTimeHorizon = 1.0f / timeHorizon_;
+
+ /* Create agent ORCA planes. */
+ for (size_t i = 0; i < agentNeighbors_.size(); ++i) {
+ const Agent *const other = agentNeighbors_[i].second;
+
+ Vector3 relativePosition = other->position_ - position_;
+ Vector3 relativeVelocity = velocity_ - other->velocity_;
+ const float combinedRadius = radius_ + other->radius_;
+
+ // This is a Godot feature that allow the agents to avoid the collision
+ // by moving only on the horizontal plane relative to the player velocity.
+ if (ignore_y_) {
+ // Skip if these are in two different heights
#define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v))
-void Agent::computeNewVelocity(float timeStep) {
- orcaPlanes_.clear();
- const float invTimeHorizon = 1.0f / timeHorizon_;
-
- /* Create agent ORCA planes. */
- for (size_t i = 0; i < agentNeighbors_.size(); ++i) {
- const Agent *const other = agentNeighbors_[i].second;
-
- Vector3 relativePosition = other->position_ - position_;
- Vector3 relativeVelocity = velocity_ - other->velocity_;
- const float combinedRadius = radius_ + other->radius_;
-
- // This is a Godot feature that allow the agents to avoid the collision
- // by moving only on the horizontal plane relative to the player velocity.
- if (ignore_y_) {
- // Skip if these are in two different heights
- if (ABS(relativePosition[1]) > combinedRadius * 2) {
- continue;
- }
- relativePosition[1] = 0;
- relativeVelocity[1] = 0;
- }
-
- const float distSq = absSq(relativePosition);
- const float combinedRadiusSq = sqr(combinedRadius);
-
- Plane plane;
- Vector3 u;
-
- if (distSq > combinedRadiusSq) {
- /* No collision. */
- const Vector3 w = relativeVelocity - invTimeHorizon * relativePosition;
- /* Vector from cutoff center to relative velocity. */
- const float wLengthSq = absSq(w);
-
- const float dotProduct = w * relativePosition;
-
- if (dotProduct < 0.0f && sqr(dotProduct) > combinedRadiusSq * wLengthSq) {
- /* Project on cut-off circle. */
- const float wLength = std::sqrt(wLengthSq);
- const Vector3 unitW = w / wLength;
-
- plane.normal = unitW;
- u = (combinedRadius * invTimeHorizon - wLength) * unitW;
- } else {
- /* Project on cone. */
- const float a = distSq;
- const float b = relativePosition * relativeVelocity;
- const float c = absSq(relativeVelocity) - absSq(cross(relativePosition, relativeVelocity)) / (distSq - combinedRadiusSq);
- const float t = (b + std::sqrt(sqr(b) - a * c)) / a;
- const Vector3 w = relativeVelocity - t * relativePosition;
+ if (ABS(relativePosition[1]) > combinedRadius * 2) {
+ continue;
+ }
+ relativePosition[1] = 0;
+ relativeVelocity[1] = 0;
+ }
+
+ const float distSq = absSq(relativePosition);
+ const float combinedRadiusSq = sqr(combinedRadius);
+
+ Plane plane;
+ Vector3 u;
+
+ if (distSq > combinedRadiusSq) {
+ /* No collision. */
+ const Vector3 w = relativeVelocity - invTimeHorizon * relativePosition;
+ /* Vector from cutoff center to relative velocity. */
+ const float wLengthSq = absSq(w);
+
+ const float dotProduct = w * relativePosition;
+
+ if (dotProduct < 0.0f && sqr(dotProduct) > combinedRadiusSq * wLengthSq) {
+ /* Project on cut-off circle. */
+ const float wLength = std::sqrt(wLengthSq);
+ const Vector3 unitW = w / wLength;
+
+ plane.normal = unitW;
+ u = (combinedRadius * invTimeHorizon - wLength) * unitW;
+ }
+ else {
+ /* Project on cone. */
+ const float a = distSq;
+ const float b = relativePosition * relativeVelocity;
+ const float c = absSq(relativeVelocity) - absSq(cross(relativePosition, relativeVelocity)) / (distSq - combinedRadiusSq);
+ const float t = (b + std::sqrt(sqr(b) - a * c)) / a;
+ const Vector3 ww = relativeVelocity - t * relativePosition;
+ const float wwLength = abs(ww);
+ const Vector3 unitWW = ww / wwLength;
+
+ plane.normal = unitWW;
+ u = (combinedRadius * t - wwLength) * unitWW;
+ }
+ }
+ else {
+ /* Collision. */
+ const float invTimeStep = 1.0f / timeStep;
+ const Vector3 w = relativeVelocity - invTimeStep * relativePosition;
const float wLength = abs(w);
const Vector3 unitW = w / wLength;
plane.normal = unitW;
- u = (combinedRadius * t - wLength) * unitW;
+ u = (combinedRadius * invTimeStep - wLength) * unitW;
}
- } else {
- /* Collision. */
- const float invTimeStep = 1.0f / timeStep;
- const Vector3 w = relativeVelocity - invTimeStep * relativePosition;
- const float wLength = abs(w);
- const Vector3 unitW = w / wLength;
-
- plane.normal = unitW;
- u = (combinedRadius * invTimeStep - wLength) * unitW;
- }
- plane.point = velocity_ + 0.5f * u;
- orcaPlanes_.push_back(plane);
- }
+ plane.point = velocity_ + 0.5f * u;
+ orcaPlanes_.push_back(plane);
+ }
- const size_t planeFail = linearProgram3(orcaPlanes_, maxSpeed_, prefVelocity_, false, newVelocity_);
+ const size_t planeFail = linearProgram3(orcaPlanes_, maxSpeed_, prefVelocity_, false, newVelocity_);
- if (planeFail < orcaPlanes_.size()) {
- linearProgram4(orcaPlanes_, planeFail, maxSpeed_, newVelocity_);
- }
+ if (planeFail < orcaPlanes_.size()) {
+ linearProgram4(orcaPlanes_, planeFail, maxSpeed_, newVelocity_);
+ }
- if (ignore_y_) {
- // Not 100% necessary, but better to have.
- newVelocity_[1] = prefVelocity_[1];
- }
-}
+ if (ignore_y_) {
+ // Not 100% necessary, but better to have.
+ newVelocity_[1] = prefVelocity_[1];
+ }
+ }
-void Agent::insertAgentNeighbor(const Agent *agent, float &rangeSq) {
- if (this != agent) {
- const float distSq = absSq(position_ - agent->position_);
+ void Agent::insertAgentNeighbor(const Agent *agent, float &rangeSq)
+ {
+ if (this != agent) {
+ const float distSq = absSq(position_ - agent->position_);
- if (distSq < rangeSq) {
- if (agentNeighbors_.size() < maxNeighbors_) {
- agentNeighbors_.push_back(std::make_pair(distSq, agent));
- }
+ if (distSq < rangeSq) {
+ if (agentNeighbors_.size() < maxNeighbors_) {
+ agentNeighbors_.push_back(std::make_pair(distSq, agent));
+ }
- size_t i = agentNeighbors_.size() - 1;
+ size_t i = agentNeighbors_.size() - 1;
- while (i != 0 && distSq < agentNeighbors_[i - 1].first) {
- agentNeighbors_[i] = agentNeighbors_[i - 1];
- --i;
- }
+ while (i != 0 && distSq < agentNeighbors_[i - 1].first) {
+ agentNeighbors_[i] = agentNeighbors_[i - 1];
+ --i;
+ }
- agentNeighbors_[i] = std::make_pair(distSq, agent);
+ agentNeighbors_[i] = std::make_pair(distSq, agent);
- if (agentNeighbors_.size() == maxNeighbors_) {
- rangeSq = agentNeighbors_.back().first;
+ if (agentNeighbors_.size() == maxNeighbors_) {
+ rangeSq = agentNeighbors_.back().first;
+ }
}
}
}
-}
-bool linearProgram1(const std::vector<Plane> &planes, size_t planeNo, const Line &line, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result) {
- const float dotProduct = line.point * line.direction;
- const float discriminant = sqr(dotProduct) + sqr(radius) - absSq(line.point);
-
- if (discriminant < 0.0f) {
- /* Max speed sphere fully invalidates line. */
- return false;
- }
-
- const float sqrtDiscriminant = std::sqrt(discriminant);
- float tLeft = -dotProduct - sqrtDiscriminant;
- float tRight = -dotProduct + sqrtDiscriminant;
-
- for (size_t i = 0; i < planeNo; ++i) {
- const float numerator = (planes[i].point - line.point) * planes[i].normal;
- const float denominator = line.direction * planes[i].normal;
-
- if (sqr(denominator) <= RVO_EPSILON) {
- /* Lines line is (almost) parallel to plane i. */
- if (numerator > 0.0f) {
- return false;
- } else {
- continue;
+ bool linearProgram1(const std::vector<Plane> &planes, size_t planeNo, const Line &line, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result)
+ {
+ const float dotProduct = line.point * line.direction;
+ const float discriminant = sqr(dotProduct) + sqr(radius) - absSq(line.point);
+
+ if (discriminant < 0.0f) {
+ /* Max speed sphere fully invalidates line. */
+ return false;
+ }
+
+ const float sqrtDiscriminant = std::sqrt(discriminant);
+ float tLeft = -dotProduct - sqrtDiscriminant;
+ float tRight = -dotProduct + sqrtDiscriminant;
+
+ for (size_t i = 0; i < planeNo; ++i) {
+ const float numerator = (planes[i].point - line.point) * planes[i].normal;
+ const float denominator = line.direction * planes[i].normal;
+
+ if (sqr(denominator) <= RVO3D_EPSILON) {
+ /* Lines line is (almost) parallel to plane i. */
+ if (numerator > 0.0f) {
+ return false;
+ }
+ else {
+ continue;
+ }
}
- }
- const float t = numerator / denominator;
+ const float t = numerator / denominator;
- if (denominator >= 0.0f) {
- /* Plane i bounds line on the left. */
- tLeft = std::max(tLeft, t);
- } else {
- /* Plane i bounds line on the right. */
- tRight = std::min(tRight, t);
+ if (denominator >= 0.0f) {
+ /* Plane i bounds line on the left. */
+ tLeft = std::max(tLeft, t);
+ }
+ else {
+ /* Plane i bounds line on the right. */
+ tRight = std::min(tRight, t);
+ }
+
+ if (tLeft > tRight) {
+ return false;
+ }
}
- if (tLeft > tRight) {
- return false;
+ if (directionOpt) {
+ /* Optimize direction. */
+ if (optVelocity * line.direction > 0.0f) {
+ /* Take right extreme. */
+ result = line.point + tRight * line.direction;
+ }
+ else {
+ /* Take left extreme. */
+ result = line.point + tLeft * line.direction;
+ }
}
- }
-
- if (directionOpt) {
- /* Optimize direction. */
- if (optVelocity * line.direction > 0.0f) {
- /* Take right extreme. */
- result = line.point + tRight * line.direction;
- } else {
- /* Take left extreme. */
- result = line.point + tLeft * line.direction;
+ else {
+ /* Optimize closest point. */
+ const float t = line.direction * (optVelocity - line.point);
+
+ if (t < tLeft) {
+ result = line.point + tLeft * line.direction;
+ }
+ else if (t > tRight) {
+ result = line.point + tRight * line.direction;
+ }
+ else {
+ result = line.point + t * line.direction;
+ }
}
- } else {
- /* Optimize closest point. */
- const float t = line.direction * (optVelocity - line.point);
-
- if (t < tLeft) {
- result = line.point + tLeft * line.direction;
- } else if (t > tRight) {
- result = line.point + tRight * line.direction;
- } else {
- result = line.point + t * line.direction;
- }
- }
- return true;
-}
+ return true;
+ }
-bool linearProgram2(const std::vector<Plane> &planes, size_t planeNo, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result) {
- const float planeDist = planes[planeNo].point * planes[planeNo].normal;
- const float planeDistSq = sqr(planeDist);
- const float radiusSq = sqr(radius);
+ bool linearProgram2(const std::vector<Plane> &planes, size_t planeNo, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result)
+ {
+ const float planeDist = planes[planeNo].point * planes[planeNo].normal;
+ const float planeDistSq = sqr(planeDist);
+ const float radiusSq = sqr(radius);
- if (planeDistSq > radiusSq) {
- /* Max speed sphere fully invalidates plane planeNo. */
- return false;
- }
+ if (planeDistSq > radiusSq) {
+ /* Max speed sphere fully invalidates plane planeNo. */
+ return false;
+ }
- const float planeRadiusSq = radiusSq - planeDistSq;
+ const float planeRadiusSq = radiusSq - planeDistSq;
- const Vector3 planeCenter = planeDist * planes[planeNo].normal;
+ const Vector3 planeCenter = planeDist * planes[planeNo].normal;
- if (directionOpt) {
- /* Project direction optVelocity on plane planeNo. */
- const Vector3 planeOptVelocity = optVelocity - (optVelocity * planes[planeNo].normal) * planes[planeNo].normal;
- const float planeOptVelocityLengthSq = absSq(planeOptVelocity);
+ if (directionOpt) {
+ /* Project direction optVelocity on plane planeNo. */
+ const Vector3 planeOptVelocity = optVelocity - (optVelocity * planes[planeNo].normal) * planes[planeNo].normal;
+ const float planeOptVelocityLengthSq = absSq(planeOptVelocity);
- if (planeOptVelocityLengthSq <= RVO_EPSILON) {
- result = planeCenter;
- } else {
- result = planeCenter + std::sqrt(planeRadiusSq / planeOptVelocityLengthSq) * planeOptVelocity;
+ if (planeOptVelocityLengthSq <= RVO3D_EPSILON) {
+ result = planeCenter;
+ }
+ else {
+ result = planeCenter + std::sqrt(planeRadiusSq / planeOptVelocityLengthSq) * planeOptVelocity;
+ }
}
- } else {
- /* Project point optVelocity on plane planeNo. */
- result = optVelocity + ((planes[planeNo].point - optVelocity) * planes[planeNo].normal) * planes[planeNo].normal;
-
- /* If outside planeCircle, project on planeCircle. */
- if (absSq(result) > radiusSq) {
- const Vector3 planeResult = result - planeCenter;
- const float planeResultLengthSq = absSq(planeResult);
- result = planeCenter + std::sqrt(planeRadiusSq / planeResultLengthSq) * planeResult;
+ else {
+ /* Project point optVelocity on plane planeNo. */
+ result = optVelocity + ((planes[planeNo].point - optVelocity) * planes[planeNo].normal) * planes[planeNo].normal;
+
+ /* If outside planeCircle, project on planeCircle. */
+ if (absSq(result) > radiusSq) {
+ const Vector3 planeResult = result - planeCenter;
+ const float planeResultLengthSq = absSq(planeResult);
+ result = planeCenter + std::sqrt(planeRadiusSq / planeResultLengthSq) * planeResult;
+ }
}
- }
-
- for (size_t i = 0; i < planeNo; ++i) {
- if (planes[i].normal * (planes[i].point - result) > 0.0f) {
- /* Result does not satisfy constraint i. Compute new optimal result. */
- /* Compute intersection line of plane i and plane planeNo. */
- Vector3 crossProduct = cross(planes[i].normal, planes[planeNo].normal);
-
- if (absSq(crossProduct) <= RVO_EPSILON) {
- /* Planes planeNo and i are (almost) parallel, and plane i fully invalidates plane planeNo. */
- return false;
- }
-
- Line line;
- line.direction = normalize(crossProduct);
- const Vector3 lineNormal = cross(line.direction, planes[planeNo].normal);
- line.point = planes[planeNo].point + (((planes[i].point - planes[planeNo].point) * planes[i].normal) / (lineNormal * planes[i].normal)) * lineNormal;
-
- if (!linearProgram1(planes, i, line, radius, optVelocity, directionOpt, result)) {
- return false;
+
+ for (size_t i = 0; i < planeNo; ++i) {
+ if (planes[i].normal * (planes[i].point - result) > 0.0f) {
+ /* Result does not satisfy constraint i. Compute new optimal result. */
+ /* Compute intersection line of plane i and plane planeNo. */
+ Vector3 crossProduct = cross(planes[i].normal, planes[planeNo].normal);
+
+ if (absSq(crossProduct) <= RVO3D_EPSILON) {
+ /* Planes planeNo and i are (almost) parallel, and plane i fully invalidates plane planeNo. */
+ return false;
+ }
+
+ Line line;
+ line.direction = normalize(crossProduct);
+ const Vector3 lineNormal = cross(line.direction, planes[planeNo].normal);
+ line.point = planes[planeNo].point + (((planes[i].point - planes[planeNo].point) * planes[i].normal) / (lineNormal * planes[i].normal)) * lineNormal;
+
+ if (!linearProgram1(planes, i, line, radius, optVelocity, directionOpt, result)) {
+ return false;
+ }
}
}
+
+ return true;
}
- return true;
-}
+ size_t linearProgram3(const std::vector<Plane> &planes, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result)
+ {
+ if (directionOpt) {
+ /* Optimize direction. Note that the optimization velocity is of unit length in this case. */
+ result = optVelocity * radius;
+ }
+ else if (absSq(optVelocity) > sqr(radius)) {
+ /* Optimize closest point and outside circle. */
+ result = normalize(optVelocity) * radius;
+ }
+ else {
+ /* Optimize closest point and inside circle. */
+ result = optVelocity;
+ }
+
+ for (size_t i = 0; i < planes.size(); ++i) {
+ if (planes[i].normal * (planes[i].point - result) > 0.0f) {
+ /* Result does not satisfy constraint i. Compute new optimal result. */
+ const Vector3 tempResult = result;
-size_t linearProgram3(const std::vector<Plane> &planes, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result) {
- if (directionOpt) {
- /* Optimize direction. Note that the optimization velocity is of unit length in this case. */
- result = optVelocity * radius;
- } else if (absSq(optVelocity) > sqr(radius)) {
- /* Optimize closest point and outside circle. */
- result = normalize(optVelocity) * radius;
- } else {
- /* Optimize closest point and inside circle. */
- result = optVelocity;
- }
-
- for (size_t i = 0; i < planes.size(); ++i) {
- if (planes[i].normal * (planes[i].point - result) > 0.0f) {
- /* Result does not satisfy constraint i. Compute new optimal result. */
- const Vector3 tempResult = result;
-
- if (!linearProgram2(planes, i, radius, optVelocity, directionOpt, result)) {
- result = tempResult;
- return i;
+ if (!linearProgram2(planes, i, radius, optVelocity, directionOpt, result)) {
+ result = tempResult;
+ return i;
+ }
}
}
- }
- return planes.size();
-}
+ return planes.size();
+ }
-void linearProgram4(const std::vector<Plane> &planes, size_t beginPlane, float radius, Vector3 &result) {
- float distance = 0.0f;
-
- for (size_t i = beginPlane; i < planes.size(); ++i) {
- if (planes[i].normal * (planes[i].point - result) > distance) {
- /* Result does not satisfy constraint of plane i. */
- std::vector<Plane> projPlanes;
-
- for (size_t j = 0; j < i; ++j) {
- Plane plane;
-
- const Vector3 crossProduct = cross(planes[j].normal, planes[i].normal);
-
- if (absSq(crossProduct) <= RVO_EPSILON) {
- /* Plane i and plane j are (almost) parallel. */
- if (planes[i].normal * planes[j].normal > 0.0f) {
- /* Plane i and plane j point in the same direction. */
- continue;
- } else {
- /* Plane i and plane j point in opposite direction. */
- plane.point = 0.5f * (planes[i].point + planes[j].point);
- }
- } else {
- /* Plane.point is point on line of intersection between plane i and plane j. */
- const Vector3 lineNormal = cross(crossProduct, planes[i].normal);
- plane.point = planes[i].point + (((planes[j].point - planes[i].point) * planes[j].normal) / (lineNormal * planes[j].normal)) * lineNormal;
+ void linearProgram4(const std::vector<Plane> &planes, size_t beginPlane, float radius, Vector3 &result)
+ {
+ float distance = 0.0f;
+
+ for (size_t i = beginPlane; i < planes.size(); ++i) {
+ if (planes[i].normal * (planes[i].point - result) > distance) {
+ /* Result does not satisfy constraint of plane i. */
+ std::vector<Plane> projPlanes;
+
+ for (size_t j = 0; j < i; ++j) {
+ Plane plane;
+
+ const Vector3 crossProduct = cross(planes[j].normal, planes[i].normal);
+
+ if (absSq(crossProduct) <= RVO3D_EPSILON) {
+ /* Plane i and plane j are (almost) parallel. */
+ if (planes[i].normal * planes[j].normal > 0.0f) {
+ /* Plane i and plane j point in the same direction. */
+ continue;
+ }
+ else {
+ /* Plane i and plane j point in opposite direction. */
+ plane.point = 0.5f * (planes[i].point + planes[j].point);
+ }
+ }
+ else {
+ /* Plane.point is point on line of intersection between plane i and plane j. */
+ const Vector3 lineNormal = cross(crossProduct, planes[i].normal);
+ plane.point = planes[i].point + (((planes[j].point - planes[i].point) * planes[j].normal) / (lineNormal * planes[j].normal)) * lineNormal;
+ }
+
+ plane.normal = normalize(planes[j].normal - planes[i].normal);
+ projPlanes.push_back(plane);
}
- plane.normal = normalize(planes[j].normal - planes[i].normal);
- projPlanes.push_back(plane);
- }
+ const Vector3 tempResult = result;
- const Vector3 tempResult = result;
+ if (linearProgram3(projPlanes, radius, planes[i].normal, true, result) < projPlanes.size()) {
+ /* This should in principle not happen. The result is by definition already in the feasible region of this linear program. If it fails, it is due to small floating point error, and the current result is kept. */
+ result = tempResult;
+ }
- if (linearProgram3(projPlanes, radius, planes[i].normal, true, result) < projPlanes.size()) {
- /* This should in principle not happen. The result is by definition already in the feasible region of this linear program. If it fails, it is due to small floating point error, and the current result is kept. */
- result = tempResult;
+ distance = planes[i].normal * (planes[i].point - result);
}
-
- distance = planes[i].normal * (planes[i].point - result);
- }
+ }
}
}
-} // namespace RVO
diff --git a/thirdparty/rvo2/Agent.h b/thirdparty/rvo2/Agent.h
index 16f75a08f6..45fbead2f5 100644
--- a/thirdparty/rvo2/Agent.h
+++ b/thirdparty/rvo2/Agent.h
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,17 +27,15 @@
* Chapel Hill, N.C. 27599-3175
* United States of America
*
- * <http://gamma.cs.unc.edu/RVO2/>
+ * <https://gamma.cs.unc.edu/RVO2/>
*/
/**
* \file Agent.h
* \brief Contains the Agent class.
*/
-#ifndef RVO_AGENT_H_
-#define RVO_AGENT_H_
-
-#include "API.h"
+#ifndef RVO3D_AGENT_H_
+#define RVO3D_AGENT_H_
#include <cstddef>
#include <utility>
@@ -53,69 +51,68 @@
// - Moved the `Plane` class here.
// - Added a new parameter `ignore_y_` in the `Agent`. This parameter is used to control a godot feature that allows to avoid collisions by moving on the horizontal plane.
namespace RVO {
-/**
- * \brief Defines a plane.
- */
-class Plane {
-public:
- /**
- * \brief A point on the plane.
- */
- Vector3 point;
-
- /**
- * \brief The normal to the plane.
- */
- Vector3 normal;
-};
+ /**
+ * \brief Defines a plane.
+ */
+ class Plane {
+ public:
+ /**
+ * \brief A point on the plane.
+ */
+ Vector3 point;
-/**
- * \brief Defines an agent in the simulation.
- */
-class Agent {
+ /**
+ * \brief The normal to the plane.
+ */
+ Vector3 normal;
+ };
-public:
- /**
+ /**
+ * \brief Defines an agent in the simulation.
+ */
+ class Agent {
+ public:
+ /**
* \brief Constructs an agent instance.
* \param sim The simulator instance.
*/
- explicit Agent();
+ explicit Agent();
- /**
+ /**
* \brief Computes the neighbors of this agent.
*/
- void computeNeighbors(class KdTree *kdTree_);
+ void computeNeighbors(class KdTree *kdTree_);
- /**
+ /**
* \brief Computes the new velocity of this agent.
*/
- void computeNewVelocity(float timeStep);
+ void computeNewVelocity(float timeStep);
- /**
+ /**
* \brief Inserts an agent neighbor into the set of neighbors of this agent.
* \param agent A pointer to the agent to be inserted.
* \param rangeSq The squared range around this agent.
*/
- void insertAgentNeighbor(const Agent *agent, float &rangeSq);
+ void insertAgentNeighbor(const Agent *agent, float &rangeSq);
- Vector3 newVelocity_;
- Vector3 position_;
- Vector3 prefVelocity_;
- Vector3 velocity_;
- size_t id_;
- size_t maxNeighbors_;
- float maxSpeed_;
- float neighborDist_;
- float radius_;
- float timeHorizon_;
- std::vector<std::pair<float, const Agent *> > agentNeighbors_;
- std::vector<Plane> orcaPlanes_;
- /// This is a godot feature that allows the Agent to avoid collision by mooving
- /// on the horizontal plane.
- bool ignore_y_;
+ Vector3 newVelocity_;
+ Vector3 position_;
+ Vector3 prefVelocity_;
+ Vector3 velocity_;
+ size_t id_;
+ size_t maxNeighbors_;
+ float maxSpeed_;
+ float neighborDist_;
+ float radius_;
+ float timeHorizon_;
+ std::vector<std::pair<float, const Agent *> > agentNeighbors_;
+ std::vector<Plane> orcaPlanes_;
+ /// This is a godot feature that allows the Agent to avoid collision by mooving
+ /// on the horizontal plane.
+ bool ignore_y_;
- friend class KdTree;
-};
-} // namespace RVO
+ friend class KdTree;
+ };
+}
-#endif /* RVO_AGENT_H_ */
+#endif /* RVO3D_AGENT_H_ */
diff --git a/thirdparty/rvo2/Definitions.h b/thirdparty/rvo2/Definitions.h
index a73aca9908..707d3c897f 100644
--- a/thirdparty/rvo2/Definitions.h
+++ b/thirdparty/rvo2/Definitions.h
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,7 +27,7 @@
* Chapel Hill, N.C. 27599-3175
* United States of America
*
- * <http://gamma.cs.unc.edu/RVO2/>
+ * <https://gamma.cs.unc.edu/RVO2/>
*/
/**
@@ -35,10 +35,8 @@
* \brief Contains functions and constants used in multiple classes.
*/
-#ifndef RVO_DEFINITIONS_H_
-#define RVO_DEFINITIONS_H_
-
-#include "API.h"
+#ifndef RVO3D_DEFINITIONS_H_
+#define RVO3D_DEFINITIONS_H_
namespace RVO {
/**
@@ -52,4 +50,4 @@ namespace RVO {
}
}
-#endif /* RVO_DEFINITIONS_H_ */
+#endif /* RVO3D_DEFINITIONS_H_ */
diff --git a/thirdparty/rvo2/KdTree.cpp b/thirdparty/rvo2/KdTree.cpp
index bc224614f0..c857f299df 100644
--- a/thirdparty/rvo2/KdTree.cpp
+++ b/thirdparty/rvo2/KdTree.cpp
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,7 +27,7 @@
* Chapel Hill, N.C. 27599-3175
* United States of America
*
- * <http://gamma.cs.unc.edu/RVO2/>
+ * <https://gamma.cs.unc.edu/RVO2/>
*/
#include "KdTree.h"
@@ -38,115 +38,123 @@
#include "Definitions.h"
namespace RVO {
-const size_t RVO_MAX_LEAF_SIZE = 10;
+ const size_t RVO3D_MAX_LEAF_SIZE = 10;
-KdTree::KdTree() {}
+ KdTree::KdTree() { }
-void KdTree::buildAgentTree(std::vector<Agent *> agents) {
- agents_.swap(agents);
+ void KdTree::buildAgentTree(std::vector<Agent *> agents)
+ {
+ agents_.swap(agents);
- if (!agents_.empty()) {
- agentTree_.resize(2 * agents_.size() - 1);
- buildAgentTreeRecursive(0, agents_.size(), 0);
+ if (!agents_.empty()) {
+ agentTree_.resize(2 * agents_.size() - 1);
+ buildAgentTreeRecursive(0, agents_.size(), 0);
+ }
}
-}
-void KdTree::buildAgentTreeRecursive(size_t begin, size_t end, size_t node) {
- agentTree_[node].begin = begin;
- agentTree_[node].end = end;
- agentTree_[node].minCoord = agents_[begin]->position_;
- agentTree_[node].maxCoord = agents_[begin]->position_;
-
- for (size_t i = begin + 1; i < end; ++i) {
- agentTree_[node].maxCoord[0] = std::max(agentTree_[node].maxCoord[0], agents_[i]->position_.x());
- agentTree_[node].minCoord[0] = std::min(agentTree_[node].minCoord[0], agents_[i]->position_.x());
- agentTree_[node].maxCoord[1] = std::max(agentTree_[node].maxCoord[1], agents_[i]->position_.y());
- agentTree_[node].minCoord[1] = std::min(agentTree_[node].minCoord[1], agents_[i]->position_.y());
- agentTree_[node].maxCoord[2] = std::max(agentTree_[node].maxCoord[2], agents_[i]->position_.z());
- agentTree_[node].minCoord[2] = std::min(agentTree_[node].minCoord[2], agents_[i]->position_.z());
- }
-
- if (end - begin > RVO_MAX_LEAF_SIZE) {
- /* No leaf node. */
- size_t coord;
-
- if (agentTree_[node].maxCoord[0] - agentTree_[node].minCoord[0] > agentTree_[node].maxCoord[1] - agentTree_[node].minCoord[1] && agentTree_[node].maxCoord[0] - agentTree_[node].minCoord[0] > agentTree_[node].maxCoord[2] - agentTree_[node].minCoord[2]) {
- coord = 0;
- } else if (agentTree_[node].maxCoord[1] - agentTree_[node].minCoord[1] > agentTree_[node].maxCoord[2] - agentTree_[node].minCoord[2]) {
- coord = 1;
- } else {
- coord = 2;
- }
-
- const float splitValue = 0.5f * (agentTree_[node].maxCoord[coord] + agentTree_[node].minCoord[coord]);
-
- size_t left = begin;
-
- size_t right = end;
-
- while (left < right) {
- while (left < right && agents_[left]->position_[coord] < splitValue) {
- ++left;
- }
-
- while (right > left && agents_[right - 1]->position_[coord] >= splitValue) {
- --right;
+ void KdTree::buildAgentTreeRecursive(size_t begin, size_t end, size_t node)
+ {
+ agentTree_[node].begin = begin;
+ agentTree_[node].end = end;
+ agentTree_[node].minCoord = agents_[begin]->position_;
+ agentTree_[node].maxCoord = agents_[begin]->position_;
+
+ for (size_t i = begin + 1; i < end; ++i) {
+ agentTree_[node].maxCoord[0] = std::max(agentTree_[node].maxCoord[0], agents_[i]->position_.x());
+ agentTree_[node].minCoord[0] = std::min(agentTree_[node].minCoord[0], agents_[i]->position_.x());
+ agentTree_[node].maxCoord[1] = std::max(agentTree_[node].maxCoord[1], agents_[i]->position_.y());
+ agentTree_[node].minCoord[1] = std::min(agentTree_[node].minCoord[1], agents_[i]->position_.y());
+ agentTree_[node].maxCoord[2] = std::max(agentTree_[node].maxCoord[2], agents_[i]->position_.z());
+ agentTree_[node].minCoord[2] = std::min(agentTree_[node].minCoord[2], agents_[i]->position_.z());
+ }
+
+ if (end - begin > RVO3D_MAX_LEAF_SIZE) {
+ /* No leaf node. */
+ size_t coord;
+
+ if (agentTree_[node].maxCoord[0] - agentTree_[node].minCoord[0] > agentTree_[node].maxCoord[1] - agentTree_[node].minCoord[1] && agentTree_[node].maxCoord[0] - agentTree_[node].minCoord[0] > agentTree_[node].maxCoord[2] - agentTree_[node].minCoord[2]) {
+ coord = 0;
+ }
+ else if (agentTree_[node].maxCoord[1] - agentTree_[node].minCoord[1] > agentTree_[node].maxCoord[2] - agentTree_[node].minCoord[2]) {
+ coord = 1;
+ }
+ else {
+ coord = 2;
}
- if (left < right) {
- std::swap(agents_[left], agents_[right - 1]);
- ++left;
- --right;
+ const float splitValue = 0.5f * (agentTree_[node].maxCoord[coord] + agentTree_[node].minCoord[coord]);
+
+ size_t left = begin;
+
+ size_t right = end;
+
+ while (left < right) {
+ while (left < right && agents_[left]->position_[coord] < splitValue) {
+ ++left;
+ }
+
+ while (right > left && agents_[right - 1]->position_[coord] >= splitValue) {
+ --right;
+ }
+
+ if (left < right) {
+ std::swap(agents_[left], agents_[right - 1]);
+ ++left;
+ --right;
+ }
}
- }
- size_t leftSize = left - begin;
+ size_t leftSize = left - begin;
- if (leftSize == 0) {
- ++leftSize;
- ++left;
- ++right;
- }
+ if (leftSize == 0) {
+ ++leftSize;
+ ++left;
+ ++right;
+ }
- agentTree_[node].left = node + 1;
- agentTree_[node].right = node + 2 * leftSize;
+ agentTree_[node].left = node + 1;
+ agentTree_[node].right = node + 2 * leftSize;
- buildAgentTreeRecursive(begin, left, agentTree_[node].left);
- buildAgentTreeRecursive(left, end, agentTree_[node].right);
+ buildAgentTreeRecursive(begin, left, agentTree_[node].left);
+ buildAgentTreeRecursive(left, end, agentTree_[node].right);
+ }
}
-}
-void KdTree::computeAgentNeighbors(Agent *agent, float rangeSq) const {
- queryAgentTreeRecursive(agent, rangeSq, 0);
-}
+ void KdTree::computeAgentNeighbors(Agent *agent, float rangeSq) const
+ {
+ queryAgentTreeRecursive(agent, rangeSq, 0);
+ }
-void KdTree::queryAgentTreeRecursive(Agent *agent, float &rangeSq, size_t node) const {
- if (agentTree_[node].end - agentTree_[node].begin <= RVO_MAX_LEAF_SIZE) {
- for (size_t i = agentTree_[node].begin; i < agentTree_[node].end; ++i) {
- agent->insertAgentNeighbor(agents_[i], rangeSq);
+ void KdTree::queryAgentTreeRecursive(Agent *agent, float &rangeSq, size_t node) const
+ {
+ if (agentTree_[node].end - agentTree_[node].begin <= RVO3D_MAX_LEAF_SIZE) {
+ for (size_t i = agentTree_[node].begin; i < agentTree_[node].end; ++i) {
+ agent->insertAgentNeighbor(agents_[i], rangeSq);
+ }
}
- } else {
- const float distSqLeft = sqr(std::max(0.0f, agentTree_[agentTree_[node].left].minCoord[0] - agent->position_.x())) + sqr(std::max(0.0f, agent->position_.x() - agentTree_[agentTree_[node].left].maxCoord[0])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].left].minCoord[1] - agent->position_.y())) + sqr(std::max(0.0f, agent->position_.y() - agentTree_[agentTree_[node].left].maxCoord[1])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].left].minCoord[2] - agent->position_.z())) + sqr(std::max(0.0f, agent->position_.z() - agentTree_[agentTree_[node].left].maxCoord[2]));
+ else {
+ const float distSqLeft = sqr(std::max(0.0f, agentTree_[agentTree_[node].left].minCoord[0] - agent->position_.x())) + sqr(std::max(0.0f, agent->position_.x() - agentTree_[agentTree_[node].left].maxCoord[0])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].left].minCoord[1] - agent->position_.y())) + sqr(std::max(0.0f, agent->position_.y() - agentTree_[agentTree_[node].left].maxCoord[1])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].left].minCoord[2] - agent->position_.z())) + sqr(std::max(0.0f, agent->position_.z() - agentTree_[agentTree_[node].left].maxCoord[2]));
- const float distSqRight = sqr(std::max(0.0f, agentTree_[agentTree_[node].right].minCoord[0] - agent->position_.x())) + sqr(std::max(0.0f, agent->position_.x() - agentTree_[agentTree_[node].right].maxCoord[0])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].right].minCoord[1] - agent->position_.y())) + sqr(std::max(0.0f, agent->position_.y() - agentTree_[agentTree_[node].right].maxCoord[1])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].right].minCoord[2] - agent->position_.z())) + sqr(std::max(0.0f, agent->position_.z() - agentTree_[agentTree_[node].right].maxCoord[2]));
+ const float distSqRight = sqr(std::max(0.0f, agentTree_[agentTree_[node].right].minCoord[0] - agent->position_.x())) + sqr(std::max(0.0f, agent->position_.x() - agentTree_[agentTree_[node].right].maxCoord[0])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].right].minCoord[1] - agent->position_.y())) + sqr(std::max(0.0f, agent->position_.y() - agentTree_[agentTree_[node].right].maxCoord[1])) + sqr(std::max(0.0f, agentTree_[agentTree_[node].right].minCoord[2] - agent->position_.z())) + sqr(std::max(0.0f, agent->position_.z() - agentTree_[agentTree_[node].right].maxCoord[2]));
- if (distSqLeft < distSqRight) {
- if (distSqLeft < rangeSq) {
- queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].left);
+ if (distSqLeft < distSqRight) {
+ if (distSqLeft < rangeSq) {
+ queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].left);
+ if (distSqRight < rangeSq) {
+ queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].right);
+ }
+ }
+ }
+ else {
if (distSqRight < rangeSq) {
queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].right);
- }
- }
- } else {
- if (distSqRight < rangeSq) {
- queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].right);
-
- if (distSqLeft < rangeSq) {
- queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].left);
+
+ if (distSqLeft < rangeSq) {
+ queryAgentTreeRecursive(agent, rangeSq, agentTree_[node].left);
+ }
}
}
}
}
}
-} // namespace RVO
diff --git a/thirdparty/rvo2/KdTree.h b/thirdparty/rvo2/KdTree.h
index 1dbad00ea4..69d8920ce0 100644
--- a/thirdparty/rvo2/KdTree.h
+++ b/thirdparty/rvo2/KdTree.h
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,16 +27,14 @@
* Chapel Hill, N.C. 27599-3175
* United States of America
*
- * <http://gamma.cs.unc.edu/RVO2/>
+ * <https://gamma.cs.unc.edu/RVO2/>
*/
/**
* \file KdTree.h
* \brief Contains the KdTree class.
*/
-#ifndef RVO_KD_TREE_H_
-#define RVO_KD_TREE_H_
-
-#include "API.h"
+#ifndef RVO3D_KD_TREE_H_
+#define RVO3D_KD_TREE_H_
#include <cstddef>
#include <vector>
@@ -47,78 +45,78 @@
// - Removed `sim_`.
// - KdTree things are public
namespace RVO {
-class Agent;
-class RVOSimulator;
+ class Agent;
+ class RVOSimulator;
-/**
+ /**
* \brief Defines <i>k</i>d-trees for agents in the simulation.
*/
-class KdTree {
-public:
- /**
+ class KdTree {
+ public:
+ /**
* \brief Defines an agent <i>k</i>d-tree node.
*/
- class AgentTreeNode {
- public:
- /**
+ class AgentTreeNode {
+ public:
+ /**
* \brief The beginning node number.
*/
- size_t begin;
+ size_t begin;
- /**
+ /**
* \brief The ending node number.
*/
- size_t end;
+ size_t end;
- /**
+ /**
* \brief The left node number.
*/
- size_t left;
+ size_t left;
- /**
+ /**
* \brief The right node number.
*/
- size_t right;
+ size_t right;
- /**
+ /**
* \brief The maximum coordinates.
*/
- Vector3 maxCoord;
+ Vector3 maxCoord;
- /**
+ /**
* \brief The minimum coordinates.
*/
- Vector3 minCoord;
- };
+ Vector3 minCoord;
+ };
- /**
+ /**
* \brief Constructs a <i>k</i>d-tree instance.
* \param sim The simulator instance.
*/
- explicit KdTree();
+ explicit KdTree();
- /**
+ /**
* \brief Builds an agent <i>k</i>d-tree.
*/
- void buildAgentTree(std::vector<Agent *> agents);
+ void buildAgentTree(std::vector<Agent *> agents);
- void buildAgentTreeRecursive(size_t begin, size_t end, size_t node);
+ void buildAgentTreeRecursive(size_t begin, size_t end, size_t node);
- /**
+ /**
* \brief Computes the agent neighbors of the specified agent.
* \param agent A pointer to the agent for which agent neighbors are to be computed.
* \param rangeSq The squared range around the agent.
*/
- void computeAgentNeighbors(Agent *agent, float rangeSq) const;
+ void computeAgentNeighbors(Agent *agent, float rangeSq) const;
- void queryAgentTreeRecursive(Agent *agent, float &rangeSq, size_t node) const;
+ void queryAgentTreeRecursive(Agent *agent, float &rangeSq, size_t node) const;
- std::vector<Agent *> agents_;
- std::vector<AgentTreeNode> agentTree_;
+ std::vector<Agent *> agents_;
+ std::vector<AgentTreeNode> agentTree_;
- friend class Agent;
- friend class RVOSimulator;
-};
-} // namespace RVO
+ friend class Agent;
+ friend class RVOSimulator;
+ };
+}
-#endif /* RVO_KD_TREE_H_ */
+#endif /* RVO3D_KD_TREE_H_ */
diff --git a/thirdparty/rvo2/README.md b/thirdparty/rvo2/README.md
deleted file mode 100644
index 96af597cb6..0000000000
--- a/thirdparty/rvo2/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-Optimal Reciprocal Collision Avoidance in Three Dimensions
-==========================================================
-
-<http://gamma.cs.unc.edu/RVO2/>
-
-[![Build Status](https://travis-ci.org/snape/RVO2-3D.png?branch=master)](https://travis-ci.org/snape/RVO2-3D)
-[![Build status](https://ci.appveyor.com/api/projects/status/ov8ec3igv588wpx7/branch/master?svg=true)](https://ci.appveyor.com/project/snape/rvo2-3d)
-
-Copyright 2008 University of North Carolina at Chapel Hill
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-<http://www.apache.org/licenses/LICENSE-2.0>
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Please send all bug reports to [geom@cs.unc.edu](mailto:geom@cs.unc.edu).
-
-The authors may be contacted via:
-
-Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, and Dinesh Manocha
-Dept. of Computer Science
-201 S. Columbia St.
-Frederick P. Brooks, Jr. Computer Science Bldg.
-Chapel Hill, N.C. 27599-3175
-United States of America
diff --git a/thirdparty/rvo2/Vector3.h b/thirdparty/rvo2/Vector3.h
index 8c8835c865..f44e311f29 100644
--- a/thirdparty/rvo2/Vector3.h
+++ b/thirdparty/rvo2/Vector3.h
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,32 +27,32 @@
* Chapel Hill, N.C. 27599-3175
* United States of America
*
- * <http://gamma.cs.unc.edu/RVO2/>
+ * <https://gamma.cs.unc.edu/RVO2/>
*/
/**
* \file Vector3.h
* \brief Contains the Vector3 class.
*/
-#ifndef RVO_VECTOR3_H_
-#define RVO_VECTOR3_H_
-
-#include "API.h"
+#ifndef RVO3D_VECTOR3_H_
+#define RVO3D_VECTOR3_H_
#include <cmath>
#include <cstddef>
#include <ostream>
+#define RVO3D_EXPORT
+
namespace RVO {
/**
* \brief Defines a three-dimensional vector.
*/
- class Vector3 {
+ class RVO3D_EXPORT Vector3 {
public:
/**
* \brief Constructs and initializes a three-dimensional vector instance to zero.
*/
- RVO_API inline Vector3()
+ inline Vector3()
{
val_[0] = 0.0f;
val_[1] = 0.0f;
@@ -63,7 +63,7 @@ namespace RVO {
* \brief Constructs and initializes a three-dimensional vector from the specified three-element array.
* \param val The three-element array containing the xyz-coordinates.
*/
- RVO_API inline explicit Vector3(const float val[3])
+ inline explicit Vector3(const float val[3])
{
val_[0] = val[0];
val_[1] = val[1];
@@ -76,7 +76,7 @@ namespace RVO {
* \param y The y-coordinate of the three-dimensional vector.
* \param z The z-coordinate of the three-dimensional vector.
*/
- RVO_API inline Vector3(float x, float y, float z)
+ inline Vector3(float x, float y, float z)
{
val_[0] = x;
val_[1] = y;
@@ -87,39 +87,39 @@ namespace RVO {
* \brief Returns the x-coordinate of this three-dimensional vector.
* \return The x-coordinate of the three-dimensional vector.
*/
- RVO_API inline float x() const { return val_[0]; }
+ inline float x() const { return val_[0]; }
/**
* \brief Returns the y-coordinate of this three-dimensional vector.
* \return The y-coordinate of the three-dimensional vector.
*/
- RVO_API inline float y() const { return val_[1]; }
+ inline float y() const { return val_[1]; }
/**
* \brief Returns the z-coordinate of this three-dimensional vector.
* \return The z-coordinate of the three-dimensional vector.
*/
- RVO_API inline float z() const { return val_[2]; }
+ inline float z() const { return val_[2]; }
/**
* \brief Returns the specified coordinate of this three-dimensional vector.
* \param i The coordinate that should be returned (0 <= i < 3).
* \return The specified coordinate of the three-dimensional vector.
*/
- RVO_API inline float operator[](size_t i) const { return val_[i]; }
+ inline float operator[](size_t i) const { return val_[i]; }
/**
* \brief Returns a reference to the specified coordinate of this three-dimensional vector.
* \param i The coordinate to which a reference should be returned (0 <= i < 3).
* \return A reference to the specified coordinate of the three-dimensional vector.
*/
- RVO_API inline float &operator[](size_t i) { return val_[i]; }
+ inline float &operator[](size_t i) { return val_[i]; }
/**
* \brief Computes the negation of this three-dimensional vector.
* \return The negation of this three-dimensional vector.
*/
- RVO_API inline Vector3 operator-() const
+ inline Vector3 operator-() const
{
return Vector3(-val_[0], -val_[1], -val_[2]);
}
@@ -129,7 +129,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which the dot product should be computed.
* \return The dot product of this three-dimensional vector with a specified three-dimensional vector.
*/
- RVO_API inline float operator*(const Vector3 &vector) const
+ inline float operator*(const Vector3 &vector) const
{
return val_[0] * vector[0] + val_[1] * vector[1] + val_[2] * vector[2];
}
@@ -139,7 +139,7 @@ namespace RVO {
* \param scalar The scalar value with which the scalar multiplication should be computed.
* \return The scalar multiplication of this three-dimensional vector with a specified scalar value.
*/
- RVO_API inline Vector3 operator*(float scalar) const
+ inline Vector3 operator*(float scalar) const
{
return Vector3(val_[0] * scalar, val_[1] * scalar, val_[2] * scalar);
}
@@ -149,7 +149,7 @@ namespace RVO {
* \param scalar The scalar value with which the scalar division should be computed.
* \return The scalar division of this three-dimensional vector with a specified scalar value.
*/
- RVO_API inline Vector3 operator/(float scalar) const
+ inline Vector3 operator/(float scalar) const
{
const float invScalar = 1.0f / scalar;
@@ -161,7 +161,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which the vector sum should be computed.
* \return The vector sum of this three-dimensional vector with a specified three-dimensional vector.
*/
- RVO_API inline Vector3 operator+(const Vector3 &vector) const
+ inline Vector3 operator+(const Vector3 &vector) const
{
return Vector3(val_[0] + vector[0], val_[1] + vector[1], val_[2] + vector[2]);
}
@@ -171,7 +171,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which the vector difference should be computed.
* \return The vector difference of this three-dimensional vector with a specified three-dimensional vector.
*/
- RVO_API inline Vector3 operator-(const Vector3 &vector) const
+ inline Vector3 operator-(const Vector3 &vector) const
{
return Vector3(val_[0] - vector[0], val_[1] - vector[1], val_[2] - vector[2]);
}
@@ -181,7 +181,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which to test for equality.
* \return True if the three-dimensional vectors are equal.
*/
- RVO_API inline bool operator==(const Vector3 &vector) const
+ inline bool operator==(const Vector3 &vector) const
{
return val_[0] == vector[0] && val_[1] == vector[1] && val_[2] == vector[2];
}
@@ -191,7 +191,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which to test for inequality.
* \return True if the three-dimensional vectors are not equal.
*/
- RVO_API inline bool operator!=(const Vector3 &vector) const
+ inline bool operator!=(const Vector3 &vector) const
{
return val_[0] != vector[0] || val_[1] != vector[1] || val_[2] != vector[2];
}
@@ -201,7 +201,7 @@ namespace RVO {
* \param scalar The scalar value with which the scalar multiplication should be computed.
* \return A reference to this three-dimensional vector.
*/
- RVO_API inline Vector3 &operator*=(float scalar)
+ inline Vector3 &operator*=(float scalar)
{
val_[0] *= scalar;
val_[1] *= scalar;
@@ -215,7 +215,7 @@ namespace RVO {
* \param scalar The scalar value with which the scalar division should be computed.
* \return A reference to this three-dimensional vector.
*/
- RVO_API inline Vector3 &operator/=(float scalar)
+ inline Vector3 &operator/=(float scalar)
{
const float invScalar = 1.0f / scalar;
@@ -232,7 +232,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which the vector sum should be computed.
* \return A reference to this three-dimensional vector.
*/
- RVO_API inline Vector3 &operator+=(const Vector3 &vector)
+ inline Vector3 &operator+=(const Vector3 &vector)
{
val_[0] += vector[0];
val_[1] += vector[1];
@@ -246,7 +246,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which the vector difference should be computed.
* \return A reference to this three-dimensional vector.
*/
- RVO_API inline Vector3 &operator-=(const Vector3 &vector)
+ inline Vector3 &operator-=(const Vector3 &vector)
{
val_[0] -= vector[0];
val_[1] -= vector[1];
@@ -267,7 +267,7 @@ namespace RVO {
* \param vector The three-dimensional vector with which the scalar multiplication should be computed.
* \return The scalar multiplication of the three-dimensional vector with the scalar value.
*/
- inline Vector3 operator*(float scalar, const Vector3 &vector)
+ RVO3D_EXPORT inline Vector3 operator*(float scalar, const Vector3 &vector)
{
return Vector3(scalar * vector[0], scalar * vector[1], scalar * vector[2]);
}
@@ -279,7 +279,7 @@ namespace RVO {
* \param vector2 The second vector with which the cross product should be computed.
* \return The cross product of the two specified vectors.
*/
- inline Vector3 cross(const Vector3 &vector1, const Vector3 &vector2)
+ RVO3D_EXPORT inline Vector3 cross(const Vector3 &vector1, const Vector3 &vector2)
{
return Vector3(vector1[1] * vector2[2] - vector1[2] * vector2[1], vector1[2] * vector2[0] - vector1[0] * vector2[2], vector1[0] * vector2[1] - vector1[1] * vector2[0]);
}
@@ -291,7 +291,7 @@ namespace RVO {
* \param vector The three-dimensional vector which to insert into the output stream.
* \return A reference to the output stream.
*/
- inline std::ostream &operator<<(std::ostream &os, const Vector3 &vector)
+ RVO3D_EXPORT inline std::ostream &operator<<(std::ostream &os, const Vector3 &vector)
{
os << "(" << vector[0] << "," << vector[1] << "," << vector[2] << ")";
@@ -304,7 +304,7 @@ namespace RVO {
* \param vector The three-dimensional vector whose length is to be computed.
* \return The length of the three-dimensional vector.
*/
- inline float abs(const Vector3 &vector)
+ RVO3D_EXPORT inline float abs(const Vector3 &vector)
{
return std::sqrt(vector * vector);
}
@@ -315,7 +315,7 @@ namespace RVO {
* \param vector The three-dimensional vector whose squared length is to be computed.
* \return The squared length of the three-dimensional vector.
*/
- inline float absSq(const Vector3 &vector)
+ RVO3D_EXPORT inline float absSq(const Vector3 &vector)
{
return vector * vector;
}
@@ -326,7 +326,7 @@ namespace RVO {
* \param vector The three-dimensional vector whose normalization is to be computed.
* \return The normalization of the three-dimensional vector.
*/
- inline Vector3 normalize(const Vector3 &vector)
+ RVO3D_EXPORT inline Vector3 normalize(const Vector3 &vector)
{
return vector / abs(vector);
}
diff --git a/thirdparty/rvo2/patches/rvo2-godot-changes.patch b/thirdparty/rvo2/patches/rvo2-godot-changes.patch
new file mode 100644
index 0000000000..16dbc203ed
--- /dev/null
+++ b/thirdparty/rvo2/patches/rvo2-godot-changes.patch
@@ -0,0 +1,282 @@
+diff --git a/thirdparty/rvo2/Agent.cpp b/thirdparty/rvo2/Agent.cpp
+index 5e49a3554c..b35eee9c12 100644
+--- a/thirdparty/rvo2/Agent.cpp
++++ b/thirdparty/rvo2/Agent.cpp
+@@ -105,18 +105,17 @@ namespace RVO {
+ */
+ void linearProgram4(const std::vector<Plane> &planes, size_t beginPlane, float radius, Vector3 &result);
+
+- Agent::Agent(RVOSimulator *sim) : sim_(sim), id_(0), maxNeighbors_(0), maxSpeed_(0.0f), neighborDist_(0.0f), radius_(0.0f), timeHorizon_(0.0f) { }
++ Agent::Agent() : id_(0), maxNeighbors_(0), maxSpeed_(0.0f), neighborDist_(0.0f), radius_(0.0f), timeHorizon_(0.0f), ignore_y_(false) { }
+
+- void Agent::computeNeighbors()
++ void Agent::computeNeighbors(KdTree *kdTree_)
+ {
+ agentNeighbors_.clear();
+-
+ if (maxNeighbors_ > 0) {
+- sim_->kdTree_->computeAgentNeighbors(this, neighborDist_ * neighborDist_);
++ kdTree_->computeAgentNeighbors(this, neighborDist_ * neighborDist_);
+ }
+ }
+
+- void Agent::computeNewVelocity()
++ void Agent::computeNewVelocity(float timeStep)
+ {
+ orcaPlanes_.clear();
+ const float invTimeHorizon = 1.0f / timeHorizon_;
+@@ -124,10 +123,24 @@ namespace RVO {
+ /* Create agent ORCA planes. */
+ for (size_t i = 0; i < agentNeighbors_.size(); ++i) {
+ const Agent *const other = agentNeighbors_[i].second;
+- const Vector3 relativePosition = other->position_ - position_;
+- const Vector3 relativeVelocity = velocity_ - other->velocity_;
+- const float distSq = absSq(relativePosition);
++
++ Vector3 relativePosition = other->position_ - position_;
++ Vector3 relativeVelocity = velocity_ - other->velocity_;
+ const float combinedRadius = radius_ + other->radius_;
++
++ // This is a Godot feature that allow the agents to avoid the collision
++ // by moving only on the horizontal plane relative to the player velocity.
++ if (ignore_y_) {
++ // Skip if these are in two different heights
++#define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v))
++ if (ABS(relativePosition[1]) > combinedRadius * 2) {
++ continue;
++ }
++ relativePosition[1] = 0;
++ relativeVelocity[1] = 0;
++ }
++
++ const float distSq = absSq(relativePosition);
+ const float combinedRadiusSq = sqr(combinedRadius);
+
+ Plane plane;
+@@ -165,7 +178,7 @@ namespace RVO {
+ }
+ else {
+ /* Collision. */
+- const float invTimeStep = 1.0f / sim_->timeStep_;
++ const float invTimeStep = 1.0f / timeStep;
+ const Vector3 w = relativeVelocity - invTimeStep * relativePosition;
+ const float wLength = abs(w);
+ const Vector3 unitW = w / wLength;
+@@ -183,6 +196,11 @@ namespace RVO {
+ if (planeFail < orcaPlanes_.size()) {
+ linearProgram4(orcaPlanes_, planeFail, maxSpeed_, newVelocity_);
+ }
++
++ if (ignore_y_) {
++ // Not 100% necessary, but better to have.
++ newVelocity_[1] = prefVelocity_[1];
++ }
+ }
+
+ void Agent::insertAgentNeighbor(const Agent *agent, float &rangeSq)
+@@ -211,12 +229,6 @@ namespace RVO {
+ }
+ }
+
+- void Agent::update()
+- {
+- velocity_ = newVelocity_;
+- position_ += velocity_ * sim_->timeStep_;
+- }
+-
+ bool linearProgram1(const std::vector<Plane> &planes, size_t planeNo, const Line &line, float radius, const Vector3 &optVelocity, bool directionOpt, Vector3 &result)
+ {
+ const float dotProduct = line.point * line.direction;
+diff --git a/thirdparty/rvo2/Agent.h b/thirdparty/rvo2/Agent.h
+index d3922ec645..45fbead2f5 100644
+--- a/thirdparty/rvo2/Agent.h
++++ b/thirdparty/rvo2/Agent.h
+@@ -41,30 +41,52 @@
+ #include <utility>
+ #include <vector>
+
+-#include "RVOSimulator.h"
+ #include "Vector3.h"
+
++// Note: Slightly modified to work better in Godot.
++// - The agent can be created by anyone.
++// - The simulator pointer is removed.
++// - The update function is removed.
++// - The compute velocity function now need the timeStep.
++// - Moved the `Plane` class here.
++// - Added a new parameter `ignore_y_` in the `Agent`. This parameter is used to control a godot feature that allows to avoid collisions by moving on the horizontal plane.
+ namespace RVO {
++ /**
++ * \brief Defines a plane.
++ */
++ class Plane {
++ public:
++ /**
++ * \brief A point on the plane.
++ */
++ Vector3 point;
++
++ /**
++ * \brief The normal to the plane.
++ */
++ Vector3 normal;
++ };
++
+ /**
+ * \brief Defines an agent in the simulation.
+ */
+ class Agent {
+- private:
++ public:
+ /**
+ * \brief Constructs an agent instance.
+ * \param sim The simulator instance.
+ */
+- explicit Agent(RVOSimulator *sim);
++ explicit Agent();
+
+ /**
+ * \brief Computes the neighbors of this agent.
+ */
+- void computeNeighbors();
++ void computeNeighbors(class KdTree *kdTree_);
+
+ /**
+ * \brief Computes the new velocity of this agent.
+ */
+- void computeNewVelocity();
++ void computeNewVelocity(float timeStep);
+
+ /**
+ * \brief Inserts an agent neighbor into the set of neighbors of this agent.
+@@ -73,16 +95,10 @@ namespace RVO {
+ */
+ void insertAgentNeighbor(const Agent *agent, float &rangeSq);
+
+- /**
+- * \brief Updates the three-dimensional position and three-dimensional velocity of this agent.
+- */
+- void update();
+-
+ Vector3 newVelocity_;
+ Vector3 position_;
+ Vector3 prefVelocity_;
+ Vector3 velocity_;
+- RVOSimulator *sim_;
+ size_t id_;
+ size_t maxNeighbors_;
+ float maxSpeed_;
+@@ -91,9 +107,11 @@ namespace RVO {
+ float timeHorizon_;
+ std::vector<std::pair<float, const Agent *> > agentNeighbors_;
+ std::vector<Plane> orcaPlanes_;
++ /// This is a godot feature that allows the Agent to avoid collision by mooving
++ /// on the horizontal plane.
++ bool ignore_y_;
+
+ friend class KdTree;
+- friend class RVOSimulator;
+ };
+ }
+
+diff --git a/thirdparty/rvo2/KdTree.cpp b/thirdparty/rvo2/KdTree.cpp
+index 5e9e9777a6..c857f299df 100644
+--- a/thirdparty/rvo2/KdTree.cpp
++++ b/thirdparty/rvo2/KdTree.cpp
+@@ -36,16 +36,15 @@
+
+ #include "Agent.h"
+ #include "Definitions.h"
+-#include "RVOSimulator.h"
+
+ namespace RVO {
+ const size_t RVO3D_MAX_LEAF_SIZE = 10;
+
+- KdTree::KdTree(RVOSimulator *sim) : sim_(sim) { }
++ KdTree::KdTree() { }
+
+- void KdTree::buildAgentTree()
++ void KdTree::buildAgentTree(std::vector<Agent *> agents)
+ {
+- agents_ = sim_->agents_;
++ agents_.swap(agents);
+
+ if (!agents_.empty()) {
+ agentTree_.resize(2 * agents_.size() - 1);
+diff --git a/thirdparty/rvo2/KdTree.h b/thirdparty/rvo2/KdTree.h
+index a09384c20f..69d8920ce0 100644
+--- a/thirdparty/rvo2/KdTree.h
++++ b/thirdparty/rvo2/KdTree.h
+@@ -41,6 +41,9 @@
+
+ #include "Vector3.h"
+
++// Note: Slightly modified to work better with Godot.
++// - Removed `sim_`.
++// - KdTree things are public
+ namespace RVO {
+ class Agent;
+ class RVOSimulator;
+@@ -49,7 +52,7 @@ namespace RVO {
+ * \brief Defines <i>k</i>d-trees for agents in the simulation.
+ */
+ class KdTree {
+- private:
++ public:
+ /**
+ * \brief Defines an agent <i>k</i>d-tree node.
+ */
+@@ -90,12 +93,12 @@ namespace RVO {
+ * \brief Constructs a <i>k</i>d-tree instance.
+ * \param sim The simulator instance.
+ */
+- explicit KdTree(RVOSimulator *sim);
++ explicit KdTree();
+
+ /**
+ * \brief Builds an agent <i>k</i>d-tree.
+ */
+- void buildAgentTree();
++ void buildAgentTree(std::vector<Agent *> agents);
+
+ void buildAgentTreeRecursive(size_t begin, size_t end, size_t node);
+
+@@ -110,7 +113,6 @@ namespace RVO {
+
+ std::vector<Agent *> agents_;
+ std::vector<AgentTreeNode> agentTree_;
+- RVOSimulator *sim_;
+
+ friend class Agent;
+ friend class RVOSimulator;
+diff --git a/thirdparty/rvo2/Vector3.h b/thirdparty/rvo2/Vector3.h
+index 6c3223bb87..f44e311f29 100644
+--- a/thirdparty/rvo2/Vector3.h
++++ b/thirdparty/rvo2/Vector3.h
+@@ -41,7 +41,7 @@
+ #include <cstddef>
+ #include <ostream>
+
+-#include "Export.h"
++#define RVO3D_EXPORT
+
+ namespace RVO {
+ /**
+@@ -59,17 +59,6 @@ namespace RVO {
+ val_[2] = 0.0f;
+ }
+
+- /**
+- * \brief Constructs and initializes a three-dimensional vector from the specified three-dimensional vector.
+- * \param vector The three-dimensional vector containing the xyz-coordinates.
+- */
+- inline Vector3(const Vector3 &vector)
+- {
+- val_[0] = vector[0];
+- val_[1] = vector[1];
+- val_[2] = vector[2];
+- }
+-
+ /**
+ * \brief Constructs and initializes a three-dimensional vector from the specified three-element array.
+ * \param val The three-element array containing the xyz-coordinates.