summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/variant/variant.h4
-rw-r--r--doc/classes/AnimationNodeOneShot.xml8
-rw-r--r--doc/classes/AnimationNodeStateMachinePlayback.xml3
-rw-r--r--doc/classes/AnimationNodeTransition.xml9
-rw-r--r--doc/classes/Font.xml3
-rw-r--r--doc/classes/PhysicsDirectSpaceState3D.xml2
-rw-r--r--platform/android/android_input_handler.cpp28
-rw-r--r--platform/android/android_input_handler.h6
-rw-r--r--platform/linuxbsd/detect.py2
-rw-r--r--scene/3d/label_3d.cpp12
-rw-r--r--scene/animation/animation_blend_tree.cpp41
-rw-r--r--scene/gui/color_picker.cpp16
-rw-r--r--scene/gui/label.cpp124
-rw-r--r--scene/gui/label.h3
-rw-r--r--scene/gui/popup_menu.cpp1
-rw-r--r--scene/resources/primitive_meshes.cpp14
-rw-r--r--scene/resources/text_line.cpp5
-rw-r--r--scene/resources/text_paragraph.cpp12
-rw-r--r--servers/physics_server_3d.cpp6
-rw-r--r--servers/physics_server_3d.h2
20 files changed, 200 insertions, 101 deletions
diff --git a/core/variant/variant.h b/core/variant/variant.h
index b2f31a6d57..f694e59051 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -346,6 +346,10 @@ public:
bool is_one() const;
bool is_null() const;
+ // Make sure Variant is not implicitly cast when accessing it with bracket notation (GH-49469).
+ Variant &operator[](const Variant &p_key) = delete;
+ const Variant &operator[](const Variant &p_key) const = delete;
+
operator bool() const;
operator signed int() const;
operator unsigned int() const; // this is the real one
diff --git a/doc/classes/AnimationNodeOneShot.xml b/doc/classes/AnimationNodeOneShot.xml
index f8d26ceba1..713296069d 100644
--- a/doc/classes/AnimationNodeOneShot.xml
+++ b/doc/classes/AnimationNodeOneShot.xml
@@ -17,6 +17,11 @@
animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
# Alternative syntax (same result as above).
animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT
+
+ # Get current state (read-only).
+ animation_tree.get("parameters/OneShot/active"))
+ # Alternative syntax (same result as above).
+ animation_tree["parameters/OneShot/active"]
[/gdscript]
[csharp]
// Play child animation connected to "shot" port.
@@ -24,6 +29,9 @@
// Abort child animation connected to "shot" port.
animationTree.Set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT);
+
+ // Get current state (read-only).
+ animationTree.Get("parameters/OneShot/active");
[/csharp]
[/codeblocks]
</description>
diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml
index 17a946bb3e..4772c1d819 100644
--- a/doc/classes/AnimationNodeStateMachinePlayback.xml
+++ b/doc/classes/AnimationNodeStateMachinePlayback.xml
@@ -24,12 +24,15 @@
<method name="get_current_length" qualifiers="const">
<return type="float" />
<description>
+ Returns the current state length.
+ [b]Note:[/b] It is possible that any [AnimationRootNode] can be nodes as well as animations. This means that there can be multiple animations within a single state. Which animation length has priority depends on the nodes connected inside it. Also, if a transition does not reset, the remaining length at that point will be returned.
</description>
</method>
<method name="get_current_node" qualifiers="const">
<return type="StringName" />
<description>
Returns the currently playing animation state.
+ [b]Note:[/b] When using a cross-fade, the current state changes to the next state immediately after the cross-fade begins.
</description>
</method>
<method name="get_current_play_position" qualifiers="const">
diff --git a/doc/classes/AnimationNodeTransition.xml b/doc/classes/AnimationNodeTransition.xml
index 7e4d87bd2c..4eeaf15b53 100644
--- a/doc/classes/AnimationNodeTransition.xml
+++ b/doc/classes/AnimationNodeTransition.xml
@@ -6,6 +6,7 @@
<description>
Simple state machine for cases which don't require a more advanced [AnimationNodeStateMachine]. Animations can be connected to the inputs and transition times can be specified.
After setting the request and changing the animation playback, the transition node automatically clears the request on the next process frame by setting its [code]transition_request[/code] value to empty.
+ [b]Note:[/b] When using a cross-fade, [code]current_state[/code] and [code]current_index[/code] change to the next state immediately after the cross-fade begins.
[codeblocks]
[gdscript]
# Play child animation connected to "state_2" port.
@@ -13,12 +14,12 @@
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/transition_request"] = "state_2"
- # Get current state name.
+ # Get current state name (read-only).
animation_tree.get("parameters/Transition/current_state")
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/current_state"]
- # Get current state index.
+ # Get current state index (read-only).
animation_tree.get("parameters/Transition/current_index"))
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/current_index"]
@@ -27,10 +28,10 @@
// Play child animation connected to "state_2" port.
animationTree.Set("parameters/Transition/transition_request", "state_2");
- // Get current state name.
+ // Get current state name (read-only).
animationTree.Get("parameters/Transition/current_state");
- // Get current state index.
+ // Get current state index (read-only).
animationTree.Get("parameters/Transition/current_index");
[/csharp]
[/codeblocks]
diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml
index 761e75339a..2f1c68c322 100644
--- a/doc/classes/Font.xml
+++ b/doc/classes/Font.xml
@@ -238,7 +238,7 @@
<param index="5" name="direction" type="int" enum="TextServer.Direction" default="0" />
<param index="6" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
- Returns the size of a bounding box of a single-line string, taking kerning and advance into account. See also [method get_multiline_string_size] and [method draw_string].
+ Returns the size of a bounding box of a single-line string, taking kerning, advance and subpixel positioning into account. See also [method get_multiline_string_size] and [method draw_string].
For example, to get the string size as displayed by a single-line Label, use:
[codeblocks]
[gdscript]
@@ -249,6 +249,7 @@
Vector2 stringSize = label.GetThemeFont("font").GetStringSize(label.Text, HorizontalAlignment.Left, -1, label.GetThemeFontSize("font_size"));
[/csharp]
[/codeblocks]
+ [b]Note:[/b] Since kerning, advance and subpixel positioning are taken into account by [method get_string_size], using separate [method get_string_size] calls on substrings of a string then adding the results together will return a different result compared to using a single [method get_string_size] call on the full string.
[b]Note:[/b] Real height of the string is context-dependent and can be significantly different from the value returned by [method get_height].
</description>
</method>
diff --git a/doc/classes/PhysicsDirectSpaceState3D.xml b/doc/classes/PhysicsDirectSpaceState3D.xml
index cc1cf8a323..f7bc74d9ad 100644
--- a/doc/classes/PhysicsDirectSpaceState3D.xml
+++ b/doc/classes/PhysicsDirectSpaceState3D.xml
@@ -21,7 +21,7 @@
</description>
</method>
<method name="collide_shape">
- <return type="PackedVector2Array[]" />
+ <return type="PackedVector3Array[]" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />
<param index="1" name="max_results" type="int" default="32" />
<description>
diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp
index 17903b3965..6d34e28182 100644
--- a/platform/android/android_input_handler.cpp
+++ b/platform/android/android_input_handler.cpp
@@ -129,13 +129,22 @@ void AndroidInputHandler::process_key_event(int p_physical_keycode, int p_unicod
Input::get_singleton()->parse_input_event(ev);
}
-void AndroidInputHandler::_parse_all_touch(bool p_pressed, bool p_double_tap) {
+void AndroidInputHandler::_cancel_all_touch() {
+ _parse_all_touch(false, false, true);
+ touch.clear();
+}
+
+void AndroidInputHandler::_parse_all_touch(bool p_pressed, bool p_double_tap, bool reset_index) {
if (touch.size()) {
//end all if exist
for (int i = 0; i < touch.size(); i++) {
Ref<InputEventScreenTouch> ev;
ev.instantiate();
- ev->set_index(touch[i].id);
+ if (reset_index) {
+ ev->set_index(-1);
+ } else {
+ ev->set_index(touch[i].id);
+ }
ev->set_pressed(p_pressed);
ev->set_position(touch[i].pos);
ev->set_double_tap(p_double_tap);
@@ -196,7 +205,9 @@ void AndroidInputHandler::process_touch_event(int p_event, int p_pointer, const
}
} break;
- case AMOTION_EVENT_ACTION_CANCEL:
+ case AMOTION_EVENT_ACTION_CANCEL: {
+ _cancel_all_touch();
+ } break;
case AMOTION_EVENT_ACTION_UP: { //release
_release_all_touch();
} break;
@@ -236,6 +247,12 @@ void AndroidInputHandler::process_touch_event(int p_event, int p_pointer, const
}
}
+void AndroidInputHandler::_cancel_mouse_event_info(bool p_source_mouse_relative) {
+ buttons_state = BitField<MouseButtonMask>();
+ _parse_mouse_event_info(BitField<MouseButtonMask>(), false, false, p_source_mouse_relative);
+ mouse_event_info.valid = false;
+}
+
void AndroidInputHandler::_parse_mouse_event_info(BitField<MouseButtonMask> event_buttons_mask, bool p_pressed, bool p_double_click, bool p_source_mouse_relative) {
if (!mouse_event_info.valid) {
return;
@@ -296,8 +313,11 @@ void AndroidInputHandler::process_mouse_event(int p_event_action, int p_event_an
_parse_mouse_event_info(event_buttons_mask, true, p_double_click, p_source_mouse_relative);
} break;
+ case AMOTION_EVENT_ACTION_CANCEL: {
+ _cancel_mouse_event_info(p_source_mouse_relative);
+ } break;
+
case AMOTION_EVENT_ACTION_UP:
- case AMOTION_EVENT_ACTION_CANCEL:
case AMOTION_EVENT_ACTION_BUTTON_RELEASE: {
_release_mouse_event_info(p_source_mouse_relative);
} break;
diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h
index 6e53dcfc89..a56b6aa6c4 100644
--- a/platform/android/android_input_handler.h
+++ b/platform/android/android_input_handler.h
@@ -87,10 +87,14 @@ private:
void _release_mouse_event_info(bool p_source_mouse_relative = false);
- void _parse_all_touch(bool p_pressed, bool p_double_tap);
+ void _cancel_mouse_event_info(bool p_source_mouse_relative = false);
+
+ void _parse_all_touch(bool p_pressed, bool p_double_tap, bool reset_index = false);
void _release_all_touch();
+ void _cancel_all_touch();
+
public:
void process_mouse_event(int p_event_action, int p_event_android_buttons_mask, Point2 p_event_pos, Vector2 p_delta, bool p_double_click, bool p_source_mouse_relative);
void process_touch_event(int p_event, int p_pointer, const Vector<TouchPos> &p_points, bool p_double_tap);
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 36e149f2b4..bae5a98aee 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -346,7 +346,7 @@ def configure(env: "Environment"):
gnu_ld_version = re.search("^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE)
if not gnu_ld_version:
print(
- "Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld, not gold or LLD."
+ "Warning: Creating export template binaries enabled for PCK embedding is currently only supported with GNU ld, not gold, LLD or mold."
)
else:
if float(gnu_ld_version.group(1)) >= 2.30:
diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp
index b39ca43d2e..5fc36abb76 100644
--- a/scene/3d/label_3d.cpp
+++ b/scene/3d/label_3d.cpp
@@ -442,6 +442,18 @@ void Label3D::_generate_glyph_surfaces(const Glyph &p_glyph, Vector2 &r_offset,
}
void Label3D::_shape() {
+ // When a shaped text is invalidated by an external source, we want to reshape it.
+ if (!TS->shaped_text_is_ready(text_rid)) {
+ dirty_text = true;
+ }
+
+ for (const RID &line_rid : lines_rid) {
+ if (!TS->shaped_text_is_ready(line_rid)) {
+ dirty_lines = true;
+ break;
+ }
+ }
+
// Clear mesh.
RS::get_singleton()->mesh_clear(mesh);
aabb = AABB();
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 5e75bd7722..d3207c1a3d 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -350,10 +350,11 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_is_exter
set_parameter(active, true);
}
- real_t blend;
- bool use_blend = fade_in > 0;
+ real_t blend = 1.0;
+ bool use_blend = sync;
if (cur_time < fade_in) {
- if (use_blend) {
+ if (fade_in > 0) {
+ use_blend = true;
blend = cur_time / fade_in;
} else {
blend = 0; // Should not happen.
@@ -365,15 +366,13 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_is_exter
} else {
blend = 0;
}
- } else {
- blend = 1.0;
}
double main_rem = 0.0;
if (mix == MIX_MODE_ADD) {
main_rem = blend_input(0, p_time, p_seek, p_is_external_seeking, 1.0, FILTER_IGNORE, sync);
- } else if (use_blend) {
- main_rem = blend_input(0, p_time, p_seek, p_is_external_seeking, 1.0 - blend, FILTER_BLEND, sync); // Unlike below, processing this edge is a corner case.
+ } else {
+ main_rem = blend_input(0, p_time, use_blend && p_seek, p_is_external_seeking, 1.0 - blend, FILTER_BLEND, sync); // Unlike below, processing this edge is a corner case.
}
double os_rem = blend_input(1, os_seek ? cur_time : p_time, os_seek, p_is_external_seeking, Math::is_zero_approx(blend) ? CMP_EPSILON : blend, FILTER_PASS, true); // Blend values must be more than CMP_EPSILON to process discrete keys in edge.
@@ -920,29 +919,31 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
} else { // Cross-fading from prev to current.
- bool use_blend = xfade_time > 0;
- real_t blend = !use_blend ? 0 : (cur_prev_xfading / xfade_time);
- if (xfade_curve.is_valid()) {
- blend = xfade_curve->sample(blend);
+ real_t blend = 0.0;
+ real_t blend_inv = 1.0;
+ bool use_blend = sync;
+ if (xfade_time > 0) {
+ use_blend = true;
+ blend = cur_prev_xfading / xfade_time;
+ if (xfade_curve.is_valid()) {
+ blend = xfade_curve->sample(blend);
+ }
+ blend_inv = 1.0 - blend;
+ blend = Math::is_zero_approx(blend) ? CMP_EPSILON : blend;
+ blend_inv = Math::is_zero_approx(blend_inv) ? CMP_EPSILON : blend_inv;
}
// Blend values must be more than CMP_EPSILON to process discrete keys in edge.
- real_t blend_inv = 1.0 - blend;
if (input_data[cur_current_index].reset && !p_seek && switched) { // Just switched, seek to start of current.
- rem = blend_input(cur_current_index, 0, true, p_is_external_seeking, Math::is_zero_approx(blend_inv) ? CMP_EPSILON : blend_inv, FILTER_IGNORE, true);
+ rem = blend_input(cur_current_index, 0, true, p_is_external_seeking, blend_inv, FILTER_IGNORE, true);
} else {
- rem = blend_input(cur_current_index, p_time, p_seek, p_is_external_seeking, Math::is_zero_approx(blend_inv) ? CMP_EPSILON : blend_inv, FILTER_IGNORE, true);
+ rem = blend_input(cur_current_index, p_time, p_seek, p_is_external_seeking, blend_inv, FILTER_IGNORE, true);
}
+ blend_input(cur_prev_index, p_time, use_blend && p_seek, p_is_external_seeking, blend, FILTER_IGNORE, true);
if (p_seek) {
- if (use_blend) {
- blend_input(cur_prev_index, p_time, true, p_is_external_seeking, Math::is_zero_approx(blend) ? CMP_EPSILON : blend, FILTER_IGNORE, true);
- }
cur_time = p_time;
} else {
- if (use_blend) {
- blend_input(cur_prev_index, p_time, false, p_is_external_seeking, Math::is_zero_approx(blend) ? CMP_EPSILON : blend, FILTER_IGNORE, true);
- }
cur_time += p_time;
cur_prev_xfading -= p_time;
if (cur_prev_xfading < 0) {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index da29bc823f..0b0698188c 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -1197,11 +1197,11 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
}
if (!spinning) {
- real_t x = CLAMP(bev->get_position().x, corner_x, c->get_size().x - corner_x);
- real_t y = CLAMP(bev->get_position().y, corner_x, c->get_size().y - corner_y);
+ real_t x = CLAMP(bev->get_position().x - corner_x, 0, real_size.x);
+ real_t y = CLAMP(bev->get_position().y - corner_y, 0, real_size.y);
- s = (x - c->get_position().x - corner_x) / real_size.x;
- v = 1.0 - (y - c->get_position().y - corner_y) / real_size.y;
+ s = x / real_size.x;
+ v = 1.0 - y / real_size.y;
}
}
@@ -1250,11 +1250,11 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
real_t corner_y = (c == wheel_uv) ? center.y - Math_SQRT12 * c->get_size().height * 0.42 : 0;
Size2 real_size(c->get_size().x - corner_x * 2, c->get_size().y - corner_y * 2);
- real_t x = CLAMP(mev->get_position().x, corner_x, c->get_size().x - corner_x);
- real_t y = CLAMP(mev->get_position().y, corner_x, c->get_size().y - corner_y);
+ real_t x = CLAMP(mev->get_position().x - corner_x, 0, real_size.x);
+ real_t y = CLAMP(mev->get_position().y - corner_y, 0, real_size.y);
- s = (x - corner_x) / real_size.x;
- v = 1.0 - (y - corner_y) / real_size.y;
+ s = x / real_size.x;
+ v = 1.0 - y / real_size.y;
}
}
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index f59702835c..829f4cc643 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -87,6 +87,8 @@ int Label::get_line_height(int p_line) const {
}
void Label::_shape() {
+ bool font_was_dirty = font_dirty;
+
Ref<StyleBox> style = theme_cache.normal_style;
int width = (get_size().width - style->get_minimum_size().width);
@@ -128,7 +130,24 @@ void Label::_shape() {
TS->free_rid(lines_rid[i]);
}
lines_rid.clear();
+ }
+
+ Size2i prev_minsize = minsize;
+ minsize = Size2();
+
+ if (xl_text.length() == 0) {
+ lines_dirty = false;
+ return;
+ }
+ // Don't compute minimum size until width is stable (two shape requests in a row with the same width.)
+ // This avoids situations in which the initial width is very narrow and the label would break text
+ // into many very short lines, causing a very tall label that can leave a deformed container.
+ bool width_stabilized = get_size().width == stable_width;
+ stable_width = get_size().width;
+
+ // With autowrap off, there's still a point in shaping before width is stable: to contribute a min width.
+ if (lines_dirty && (width_stabilized || autowrap_mode == TextServer::AUTOWRAP_OFF)) {
BitField<TextServer::LineBreakFlag> autowrap_flags = TextServer::BREAK_MANDATORY;
switch (autowrap_mode) {
case TextServer::AUTOWRAP_WORD_SMART:
@@ -152,13 +171,7 @@ void Label::_shape() {
}
}
- if (xl_text.length() == 0) {
- minsize = Size2(1, get_line_height());
- return;
- }
-
if (autowrap_mode == TextServer::AUTOWRAP_OFF) {
- minsize.width = 0.0f;
for (int i = 0; i < lines_rid.size(); i++) {
if (minsize.width < TS->shaped_text_get_size(lines_rid[i]).x) {
minsize.width = TS->shaped_text_get_size(lines_rid[i]).x;
@@ -166,7 +179,7 @@ void Label::_shape() {
}
}
- if (lines_dirty) {
+ if (lines_dirty && width_stabilized) {
BitField<TextServer::TextOverrunFlag> overrun_flags = TextServer::OVERRUN_NO_TRIM;
switch (overrun_behavior) {
case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS:
@@ -191,8 +204,11 @@ void Label::_shape() {
// Fill after min_size calculation.
+ int visible_lines = lines_rid.size();
+ if (max_lines_visible >= 0 && visible_lines > max_lines_visible) {
+ visible_lines = max_lines_visible;
+ }
if (autowrap_mode != TextServer::AUTOWRAP_OFF) {
- int visible_lines = get_visible_line_count();
bool lines_hidden = visible_lines > 0 && visible_lines < lines_rid.size();
if (lines_hidden) {
overrun_flags.set_flag(TextServer::OVERRUN_ENFORCE_ELLIPSIS);
@@ -221,33 +237,22 @@ void Label::_shape() {
}
}
}
- lines_dirty = false;
- lines_shaped_last_width = get_size().width;
- }
- _update_visible();
+ int last_line = MIN(lines_rid.size(), visible_lines + lines_skipped);
+ int line_spacing = settings.is_valid() ? settings->get_line_spacing() : theme_cache.line_spacing;
+ for (int64_t i = lines_skipped; i < last_line; i++) {
+ minsize.height += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
+ }
- if (autowrap_mode == TextServer::AUTOWRAP_OFF || !clip || overrun_behavior == TextServer::OVERRUN_NO_TRIMMING) {
- update_minimum_size();
+ lines_dirty = false;
}
-}
-
-void Label::_update_visible() {
- int line_spacing = settings.is_valid() ? settings->get_line_spacing() : theme_cache.line_spacing;
- Ref<StyleBox> style = theme_cache.normal_style;
- int lines_visible = lines_rid.size();
- if (max_lines_visible >= 0 && lines_visible > max_lines_visible) {
- lines_visible = max_lines_visible;
+ if (minsize != prev_minsize || font_was_dirty) {
+ update_minimum_size();
}
- minsize.height = 0;
- int last_line = MIN(lines_rid.size(), lines_visible + lines_skipped);
- for (int64_t i = lines_skipped; i < last_line; i++) {
- minsize.height += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
- if (minsize.height > (get_size().height - style->get_minimum_size().height + line_spacing)) {
- break;
- }
+ if (!width_stabilized) {
+ callable_mp(this, &Label::_shape).call_deferred();
}
}
@@ -345,8 +350,25 @@ void Label::_notification(int p_what) {
RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
}
+ // When a shaped text is invalidated by an external source, we want to reshape it.
+ if (!TS->shaped_text_is_ready(text_rid)) {
+ dirty = true;
+ }
+
+ for (const RID &line_rid : lines_rid) {
+ if (!TS->shaped_text_is_ready(line_rid)) {
+ lines_dirty = true;
+ break;
+ }
+ }
+
if (dirty || font_dirty || lines_dirty) {
_shape();
+ if (lines_dirty) {
+ // There will be another pass.
+ queue_redraw();
+ break;
+ }
}
RID ci = get_canvas_item();
@@ -370,7 +392,7 @@ void Label::_notification(int p_what) {
style->draw(ci, Rect2(Point2(0, 0), get_size()));
float total_h = 0.0;
- int lines_visible = 0;
+ int visible_lines = 0;
// Get number of lines to fit to the height.
for (int64_t i = lines_skipped; i < lines_rid.size(); i++) {
@@ -378,14 +400,14 @@ void Label::_notification(int p_what) {
if (total_h > (get_size().height - style->get_minimum_size().height + line_spacing)) {
break;
}
- lines_visible++;
+ visible_lines++;
}
- if (max_lines_visible >= 0 && lines_visible > max_lines_visible) {
- lines_visible = max_lines_visible;
+ if (max_lines_visible >= 0 && visible_lines > max_lines_visible) {
+ visible_lines = max_lines_visible;
}
- int last_line = MIN(lines_rid.size(), lines_visible + lines_skipped);
+ int last_line = MIN(lines_rid.size(), visible_lines + lines_skipped);
bool trim_chars = (visible_chars >= 0) && (visible_chars_behavior == TextServer::VC_CHARS_AFTER_SHAPING);
bool trim_glyphs_ltr = (visible_chars >= 0) && ((visible_chars_behavior == TextServer::VC_GLYPHS_LTR) || ((visible_chars_behavior == TextServer::VC_GLYPHS_AUTO) && !rtl_layout));
bool trim_glyphs_rtl = (visible_chars >= 0) && ((visible_chars_behavior == TextServer::VC_GLYPHS_RTL) || ((visible_chars_behavior == TextServer::VC_GLYPHS_AUTO) && rtl_layout));
@@ -402,7 +424,7 @@ void Label::_notification(int p_what) {
total_h += style->get_margin(SIDE_TOP) + style->get_margin(SIDE_BOTTOM);
int vbegin = 0, vsep = 0;
- if (lines_visible > 0) {
+ if (visible_lines > 0) {
switch (vertical_alignment) {
case VERTICAL_ALIGNMENT_TOP: {
// Nothing.
@@ -419,8 +441,8 @@ void Label::_notification(int p_what) {
} break;
case VERTICAL_ALIGNMENT_FILL: {
vbegin = 0;
- if (lines_visible > 1) {
- vsep = (size.y - (total_h - line_spacing)) / (lines_visible - 1);
+ if (visible_lines > 1) {
+ vsep = (size.y - (total_h - line_spacing)) / (visible_lines - 1);
} else {
vsep = 0;
}
@@ -597,13 +619,7 @@ void Label::_notification(int p_what) {
} break;
case NOTIFICATION_RESIZED: {
- // It may happen that the reshaping due to this size change triggers a cascade of re-layout
- // across the hierarchy where this label belongs to in a way that its size changes multiple
- // times, but ending up with the original size it was already shaped for.
- // This check prevents the catastrophic, freezing infinite cascade of re-layout.
- if (lines_shaped_last_width != get_size().width) {
- lines_dirty = true;
- }
+ lines_dirty = true;
} break;
}
}
@@ -646,25 +662,25 @@ int Label::get_line_count() const {
int Label::get_visible_line_count() const {
Ref<StyleBox> style = theme_cache.normal_style;
int line_spacing = settings.is_valid() ? settings->get_line_spacing() : theme_cache.line_spacing;
- int lines_visible = 0;
+ int visible_lines = 0;
float total_h = 0.0;
for (int64_t i = lines_skipped; i < lines_rid.size(); i++) {
total_h += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
if (total_h > (get_size().height - style->get_minimum_size().height + line_spacing)) {
break;
}
- lines_visible++;
+ visible_lines++;
}
- if (lines_visible > lines_rid.size()) {
- lines_visible = lines_rid.size();
+ if (visible_lines > lines_rid.size()) {
+ visible_lines = lines_rid.size();
}
- if (max_lines_visible >= 0 && lines_visible > max_lines_visible) {
- lines_visible = max_lines_visible;
+ if (max_lines_visible >= 0 && visible_lines > max_lines_visible) {
+ visible_lines = max_lines_visible;
}
- return lines_visible;
+ return visible_lines;
}
void Label::set_horizontal_alignment(HorizontalAlignment p_alignment) {
@@ -886,7 +902,7 @@ void Label::set_lines_skipped(int p_lines) {
}
lines_skipped = p_lines;
- _update_visible();
+ lines_dirty = true;
queue_redraw();
}
@@ -900,7 +916,7 @@ void Label::set_max_lines_visible(int p_lines) {
}
max_lines_visible = p_lines;
- _update_visible();
+ lines_dirty = true;
queue_redraw();
}
@@ -949,7 +965,7 @@ void Label::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_visible_ratio"), &Label::get_visible_ratio);
ClassDB::bind_method(D_METHOD("set_lines_skipped", "lines_skipped"), &Label::set_lines_skipped);
ClassDB::bind_method(D_METHOD("get_lines_skipped"), &Label::get_lines_skipped);
- ClassDB::bind_method(D_METHOD("set_max_lines_visible", "lines_visible"), &Label::set_max_lines_visible);
+ ClassDB::bind_method(D_METHOD("set_max_lines_visible", "visible_lines"), &Label::set_max_lines_visible);
ClassDB::bind_method(D_METHOD("get_max_lines_visible"), &Label::get_max_lines_visible);
ClassDB::bind_method(D_METHOD("set_structured_text_bidi_override", "parser"), &Label::set_structured_text_bidi_override);
ClassDB::bind_method(D_METHOD("get_structured_text_bidi_override"), &Label::get_structured_text_bidi_override);
diff --git a/scene/gui/label.h b/scene/gui/label.h
index b80646810b..448cb245eb 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -46,10 +46,10 @@ private:
bool clip = false;
TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING;
Size2 minsize;
+ real_t stable_width = -1;
bool uppercase = false;
bool lines_dirty = true;
- int lines_shaped_last_width = -1;
bool dirty = true;
bool font_dirty = true;
@@ -83,7 +83,6 @@ private:
int font_shadow_outline_size;
} theme_cache;
- void _update_visible();
void _shape();
void _invalidate();
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 0eeac2f285..1a6adca121 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -59,6 +59,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
for (int i = 0; i < items.size(); i++) {
Size2 item_size;
+ const_cast<PopupMenu *>(this)->_shape_item(i);
Size2 icon_size = items[i].get_icon_size();
item_size.height = _get_item_height(i);
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index ef1f6459e9..8ed68626a8 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -2890,6 +2890,18 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
dirty_cache = false;
}
+ // When a shaped text is invalidated by an external source, we want to reshape it.
+ if (!TS->shaped_text_is_ready(text_rid)) {
+ dirty_text = true;
+ }
+
+ for (const RID &line_rid : lines_rid) {
+ if (!TS->shaped_text_is_ready(line_rid)) {
+ dirty_lines = true;
+ break;
+ }
+ }
+
// Update text buffer.
if (dirty_text) {
TS->shaped_text_clear(text_rid);
@@ -3328,7 +3340,7 @@ void TextMesh::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pixel_size", PROPERTY_HINT_RANGE, "0.0001,128,0.0001,suffix:m"), "set_pixel_size", "get_pixel_size");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "curve_step", PROPERTY_HINT_RANGE, "0.1,10,0.1,suffix:px"), "set_curve_step", "get_curve_step");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_RANGE, "0.0,100.0,0.001,or_greater,suffix:m"), "set_depth", "get_depth");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:m"), "set_width", "get_width");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:px"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset", PROPERTY_HINT_NONE, "suffix:px"), "set_offset", "get_offset");
ADD_GROUP("BiDi", "");
diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp
index 93611ea2c4..38a865b170 100644
--- a/scene/resources/text_line.cpp
+++ b/scene/resources/text_line.cpp
@@ -101,6 +101,11 @@ void TextLine::_bind_methods() {
}
void TextLine::_shape() {
+ // When a shaped text is invalidated by an external source, we want to reshape it.
+ if (!TS->shaped_text_is_ready(rid)) {
+ dirty = true;
+ }
+
if (dirty) {
if (!tab_stops.is_empty()) {
TS->shaped_text_tab_align(rid, tab_stops);
diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp
index dfafc7d2bc..729063245c 100644
--- a/scene/resources/text_paragraph.cpp
+++ b/scene/resources/text_paragraph.cpp
@@ -134,6 +134,18 @@ void TextParagraph::_bind_methods() {
}
void TextParagraph::_shape_lines() {
+ // When a shaped text is invalidated by an external source, we want to reshape it.
+ if (!TS->shaped_text_is_ready(rid) || !TS->shaped_text_is_ready(dropcap_rid)) {
+ lines_dirty = true;
+ }
+
+ for (const RID &line_rid : lines_rid) {
+ if (!TS->shaped_text_is_ready(line_rid)) {
+ lines_dirty = true;
+ break;
+ }
+ }
+
if (lines_dirty) {
for (const RID &line_rid : lines_rid) {
TS->free_rid(line_rid);
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp
index 6a163c86d2..c9cf8f99af 100644
--- a/servers/physics_server_3d.cpp
+++ b/servers/physics_server_3d.cpp
@@ -429,7 +429,7 @@ Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQue
return ret;
}
-TypedArray<PackedVector2Array> PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
+TypedArray<PackedVector3Array> PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<Vector3> ret;
@@ -437,9 +437,9 @@ TypedArray<PackedVector2Array> PhysicsDirectSpaceState3D::_collide_shape(const R
int rc = 0;
bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
if (!res) {
- return TypedArray<PackedVector2Array>();
+ return TypedArray<PackedVector3Array>();
}
- TypedArray<PackedVector2Array> r;
+ TypedArray<PackedVector3Array> r;
r.resize(rc * 2);
for (int i = 0; i < rc * 2; i++) {
r[i] = ret[i];
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h
index abf22e68a4..2c7ebeea66 100644
--- a/servers/physics_server_3d.h
+++ b/servers/physics_server_3d.h
@@ -125,7 +125,7 @@ private:
TypedArray<Dictionary> _intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results = 32);
TypedArray<Dictionary> _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
Vector<real_t> _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
- TypedArray<PackedVector2Array> _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
+ TypedArray<PackedVector3Array> _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
protected: