summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/io/image.cpp10
-rw-r--r--core/io/image.h1
-rw-r--r--core/variant/variant_call.cpp24
-rw-r--r--doc/classes/@GlobalScope.xml2
-rw-r--r--doc/classes/RichTextLabel.xml9
-rw-r--r--doc/classes/Vector2.xml28
-rw-r--r--doc/classes/Vector2i.xml28
-rw-r--r--doc/classes/Vector3.xml28
-rw-r--r--doc/classes/Vector3i.xml28
-rw-r--r--doc/classes/Vector4.xml28
-rw-r--r--doc/classes/Vector4i.xml28
-rw-r--r--misc/extension_api_validation/4.2-stable.expected7
-rw-r--r--modules/astcenc/image_compress_astcenc.cpp2
-rw-r--r--modules/basis_universal/image_compress_basisu.cpp2
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp2
-rw-r--r--modules/etcpak/image_compress_etcpak.cpp2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs14
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs14
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs64
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs64
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs51
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs68
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs72
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs72
-rw-r--r--scene/gui/rich_text_label.compat.inc5
-rw-r--r--scene/gui/rich_text_label.cpp43
-rw-r--r--scene/gui/rich_text_label.h4
28 files changed, 672 insertions, 30 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 6096211cff..5498b448d7 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -521,7 +521,7 @@ void Image::convert(Format p_new_format) {
// Includes the main image.
const int mipmap_count = get_mipmap_count() + 1;
- if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) {
+ if (Image::is_format_compressed(format) || Image::is_format_compressed(p_new_format)) {
ERR_FAIL_MSG("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead.");
} else if (format > FORMAT_RGBA8 || p_new_format > FORMAT_RGBA8) {
@@ -1662,7 +1662,7 @@ int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &
}
bool Image::_can_modify(Format p_format) const {
- return p_format <= FORMAT_RGBE9995;
+ return !Image::is_format_compressed(p_format);
}
template <typename Component, int CC, bool renormalize,
@@ -2616,7 +2616,11 @@ int Image::get_image_mipmap_offset_and_dimensions(int p_width, int p_height, For
}
bool Image::is_compressed() const {
- return format > FORMAT_RGBE9995;
+ return is_format_compressed(format);
+}
+
+bool Image::is_format_compressed(Format p_format) {
+ return p_format > FORMAT_RGBE9995;
}
Error Image::decompress() {
diff --git a/core/io/image.h b/core/io/image.h
index 2cabbb767a..daddfac59d 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -376,6 +376,7 @@ public:
Error compress_from_channels(CompressMode p_mode, UsedChannels p_channels, ASTCFormat p_astc_format = ASTC_FORMAT_4x4);
Error decompress();
bool is_compressed() const;
+ static bool is_format_compressed(Format p_format);
void fix_alpha_edges();
void premultiply_alpha();
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 08fb2a9c91..986b34c662 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1807,6 +1807,10 @@ static void _register_variant_builtin_methods() {
bind_method(Vector2, clampf, sarray("min", "max"), varray());
bind_method(Vector2, snapped, sarray("step"), varray());
bind_method(Vector2, snappedf, sarray("step"), varray());
+ bind_method(Vector2, min, sarray("with"), varray());
+ bind_method(Vector2, minf, sarray("with"), varray());
+ bind_method(Vector2, max, sarray("with"), varray());
+ bind_method(Vector2, maxf, sarray("with"), varray());
bind_static_method(Vector2, from_angle, sarray("angle"), varray());
@@ -1825,6 +1829,10 @@ static void _register_variant_builtin_methods() {
bind_method(Vector2i, clampi, sarray("min", "max"), varray());
bind_method(Vector2i, snapped, sarray("step"), varray());
bind_method(Vector2i, snappedi, sarray("step"), varray());
+ bind_method(Vector2i, min, sarray("with"), varray());
+ bind_method(Vector2i, mini, sarray("with"), varray());
+ bind_method(Vector2i, max, sarray("with"), varray());
+ bind_method(Vector2i, maxi, sarray("with"), varray());
/* Rect2 */
@@ -1905,6 +1913,10 @@ static void _register_variant_builtin_methods() {
bind_method(Vector3, reflect, sarray("n"), varray());
bind_method(Vector3, sign, sarray(), varray());
bind_method(Vector3, octahedron_encode, sarray(), varray());
+ bind_method(Vector3, min, sarray("with"), varray());
+ bind_method(Vector3, minf, sarray("with"), varray());
+ bind_method(Vector3, max, sarray("with"), varray());
+ bind_method(Vector3, maxf, sarray("with"), varray());
bind_static_method(Vector3, octahedron_decode, sarray("uv"), varray());
/* Vector3i */
@@ -1921,6 +1933,10 @@ static void _register_variant_builtin_methods() {
bind_method(Vector3i, clampi, sarray("min", "max"), varray());
bind_method(Vector3i, snapped, sarray("step"), varray());
bind_method(Vector3i, snappedi, sarray("step"), varray());
+ bind_method(Vector3i, min, sarray("with"), varray());
+ bind_method(Vector3i, mini, sarray("with"), varray());
+ bind_method(Vector3i, max, sarray("with"), varray());
+ bind_method(Vector3i, maxi, sarray("with"), varray());
/* Vector4 */
@@ -1952,6 +1968,10 @@ static void _register_variant_builtin_methods() {
bind_method(Vector4, is_equal_approx, sarray("to"), varray());
bind_method(Vector4, is_zero_approx, sarray(), varray());
bind_method(Vector4, is_finite, sarray(), varray());
+ bind_method(Vector4, min, sarray("with"), varray());
+ bind_method(Vector4, minf, sarray("with"), varray());
+ bind_method(Vector4, max, sarray("with"), varray());
+ bind_method(Vector4, maxf, sarray("with"), varray());
/* Vector4i */
@@ -1965,6 +1985,10 @@ static void _register_variant_builtin_methods() {
bind_method(Vector4i, clampi, sarray("min", "max"), varray());
bind_method(Vector4i, snapped, sarray("step"), varray());
bind_method(Vector4i, snappedi, sarray("step"), varray());
+ bind_method(Vector4i, min, sarray("with"), varray());
+ bind_method(Vector4i, mini, sarray("with"), varray());
+ bind_method(Vector4i, max, sarray("with"), varray());
+ bind_method(Vector4i, maxi, sarray("with"), varray());
bind_method(Vector4i, distance_to, sarray("to"), varray());
bind_method(Vector4i, distance_squared_to, sarray("to"), varray());
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 0307684588..f2a6517a0c 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -696,6 +696,7 @@
[codeblock]
max(1, 7, 3, -6, 5) # Returns 7
[/codeblock]
+ [b]Note:[/b] When using this on vectors it will [i]not[/i] perform component-wise maximum, and will pick the largest value when compared using [code]x &lt; y[/code]. To perform component-wise maximum, use [method Vector2.max], [method Vector2i.max], [method Vector3.max], [method Vector3i.max], [method Vector4.max], and [method Vector4i.max].
</description>
</method>
<method name="maxf">
@@ -729,6 +730,7 @@
[codeblock]
min(1, 7, 3, -6, 5) # Returns -6
[/codeblock]
+ [b]Note:[/b] When using this on vectors it will [i]not[/i] perform component-wise minimum, and will pick the smallest value when compared using [code]x &lt; y[/code]. To perform component-wise minimum, use [method Vector2.min], [method Vector2i.min], [method Vector3.min], [method Vector3i.min], [method Vector4.min], and [method Vector4i.min].
</description>
</method>
<method name="minf">
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 01c4074e6d..f4e3c1209f 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -249,6 +249,13 @@
[/codeblock]
</description>
</method>
+ <method name="invalidate_paragraph">
+ <return type="bool" />
+ <param index="0" name="paragraph" type="int" />
+ <description>
+ Invalidates [param paragraph] and all subsequent paragraphs cache.
+ </description>
+ </method>
<method name="is_menu_visible" qualifiers="const">
<return type="bool" />
<description>
@@ -497,9 +504,11 @@
<method name="remove_paragraph">
<return type="bool" />
<param index="0" name="paragraph" type="int" />
+ <param index="1" name="no_invalidate" type="bool" default="false" />
<description>
Removes a paragraph of content from the label. Returns [code]true[/code] if the paragraph exists.
The [param paragraph] argument is the index of the paragraph to remove, it can take values in the interval [code][0, get_paragraph_count() - 1][/code].
+ If [param no_invalidate] is set to [code]true[/code], cache for the subsequent paragraphs is not invalidated. Use it for faster updates if deleted paragraph is fully self-contained (have no unclosed tags), or this call is part of the complex edit operation and [method invalidate_paragraph] will be called at the end of operation.
</description>
</method>
<method name="scroll_to_line">
diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml
index 961a60060a..5fadfd0d95 100644
--- a/doc/classes/Vector2.xml
+++ b/doc/classes/Vector2.xml
@@ -273,18 +273,46 @@
Returns the vector with a maximum length by limiting its length to [param length].
</description>
</method>
+ <method name="max" qualifiers="const">
+ <return type="Vector2" />
+ <param index="0" name="with" type="Vector2" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2(maxf(x, with.x), maxf(y, with.y))[/code].
+ </description>
+ </method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
+ <method name="maxf" qualifiers="const">
+ <return type="Vector2" />
+ <param index="0" name="with" type="float" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2(maxf(x, with), maxf(y, with))[/code].
+ </description>
+ </method>
+ <method name="min" qualifiers="const">
+ <return type="Vector2" />
+ <param index="0" name="with" type="Vector2" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2(minf(x, with.x), minf(y, with.y))[/code].
+ </description>
+ </method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Y].
</description>
</method>
+ <method name="minf" qualifiers="const">
+ <return type="Vector2" />
+ <param index="0" name="with" type="float" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2(minf(x, with), minf(y, with))[/code].
+ </description>
+ </method>
<method name="move_toward" qualifiers="const">
<return type="Vector2" />
<param index="0" name="to" type="Vector2" />
diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml
index db848e3186..4afc62e038 100644
--- a/doc/classes/Vector2i.xml
+++ b/doc/classes/Vector2i.xml
@@ -100,18 +100,46 @@
This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
+ <method name="max" qualifiers="const">
+ <return type="Vector2i" />
+ <param index="0" name="with" type="Vector2i" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2i(maxi(x, with.x), maxi(y, with.y))[/code].
+ </description>
+ </method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
+ <method name="maxi" qualifiers="const">
+ <return type="Vector2i" />
+ <param index="0" name="with" type="int" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2i(maxi(x, with), maxi(y, with))[/code].
+ </description>
+ </method>
+ <method name="min" qualifiers="const">
+ <return type="Vector2i" />
+ <param index="0" name="with" type="Vector2i" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2i(mini(x, with.x), mini(y, with.y))[/code].
+ </description>
+ </method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Y].
</description>
</method>
+ <method name="mini" qualifiers="const">
+ <return type="Vector2i" />
+ <param index="0" name="with" type="int" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2i(mini(x, with), mini(y, with))[/code].
+ </description>
+ </method>
<method name="sign" qualifiers="const">
<return type="Vector2i" />
<description>
diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml
index a98ed479d4..387359a97f 100644
--- a/doc/classes/Vector3.xml
+++ b/doc/classes/Vector3.xml
@@ -242,18 +242,46 @@
Returns the vector with a maximum length by limiting its length to [param length].
</description>
</method>
+ <method name="max" qualifiers="const">
+ <return type="Vector3" />
+ <param index="0" name="with" type="Vector3" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z))[/code].
+ </description>
+ </method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
+ <method name="maxf" qualifiers="const">
+ <return type="Vector3" />
+ <param index="0" name="with" type="float" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3(maxf(x, with), maxf(y, with), maxf(z, with))[/code].
+ </description>
+ </method>
+ <method name="min" qualifiers="const">
+ <return type="Vector3" />
+ <param index="0" name="with" type="Vector3" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3(minf(x, with.x), minf(y, with.y), minf(z, with.z))[/code].
+ </description>
+ </method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z].
</description>
</method>
+ <method name="minf" qualifiers="const">
+ <return type="Vector3" />
+ <param index="0" name="with" type="float" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3(minf(x, with), minf(y, with), minf(z, with))[/code].
+ </description>
+ </method>
<method name="move_toward" qualifiers="const">
<return type="Vector3" />
<param index="0" name="to" type="Vector3" />
diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml
index 8fc0309685..df4624dbb1 100644
--- a/doc/classes/Vector3i.xml
+++ b/doc/classes/Vector3i.xml
@@ -95,18 +95,46 @@
This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
+ <method name="max" qualifiers="const">
+ <return type="Vector3i" />
+ <param index="0" name="with" type="Vector3i" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3i(maxi(x, with.x), maxi(y, with.y), maxi(z, with.z))[/code].
+ </description>
+ </method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
+ <method name="maxi" qualifiers="const">
+ <return type="Vector3i" />
+ <param index="0" name="with" type="int" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3i(maxi(x, with), maxi(y, with), maxi(z, with))[/code].
+ </description>
+ </method>
+ <method name="min" qualifiers="const">
+ <return type="Vector3i" />
+ <param index="0" name="with" type="Vector3i" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3i(mini(x, with.x), mini(y, with.y), mini(z, with.z))[/code].
+ </description>
+ </method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z].
</description>
</method>
+ <method name="mini" qualifiers="const">
+ <return type="Vector3i" />
+ <param index="0" name="with" type="int" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3i(mini(x, with), mini(y, with), mini(z, with))[/code].
+ </description>
+ </method>
<method name="sign" qualifiers="const">
<return type="Vector3i" />
<description>
diff --git a/doc/classes/Vector4.xml b/doc/classes/Vector4.xml
index 49cf726086..87af370462 100644
--- a/doc/classes/Vector4.xml
+++ b/doc/classes/Vector4.xml
@@ -184,18 +184,46 @@
Returns the result of the linear interpolation between this vector and [param to] by amount [param weight]. [param weight] is on the range of [code]0.0[/code] to [code]1.0[/code], representing the amount of interpolation.
</description>
</method>
+ <method name="max" qualifiers="const">
+ <return type="Vector4" />
+ <param index="0" name="with" type="Vector4" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z), maxf(w, with.w))[/code].
+ </description>
+ </method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
+ <method name="maxf" qualifiers="const">
+ <return type="Vector4" />
+ <param index="0" name="with" type="float" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4(maxf(x, with), maxf(y, with), maxf(z, with), maxf(w, with))[/code].
+ </description>
+ </method>
+ <method name="min" qualifiers="const">
+ <return type="Vector4" />
+ <param index="0" name="with" type="Vector4" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4(minf(x, with.x), minf(y, with.y), minf(z, with.z), minf(w, with.w))[/code].
+ </description>
+ </method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_W].
</description>
</method>
+ <method name="minf" qualifiers="const">
+ <return type="Vector4" />
+ <param index="0" name="with" type="float" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4(minf(x, with), minf(y, with), minf(z, with), minf(w, with))[/code].
+ </description>
+ </method>
<method name="normalized" qualifiers="const">
<return type="Vector4" />
<description>
diff --git a/doc/classes/Vector4i.xml b/doc/classes/Vector4i.xml
index ade558dd06..8f54b767e0 100644
--- a/doc/classes/Vector4i.xml
+++ b/doc/classes/Vector4i.xml
@@ -93,18 +93,46 @@
This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
+ <method name="max" qualifiers="const">
+ <return type="Vector4i" />
+ <param index="0" name="with" type="Vector4i" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4i(maxi(x, with.x), maxi(y, with.y), maxi(z, with.z), maxi(w, with.w))[/code].
+ </description>
+ </method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
+ <method name="maxi" qualifiers="const">
+ <return type="Vector4i" />
+ <param index="0" name="with" type="int" />
+ <description>
+ Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4i(maxi(x, with), maxi(y, with), maxi(z, with), maxi(w, with))[/code].
+ </description>
+ </method>
+ <method name="min" qualifiers="const">
+ <return type="Vector4i" />
+ <param index="0" name="with" type="Vector4i" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4i(mini(x, with.x), mini(y, with.y), mini(z, with.z), mini(w, with.w))[/code].
+ </description>
+ </method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_W].
</description>
</method>
+ <method name="mini" qualifiers="const">
+ <return type="Vector4i" />
+ <param index="0" name="with" type="int" />
+ <description>
+ Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4i(mini(x, with), mini(y, with), mini(z, with), mini(w, with))[/code].
+ </description>
+ </method>
<method name="sign" qualifiers="const">
<return type="Vector4i" />
<description>
diff --git a/misc/extension_api_validation/4.2-stable.expected b/misc/extension_api_validation/4.2-stable.expected
index f935a512b9..5a9976dc71 100644
--- a/misc/extension_api_validation/4.2-stable.expected
+++ b/misc/extension_api_validation/4.2-stable.expected
@@ -330,3 +330,10 @@ GH-84472
Validate extension JSON: Error: Field 'classes/CanvasItem/methods/draw_circle/arguments': size changed value in new API, from 3 to 6.
Optional arguments added. Compatibility methods registered.
+
+
+GH-91098
+--------
+Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/remove_paragraph/arguments': size changed value in new API, from 1 to 2.
+
+Added optional argument. Compatibility method registered.
diff --git a/modules/astcenc/image_compress_astcenc.cpp b/modules/astcenc/image_compress_astcenc.cpp
index 31df83efae..941c1f44be 100644
--- a/modules/astcenc/image_compress_astcenc.cpp
+++ b/modules/astcenc/image_compress_astcenc.cpp
@@ -41,7 +41,7 @@ void _compress_astc(Image *r_img, Image::ASTCFormat p_format) {
// TODO: See how to handle lossy quality.
Image::Format img_format = r_img->get_format();
- if (img_format >= Image::FORMAT_DXT1) {
+ if (Image::is_format_compressed(img_format)) {
return; // Do not compress, already compressed.
}
diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp
index 531b738041..d8ef1c0414 100644
--- a/modules/basis_universal/image_compress_basisu.cpp
+++ b/modules/basis_universal/image_compress_basisu.cpp
@@ -299,7 +299,7 @@ Ref<Image> basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size) {
basist::basisu_image_level_info basisu_level;
transcoder.get_image_level_info(src_ptr, src_size, basisu_level, 0, i);
- uint32_t mip_block_or_pixel_count = image_format >= Image::FORMAT_DXT1 ? basisu_level.m_total_blocks : basisu_level.m_orig_width * basisu_level.m_orig_height;
+ uint32_t mip_block_or_pixel_count = Image::is_format_compressed(image_format) ? basisu_level.m_total_blocks : basisu_level.m_orig_width * basisu_level.m_orig_height;
int ofs = Image::get_image_mipmap_offset(basisu_info.m_width, basisu_info.m_height, image_format, i);
bool result = transcoder.transcode_image_level(src_ptr, src_size, 0, i, dst + ofs, mip_block_or_pixel_count, basisu_format);
diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index e9a7009d7c..7335315c51 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -142,7 +142,7 @@ static void _digest_job_queue(void *p_job_queue, uint32_t p_index) {
}
void image_compress_cvtt(Image *p_image, Image::UsedChannels p_channels) {
- if (p_image->get_format() >= Image::FORMAT_BPTC_RGBA) {
+ if (p_image->is_compressed()) {
return; //do not compress, already compressed
}
int w = p_image->get_width();
diff --git a/modules/etcpak/image_compress_etcpak.cpp b/modules/etcpak/image_compress_etcpak.cpp
index dcd73101c2..4ce0cf50d9 100644
--- a/modules/etcpak/image_compress_etcpak.cpp
+++ b/modules/etcpak/image_compress_etcpak.cpp
@@ -92,7 +92,7 @@ void _compress_etcpak(EtcpakType p_compresstype, Image *r_img) {
uint64_t start_time = OS::get_singleton()->get_ticks_msec();
Image::Format img_format = r_img->get_format();
- if (img_format >= Image::FORMAT_DXT1) {
+ if (Image::is_format_compressed(img_format)) {
return; // Do not compress, already compressed.
}
if (img_format > Image::FORMAT_RGBA8) {
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs
index feaa1d07da..ab7f8ede44 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs
@@ -69,7 +69,7 @@ namespace Godot
public readonly Aabb Abs()
{
Vector3 end = End;
- Vector3 topLeft = new Vector3(Mathf.Min(_position.X, end.X), Mathf.Min(_position.Y, end.Y), Mathf.Min(_position.Z, end.Z));
+ Vector3 topLeft = end.Min(_position);
return new Aabb(topLeft, _size.Abs());
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
index 9d9065911e..19721b6cca 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
@@ -69,7 +69,7 @@ namespace Godot
public readonly Rect2 Abs()
{
Vector2 end = End;
- Vector2 topLeft = new Vector2(Mathf.Min(_position.X, end.X), Mathf.Min(_position.Y, end.Y));
+ Vector2 topLeft = end.Min(_position);
return new Rect2(topLeft, _size.Abs());
}
@@ -91,14 +91,12 @@ namespace Godot
return new Rect2();
}
- newRect._position.X = Mathf.Max(b._position.X, _position.X);
- newRect._position.Y = Mathf.Max(b._position.Y, _position.Y);
+ newRect._position = b._position.Max(_position);
Vector2 bEnd = b._position + b._size;
Vector2 end = _position + _size;
- newRect._size.X = Mathf.Min(bEnd.X, end.X) - newRect._position.X;
- newRect._size.Y = Mathf.Min(bEnd.Y, end.Y) - newRect._position.Y;
+ newRect._size = bEnd.Min(end) - newRect._position;
return newRect;
}
@@ -338,11 +336,9 @@ namespace Godot
{
Rect2 newRect;
- newRect._position.X = Mathf.Min(b._position.X, _position.X);
- newRect._position.Y = Mathf.Min(b._position.Y, _position.Y);
+ newRect._position = b._position.Min(_position);
- newRect._size.X = Mathf.Max(b._position.X + b._size.X, _position.X + _size.X);
- newRect._size.Y = Mathf.Max(b._position.Y + b._size.Y, _position.Y + _size.Y);
+ newRect._size = (b._position + b._size).Max(_position + _size);
newRect._size -= newRect._position; // Make relative again
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs
index 65704b3da7..7ee9ff8552 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs
@@ -69,7 +69,7 @@ namespace Godot
public readonly Rect2I Abs()
{
Vector2I end = End;
- Vector2I topLeft = new Vector2I(Mathf.Min(_position.X, end.X), Mathf.Min(_position.Y, end.Y));
+ Vector2I topLeft = end.Min(_position);
return new Rect2I(topLeft, _size.Abs());
}
@@ -91,14 +91,12 @@ namespace Godot
return new Rect2I();
}
- newRect._position.X = Mathf.Max(b._position.X, _position.X);
- newRect._position.Y = Mathf.Max(b._position.Y, _position.Y);
+ newRect._position = b._position.Max(_position);
Vector2I bEnd = b._position + b._size;
Vector2I end = _position + _size;
- newRect._size.X = Mathf.Min(bEnd.X, end.X) - newRect._position.X;
- newRect._size.Y = Mathf.Min(bEnd.Y, end.Y) - newRect._position.Y;
+ newRect._size = bEnd.Min(end) - newRect._position;
return newRect;
}
@@ -295,11 +293,9 @@ namespace Godot
{
Rect2I newRect;
- newRect._position.X = Mathf.Min(b._position.X, _position.X);
- newRect._position.Y = Mathf.Min(b._position.Y, _position.Y);
+ newRect._position = b._position.Min(_position);
- newRect._size.X = Mathf.Max(b._position.X + b._size.X, _position.X + _size.X);
- newRect._size.Y = Mathf.Max(b._position.Y + b._size.Y, _position.Y + _size.Y);
+ newRect._size = (b._position + b._size).Max(_position + _size);
newRect._size -= newRect._position; // Make relative again
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index 16de028045..50bf56d832 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -430,6 +430,70 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2 Max(Vector2 with)
+ {
+ return new Vector2
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Max(X, with), Mathf.Max(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2 Max(real_t with)
+ {
+ return new Vector2
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2 Min(Vector2 with)
+ {
+ return new Vector2
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Min(X, with), Mathf.Min(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2 Min(real_t with)
+ {
+ return new Vector2
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If both components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
index 3d11a15e28..9442db4d86 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
@@ -192,6 +192,70 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2I Max(Vector2I with)
+ {
+ return new Vector2I
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Max(X, with), Mathf.Max(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2I Max(int with)
+ {
+ return new Vector2I
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2I Min(Vector2I with)
+ {
+ return new Vector2I
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Min(X, with), Mathf.Min(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2I Min(int with)
+ {
+ return new Vector2I
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If both components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index a2d5c012c0..27f2713efa 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -437,6 +437,57 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3 Max(Vector3 with)
+ {
+ return new Vector3
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3 Max(real_t with)
+ {
+ return new Vector3
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector3 Min(Vector3 with)
+ {
+ return new Vector3
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
index 642c73a8ec..8312e2c231 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
@@ -203,6 +203,74 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3I Max(Vector3I with)
+ {
+ return new Vector3I
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3I Max(int with)
+ {
+ return new Vector3I
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector3I Min(Vector3I with)
+ {
+ return new Vector3I
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Min(X, with), Mathf.Min(Y, with), Mathf.Min(Z, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector3I Min(int with)
+ {
+ return new Vector3I
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with),
+ Mathf.Min(Z, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs
index 9862dfdab6..ec59197fa3 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs
@@ -371,6 +371,78 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z), Mathf.Max(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4 Max(Vector4 with)
+ {
+ return new Vector4
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z),
+ Mathf.Max(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with), Mathf.Max(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4 Max(real_t with)
+ {
+ return new Vector4
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with),
+ Mathf.Max(W, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z), Mathf.Min(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4 Min(Vector4 with)
+ {
+ return new Vector4
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z),
+ Mathf.Min(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Min(X, with), Mathf.Min(Y, with), Mathf.Min(Z, with), Mathf.Min(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4 Min(real_t with)
+ {
+ return new Vector4
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with),
+ Mathf.Min(Z, with),
+ Mathf.Min(W, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
index 321f985209..ba8e54b88b 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
@@ -223,6 +223,78 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z), Mathf.Max(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4I Max(Vector4I with)
+ {
+ return new Vector4I
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z),
+ Mathf.Max(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with), Mathf.Max(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4I Max(int with)
+ {
+ return new Vector4I
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with),
+ Mathf.Max(W, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z), Mathf.Min(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4I Min(Vector4I with)
+ {
+ return new Vector4I
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z),
+ Mathf.Min(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Min(X, with), Mathf.Min(Y, with), Mathf.Min(Z, with), Mathf.Min(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4I Min(int with)
+ {
+ return new Vector4I
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with),
+ Mathf.Min(Z, with),
+ Mathf.Min(W, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
diff --git a/scene/gui/rich_text_label.compat.inc b/scene/gui/rich_text_label.compat.inc
index 626278a405..97739c4b79 100644
--- a/scene/gui/rich_text_label.compat.inc
+++ b/scene/gui/rich_text_label.compat.inc
@@ -38,9 +38,14 @@ void RichTextLabel::_add_image_bind_compat_80410(const Ref<Texture2D> &p_image,
add_image(p_image, p_width, p_height, p_color, p_alignment, p_region, Variant(), false, String(), false);
}
+bool RichTextLabel::_remove_paragraph_bind_compat_91098(int p_paragraph) {
+ return remove_paragraph(p_paragraph, false);
+}
+
void RichTextLabel::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("push_meta", "data"), &RichTextLabel::_push_meta_bind_compat_89024);
ClassDB::bind_compatibility_method(D_METHOD("add_image", "image", "width", "height", "color", "inline_align", "region"), &RichTextLabel::_add_image_bind_compat_80410, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(Rect2()));
+ ClassDB::bind_compatibility_method(D_METHOD("remove_paragraph", "paragraph"), &RichTextLabel::_remove_paragraph_bind_compat_91098);
}
#endif // DISABLE_DEPRECATED
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 0773181239..19b02f33c6 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -3342,7 +3342,7 @@ void RichTextLabel::_remove_frame(HashSet<Item *> &r_erase_list, ItemFrame *p_fr
}
}
-bool RichTextLabel::remove_paragraph(const int p_paragraph) {
+bool RichTextLabel::remove_paragraph(int p_paragraph, bool p_no_invalidate) {
_stop_thread();
MutexLock data_lock(data_mutex);
@@ -3391,8 +3391,44 @@ bool RichTextLabel::remove_paragraph(const int p_paragraph) {
selection.click_frame = nullptr;
selection.click_item = nullptr;
- deselect();
+ selection.active = false;
+
+ if (p_no_invalidate) {
+ // Do not invalidate cache, only update vertical offsets of the paragraphs after deleted one and scrollbar.
+ int to_line = main->first_invalid_line.load() - 1;
+ float total_height = (p_paragraph == 0) ? 0 : _calculate_line_vertical_offset(main->lines[p_paragraph - 1]);
+ for (int i = p_paragraph; i < to_line; i++) {
+ MutexLock lock(main->lines[to_line - 1].text_buf->get_mutex());
+ main->lines[i].offset.y = total_height;
+ total_height = _calculate_line_vertical_offset(main->lines[i]);
+ }
+ updating_scroll = true;
+ vscroll->set_max(total_height);
+ updating_scroll = false;
+
+ main->first_invalid_line.store(MAX(main->first_invalid_line.load() - 1, 0));
+ main->first_resized_line.store(MAX(main->first_resized_line.load() - 1, 0));
+ main->first_invalid_font_line.store(MAX(main->first_invalid_font_line.load() - 1, 0));
+ } else {
+ // Invalidate cache after the deleted paragraph.
+ main->first_invalid_line.store(MIN(main->first_invalid_line.load(), p_paragraph));
+ main->first_resized_line.store(MIN(main->first_resized_line.load(), p_paragraph));
+ main->first_invalid_font_line.store(MIN(main->first_invalid_font_line.load(), p_paragraph));
+ }
+ queue_redraw();
+
+ return true;
+}
+
+bool RichTextLabel::invalidate_paragraph(int p_paragraph) {
+ _stop_thread();
+ MutexLock data_lock(data_mutex);
+
+ if (p_paragraph >= (int)main->lines.size() || p_paragraph < 0) {
+ return false;
+ }
+ // Invalidate cache.
main->first_invalid_line.store(MIN(main->first_invalid_line.load(), p_paragraph));
main->first_resized_line.store(MIN(main->first_resized_line.load(), p_paragraph));
main->first_invalid_font_line.store(MIN(main->first_invalid_font_line.load(), p_paragraph));
@@ -5851,7 +5887,8 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height", "color", "inline_align", "region", "key", "pad", "tooltip", "size_in_percent"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(Rect2()), DEFVAL(Variant()), DEFVAL(false), DEFVAL(String()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("update_image", "key", "mask", "image", "width", "height", "color", "inline_align", "region", "pad", "tooltip", "size_in_percent"), &RichTextLabel::update_image, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(Rect2()), DEFVAL(false), DEFVAL(String()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("newline"), &RichTextLabel::add_newline);
- ClassDB::bind_method(D_METHOD("remove_paragraph", "paragraph"), &RichTextLabel::remove_paragraph);
+ ClassDB::bind_method(D_METHOD("remove_paragraph", "paragraph", "no_invalidate"), &RichTextLabel::remove_paragraph, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("invalidate_paragraph", "paragraph"), &RichTextLabel::invalidate_paragraph);
ClassDB::bind_method(D_METHOD("push_font", "font", "font_size"), &RichTextLabel::push_font, DEFVAL(0));
ClassDB::bind_method(D_METHOD("push_font_size", "font_size"), &RichTextLabel::push_font_size);
ClassDB::bind_method(D_METHOD("push_normal"), &RichTextLabel::push_normal);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 371f6724d7..189ee1da6e 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -134,6 +134,7 @@ protected:
#ifndef DISABLE_DEPRECATED
void _push_meta_bind_compat_89024(const Variant &p_meta);
void _add_image_bind_compat_80410(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region);
+ bool _remove_paragraph_bind_compat_91098(int p_paragraph);
static void _bind_compatibility_methods();
#endif
@@ -664,7 +665,8 @@ public:
void add_image(const Ref<Texture2D> &p_image, int p_width = 0, int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), InlineAlignment p_alignment = INLINE_ALIGNMENT_CENTER, const Rect2 &p_region = Rect2(), const Variant &p_key = Variant(), bool p_pad = false, const String &p_tooltip = String(), bool p_size_in_percent = false);
void update_image(const Variant &p_key, BitField<ImageUpdateMask> p_mask, const Ref<Texture2D> &p_image, int p_width = 0, int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), InlineAlignment p_alignment = INLINE_ALIGNMENT_CENTER, const Rect2 &p_region = Rect2(), bool p_pad = false, const String &p_tooltip = String(), bool p_size_in_percent = false);
void add_newline();
- bool remove_paragraph(const int p_paragraph);
+ bool remove_paragraph(int p_paragraph, bool p_no_invalidate = false);
+ bool invalidate_paragraph(int p_paragraph);
void push_dropcap(const String &p_string, const Ref<Font> &p_font, int p_size, const Rect2 &p_dropcap_margins = Rect2(), const Color &p_color = Color(1, 1, 1), int p_ol_size = 0, const Color &p_ol_color = Color(0, 0, 0, 0));
void _push_def_font(DefaultFont p_def_font);
void _push_def_font_var(DefaultFont p_def_font, const Ref<Font> &p_font, int p_size = -1);