summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2023-04-11 21:01:58 +0200
committerGitHub <noreply@github.com>2023-04-11 21:01:58 +0200
commit16a6bdd423aa85272837d0bc6b9e709febdb4ec0 (patch)
treea7f70f8ed81aec219e990c0b3f174dbd200ae793 /scene
parent4762303f182e65c5293db8d22a4ce88521eba445 (diff)
parent177be9bd37e3dfa4d591eea3bb8ab14a17d06007 (diff)
Merge pull request #75786 from YuriSizov/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 1st batch
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/audio_stream_player_2d.cpp6
-rw-r--r--scene/2d/audio_stream_player_2d.h3
-rw-r--r--scene/2d/navigation_agent_2d.cpp28
-rw-r--r--scene/2d/navigation_agent_2d.h12
-rw-r--r--scene/2d/navigation_obstacle_2d.cpp7
-rw-r--r--scene/2d/navigation_obstacle_2d.h2
-rw-r--r--scene/2d/remote_transform_2d.cpp61
-rw-r--r--scene/3d/navigation_agent_3d.cpp28
-rw-r--r--scene/3d/navigation_agent_3d.h12
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp7
-rw-r--r--scene/3d/navigation_obstacle_3d.h2
-rw-r--r--scene/gui/graph_edit.cpp6
-rw-r--r--scene/gui/graph_node.cpp2
-rw-r--r--scene/gui/texture_progress_bar.cpp49
-rw-r--r--scene/gui/texture_progress_bar.h2
-rw-r--r--scene/gui/view_panner.cpp7
-rw-r--r--scene/main/scene_tree.cpp4
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp30
-rw-r--r--scene/resources/text_paragraph.cpp20
19 files changed, 213 insertions, 75 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index c175edb6cb..466ffad951 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -68,7 +68,8 @@ void AudioStreamPlayer2D::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
// Update anything related to position first, if possible of course.
- if (setplay.get() > 0 || (active.is_set() && last_mix_count != AudioServer::get_singleton()->get_mix_count())) {
+ if (setplay.get() > 0 || (active.is_set() && last_mix_count != AudioServer::get_singleton()->get_mix_count()) || force_update_panning) {
+ force_update_panning = false;
_update_panning();
}
@@ -109,6 +110,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
}
}
+// Interacts with PhysicsServer2D, so can only be called during _physics_process
StringName AudioStreamPlayer2D::_get_actual_bus() {
Vector2 global_pos = get_global_position();
@@ -117,6 +119,7 @@ StringName AudioStreamPlayer2D::_get_actual_bus() {
ERR_FAIL_COND_V(world_2d.is_null(), SNAME("Master"));
PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space());
+ ERR_FAIL_COND_V(space_state == nullptr, SNAME("Master"));
PhysicsDirectSpaceState2D::ShapeResult sr[MAX_INTERSECT_AREAS];
PhysicsDirectSpaceState2D::PointParameters point_params;
@@ -142,6 +145,7 @@ StringName AudioStreamPlayer2D::_get_actual_bus() {
return default_bus;
}
+// Interacts with PhysicsServer2D, so can only be called during _physics_process
void AudioStreamPlayer2D::_update_panning() {
if (!active.is_set() || stream.is_null()) {
return;
diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h
index 79a026fed2..9b23fd3943 100644
--- a/scene/2d/audio_stream_player_2d.h
+++ b/scene/2d/audio_stream_player_2d.h
@@ -61,6 +61,7 @@ private:
Vector<AudioFrame> volume_vector;
uint64_t last_mix_count = -1;
+ bool force_update_panning = false;
float volume_db = 0.0;
float pitch_scale = 1.0;
@@ -75,7 +76,7 @@ private:
void _update_panning();
void _bus_layout_changed();
- static void _listener_changed_cb(void *self) { reinterpret_cast<AudioStreamPlayer2D *>(self)->_update_panning(); }
+ static void _listener_changed_cb(void *self) { reinterpret_cast<AudioStreamPlayer2D *>(self)->force_update_panning = true; }
uint32_t area_mask = 1;
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index 157318125b..d101cac4eb 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -71,6 +71,12 @@ void NavigationAgent2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationAgent2D::set_navigation_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationAgent2D::get_navigation_layer_value);
+ ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationAgent2D::set_pathfinding_algorithm);
+ ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationAgent2D::get_pathfinding_algorithm);
+
+ ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationAgent2D::set_path_postprocessing);
+ ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationAgent2D::get_path_postprocessing);
+
ClassDB::bind_method(D_METHOD("set_path_metadata_flags", "flags"), &NavigationAgent2D::set_path_metadata_flags);
ClassDB::bind_method(D_METHOD("get_path_metadata_flags"), &NavigationAgent2D::get_path_metadata_flags);
@@ -99,6 +105,8 @@ void NavigationAgent2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,or_greater,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "10,1000,1,or_greater,suffix:px"), "set_path_max_distance", "get_path_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered"), "set_path_postprocessing", "get_path_postprocessing");
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_path_metadata_flags", "get_path_metadata_flags");
ADD_GROUP("Avoidance", "");
@@ -328,6 +336,26 @@ bool NavigationAgent2D::get_navigation_layer_value(int p_layer_number) const {
return get_navigation_layers() & (1 << (p_layer_number - 1));
}
+void NavigationAgent2D::set_pathfinding_algorithm(const NavigationPathQueryParameters2D::PathfindingAlgorithm p_pathfinding_algorithm) {
+ if (pathfinding_algorithm == p_pathfinding_algorithm) {
+ return;
+ }
+
+ pathfinding_algorithm = p_pathfinding_algorithm;
+
+ navigation_query->set_pathfinding_algorithm(pathfinding_algorithm);
+}
+
+void NavigationAgent2D::set_path_postprocessing(const NavigationPathQueryParameters2D::PathPostProcessing p_path_postprocessing) {
+ if (path_postprocessing == p_path_postprocessing) {
+ return;
+ }
+
+ path_postprocessing = p_path_postprocessing;
+
+ navigation_query->set_path_postprocessing(path_postprocessing);
+}
+
void NavigationAgent2D::set_path_metadata_flags(BitField<NavigationPathQueryParameters2D::PathMetadataFlags> p_path_metadata_flags) {
if (path_metadata_flags == p_path_metadata_flags) {
return;
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 97c5d94483..b7febba89d 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -48,6 +48,8 @@ class NavigationAgent2D : public Node {
bool avoidance_enabled = false;
uint32_t navigation_layers = 1;
+ NavigationPathQueryParameters2D::PathfindingAlgorithm pathfinding_algorithm = NavigationPathQueryParameters2D::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR;
+ NavigationPathQueryParameters2D::PathPostProcessing path_postprocessing = NavigationPathQueryParameters2D::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL;
BitField<NavigationPathQueryParameters2D::PathMetadataFlags> path_metadata_flags = NavigationPathQueryParameters2D::PathMetadataFlags::PATH_METADATA_INCLUDE_ALL;
real_t path_desired_distance = 20.0;
@@ -112,6 +114,16 @@ public:
void set_navigation_layer_value(int p_layer_number, bool p_value);
bool get_navigation_layer_value(int p_layer_number) const;
+ void set_pathfinding_algorithm(const NavigationPathQueryParameters2D::PathfindingAlgorithm p_pathfinding_algorithm);
+ NavigationPathQueryParameters2D::PathfindingAlgorithm get_pathfinding_algorithm() const {
+ return pathfinding_algorithm;
+ }
+
+ void set_path_postprocessing(const NavigationPathQueryParameters2D::PathPostProcessing p_path_postprocessing);
+ NavigationPathQueryParameters2D::PathPostProcessing get_path_postprocessing() const {
+ return path_postprocessing;
+ }
+
void set_path_metadata_flags(BitField<NavigationPathQueryParameters2D::PathMetadataFlags> p_flags);
BitField<NavigationPathQueryParameters2D::PathMetadataFlags> get_path_metadata_flags() const {
return path_metadata_flags;
diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp
index d7ef77e25b..2366cb696e 100644
--- a/scene/2d/navigation_obstacle_2d.cpp
+++ b/scene/2d/navigation_obstacle_2d.cpp
@@ -196,13 +196,20 @@ void NavigationObstacle2D::set_agent_parent(Node *p_agent_parent) {
} else {
NavigationServer2D::get_singleton()->agent_set_map(get_rid(), parent_node2d->get_world_2d()->get_navigation_map());
}
+ // Need to register Callback as obstacle requires a valid Callback to be added to avoidance simulation.
+ NavigationServer2D::get_singleton()->agent_set_callback(get_rid(), callable_mp(this, &NavigationObstacle2D::_avoidance_done));
reevaluate_agent_radius();
} else {
parent_node2d = nullptr;
NavigationServer2D::get_singleton()->agent_set_map(get_rid(), RID());
+ NavigationServer2D::get_singleton()->agent_set_callback(agent, Callable());
}
}
+void NavigationObstacle2D::_avoidance_done(Vector3 p_new_velocity) {
+ // Dummy function as obstacle requires a valid Callback to be added to avoidance simulation.
+}
+
void NavigationObstacle2D::set_navigation_map(RID p_navigation_map) {
if (map_override == p_navigation_map) {
return;
diff --git a/scene/2d/navigation_obstacle_2d.h b/scene/2d/navigation_obstacle_2d.h
index 12ddcaf219..f856c481b0 100644
--- a/scene/2d/navigation_obstacle_2d.h
+++ b/scene/2d/navigation_obstacle_2d.h
@@ -75,6 +75,8 @@ public:
PackedStringArray get_configuration_warnings() const override;
+ void _avoidance_done(Vector3 p_new_velocity); // Dummy
+
private:
void initialize_agent();
void reevaluate_agent_radius();
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index c6730f7ab2..cd0d9f3750 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -60,54 +60,51 @@ void RemoteTransform2D::_update_remote() {
return;
}
+ if (!(update_remote_position || update_remote_rotation || update_remote_scale)) {
+ return; // The transform data of the RemoteTransform2D is not used at all.
+ }
+
//todo make faster
if (use_global_coordinates) {
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_global_transform(get_global_transform());
- } else {
- Transform2D n_trans = n->get_global_transform();
- Transform2D our_trans = get_global_transform();
- Vector2 n_scale = n->get_scale();
+ return;
+ }
- if (!update_remote_position) {
- our_trans.set_origin(n_trans.get_origin());
- }
- if (!update_remote_rotation) {
- our_trans.set_rotation(n_trans.get_rotation());
- }
+ Transform2D n_trans = n->get_global_transform();
+ Transform2D our_trans = get_global_transform();
- n->set_global_transform(our_trans);
+ // There are more steps in the operation of set_rotation, so avoid calling it.
+ Transform2D trans = update_remote_rotation ? our_trans : n_trans;
- if (update_remote_scale) {
- n->set_scale(get_global_scale());
- } else {
- n->set_scale(n_scale);
- }
+ if (update_remote_rotation ^ update_remote_position) {
+ trans.set_origin(update_remote_position ? our_trans.get_origin() : n_trans.get_origin());
+ }
+ if (update_remote_rotation ^ update_remote_scale) {
+ trans.set_scale(update_remote_scale ? our_trans.get_scale() : n_trans.get_scale());
}
+ n->set_global_transform(trans);
} else {
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_transform(get_transform());
- } else {
- Transform2D n_trans = n->get_transform();
- Transform2D our_trans = get_transform();
- Vector2 n_scale = n->get_scale();
+ return;
+ }
- if (!update_remote_position) {
- our_trans.set_origin(n_trans.get_origin());
- }
- if (!update_remote_rotation) {
- our_trans.set_rotation(n_trans.get_rotation());
- }
+ Transform2D n_trans = n->get_transform();
+ Transform2D our_trans = get_transform();
- n->set_transform(our_trans);
+ // There are more steps in the operation of set_rotation, so avoid calling it.
+ Transform2D trans = update_remote_rotation ? our_trans : n_trans;
- if (update_remote_scale) {
- n->set_scale(get_scale());
- } else {
- n->set_scale(n_scale);
- }
+ if (update_remote_rotation ^ update_remote_position) {
+ trans.set_origin(update_remote_position ? our_trans.get_origin() : n_trans.get_origin());
+ }
+ if (update_remote_rotation ^ update_remote_scale) {
+ trans.set_scale(update_remote_scale ? our_trans.get_scale() : n_trans.get_scale());
}
+
+ n->set_transform(trans);
}
}
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index 3730070b16..7d404ffa07 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -75,6 +75,12 @@ void NavigationAgent3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationAgent3D::set_navigation_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationAgent3D::get_navigation_layer_value);
+ ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationAgent3D::set_pathfinding_algorithm);
+ ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationAgent3D::get_pathfinding_algorithm);
+
+ ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationAgent3D::set_path_postprocessing);
+ ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationAgent3D::get_path_postprocessing);
+
ClassDB::bind_method(D_METHOD("set_path_metadata_flags", "flags"), &NavigationAgent3D::set_path_metadata_flags);
ClassDB::bind_method(D_METHOD("get_path_metadata_flags"), &NavigationAgent3D::get_path_metadata_flags);
@@ -104,6 +110,8 @@ void NavigationAgent3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "agent_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01,or_greater,suffix:m"), "set_agent_height_offset", "get_agent_height_offset");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "0.01,100,0.1,or_greater,suffix:m"), "set_path_max_distance", "get_path_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered"), "set_path_postprocessing", "get_path_postprocessing");
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_path_metadata_flags", "get_path_metadata_flags");
ADD_GROUP("Avoidance", "");
@@ -335,6 +343,26 @@ bool NavigationAgent3D::get_navigation_layer_value(int p_layer_number) const {
return get_navigation_layers() & (1 << (p_layer_number - 1));
}
+void NavigationAgent3D::set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm) {
+ if (pathfinding_algorithm == p_pathfinding_algorithm) {
+ return;
+ }
+
+ pathfinding_algorithm = p_pathfinding_algorithm;
+
+ navigation_query->set_pathfinding_algorithm(pathfinding_algorithm);
+}
+
+void NavigationAgent3D::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {
+ if (path_postprocessing == p_path_postprocessing) {
+ return;
+ }
+
+ path_postprocessing = p_path_postprocessing;
+
+ navigation_query->set_path_postprocessing(path_postprocessing);
+}
+
void NavigationAgent3D::set_path_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_path_metadata_flags) {
if (path_metadata_flags == p_path_metadata_flags) {
return;
diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h
index cde826ed5c..16d702f9a5 100644
--- a/scene/3d/navigation_agent_3d.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -48,6 +48,8 @@ class NavigationAgent3D : public Node {
bool avoidance_enabled = false;
uint32_t navigation_layers = 1;
+ NavigationPathQueryParameters3D::PathfindingAlgorithm pathfinding_algorithm = NavigationPathQueryParameters3D::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR;
+ NavigationPathQueryParameters3D::PathPostProcessing path_postprocessing = NavigationPathQueryParameters3D::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL;
BitField<NavigationPathQueryParameters3D::PathMetadataFlags> path_metadata_flags = NavigationPathQueryParameters3D::PathMetadataFlags::PATH_METADATA_INCLUDE_ALL;
real_t path_desired_distance = 1.0;
@@ -116,6 +118,16 @@ public:
void set_navigation_layer_value(int p_layer_number, bool p_value);
bool get_navigation_layer_value(int p_layer_number) const;
+ void set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm);
+ NavigationPathQueryParameters3D::PathfindingAlgorithm get_pathfinding_algorithm() const {
+ return pathfinding_algorithm;
+ }
+
+ void set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing);
+ NavigationPathQueryParameters3D::PathPostProcessing get_path_postprocessing() const {
+ return path_postprocessing;
+ }
+
void set_path_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags);
BitField<NavigationPathQueryParameters3D::PathMetadataFlags> get_path_metadata_flags() const {
return path_metadata_flags;
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index 85b3c164cc..14d93fb0e0 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -203,13 +203,20 @@ void NavigationObstacle3D::set_agent_parent(Node *p_agent_parent) {
} else {
NavigationServer3D::get_singleton()->agent_set_map(get_rid(), parent_node3d->get_world_3d()->get_navigation_map());
}
+ // Need to register Callback as obstacle requires a valid Callback to be added to avoidance simulation.
+ NavigationServer3D::get_singleton()->agent_set_callback(get_rid(), callable_mp(this, &NavigationObstacle3D::_avoidance_done));
reevaluate_agent_radius();
} else {
parent_node3d = nullptr;
NavigationServer3D::get_singleton()->agent_set_map(get_rid(), RID());
+ NavigationServer3D::get_singleton()->agent_set_callback(agent, Callable());
}
}
+void NavigationObstacle3D::_avoidance_done(Vector3 p_new_velocity) {
+ // Dummy function as obstacle requires a valid Callback to be added to avoidance simulation.
+}
+
void NavigationObstacle3D::set_navigation_map(RID p_navigation_map) {
if (map_override == p_navigation_map) {
return;
diff --git a/scene/3d/navigation_obstacle_3d.h b/scene/3d/navigation_obstacle_3d.h
index 416b32c026..c5a9d737f6 100644
--- a/scene/3d/navigation_obstacle_3d.h
+++ b/scene/3d/navigation_obstacle_3d.h
@@ -74,6 +74,8 @@ public:
PackedStringArray get_configuration_warnings() const override;
+ void _avoidance_done(Vector3 p_new_velocity); // Dummy
+
private:
void initialize_agent();
void reevaluate_agent_radius();
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 9c0c25b1ac..946e8a2ad5 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -533,7 +533,6 @@ void GraphEdit::_notification(int p_what) {
void GraphEdit::_update_comment_enclosed_nodes_list(GraphNode *p_node, HashMap<StringName, Vector<GraphNode *>> &p_comment_enclosed_nodes) {
Rect2 comment_node_rect = p_node->get_rect();
- comment_node_rect.size *= zoom;
Vector<GraphNode *> enclosed_nodes;
for (int i = 0; i < get_child_count(); i++) {
@@ -543,7 +542,6 @@ void GraphEdit::_update_comment_enclosed_nodes_list(GraphNode *p_node, HashMap<S
}
Rect2 node_rect = gn->get_rect();
- node_rect.size *= zoom;
bool included = comment_node_rect.encloses(node_rect);
if (included) {
@@ -806,7 +804,6 @@ bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &mpos
}
Rect2 control_rect = p_control->get_rect();
- control_rect.size *= zoom;
control_rect.position *= zoom;
control_rect.position += p_offset;
@@ -873,7 +870,6 @@ bool GraphEdit::is_in_port_hotzone(const Vector2 &p_pos, const Vector2 &p_mouse_
continue;
}
Rect2 child_rect = child->get_rect();
- child_rect.size *= zoom;
if (child_rect.has_point(p_mouse_pos * zoom)) {
for (int j = 0; j < child->get_child_count(); j++) {
@@ -1169,7 +1165,6 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
}
Rect2 r = gn->get_rect();
- r.size *= zoom;
bool in_box = r.intersects(box_selecting_rect);
if (in_box) {
@@ -1215,7 +1210,6 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
if (gn) {
Rect2 r = gn->get_rect();
- r.size *= zoom;
if (r.has_point(mb->get_position())) {
gn->set_selected(false);
}
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 7d9cdd62ff..8b2d462d85 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -664,7 +664,7 @@ Size2 GraphNode::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c) {
+ if (!c || !c->is_visible()) {
continue;
}
if (c->is_set_as_top_level()) {
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp
index 2526ee8215..2464e005ee 100644
--- a/scene/gui/texture_progress_bar.cpp
+++ b/scene/gui/texture_progress_bar.cpp
@@ -31,15 +31,10 @@
#include "texture_progress_bar.h"
#include "core/config/engine.h"
+#include "core/core_string_names.h"
void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) {
- if (under == p_texture) {
- return;
- }
-
- under = p_texture;
- queue_redraw();
- update_minimum_size();
+ _set_texture(&under, p_texture);
}
Ref<Texture2D> TextureProgressBar::get_under_texture() const {
@@ -47,15 +42,7 @@ Ref<Texture2D> TextureProgressBar::get_under_texture() const {
}
void TextureProgressBar::set_over_texture(const Ref<Texture2D> &p_texture) {
- if (over == p_texture) {
- return;
- }
-
- over = p_texture;
- queue_redraw();
- if (under.is_null()) {
- update_minimum_size();
- }
+ _set_texture(&over, p_texture);
}
Ref<Texture2D> TextureProgressBar::get_over_texture() const {
@@ -108,13 +95,7 @@ Size2 TextureProgressBar::get_minimum_size() const {
}
void TextureProgressBar::set_progress_texture(const Ref<Texture2D> &p_texture) {
- if (progress == p_texture) {
- return;
- }
-
- progress = p_texture;
- queue_redraw();
- update_minimum_size();
+ _set_texture(&progress, p_texture);
}
Ref<Texture2D> TextureProgressBar::get_progress_texture() const {
@@ -173,6 +154,28 @@ Color TextureProgressBar::get_tint_over() const {
return tint_over;
}
+void TextureProgressBar::_set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture) {
+ DEV_ASSERT(p_destination);
+ Ref<Texture2D> &destination = *p_destination;
+ if (destination == p_texture) {
+ return;
+ }
+ if (destination.is_valid()) {
+ destination->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureProgressBar::_texture_changed));
+ }
+ destination = p_texture;
+ if (destination.is_valid()) {
+ // Pass `CONNECT_REFERENCE_COUNTED` to avoid early disconnect in case the same texture is assigned to different "slots".
+ destination->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureProgressBar::_texture_changed), CONNECT_REFERENCE_COUNTED);
+ }
+ _texture_changed();
+}
+
+void TextureProgressBar::_texture_changed() {
+ update_minimum_size();
+ queue_redraw();
+}
+
Point2 TextureProgressBar::unit_val_to_uv(float val) {
if (progress.is_null()) {
return Point2();
diff --git a/scene/gui/texture_progress_bar.h b/scene/gui/texture_progress_bar.h
index 53ec6fa2ae..5999aa986b 100644
--- a/scene/gui/texture_progress_bar.h
+++ b/scene/gui/texture_progress_bar.h
@@ -113,6 +113,8 @@ private:
Color tint_progress = Color(1, 1, 1);
Color tint_over = Color(1, 1, 1);
+ void _set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture);
+ void _texture_changed();
Point2 unit_val_to_uv(float val);
Point2 get_relative_center();
void draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate);
diff --git a/scene/gui/view_panner.cpp b/scene/gui/view_panner.cpp
index 51af886709..6d1905f111 100644
--- a/scene/gui/view_panner.cpp
+++ b/scene/gui/view_panner.cpp
@@ -130,7 +130,12 @@ bool ViewPanner::gui_input(const Ref<InputEvent> &p_event, Rect2 p_canvas_rect)
Ref<InputEventScreenDrag> screen_drag = p_event;
if (screen_drag.is_valid()) {
- callback_helper(pan_callback, varray(screen_drag->get_relative(), p_event));
+ if (Input::get_singleton()->is_emulating_mouse_from_touch() || Input::get_singleton()->is_emulating_touch_from_mouse()) {
+ // This set of events also generates/is generated by
+ // InputEventMouseButton/InputEventMouseMotion events which will be processed instead.
+ } else {
+ callback_helper(pan_callback, varray(screen_drag->get_relative(), p_event));
+ }
}
Ref<InputEventKey> k = p_event;
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index fbe11c94d1..9327102cc8 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1408,6 +1408,10 @@ SceneTree::SceneTree() {
root->set_name("root");
root->set_title(GLOBAL_GET("application/config/name"));
+ if (Engine::get_singleton()->is_editor_hint()) {
+ root->set_wrap_controls(true);
+ }
+
#ifndef _3D_DISABLED
if (!root->get_world_3d().is_valid()) {
root->set_world_3d(Ref<World3D>(memnew(World3D)));
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 7f19dd63e6..0d9e570149 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -38,11 +38,41 @@ bool ConvexPolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, dou
return Geometry2D::is_point_in_polygon(p_point, points);
}
+#ifdef DEBUG_ENABLED
+// Check if point p3 is to the left of [p1, p2] segment or on it.
+bool left_test(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3) {
+ Vector2 p12 = p2 - p1;
+ Vector2 p13 = p3 - p1;
+ // If the value of the cross product is positive or zero; p3 is to the left or on the segment, respectively.
+ return p12.cross(p13) >= 0;
+}
+
+bool is_convex(const Vector<Vector2> &p_points) {
+ // Pre-condition: Polygon is in counter-clockwise order.
+ int polygon_size = p_points.size();
+ for (int i = 0; i < polygon_size && polygon_size > 3; i++) {
+ int j = (i + 1) % polygon_size;
+ int k = (j + 1) % polygon_size;
+ // If any consecutive three points fail left-test, then there is a concavity.
+ if (!left_test(p_points[i], p_points[j], p_points[k])) {
+ return false;
+ }
+ }
+
+ return true;
+}
+#endif
+
void ConvexPolygonShape2D::_update_shape() {
Vector<Vector2> final_points = points;
if (Geometry2D::is_polygon_clockwise(final_points)) { //needs to be counter clockwise
final_points.reverse();
}
+#ifdef DEBUG_ENABLED
+ if (!is_convex(final_points)) {
+ WARN_PRINT("Concave polygon is assigned to ConvexPolygonShape2D.");
+ }
+#endif
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), final_points);
emit_changed();
}
diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp
index 729063245c..191b71f301 100644
--- a/scene/resources/text_paragraph.cpp
+++ b/scene/resources/text_paragraph.cpp
@@ -233,27 +233,27 @@ void TextParagraph::_shape_lines() {
}
if (alignment == HORIZONTAL_ALIGNMENT_FILL) {
for (int i = 0; i < (int)lines_rid.size(); i++) {
+ float line_w = (i <= dropcap_lines) ? (width - h_offset) : width;
if (i < visible_lines - 1 || (int)lines_rid.size() == 1) {
- TS->shaped_text_fit_to_width(lines_rid[i], width, jst_flags);
+ TS->shaped_text_fit_to_width(lines_rid[i], line_w, jst_flags);
} else if (i == (visible_lines - 1)) {
- TS->shaped_text_overrun_trim_to_width(lines_rid[visible_lines - 1], width, overrun_flags);
+ TS->shaped_text_overrun_trim_to_width(lines_rid[visible_lines - 1], line_w, overrun_flags);
}
}
-
} else if (lines_hidden) {
- TS->shaped_text_overrun_trim_to_width(lines_rid[visible_lines - 1], width, overrun_flags);
+ TS->shaped_text_overrun_trim_to_width(lines_rid[visible_lines - 1], (visible_lines - 1 <= dropcap_lines) ? (width - h_offset) : width, overrun_flags);
}
-
} else {
// Autowrap disabled.
- for (const RID &line_rid : lines_rid) {
+ for (int i = 0; i < (int)lines_rid.size(); i++) {
+ float line_w = (i <= dropcap_lines) ? (width - h_offset) : width;
if (alignment == HORIZONTAL_ALIGNMENT_FILL) {
- TS->shaped_text_fit_to_width(line_rid, width, jst_flags);
+ TS->shaped_text_fit_to_width(lines_rid[i], line_w, jst_flags);
overrun_flags.set_flag(TextServer::OVERRUN_JUSTIFICATION_AWARE);
- TS->shaped_text_overrun_trim_to_width(line_rid, width, overrun_flags);
- TS->shaped_text_fit_to_width(line_rid, width, jst_flags | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
+ TS->shaped_text_overrun_trim_to_width(lines_rid[i], line_w, overrun_flags);
+ TS->shaped_text_fit_to_width(lines_rid[i], line_w, jst_flags | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
} else {
- TS->shaped_text_overrun_trim_to_width(line_rid, width, overrun_flags);
+ TS->shaped_text_overrun_trim_to_width(lines_rid[i], line_w, overrun_flags);
}
}
}