diff options
61 files changed, 453 insertions, 474 deletions
diff --git a/core/multiplayer/multiplayer_replicator.cpp b/core/multiplayer/multiplayer_replicator.cpp index 6604510394..c57562552a 100644 --- a/core/multiplayer/multiplayer_replicator.cpp +++ b/core/multiplayer/multiplayer_replicator.cpp @@ -207,7 +207,7 @@ Error MultiplayerReplicator::_send_default_spawn_despawn(int p_peer_id, const Re const Vector<StringName> names = rel_path.get_names(); ERR_FAIL_COND_V(names.size() < 2, ERR_INVALID_PARAMETER); - NodePath parent = NodePath(names.subarray(0, names.size() - 2), false); + NodePath parent = NodePath(names.slice(0, names.size() - 1), false); ERR_FAIL_COND_V_MSG(!root_node->has_node(parent), ERR_INVALID_PARAMETER, "Path not found: " + parent); int path_id = 0; diff --git a/core/templates/vector.h b/core/templates/vector.h index 376d5cbeff..2f51a83848 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -143,27 +143,28 @@ public: return ret; } - Vector<T> subarray(int p_from, int p_to) const { - if (p_from < 0) { - p_from = size() + p_from; - } - if (p_to < 0) { - p_to = size() + p_to; + Vector<T> slice(int p_begin, int p_end) const { + Vector<T> result; + + if (p_end < 0) { + p_end += size() + 1; } - ERR_FAIL_INDEX_V(p_from, size(), Vector<T>()); - ERR_FAIL_INDEX_V(p_to, size(), Vector<T>()); + ERR_FAIL_INDEX_V(p_begin, size(), result); + ERR_FAIL_INDEX_V(p_end, size() + 1, result); + + ERR_FAIL_COND_V(p_begin > p_end, result); + + int result_size = p_end - p_begin; + result.resize(result_size); - Vector<T> slice; - int span = 1 + p_to - p_from; - slice.resize(span); - const T *r = ptr(); - T *w = slice.ptrw(); - for (int i = 0; i < span; ++i) { - w[i] = r[p_from + i]; + const T *const r = ptr(); + T *const w = result.ptrw(); + for (int i = 0; i < result_size; ++i) { + w[i] = r[p_begin + i]; } - return slice; + return result; } bool operator==(const Vector<T> &p_arr) const { diff --git a/core/variant/array.cpp b/core/variant/array.cpp index b049c29688..45f2e0c5ac 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -365,55 +365,30 @@ Array Array::recursive_duplicate(bool p_deep, int recursion_count) const { return new_arr; } -int Array::_clamp_slice_index(int p_index) const { - int arr_size = size(); - int fixed_index = CLAMP(p_index, -arr_size, arr_size - 1); - if (fixed_index < 0) { - fixed_index = arr_size + fixed_index; - } - return fixed_index; -} +Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { + Array result; -Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound - - Array new_arr; + ERR_FAIL_COND_V_MSG(p_step == 0, result, "Slice step cannot be zero."); - ERR_FAIL_COND_V_MSG(p_step == 0, new_arr, "Array slice step size cannot be zero."); - - if (is_empty()) { // Don't try to slice empty arrays. - return new_arr; - } - if (p_step > 0) { - if (p_begin >= size() || p_end < -size()) { - return new_arr; - } - } else { // p_step < 0 - if (p_begin < -size() || p_end >= size()) { - return new_arr; - } + if (p_end < 0) { + p_end += size() + 1; } - int begin = _clamp_slice_index(p_begin); - int end = _clamp_slice_index(p_end); + ERR_FAIL_INDEX_V(p_begin, size(), result); + ERR_FAIL_INDEX_V(p_end, size() + 1, result); - int new_arr_size = MAX(((end - begin + p_step) / p_step), 0); - new_arr.resize(new_arr_size); + ERR_FAIL_COND_V_MSG(p_step > 0 && p_begin > p_end, result, "Slice is positive, but bounds is decreasing"); + ERR_FAIL_COND_V_MSG(p_step < 0 && p_begin < p_end, result, "Slice is negative, but bounds is increasing"); - if (p_step > 0) { - int dest_idx = 0; - for (int idx = begin; idx <= end; idx += p_step) { - ERR_FAIL_COND_V_MSG(dest_idx < 0 || dest_idx >= new_arr_size, Array(), "Bug in Array slice()"); - new_arr[dest_idx++] = p_deep ? get(idx).duplicate(p_deep) : get(idx); - } - } else { // p_step < 0 - int dest_idx = 0; - for (int idx = begin; idx >= end; idx += p_step) { - ERR_FAIL_COND_V_MSG(dest_idx < 0 || dest_idx >= new_arr_size, Array(), "Bug in Array slice()"); - new_arr[dest_idx++] = p_deep ? get(idx).duplicate(p_deep) : get(idx); - } + int result_size = (p_end - p_begin) / p_step; + result.resize(result_size); + + for (int src_idx = p_begin, dest_idx = 0; dest_idx < result_size; ++dest_idx) { + result[dest_idx] = p_deep ? get(src_idx).duplicate(true) : get(src_idx); + src_idx += p_step; } - return new_arr; + return result; } Array Array::filter(const Callable &p_callable) const { diff --git a/core/variant/array.h b/core/variant/array.h index 5d2839dda7..6a68a9b9ff 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -44,8 +44,6 @@ class Array { void _ref(const Array &p_from) const; void _unref() const; - inline int _clamp_slice_index(int p_index) const; - protected: Array(const Array &p_base, uint32_t p_type, const StringName &p_class_name, const Variant &p_script); bool _assign(const Array &p_array); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 75f986bdf5..82f547e78c 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1852,7 +1852,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedByteArray, resize, sarray("new_size"), varray()); bind_method(PackedByteArray, has, sarray("value"), varray()); bind_method(PackedByteArray, reverse, sarray(), varray()); - bind_method(PackedByteArray, subarray, sarray("from", "to"), varray()); + bind_method(PackedByteArray, slice, sarray("begin", "end"), varray()); bind_method(PackedByteArray, sort, sarray(), varray()); bind_method(PackedByteArray, bsearch, sarray("value", "before"), varray(true)); bind_method(PackedByteArray, duplicate, sarray(), varray()); @@ -1913,7 +1913,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt32Array, resize, sarray("new_size"), varray()); bind_method(PackedInt32Array, has, sarray("value"), varray()); bind_method(PackedInt32Array, reverse, sarray(), varray()); - bind_method(PackedInt32Array, subarray, sarray("from", "to"), varray()); + bind_method(PackedInt32Array, slice, sarray("begin", "end"), varray()); bind_method(PackedInt32Array, to_byte_array, sarray(), varray()); bind_method(PackedInt32Array, sort, sarray(), varray()); bind_method(PackedInt32Array, bsearch, sarray("value", "before"), varray(true)); @@ -1933,7 +1933,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt64Array, resize, sarray("new_size"), varray()); bind_method(PackedInt64Array, has, sarray("value"), varray()); bind_method(PackedInt64Array, reverse, sarray(), varray()); - bind_method(PackedInt64Array, subarray, sarray("from", "to"), varray()); + bind_method(PackedInt64Array, slice, sarray("begin", "end"), varray()); bind_method(PackedInt64Array, to_byte_array, sarray(), varray()); bind_method(PackedInt64Array, sort, sarray(), varray()); bind_method(PackedInt64Array, bsearch, sarray("value", "before"), varray(true)); @@ -1953,7 +1953,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat32Array, resize, sarray("new_size"), varray()); bind_method(PackedFloat32Array, has, sarray("value"), varray()); bind_method(PackedFloat32Array, reverse, sarray(), varray()); - bind_method(PackedFloat32Array, subarray, sarray("from", "to"), varray()); + bind_method(PackedFloat32Array, slice, sarray("begin", "end"), varray()); bind_method(PackedFloat32Array, to_byte_array, sarray(), varray()); bind_method(PackedFloat32Array, sort, sarray(), varray()); bind_method(PackedFloat32Array, bsearch, sarray("value", "before"), varray(true)); @@ -1973,7 +1973,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat64Array, resize, sarray("new_size"), varray()); bind_method(PackedFloat64Array, has, sarray("value"), varray()); bind_method(PackedFloat64Array, reverse, sarray(), varray()); - bind_method(PackedFloat64Array, subarray, sarray("from", "to"), varray()); + bind_method(PackedFloat64Array, slice, sarray("begin", "end"), varray()); bind_method(PackedFloat64Array, to_byte_array, sarray(), varray()); bind_method(PackedFloat64Array, sort, sarray(), varray()); bind_method(PackedFloat64Array, bsearch, sarray("value", "before"), varray(true)); @@ -1993,7 +1993,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedStringArray, resize, sarray("new_size"), varray()); bind_method(PackedStringArray, has, sarray("value"), varray()); bind_method(PackedStringArray, reverse, sarray(), varray()); - bind_method(PackedStringArray, subarray, sarray("from", "to"), varray()); + bind_method(PackedStringArray, slice, sarray("begin", "end"), varray()); bind_method(PackedStringArray, to_byte_array, sarray(), varray()); bind_method(PackedStringArray, sort, sarray(), varray()); bind_method(PackedStringArray, bsearch, sarray("value", "before"), varray(true)); @@ -2013,7 +2013,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector2Array, resize, sarray("new_size"), varray()); bind_method(PackedVector2Array, has, sarray("value"), varray()); bind_method(PackedVector2Array, reverse, sarray(), varray()); - bind_method(PackedVector2Array, subarray, sarray("from", "to"), varray()); + bind_method(PackedVector2Array, slice, sarray("begin", "end"), varray()); bind_method(PackedVector2Array, to_byte_array, sarray(), varray()); bind_method(PackedVector2Array, sort, sarray(), varray()); bind_method(PackedVector2Array, bsearch, sarray("value", "before"), varray(true)); @@ -2033,7 +2033,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector3Array, resize, sarray("new_size"), varray()); bind_method(PackedVector3Array, has, sarray("value"), varray()); bind_method(PackedVector3Array, reverse, sarray(), varray()); - bind_method(PackedVector3Array, subarray, sarray("from", "to"), varray()); + bind_method(PackedVector3Array, slice, sarray("begin", "end"), varray()); bind_method(PackedVector3Array, to_byte_array, sarray(), varray()); bind_method(PackedVector3Array, sort, sarray(), varray()); bind_method(PackedVector3Array, bsearch, sarray("value", "before"), varray(true)); @@ -2053,7 +2053,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedColorArray, resize, sarray("new_size"), varray()); bind_method(PackedColorArray, has, sarray("value"), varray()); bind_method(PackedColorArray, reverse, sarray(), varray()); - bind_method(PackedColorArray, subarray, sarray("from", "to"), varray()); + bind_method(PackedColorArray, slice, sarray("begin", "end"), varray()); bind_method(PackedColorArray, to_byte_array, sarray(), varray()); bind_method(PackedColorArray, sort, sarray(), varray()); bind_method(PackedColorArray, bsearch, sarray("value", "before"), varray(true)); diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index d505ee98cc..5b1861bc9a 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -449,7 +449,10 @@ <argument index="2" name="step" type="int" default="1" /> <argument index="3" name="deep" type="bool" default="false" /> <description> - Duplicates the subset described in the function and returns it in an array, deeply copying the array if [code]deep[/code] is [code]true[/code]. Lower and upper index are inclusive, with the [code]step[/code] describing the change between indices while slicing. Wraps around if [code]begin[/code] or [code]end[/code] are out of bounds or negative. Returns an empty array for invalid parameters. + Returns the slice of the [Array], from [code]begin[/code] (inclusive) to [code]end[/code] (exclusive), as a new [Array]. + If [code]end[/code] is negative, it will be relative to the end of the array. + If specified, [code]step[/code] is the relative index between source elements. + If [code]deep[/code] is true, each element will be copied by value rather than by reference. </description> </method> <method name="sort"> diff --git a/doc/classes/EditorInspector.xml b/doc/classes/EditorInspector.xml index 46cebbd795..dbfbaf103d 100644 --- a/doc/classes/EditorInspector.xml +++ b/doc/classes/EditorInspector.xml @@ -10,7 +10,7 @@ <tutorials> </tutorials> <members> - <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" overrides="ScrollContainer" default="false" /> + <member name="horizontal_scroll_mode" type="int" setter="set_horizontal_scroll_mode" getter="get_horizontal_scroll_mode" overrides="ScrollContainer" enum="ScrollContainer.ScrollMode" default="0" /> </members> <signals> <signal name="object_id_selected"> diff --git a/doc/classes/GPUParticlesAttractorBox.xml b/doc/classes/GPUParticlesAttractorBox3D.xml index 93fdc45e56..0795e11b16 100644 --- a/doc/classes/GPUParticlesAttractorBox.xml +++ b/doc/classes/GPUParticlesAttractorBox3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesAttractorBox" inherits="GPUParticlesAttractor3D" version="4.0"> +<class name="GPUParticlesAttractorBox3D" inherits="GPUParticlesAttractor3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/GPUParticlesAttractorSphere.xml b/doc/classes/GPUParticlesAttractorSphere3D.xml index 4398de55e9..590c966d70 100644 --- a/doc/classes/GPUParticlesAttractorSphere.xml +++ b/doc/classes/GPUParticlesAttractorSphere3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesAttractorSphere" inherits="GPUParticlesAttractor3D" version="4.0"> +<class name="GPUParticlesAttractorSphere3D" inherits="GPUParticlesAttractor3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/GPUParticlesAttractorVectorField.xml b/doc/classes/GPUParticlesAttractorVectorField3D.xml index e164343528..d0dbf886f6 100644 --- a/doc/classes/GPUParticlesAttractorVectorField.xml +++ b/doc/classes/GPUParticlesAttractorVectorField3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesAttractorVectorField" inherits="GPUParticlesAttractor3D" version="4.0"> +<class name="GPUParticlesAttractorVectorField3D" inherits="GPUParticlesAttractor3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/GPUParticlesCollisionBox.xml b/doc/classes/GPUParticlesCollisionBox3D.xml index d2bf4ef538..e899637206 100644 --- a/doc/classes/GPUParticlesCollisionBox.xml +++ b/doc/classes/GPUParticlesCollisionBox3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesCollisionBox" inherits="GPUParticlesCollision3D" version="4.0"> +<class name="GPUParticlesCollisionBox3D" inherits="GPUParticlesCollision3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/GPUParticlesCollisionHeightField.xml b/doc/classes/GPUParticlesCollisionHeightField3D.xml index 99b2ad3ce0..801120d911 100644 --- a/doc/classes/GPUParticlesCollisionHeightField.xml +++ b/doc/classes/GPUParticlesCollisionHeightField3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesCollisionHeightField" inherits="GPUParticlesCollision3D" version="4.0"> +<class name="GPUParticlesCollisionHeightField3D" inherits="GPUParticlesCollision3D" version="4.0"> <brief_description> </brief_description> <description> @@ -13,9 +13,9 @@ </member> <member name="follow_camera_push_ratio" type="float" setter="set_follow_camera_push_ratio" getter="get_follow_camera_push_ratio" default="0.1"> </member> - <member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionHeightField.Resolution" default="2"> + <member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionHeightField3D.Resolution" default="2"> </member> - <member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="GPUParticlesCollisionHeightField.UpdateMode" default="0"> + <member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="GPUParticlesCollisionHeightField3D.UpdateMode" default="0"> </member> </members> <constants> diff --git a/doc/classes/GPUParticlesCollisionSDF.xml b/doc/classes/GPUParticlesCollisionSDF3D.xml index 8d798a9d28..9e86d16eef 100644 --- a/doc/classes/GPUParticlesCollisionSDF.xml +++ b/doc/classes/GPUParticlesCollisionSDF3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesCollisionSDF" inherits="GPUParticlesCollision3D" version="4.0"> +<class name="GPUParticlesCollisionSDF3D" inherits="GPUParticlesCollision3D" version="4.0"> <brief_description> </brief_description> <description> @@ -9,7 +9,7 @@ <members> <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> </member> - <member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF.Resolution" default="2"> + <member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF3D.Resolution" default="2"> </member> <member name="texture" type="Texture3D" setter="set_texture" getter="get_texture"> </member> diff --git a/doc/classes/GPUParticlesCollisionSphere.xml b/doc/classes/GPUParticlesCollisionSphere3D.xml index ddb2391fd9..82728f853b 100644 --- a/doc/classes/GPUParticlesCollisionSphere.xml +++ b/doc/classes/GPUParticlesCollisionSphere3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GPUParticlesCollisionSphere" inherits="GPUParticlesCollision3D" version="4.0"> +<class name="GPUParticlesCollisionSphere3D" inherits="GPUParticlesCollision3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml index fd098481e4..b16d45b8ca 100644 --- a/doc/classes/PackedByteArray.xml +++ b/doc/classes/PackedByteArray.xml @@ -366,18 +366,19 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedByteArray" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. + Returns the slice of the [PackedByteArray], from [code]begin[/code] (inclusive) to [code]end[/code] (exclusive), as a new [PackedByteArray]. + If [code]end[/code]is negative, it will be relative to the end of the array. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedByteArray" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> - Returns the slice of the [PackedByteArray] between indices (inclusive) as a new [PackedByteArray]. Any negative index is considered to be from the end of the array. + Sorts the elements of the array in ascending order. </description> </method> <method name="to_float32_array" qualifiers="const"> diff --git a/doc/classes/PackedColorArray.xml b/doc/classes/PackedColorArray.xml index f69c5504da..13d7440bb9 100644 --- a/doc/classes/PackedColorArray.xml +++ b/doc/classes/PackedColorArray.xml @@ -129,17 +129,17 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedColorArray" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedColorArray" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedFloat32Array.xml b/doc/classes/PackedFloat32Array.xml index ccac607386..151014192f 100644 --- a/doc/classes/PackedFloat32Array.xml +++ b/doc/classes/PackedFloat32Array.xml @@ -130,17 +130,17 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedFloat32Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedFloat32Array" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedFloat64Array.xml b/doc/classes/PackedFloat64Array.xml index b164283b3e..963a02ace8 100644 --- a/doc/classes/PackedFloat64Array.xml +++ b/doc/classes/PackedFloat64Array.xml @@ -130,17 +130,17 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedFloat64Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedFloat64Array" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedInt32Array.xml b/doc/classes/PackedInt32Array.xml index c6ff31ebdd..cef113dee9 100644 --- a/doc/classes/PackedInt32Array.xml +++ b/doc/classes/PackedInt32Array.xml @@ -130,17 +130,17 @@ Returns the array size. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedInt32Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedInt32Array" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedInt64Array.xml b/doc/classes/PackedInt64Array.xml index ff48eb1aad..072df519c6 100644 --- a/doc/classes/PackedInt64Array.xml +++ b/doc/classes/PackedInt64Array.xml @@ -130,17 +130,17 @@ Returns the array size. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedInt64Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedInt64Array" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedStringArray.xml b/doc/classes/PackedStringArray.xml index 4204277ea2..0bded150a3 100644 --- a/doc/classes/PackedStringArray.xml +++ b/doc/classes/PackedStringArray.xml @@ -130,17 +130,17 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedStringArray" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedStringArray" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedVector2Array.xml b/doc/classes/PackedVector2Array.xml index e6a7b2fa41..8e993c41ab 100644 --- a/doc/classes/PackedVector2Array.xml +++ b/doc/classes/PackedVector2Array.xml @@ -130,17 +130,17 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedVector2Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedVector2Array" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/PackedVector3Array.xml b/doc/classes/PackedVector3Array.xml index 6992bbca01..df69e3cd4a 100644 --- a/doc/classes/PackedVector3Array.xml +++ b/doc/classes/PackedVector3Array.xml @@ -129,17 +129,17 @@ Returns the size of the array. </description> </method> - <method name="sort"> - <return type="void" /> + <method name="slice" qualifiers="const"> + <return type="PackedVector3Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> <description> - Sorts the elements of the array in ascending order. </description> </method> - <method name="subarray" qualifiers="const"> - <return type="PackedVector3Array" /> - <argument index="0" name="from" type="int" /> - <argument index="1" name="to" type="int" /> + <method name="sort"> + <return type="void" /> <description> + Sorts the elements of the array in ascending order. </description> </method> <method name="to_byte_array" qualifiers="const"> diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index f0c739bfa3..94d9bfdc31 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -22,14 +22,14 @@ <return type="HScrollBar" /> <description> Returns the horizontal scrollbar [HScrollBar] of this [ScrollContainer]. - [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to disable the horizontal scrollbar, use [member scroll_horizontal_enabled]. If you want to only hide it instead, use [member scroll_horizontal_visible]. + [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use [member horizontal_scroll_mode]. </description> </method> <method name="get_v_scrollbar"> <return type="VScrollBar" /> <description> Returns the vertical scrollbar [VScrollBar] of this [ScrollContainer]. - [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to disable the vertical scrollbar, use [member scroll_vertical_enabled]. If you want to only hide it instead, use [member scroll_vertical_visible]. + [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use [member vertical_scroll_mode]. </description> </method> </methods> @@ -37,26 +37,20 @@ <member name="follow_focus" type="bool" setter="set_follow_focus" getter="is_following_focus" default="false"> If [code]true[/code], the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible. </member> + <member name="horizontal_scroll_mode" type="int" setter="set_horizontal_scroll_mode" getter="get_horizontal_scroll_mode" enum="ScrollContainer.ScrollMode" default="1"> + Controls whether horizontal scrollbar can be used and when it should be visible. See [enum ScrollMode] for options. + </member> <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" /> <member name="scroll_deadzone" type="int" setter="set_deadzone" getter="get_deadzone" default="0"> </member> <member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0"> The current horizontal scroll value. </member> - <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" default="true"> - If [code]true[/code], enables horizontal scrolling. - </member> - <member name="scroll_horizontal_visible" type="bool" setter="set_h_scroll_visible" getter="is_h_scroll_visible" default="true"> - If [code]false[/code], hides the horizontal scrollbar. - </member> <member name="scroll_vertical" type="int" setter="set_v_scroll" getter="get_v_scroll" default="0"> The current vertical scroll value. </member> - <member name="scroll_vertical_enabled" type="bool" setter="set_enable_v_scroll" getter="is_v_scroll_enabled" default="true"> - If [code]true[/code], enables vertical scrolling. - </member> - <member name="scroll_vertical_visible" type="bool" setter="set_v_scroll_visible" getter="is_v_scroll_visible" default="true"> - If [code]false[/code], hides the vertical scrollbar. + <member name="vertical_scroll_mode" type="int" setter="set_vertical_scroll_mode" getter="get_vertical_scroll_mode" enum="ScrollContainer.ScrollMode" default="1"> + Controls whether vertical scrollbar can be used and when it should be visible. See [enum ScrollMode] for options. </member> </members> <signals> @@ -71,6 +65,20 @@ </description> </signal> </signals> + <constants> + <constant name="SCROLL_MODE_DISABLED" value="0" enum="ScrollMode"> + Scrolling disabled, scrollbar will be invisible. + </constant> + <constant name="SCROLL_MODE_AUTO" value="1" enum="ScrollMode"> + Scrolling enabled, scrollbar will be visible only if necessary, i.e. container's content is bigger than the container. + </constant> + <constant name="SCROLL_MODE_SHOW_ALWAYS" value="2" enum="ScrollMode"> + Scrolling enabled, scrollbar will be always visible. + </constant> + <constant name="SCROLL_MODE_SHOW_NEVER" value="3" enum="ScrollMode"> + Scrolling enabled, scrollbar will be hidden. + </constant> + </constants> <theme_items> <theme_item name="bg" data_type="style" type="StyleBox"> The background [StyleBox] of the [ScrollContainer]. diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 0c2754ba74..a306fc20de 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -6117,8 +6117,7 @@ AnimationTrackEditor::AnimationTrackEditor() { track_vbox = memnew(VBoxContainer); scroll->add_child(track_vbox); track_vbox->set_h_size_flags(SIZE_EXPAND_FILL); - scroll->set_enable_h_scroll(false); - scroll->set_enable_v_scroll(true); + scroll->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); track_vbox->add_theme_constant_override("separation", 0); HBoxContainer *bottom_hb = memnew(HBoxContainer); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 1f01e9d4cf..0f6fdcdae5 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1854,7 +1854,7 @@ CodeTextEditor::CodeTextEditor() { ScrollContainer *scroll = memnew(ScrollContainer); scroll->set_h_size_flags(SIZE_EXPAND_FILL); scroll->set_v_size_flags(SIZE_EXPAND_FILL); - scroll->set_enable_v_scroll(false); + scroll->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); status_bar->add_child(scroll); error = memnew(Label); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index dec4f50f03..921c03e8ad 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -339,8 +339,10 @@ void CreateDialog::_confirmed() { memdelete(f); } - emit_signal(SNAME("create")); + // To prevent, emitting an error from the transient window (shader dialog for example) hide this dialog before emitting the "create" signal. hide(); + + emit_signal(SNAME("create")); _cleanup(); } diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 0d7a2eded9..656c219d1c 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1298,8 +1298,7 @@ EditorAudioBuses::EditorAudioBuses() { bus_scroll = memnew(ScrollContainer); bus_scroll->set_v_size_flags(SIZE_EXPAND_FILL); - bus_scroll->set_enable_h_scroll(true); - bus_scroll->set_enable_v_scroll(false); + bus_scroll->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); add_child(bus_scroll); bus_hb = memnew(HBoxContainer); bus_hb->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index d61be38014..485a093aa1 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3540,8 +3540,7 @@ EditorInspector::EditorInspector() { main_vbox->set_h_size_flags(SIZE_EXPAND_FILL); main_vbox->add_theme_constant_override("separation", 0); add_child(main_vbox); - set_enable_h_scroll(false); - set_enable_v_scroll(true); + set_horizontal_scroll_mode(SCROLL_MODE_DISABLED); wide_editors = false; show_categories = false; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 9ffe677091..f06ef39bc3 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -7010,7 +7010,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this))); add_editor_plugin(memnew(MeshEditorPlugin(this))); add_editor_plugin(memnew(MaterialEditorPlugin(this))); - add_editor_plugin(memnew(GPUParticlesCollisionSDFEditorPlugin(this))); + add_editor_plugin(memnew(GPUParticlesCollisionSDF3DEditorPlugin(this))); add_editor_plugin(memnew(InputEventEditorPlugin(this))); add_editor_plugin(memnew(SubViewportPreviewEditorPlugin(this))); add_editor_plugin(memnew(TextControlEditorPlugin(this))); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b30168e5c3..24c229adfd 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -3065,7 +3065,7 @@ void EditorPropertyResource::update_property() { if (res.is_valid() && get_edited_object()->editor_is_section_unfolded(get_edited_property())) { if (!sub_inspector) { sub_inspector = memnew(EditorInspector); - sub_inspector->set_enable_v_scroll(false); + sub_inspector->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); sub_inspector->set_use_doc_hints(true); sub_inspector->set_sub_inspector(true); diff --git a/editor/icons/GPUParticlesAttractorBox.svg b/editor/icons/GPUParticlesAttractorBox3D.svg index 7a2ee7a6b9..7a2ee7a6b9 100644 --- a/editor/icons/GPUParticlesAttractorBox.svg +++ b/editor/icons/GPUParticlesAttractorBox3D.svg diff --git a/editor/icons/GPUParticlesAttractorSphere.svg b/editor/icons/GPUParticlesAttractorSphere3D.svg index 2215331a18..2215331a18 100644 --- a/editor/icons/GPUParticlesAttractorSphere.svg +++ b/editor/icons/GPUParticlesAttractorSphere3D.svg diff --git a/editor/icons/GPUParticlesAttractorVectorField.svg b/editor/icons/GPUParticlesAttractorVectorField3D.svg index 87b2b21804..87b2b21804 100644 --- a/editor/icons/GPUParticlesAttractorVectorField.svg +++ b/editor/icons/GPUParticlesAttractorVectorField3D.svg diff --git a/editor/icons/GPUParticlesCollisionBox.svg b/editor/icons/GPUParticlesCollisionBox3D.svg index 4f7325d086..4f7325d086 100644 --- a/editor/icons/GPUParticlesCollisionBox.svg +++ b/editor/icons/GPUParticlesCollisionBox3D.svg diff --git a/editor/icons/GPUParticlesCollisionHeightField.svg b/editor/icons/GPUParticlesCollisionHeightField3D.svg index 8bdc98a84b..8bdc98a84b 100644 --- a/editor/icons/GPUParticlesCollisionHeightField.svg +++ b/editor/icons/GPUParticlesCollisionHeightField3D.svg diff --git a/editor/icons/GPUParticlesCollisionSDF.svg b/editor/icons/GPUParticlesCollisionSDF3D.svg index 00eca8295d..00eca8295d 100644 --- a/editor/icons/GPUParticlesCollisionSDF.svg +++ b/editor/icons/GPUParticlesCollisionSDF3D.svg diff --git a/editor/icons/GPUParticlesCollisionSphere.svg b/editor/icons/GPUParticlesCollisionSphere3D.svg index cd188ddacc..cd188ddacc 100644 --- a/editor/icons/GPUParticlesCollisionSphere.svg +++ b/editor/icons/GPUParticlesCollisionSphere3D.svg diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 6c5606fbfd..258eb9005f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -226,8 +226,7 @@ AnimationTreeEditor::AnimationTreeEditor() { AnimationNodeAnimation::get_editable_animation_list = get_animation_list; path_edit = memnew(ScrollContainer); add_child(path_edit); - path_edit->set_enable_h_scroll(true); - path_edit->set_enable_v_scroll(false); + path_edit->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); path_hb = memnew(HBoxContainer); path_edit->add_child(path_hb); path_hb->add_child(memnew(Label(TTR("Path:")))); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 1a216b3862..5cfd7525e5 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -288,8 +288,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { previews = memnew(ScrollContainer); previews_bg->add_child(previews); - previews->set_enable_v_scroll(false); - previews->set_enable_h_scroll(true); + previews->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); preview_hb = memnew(HBoxContainer); preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -1431,8 +1430,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_scroll_bg->set_v_size_flags(Control::SIZE_EXPAND_FILL); library_scroll = memnew(ScrollContainer); - library_scroll->set_enable_v_scroll(true); - library_scroll->set_enable_h_scroll(false); + library_scroll->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); library_scroll_bg->add_child(library_scroll); @@ -1499,8 +1497,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { set_process_unhandled_key_input(true); // Global shortcuts since there is no main element to be focused. downloads_scroll = memnew(ScrollContainer); - downloads_scroll->set_enable_h_scroll(true); - downloads_scroll->set_enable_v_scroll(false); + downloads_scroll->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); library_main->add_child(downloads_scroll); downloads_hb = memnew(HBoxContainer); downloads_scroll->add_child(downloads_hb); diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index 57279c57e7..c1a1e44ba2 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "gpu_particles_collision_sdf_editor_plugin.h" -void GPUParticlesCollisionSDFEditorPlugin::_bake() { +void GPUParticlesCollisionSDF3DEditorPlugin::_bake() { if (col_sdf) { if (col_sdf->get_texture().is_null() || !col_sdf->get_texture()->get_path().is_resource_file()) { String path = get_tree()->get_edited_scene_root()->get_scene_file_path(); @@ -49,8 +49,8 @@ void GPUParticlesCollisionSDFEditorPlugin::_bake() { } } -void GPUParticlesCollisionSDFEditorPlugin::edit(Object *p_object) { - GPUParticlesCollisionSDF *s = Object::cast_to<GPUParticlesCollisionSDF>(p_object); +void GPUParticlesCollisionSDF3DEditorPlugin::edit(Object *p_object) { + GPUParticlesCollisionSDF3D *s = Object::cast_to<GPUParticlesCollisionSDF3D>(p_object); if (!s) { return; } @@ -58,11 +58,11 @@ void GPUParticlesCollisionSDFEditorPlugin::edit(Object *p_object) { col_sdf = s; } -bool GPUParticlesCollisionSDFEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("GPUParticlesCollisionSDF"); +bool GPUParticlesCollisionSDF3DEditorPlugin::handles(Object *p_object) const { + return p_object->is_class("GPUParticlesCollisionSDF3D"); } -void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { +void GPUParticlesCollisionSDF3DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { if (!col_sdf) { return; @@ -77,7 +77,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { int data_size = 2; const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF node is using a lot of VRAM. + // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF3D node is using a lot of VRAM. String size_quality; if (size_mb < 8.0) { size_quality = TTR("Low"); @@ -101,7 +101,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { } } -void GPUParticlesCollisionSDFEditorPlugin::make_visible(bool p_visible) { +void GPUParticlesCollisionSDF3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { bake_hb->show(); set_process(true); @@ -111,26 +111,26 @@ void GPUParticlesCollisionSDFEditorPlugin::make_visible(bool p_visible) { } } -EditorProgress *GPUParticlesCollisionSDFEditorPlugin::tmp_progress = nullptr; +EditorProgress *GPUParticlesCollisionSDF3DEditorPlugin::tmp_progress = nullptr; -void GPUParticlesCollisionSDFEditorPlugin::bake_func_begin(int p_steps) { +void GPUParticlesCollisionSDF3DEditorPlugin::bake_func_begin(int p_steps) { ERR_FAIL_COND(tmp_progress != nullptr); tmp_progress = memnew(EditorProgress("bake_sdf", TTR("Bake SDF"), p_steps)); } -void GPUParticlesCollisionSDFEditorPlugin::bake_func_step(int p_step, const String &p_description) { +void GPUParticlesCollisionSDF3DEditorPlugin::bake_func_step(int p_step, const String &p_description) { ERR_FAIL_COND(tmp_progress == nullptr); tmp_progress->step(p_description, p_step, false); } -void GPUParticlesCollisionSDFEditorPlugin::bake_func_end() { +void GPUParticlesCollisionSDF3DEditorPlugin::bake_func_end() { ERR_FAIL_COND(tmp_progress == nullptr); memdelete(tmp_progress); tmp_progress = nullptr; } -void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String &p_path) { +void GPUParticlesCollisionSDF3DEditorPlugin::_sdf_save_path_and_bake(const String &p_path) { probe_file->hide(); if (col_sdf) { Ref<Image> bake_img = col_sdf->bake(); @@ -168,10 +168,10 @@ void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String } } -void GPUParticlesCollisionSDFEditorPlugin::_bind_methods() { +void GPUParticlesCollisionSDF3DEditorPlugin::_bind_methods() { } -GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(EditorNode *p_node) { +GPUParticlesCollisionSDF3DEditorPlugin::GPUParticlesCollisionSDF3DEditorPlugin(EditorNode *p_node) { editor = p_node; bake_hb = memnew(HBoxContainer); bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -180,7 +180,7 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito bake->set_flat(true); bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake SDF")); - bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake)); + bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDF3DEditorPlugin::_bake)); bake_hb->add_child(bake); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); @@ -188,14 +188,14 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito probe_file = memnew(EditorFileDialog); probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); probe_file->add_filter("*.exr"); - probe_file->connect("file_selected", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake)); + probe_file->connect("file_selected", callable_mp(this, &GPUParticlesCollisionSDF3DEditorPlugin::_sdf_save_path_and_bake)); get_editor_interface()->get_base_control()->add_child(probe_file); probe_file->set_title(TTR("Select path for SDF Texture")); - GPUParticlesCollisionSDF::bake_begin_function = bake_func_begin; - GPUParticlesCollisionSDF::bake_step_function = bake_func_step; - GPUParticlesCollisionSDF::bake_end_function = bake_func_end; + GPUParticlesCollisionSDF3D::bake_begin_function = bake_func_begin; + GPUParticlesCollisionSDF3D::bake_step_function = bake_func_step; + GPUParticlesCollisionSDF3D::bake_end_function = bake_func_end; } -GPUParticlesCollisionSDFEditorPlugin::~GPUParticlesCollisionSDFEditorPlugin() { +GPUParticlesCollisionSDF3DEditorPlugin::~GPUParticlesCollisionSDF3DEditorPlugin() { } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h index 26b8b352d6..ce7ca18293 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h @@ -36,10 +36,10 @@ #include "scene/3d/gpu_particles_collision_3d.h" #include "scene/resources/material.h" -class GPUParticlesCollisionSDFEditorPlugin : public EditorPlugin { - GDCLASS(GPUParticlesCollisionSDFEditorPlugin, EditorPlugin); +class GPUParticlesCollisionSDF3DEditorPlugin : public EditorPlugin { + GDCLASS(GPUParticlesCollisionSDF3DEditorPlugin, EditorPlugin); - GPUParticlesCollisionSDF *col_sdf; + GPUParticlesCollisionSDF3D *col_sdf; HBoxContainer *bake_hb; Button *bake; @@ -60,14 +60,14 @@ protected: void _notification(int p_what); public: - virtual String get_name() const override { return "GPUParticlesCollisionSDF"; } + virtual String get_name() const override { return "GPUParticlesCollisionSDF3D"; } bool has_main_screen() const override { return false; } virtual void edit(Object *p_object) override; virtual bool handles(Object *p_object) const override; virtual void make_visible(bool p_visible) override; - GPUParticlesCollisionSDFEditorPlugin(EditorNode *p_node); - ~GPUParticlesCollisionSDFEditorPlugin(); + GPUParticlesCollisionSDF3DEditorPlugin(EditorNode *p_node); + ~GPUParticlesCollisionSDF3DEditorPlugin(); }; #endif // GPU_PARTICLES_COLLISION_SDF_EDITOR_PLUGIN_H diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 1f5d68929a..32355735cc 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -2767,11 +2767,11 @@ int GPUParticlesCollision3DGizmoPlugin::get_priority() const { String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { const Node3D *cs = p_gizmo->get_spatial_node(); - if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { + if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) { return "Radius"; } - if (Object::cast_to<GPUParticlesCollisionBox>(cs) || Object::cast_to<GPUParticlesAttractorBox>(cs) || Object::cast_to<GPUParticlesAttractorVectorField>(cs) || Object::cast_to<GPUParticlesCollisionSDF>(cs) || Object::cast_to<GPUParticlesCollisionHeightField>(cs)) { + if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) { return "Extents"; } @@ -2781,11 +2781,11 @@ String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGiz Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { const Node3D *cs = p_gizmo->get_spatial_node(); - if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { + if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) { return p_gizmo->get_spatial_node()->call("get_radius"); } - if (Object::cast_to<GPUParticlesCollisionBox>(cs) || Object::cast_to<GPUParticlesAttractorBox>(cs) || Object::cast_to<GPUParticlesAttractorVectorField>(cs) || Object::cast_to<GPUParticlesCollisionSDF>(cs) || Object::cast_to<GPUParticlesCollisionHeightField>(cs)) { + if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) { return Vector3(p_gizmo->get_spatial_node()->call("get_extents")); } @@ -2803,7 +2803,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - if (Object::cast_to<GPUParticlesCollisionSphere>(sn) || Object::cast_to<GPUParticlesAttractorSphere>(sn)) { + if (Object::cast_to<GPUParticlesCollisionSphere3D>(sn) || Object::cast_to<GPUParticlesAttractorSphere3D>(sn)) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb); float d = ra.x; @@ -2818,7 +2818,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g sn->call("set_radius", d); } - if (Object::cast_to<GPUParticlesCollisionBox>(sn) || Object::cast_to<GPUParticlesAttractorBox>(sn) || Object::cast_to<GPUParticlesAttractorVectorField>(sn) || Object::cast_to<GPUParticlesCollisionSDF>(sn) || Object::cast_to<GPUParticlesCollisionHeightField>(sn)) { + if (Object::cast_to<GPUParticlesCollisionBox3D>(sn) || Object::cast_to<GPUParticlesAttractorBox3D>(sn) || Object::cast_to<GPUParticlesAttractorVectorField3D>(sn) || Object::cast_to<GPUParticlesCollisionSDF3D>(sn) || Object::cast_to<GPUParticlesCollisionHeightField3D>(sn)) { Vector3 axis; axis[p_id] = 1.0; Vector3 ra, rb; @@ -2841,7 +2841,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) { Node3D *sn = p_gizmo->get_spatial_node(); - if (Object::cast_to<GPUParticlesCollisionSphere>(sn) || Object::cast_to<GPUParticlesAttractorSphere>(sn)) { + if (Object::cast_to<GPUParticlesCollisionSphere3D>(sn) || Object::cast_to<GPUParticlesAttractorSphere3D>(sn)) { if (p_cancel) { sn->call("set_radius", p_restore); return; @@ -2854,7 +2854,7 @@ void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo * ur->commit_action(); } - if (Object::cast_to<GPUParticlesCollisionBox>(sn) || Object::cast_to<GPUParticlesAttractorBox>(sn) || Object::cast_to<GPUParticlesAttractorVectorField>(sn) || Object::cast_to<GPUParticlesCollisionSDF>(sn) || Object::cast_to<GPUParticlesCollisionHeightField>(sn)) { + if (Object::cast_to<GPUParticlesCollisionBox3D>(sn) || Object::cast_to<GPUParticlesAttractorBox3D>(sn) || Object::cast_to<GPUParticlesAttractorVectorField3D>(sn) || Object::cast_to<GPUParticlesCollisionSDF3D>(sn) || Object::cast_to<GPUParticlesCollisionHeightField3D>(sn)) { if (p_cancel) { sn->call("set_extents", p_restore); return; @@ -2880,7 +2880,7 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> handles_material = get_material("handles"); - if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { + if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) { float r = cs->call("get_radius"); Vector<Vector3> points; @@ -2922,7 +2922,7 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->add_handles(handles, handles_material); } - if (Object::cast_to<GPUParticlesCollisionBox>(cs) || Object::cast_to<GPUParticlesAttractorBox>(cs) || Object::cast_to<GPUParticlesAttractorVectorField>(cs) || Object::cast_to<GPUParticlesCollisionSDF>(cs) || Object::cast_to<GPUParticlesCollisionHeightField>(cs)) { + if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) { Vector<Vector3> lines; AABB aabb; aabb.position = -cs->call("get_extents").operator Vector3(); @@ -2947,9 +2947,9 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->add_collision_segments(lines); p_gizmo->add_handles(handles, handles_material); - GPUParticlesCollisionSDF *col_sdf = Object::cast_to<GPUParticlesCollisionSDF>(cs); + GPUParticlesCollisionSDF3D *col_sdf = Object::cast_to<GPUParticlesCollisionSDF3D>(cs); if (col_sdf) { - static const int subdivs[GPUParticlesCollisionSDF::RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 }; + static const int subdivs[GPUParticlesCollisionSDF3D::RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 }; int subdiv = subdivs[col_sdf->get_resolution()]; float cell_size = aabb.get_longest_axis_size() / subdiv; diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index eb5e527640..48b10d5a8b 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -526,8 +526,6 @@ Sprite2DEditor::Sprite2DEditor() { debug_uv_dialog->add_child(vb); ScrollContainer *scroll = memnew(ScrollContainer); scroll->set_custom_minimum_size(Size2(800, 500) * EDSCALE); - scroll->set_enable_h_scroll(true); - scroll->set_enable_v_scroll(true); vb->add_margin_child(TTR("Preview:"), scroll, true); debug_uv = memnew(Control); debug_uv->connect("draw", callable_mp(this, &Sprite2DEditor::_debug_uv_draw)); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index d455f4618b..316ef7b195 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1238,8 +1238,6 @@ SpriteFramesEditor::SpriteFramesEditor() { split_sheet_preview->connect("gui_input", callable_mp(this, &SpriteFramesEditor::_sheet_preview_input)); split_sheet_scroll = memnew(ScrollContainer); - split_sheet_scroll->set_enable_h_scroll(true); - split_sheet_scroll->set_enable_v_scroll(true); split_sheet_scroll->connect("gui_input", callable_mp(this, &SpriteFramesEditor::_sheet_scroll_input)); split_sheet_panel->add_child(split_sheet_scroll); CenterContainer *cc = memnew(CenterContainer); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index f62dbfc2cc..a13cbfa515 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -941,7 +941,7 @@ ThemeItemImportTree::ThemeItemImportTree() { ScrollContainer *import_bulk_sc = memnew(ScrollContainer); import_bulk_sc->set_custom_minimum_size(Size2(260.0, 0.0) * EDSCALE); - import_bulk_sc->set_enable_h_scroll(false); + import_bulk_sc->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); import_main_hb->add_child(import_bulk_sc); VBoxContainer *import_bulk_vb = memnew(VBoxContainer); import_bulk_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -2113,7 +2113,7 @@ VBoxContainer *ThemeTypeEditor::_create_item_list(Theme::DataType p_data_type) { ScrollContainer *items_sc = memnew(ScrollContainer); items_sc->set_v_size_flags(SIZE_EXPAND_FILL); - items_sc->set_enable_h_scroll(false); + items_sc->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); items_tab->add_child(items_sc); VBoxContainer *items_list = memnew(VBoxContainer); items_list->set_h_size_flags(SIZE_EXPAND_FILL); @@ -3102,7 +3102,7 @@ ThemeTypeEditor::ThemeTypeEditor() { ScrollContainer *type_settings_sc = memnew(ScrollContainer); type_settings_sc->set_v_size_flags(SIZE_EXPAND_FILL); - type_settings_sc->set_enable_h_scroll(false); + type_settings_sc->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); type_settings_tab->add_child(type_settings_sc); VBoxContainer *type_settings_list = memnew(VBoxContainer); type_settings_list->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index 7340c17b6e..52155a7136 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -228,8 +228,6 @@ ThemeEditorPreview::ThemeEditorPreview() { add_child(preview_body); preview_container = memnew(ScrollContainer); - preview_container->set_enable_v_scroll(true); - preview_container->set_enable_h_scroll(true); preview_body->add_child(preview_container); MarginContainer *preview_root = memnew(MarginContainer); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index a48c0e795c..436fea77d7 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -2321,7 +2321,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { // Middle panel. ScrollContainer *middle_panel = memnew(ScrollContainer); - middle_panel->set_enable_h_scroll(false); + middle_panel->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); middle_panel->set_custom_minimum_size(Size2i(200, 0) * EDSCALE); split_container_right_side->add_child(middle_panel); @@ -2339,7 +2339,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { tile_inspector = memnew(EditorInspector); tile_inspector->set_undo_redo(undo_redo); - tile_inspector->set_enable_v_scroll(false); + tile_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); tile_inspector->edit(tile_proxy_object); tile_inspector->set_use_folding(true); tile_inspector->connect("property_selected", callable_mp(this, &TileSetAtlasSourceEditor::_inspector_property_selected)); @@ -2385,7 +2385,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { atlas_source_inspector = memnew(EditorInspector); atlas_source_inspector->set_undo_redo(undo_redo); - atlas_source_inspector->set_enable_v_scroll(false); + atlas_source_inspector->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); atlas_source_inspector->edit(atlas_source_proxy_object); middle_vbox_container->add_child(atlas_source_inspector); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index d687d9651d..035fe57d95 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -459,7 +459,7 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() { // Middle panel. ScrollContainer *middle_panel = memnew(ScrollContainer); - middle_panel->set_enable_h_scroll(false); + middle_panel->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); middle_panel->set_custom_minimum_size(Size2i(200, 0) * EDSCALE); split_container_right_side->add_child(middle_panel); @@ -477,7 +477,7 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() { scenes_collection_source_inspector = memnew(EditorInspector); scenes_collection_source_inspector->set_undo_redo(undo_redo); - scenes_collection_source_inspector->set_enable_v_scroll(false); + scenes_collection_source_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); scenes_collection_source_inspector->edit(scenes_collection_source_proxy_object); middle_vbox_container->add_child(scenes_collection_source_inspector); @@ -493,7 +493,7 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() { tile_inspector = memnew(EditorInspector); tile_inspector->set_undo_redo(undo_redo); - tile_inspector->set_enable_v_scroll(false); + tile_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); tile_inspector->edit(tile_proxy_object); tile_inspector->set_use_folding(true); middle_vbox_container->add_child(tile_inspector); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 7ae03b3072..341b59779d 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2595,7 +2595,7 @@ ProjectManager::ProjectManager() { _project_list = memnew(ProjectList); _project_list->connect(ProjectList::SIGNAL_SELECTION_CHANGED, callable_mp(this, &ProjectManager::_update_project_buttons)); _project_list->connect(ProjectList::SIGNAL_PROJECT_ASK_OPEN, callable_mp(this, &ProjectManager::_open_selected_projects_ask)); - _project_list->set_enable_h_scroll(false); + _project_list->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); pc->add_child(_project_list); } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 2235de1599..adb532145b 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -62,68 +62,68 @@ GPUParticlesCollision3D::~GPUParticlesCollision3D() { ///////////////////////////////// -void GPUParticlesCollisionSphere::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesCollisionSphere::set_radius); - ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesCollisionSphere::get_radius); +void GPUParticlesCollisionSphere3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesCollisionSphere3D::set_radius); + ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesCollisionSphere3D::get_radius); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius"); } -void GPUParticlesCollisionSphere::set_radius(real_t p_radius) { +void GPUParticlesCollisionSphere3D::set_radius(real_t p_radius) { radius = p_radius; RS::get_singleton()->particles_collision_set_sphere_radius(_get_collision(), radius); update_gizmos(); } -real_t GPUParticlesCollisionSphere::get_radius() const { +real_t GPUParticlesCollisionSphere3D::get_radius() const { return radius; } -AABB GPUParticlesCollisionSphere::get_aabb() const { +AABB GPUParticlesCollisionSphere3D::get_aabb() const { return AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2, radius * 2, radius * 2)); } -GPUParticlesCollisionSphere::GPUParticlesCollisionSphere() : +GPUParticlesCollisionSphere3D::GPUParticlesCollisionSphere3D() : GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE) { } -GPUParticlesCollisionSphere::~GPUParticlesCollisionSphere() { +GPUParticlesCollisionSphere3D::~GPUParticlesCollisionSphere3D() { } /////////////////////////// -void GPUParticlesCollisionBox::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionBox::set_extents); - ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionBox::get_extents); +void GPUParticlesCollisionBox3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionBox3D::set_extents); + ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionBox3D::get_extents); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents"); } -void GPUParticlesCollisionBox::set_extents(const Vector3 &p_extents) { +void GPUParticlesCollisionBox3D::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); update_gizmos(); } -Vector3 GPUParticlesCollisionBox::get_extents() const { +Vector3 GPUParticlesCollisionBox3D::get_extents() const { return extents; } -AABB GPUParticlesCollisionBox::get_aabb() const { +AABB GPUParticlesCollisionBox3D::get_aabb() const { return AABB(-extents, extents * 2); } -GPUParticlesCollisionBox::GPUParticlesCollisionBox() : +GPUParticlesCollisionBox3D::GPUParticlesCollisionBox3D() : GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_BOX_COLLIDE) { } -GPUParticlesCollisionBox::~GPUParticlesCollisionBox() { +GPUParticlesCollisionBox3D::~GPUParticlesCollisionBox3D() { } /////////////////////////////// /////////////////////////// -void GPUParticlesCollisionSDF::_find_meshes(const AABB &p_aabb, Node *p_at_node, List<PlotMesh> &plot_meshes) { +void GPUParticlesCollisionSDF3D::_find_meshes(const AABB &p_aabb, Node *p_at_node, List<PlotMesh> &plot_meshes) { MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node); if (mi && mi->is_visible_in_tree()) { Ref<Mesh> mesh = mi->get_mesh(); @@ -172,7 +172,7 @@ void GPUParticlesCollisionSDF::_find_meshes(const AABB &p_aabb, Node *p_at_node, } } -uint32_t GPUParticlesCollisionSDF::_create_bvh(LocalVector<BVH> &bvh_tree, FacePos *p_faces, uint32_t p_face_count, const Face3 *p_triangles, float p_thickness) { +uint32_t GPUParticlesCollisionSDF3D::_create_bvh(LocalVector<BVH> &bvh_tree, FacePos *p_faces, uint32_t p_face_count, const Face3 *p_triangles, float p_thickness) { if (p_face_count == 1) { return BVH::LEAF_BIT | p_faces[0].index; } @@ -220,7 +220,7 @@ static _FORCE_INLINE_ real_t Vector3_dot2(const Vector3 &p_vec3) { return p_vec3.dot(p_vec3); } -void GPUParticlesCollisionSDF::_find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance) { +void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance) { if (p_bvh_cell & BVH::LEAF_BIT) { p_bvh_cell &= BVH::LEAF_MASK; //remove bit @@ -321,7 +321,7 @@ void GPUParticlesCollisionSDF::_find_closest_distance(const Vector3 &p_pos, cons } } -void GPUParticlesCollisionSDF::_compute_sdf_z(uint32_t p_z, ComputeSDFParams *params) { +void GPUParticlesCollisionSDF3D::_compute_sdf_z(uint32_t p_z, ComputeSDFParams *params) { int32_t z_ofs = p_z * params->size.y * params->size.x; for (int32_t y = 0; y < params->size.y; y++) { int32_t y_ofs = z_ofs + y * params->size.x; @@ -338,10 +338,10 @@ void GPUParticlesCollisionSDF::_compute_sdf_z(uint32_t p_z, ComputeSDFParams *pa } } -void GPUParticlesCollisionSDF::_compute_sdf(ComputeSDFParams *params) { +void GPUParticlesCollisionSDF3D::_compute_sdf(ComputeSDFParams *params) { ThreadWorkPool work_pool; work_pool.init(); - work_pool.begin_work(params->size.z, this, &GPUParticlesCollisionSDF::_compute_sdf_z, params); + work_pool.begin_work(params->size.z, this, &GPUParticlesCollisionSDF3D::_compute_sdf_z, params); while (!work_pool.is_done_dispatching()) { OS::get_singleton()->delay_usec(10000); bake_step_function(work_pool.get_work_index() * 100 / params->size.z, "Baking SDF"); @@ -350,7 +350,7 @@ void GPUParticlesCollisionSDF::_compute_sdf(ComputeSDFParams *params) { work_pool.finish(); } -Vector3i GPUParticlesCollisionSDF::get_estimated_cell_size() const { +Vector3i GPUParticlesCollisionSDF3D::get_estimated_cell_size() const { static const int subdivs[RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 }; int subdiv = subdivs[get_resolution()]; @@ -365,7 +365,7 @@ Vector3i GPUParticlesCollisionSDF::get_estimated_cell_size() const { return sdf_size; } -Ref<Image> GPUParticlesCollisionSDF::bake() { +Ref<Image> GPUParticlesCollisionSDF3D::bake() { static const int subdivs[RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 }; int subdiv = subdivs[get_resolution()]; @@ -501,18 +501,18 @@ Ref<Image> GPUParticlesCollisionSDF::bake() { return ret; } -void GPUParticlesCollisionSDF::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionSDF::set_extents); - ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionSDF::get_extents); +void GPUParticlesCollisionSDF3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionSDF3D::set_extents); + ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionSDF3D::get_extents); - ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionSDF::set_resolution); - ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionSDF::get_resolution); + ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionSDF3D::set_resolution); + ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionSDF3D::get_resolution); - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesCollisionSDF::set_texture); - ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesCollisionSDF::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesCollisionSDF3D::set_texture); + ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesCollisionSDF3D::get_texture); - ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &GPUParticlesCollisionSDF::set_thickness); - ClassDB::bind_method(D_METHOD("get_thickness"), &GPUParticlesCollisionSDF::get_thickness); + ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &GPUParticlesCollisionSDF3D::set_thickness); + ClassDB::bind_method(D_METHOD("get_thickness"), &GPUParticlesCollisionSDF3D::get_thickness); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents"); ADD_PROPERTY(PropertyInfo(Variant::INT, "resolution", PROPERTY_HINT_ENUM, "16,32,64,128,256,512"), "set_resolution", "get_resolution"); @@ -528,62 +528,62 @@ void GPUParticlesCollisionSDF::_bind_methods() { BIND_ENUM_CONSTANT(RESOLUTION_MAX); } -void GPUParticlesCollisionSDF::set_thickness(float p_thickness) { +void GPUParticlesCollisionSDF3D::set_thickness(float p_thickness) { thickness = p_thickness; } -float GPUParticlesCollisionSDF::get_thickness() const { +float GPUParticlesCollisionSDF3D::get_thickness() const { return thickness; } -void GPUParticlesCollisionSDF::set_extents(const Vector3 &p_extents) { +void GPUParticlesCollisionSDF3D::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); update_gizmos(); } -Vector3 GPUParticlesCollisionSDF::get_extents() const { +Vector3 GPUParticlesCollisionSDF3D::get_extents() const { return extents; } -void GPUParticlesCollisionSDF::set_resolution(Resolution p_resolution) { +void GPUParticlesCollisionSDF3D::set_resolution(Resolution p_resolution) { resolution = p_resolution; update_gizmos(); } -GPUParticlesCollisionSDF::Resolution GPUParticlesCollisionSDF::get_resolution() const { +GPUParticlesCollisionSDF3D::Resolution GPUParticlesCollisionSDF3D::get_resolution() const { return resolution; } -void GPUParticlesCollisionSDF::set_texture(const Ref<Texture3D> &p_texture) { +void GPUParticlesCollisionSDF3D::set_texture(const Ref<Texture3D> &p_texture) { texture = p_texture; RID tex = texture.is_valid() ? texture->get_rid() : RID(); RS::get_singleton()->particles_collision_set_field_texture(_get_collision(), tex); } -Ref<Texture3D> GPUParticlesCollisionSDF::get_texture() const { +Ref<Texture3D> GPUParticlesCollisionSDF3D::get_texture() const { return texture; } -AABB GPUParticlesCollisionSDF::get_aabb() const { +AABB GPUParticlesCollisionSDF3D::get_aabb() const { return AABB(-extents, extents * 2); } -GPUParticlesCollisionSDF::BakeBeginFunc GPUParticlesCollisionSDF::bake_begin_function = nullptr; -GPUParticlesCollisionSDF::BakeStepFunc GPUParticlesCollisionSDF::bake_step_function = nullptr; -GPUParticlesCollisionSDF::BakeEndFunc GPUParticlesCollisionSDF::bake_end_function = nullptr; +GPUParticlesCollisionSDF3D::BakeBeginFunc GPUParticlesCollisionSDF3D::bake_begin_function = nullptr; +GPUParticlesCollisionSDF3D::BakeStepFunc GPUParticlesCollisionSDF3D::bake_step_function = nullptr; +GPUParticlesCollisionSDF3D::BakeEndFunc GPUParticlesCollisionSDF3D::bake_end_function = nullptr; -GPUParticlesCollisionSDF::GPUParticlesCollisionSDF() : +GPUParticlesCollisionSDF3D::GPUParticlesCollisionSDF3D() : GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_SDF_COLLIDE) { } -GPUParticlesCollisionSDF::~GPUParticlesCollisionSDF() { +GPUParticlesCollisionSDF3D::~GPUParticlesCollisionSDF3D() { } //////////////////////////// //////////////////////////// -void GPUParticlesCollisionHeightField::_notification(int p_what) { +void GPUParticlesCollisionHeightField3D::_notification(int p_what) { if (p_what == NOTIFICATION_INTERNAL_PROCESS) { if (update_mode == UPDATE_MODE_ALWAYS) { RS::get_singleton()->particles_collision_height_field_update(_get_collision()); @@ -628,21 +628,21 @@ void GPUParticlesCollisionHeightField::_notification(int p_what) { } } -void GPUParticlesCollisionHeightField::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionHeightField::set_extents); - ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionHeightField::get_extents); +void GPUParticlesCollisionHeightField3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionHeightField3D::set_extents); + ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionHeightField3D::get_extents); - ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionHeightField::set_resolution); - ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionHeightField::get_resolution); + ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionHeightField3D::set_resolution); + ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionHeightField3D::get_resolution); - ClassDB::bind_method(D_METHOD("set_update_mode", "update_mode"), &GPUParticlesCollisionHeightField::set_update_mode); - ClassDB::bind_method(D_METHOD("get_update_mode"), &GPUParticlesCollisionHeightField::get_update_mode); + ClassDB::bind_method(D_METHOD("set_update_mode", "update_mode"), &GPUParticlesCollisionHeightField3D::set_update_mode); + ClassDB::bind_method(D_METHOD("get_update_mode"), &GPUParticlesCollisionHeightField3D::get_update_mode); - ClassDB::bind_method(D_METHOD("set_follow_camera_mode", "enabled"), &GPUParticlesCollisionHeightField::set_follow_camera_mode); - ClassDB::bind_method(D_METHOD("is_follow_camera_mode_enabled"), &GPUParticlesCollisionHeightField::is_follow_camera_mode_enabled); + ClassDB::bind_method(D_METHOD("set_follow_camera_mode", "enabled"), &GPUParticlesCollisionHeightField3D::set_follow_camera_mode); + ClassDB::bind_method(D_METHOD("is_follow_camera_mode_enabled"), &GPUParticlesCollisionHeightField3D::is_follow_camera_mode_enabled); - ClassDB::bind_method(D_METHOD("set_follow_camera_push_ratio", "ratio"), &GPUParticlesCollisionHeightField::set_follow_camera_push_ratio); - ClassDB::bind_method(D_METHOD("get_follow_camera_push_ratio"), &GPUParticlesCollisionHeightField::get_follow_camera_push_ratio); + ClassDB::bind_method(D_METHOD("set_follow_camera_push_ratio", "ratio"), &GPUParticlesCollisionHeightField3D::set_follow_camera_push_ratio); + ClassDB::bind_method(D_METHOD("get_follow_camera_push_ratio"), &GPUParticlesCollisionHeightField3D::get_follow_camera_push_ratio); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents"); ADD_PROPERTY(PropertyInfo(Variant::INT, "resolution", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096,8192"), "set_resolution", "get_resolution"); @@ -663,63 +663,63 @@ void GPUParticlesCollisionHeightField::_bind_methods() { BIND_ENUM_CONSTANT(UPDATE_MODE_ALWAYS); } -void GPUParticlesCollisionHeightField::set_follow_camera_push_ratio(float p_follow_camera_push_ratio) { +void GPUParticlesCollisionHeightField3D::set_follow_camera_push_ratio(float p_follow_camera_push_ratio) { follow_camera_push_ratio = p_follow_camera_push_ratio; } -float GPUParticlesCollisionHeightField::get_follow_camera_push_ratio() const { +float GPUParticlesCollisionHeightField3D::get_follow_camera_push_ratio() const { return follow_camera_push_ratio; } -void GPUParticlesCollisionHeightField::set_extents(const Vector3 &p_extents) { +void GPUParticlesCollisionHeightField3D::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); update_gizmos(); RS::get_singleton()->particles_collision_height_field_update(_get_collision()); } -Vector3 GPUParticlesCollisionHeightField::get_extents() const { +Vector3 GPUParticlesCollisionHeightField3D::get_extents() const { return extents; } -void GPUParticlesCollisionHeightField::set_resolution(Resolution p_resolution) { +void GPUParticlesCollisionHeightField3D::set_resolution(Resolution p_resolution) { resolution = p_resolution; RS::get_singleton()->particles_collision_set_height_field_resolution(_get_collision(), RS::ParticlesCollisionHeightfieldResolution(resolution)); update_gizmos(); RS::get_singleton()->particles_collision_height_field_update(_get_collision()); } -GPUParticlesCollisionHeightField::Resolution GPUParticlesCollisionHeightField::get_resolution() const { +GPUParticlesCollisionHeightField3D::Resolution GPUParticlesCollisionHeightField3D::get_resolution() const { return resolution; } -void GPUParticlesCollisionHeightField::set_update_mode(UpdateMode p_update_mode) { +void GPUParticlesCollisionHeightField3D::set_update_mode(UpdateMode p_update_mode) { update_mode = p_update_mode; set_process_internal(follow_camera_mode || update_mode == UPDATE_MODE_ALWAYS); } -GPUParticlesCollisionHeightField::UpdateMode GPUParticlesCollisionHeightField::get_update_mode() const { +GPUParticlesCollisionHeightField3D::UpdateMode GPUParticlesCollisionHeightField3D::get_update_mode() const { return update_mode; } -void GPUParticlesCollisionHeightField::set_follow_camera_mode(bool p_enabled) { +void GPUParticlesCollisionHeightField3D::set_follow_camera_mode(bool p_enabled) { follow_camera_mode = p_enabled; set_process_internal(follow_camera_mode || update_mode == UPDATE_MODE_ALWAYS); } -bool GPUParticlesCollisionHeightField::is_follow_camera_mode_enabled() const { +bool GPUParticlesCollisionHeightField3D::is_follow_camera_mode_enabled() const { return follow_camera_mode; } -AABB GPUParticlesCollisionHeightField::get_aabb() const { +AABB GPUParticlesCollisionHeightField3D::get_aabb() const { return AABB(-extents, extents * 2); } -GPUParticlesCollisionHeightField::GPUParticlesCollisionHeightField() : +GPUParticlesCollisionHeightField3D::GPUParticlesCollisionHeightField3D() : GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE) { } -GPUParticlesCollisionHeightField::~GPUParticlesCollisionHeightField() { +GPUParticlesCollisionHeightField3D::~GPUParticlesCollisionHeightField3D() { } //////////////////////////// @@ -792,104 +792,104 @@ GPUParticlesAttractor3D::~GPUParticlesAttractor3D() { ///////////////////////////////// -void GPUParticlesAttractorSphere::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesAttractorSphere::set_radius); - ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesAttractorSphere::get_radius); +void GPUParticlesAttractorSphere3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesAttractorSphere3D::set_radius); + ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesAttractorSphere3D::get_radius); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius"); } -void GPUParticlesAttractorSphere::set_radius(real_t p_radius) { +void GPUParticlesAttractorSphere3D::set_radius(real_t p_radius) { radius = p_radius; RS::get_singleton()->particles_collision_set_sphere_radius(_get_collision(), radius); update_gizmos(); } -real_t GPUParticlesAttractorSphere::get_radius() const { +real_t GPUParticlesAttractorSphere3D::get_radius() const { return radius; } -AABB GPUParticlesAttractorSphere::get_aabb() const { +AABB GPUParticlesAttractorSphere3D::get_aabb() const { return AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2, radius * 2, radius * 2)); } -GPUParticlesAttractorSphere::GPUParticlesAttractorSphere() : +GPUParticlesAttractorSphere3D::GPUParticlesAttractorSphere3D() : GPUParticlesAttractor3D(RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT) { } -GPUParticlesAttractorSphere::~GPUParticlesAttractorSphere() { +GPUParticlesAttractorSphere3D::~GPUParticlesAttractorSphere3D() { } /////////////////////////// -void GPUParticlesAttractorBox::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorBox::set_extents); - ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorBox::get_extents); +void GPUParticlesAttractorBox3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorBox3D::set_extents); + ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorBox3D::get_extents); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents"); } -void GPUParticlesAttractorBox::set_extents(const Vector3 &p_extents) { +void GPUParticlesAttractorBox3D::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); update_gizmos(); } -Vector3 GPUParticlesAttractorBox::get_extents() const { +Vector3 GPUParticlesAttractorBox3D::get_extents() const { return extents; } -AABB GPUParticlesAttractorBox::get_aabb() const { +AABB GPUParticlesAttractorBox3D::get_aabb() const { return AABB(-extents, extents * 2); } -GPUParticlesAttractorBox::GPUParticlesAttractorBox() : +GPUParticlesAttractorBox3D::GPUParticlesAttractorBox3D() : GPUParticlesAttractor3D(RS::PARTICLES_COLLISION_TYPE_BOX_ATTRACT) { } -GPUParticlesAttractorBox::~GPUParticlesAttractorBox() { +GPUParticlesAttractorBox3D::~GPUParticlesAttractorBox3D() { } /////////////////////////// -void GPUParticlesAttractorVectorField::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorVectorField::set_extents); - ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorVectorField::get_extents); +void GPUParticlesAttractorVectorField3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorVectorField3D::set_extents); + ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorVectorField3D::get_extents); - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesAttractorVectorField::set_texture); - ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesAttractorVectorField::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesAttractorVectorField3D::set_texture); + ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesAttractorVectorField3D::get_texture); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture3D"), "set_texture", "get_texture"); } -void GPUParticlesAttractorVectorField::set_extents(const Vector3 &p_extents) { +void GPUParticlesAttractorVectorField3D::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); update_gizmos(); } -Vector3 GPUParticlesAttractorVectorField::get_extents() const { +Vector3 GPUParticlesAttractorVectorField3D::get_extents() const { return extents; } -void GPUParticlesAttractorVectorField::set_texture(const Ref<Texture3D> &p_texture) { +void GPUParticlesAttractorVectorField3D::set_texture(const Ref<Texture3D> &p_texture) { texture = p_texture; RID tex = texture.is_valid() ? texture->get_rid() : RID(); RS::get_singleton()->particles_collision_set_field_texture(_get_collision(), tex); } -Ref<Texture3D> GPUParticlesAttractorVectorField::get_texture() const { +Ref<Texture3D> GPUParticlesAttractorVectorField3D::get_texture() const { return texture; } -AABB GPUParticlesAttractorVectorField::get_aabb() const { +AABB GPUParticlesAttractorVectorField3D::get_aabb() const { return AABB(-extents, extents * 2); } -GPUParticlesAttractorVectorField::GPUParticlesAttractorVectorField() : +GPUParticlesAttractorVectorField3D::GPUParticlesAttractorVectorField3D() : GPUParticlesAttractor3D(RS::PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT) { } -GPUParticlesAttractorVectorField::~GPUParticlesAttractorVectorField() { +GPUParticlesAttractorVectorField3D::~GPUParticlesAttractorVectorField3D() { } diff --git a/scene/3d/gpu_particles_collision_3d.h b/scene/3d/gpu_particles_collision_3d.h index fbf68ed6df..5568ecdfc1 100644 --- a/scene/3d/gpu_particles_collision_3d.h +++ b/scene/3d/gpu_particles_collision_3d.h @@ -55,8 +55,8 @@ public: ~GPUParticlesCollision3D(); }; -class GPUParticlesCollisionSphere : public GPUParticlesCollision3D { - GDCLASS(GPUParticlesCollisionSphere, GPUParticlesCollision3D); +class GPUParticlesCollisionSphere3D : public GPUParticlesCollision3D { + GDCLASS(GPUParticlesCollisionSphere3D, GPUParticlesCollision3D); real_t radius = 1.0; @@ -69,12 +69,12 @@ public: virtual AABB get_aabb() const override; - GPUParticlesCollisionSphere(); - ~GPUParticlesCollisionSphere(); + GPUParticlesCollisionSphere3D(); + ~GPUParticlesCollisionSphere3D(); }; -class GPUParticlesCollisionBox : public GPUParticlesCollision3D { - GDCLASS(GPUParticlesCollisionBox, GPUParticlesCollision3D); +class GPUParticlesCollisionBox3D : public GPUParticlesCollision3D { + GDCLASS(GPUParticlesCollisionBox3D, GPUParticlesCollision3D); Vector3 extents = Vector3(1, 1, 1); @@ -87,12 +87,12 @@ public: virtual AABB get_aabb() const override; - GPUParticlesCollisionBox(); - ~GPUParticlesCollisionBox(); + GPUParticlesCollisionBox3D(); + ~GPUParticlesCollisionBox3D(); }; -class GPUParticlesCollisionSDF : public GPUParticlesCollision3D { - GDCLASS(GPUParticlesCollisionSDF, GPUParticlesCollision3D); +class GPUParticlesCollisionSDF3D : public GPUParticlesCollision3D { + GDCLASS(GPUParticlesCollisionSDF3D, GPUParticlesCollision3D); public: enum Resolution { @@ -184,14 +184,14 @@ public: static BakeStepFunc bake_step_function; static BakeEndFunc bake_end_function; - GPUParticlesCollisionSDF(); - ~GPUParticlesCollisionSDF(); + GPUParticlesCollisionSDF3D(); + ~GPUParticlesCollisionSDF3D(); }; -VARIANT_ENUM_CAST(GPUParticlesCollisionSDF::Resolution) +VARIANT_ENUM_CAST(GPUParticlesCollisionSDF3D::Resolution) -class GPUParticlesCollisionHeightField : public GPUParticlesCollision3D { - GDCLASS(GPUParticlesCollisionHeightField, GPUParticlesCollision3D); +class GPUParticlesCollisionHeightField3D : public GPUParticlesCollision3D { + GDCLASS(GPUParticlesCollisionHeightField3D, GPUParticlesCollision3D); public: enum Resolution { @@ -239,12 +239,12 @@ public: virtual AABB get_aabb() const override; - GPUParticlesCollisionHeightField(); - ~GPUParticlesCollisionHeightField(); + GPUParticlesCollisionHeightField3D(); + ~GPUParticlesCollisionHeightField3D(); }; -VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField::Resolution) -VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField::UpdateMode) +VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField3D::Resolution) +VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField3D::UpdateMode) class GPUParticlesAttractor3D : public VisualInstance3D { GDCLASS(GPUParticlesAttractor3D, VisualInstance3D); @@ -279,8 +279,8 @@ public: ~GPUParticlesAttractor3D(); }; -class GPUParticlesAttractorSphere : public GPUParticlesAttractor3D { - GDCLASS(GPUParticlesAttractorSphere, GPUParticlesAttractor3D); +class GPUParticlesAttractorSphere3D : public GPUParticlesAttractor3D { + GDCLASS(GPUParticlesAttractorSphere3D, GPUParticlesAttractor3D); real_t radius = 1.0; @@ -293,12 +293,12 @@ public: virtual AABB get_aabb() const override; - GPUParticlesAttractorSphere(); - ~GPUParticlesAttractorSphere(); + GPUParticlesAttractorSphere3D(); + ~GPUParticlesAttractorSphere3D(); }; -class GPUParticlesAttractorBox : public GPUParticlesAttractor3D { - GDCLASS(GPUParticlesAttractorBox, GPUParticlesAttractor3D); +class GPUParticlesAttractorBox3D : public GPUParticlesAttractor3D { + GDCLASS(GPUParticlesAttractorBox3D, GPUParticlesAttractor3D); Vector3 extents = Vector3(1, 1, 1); @@ -311,12 +311,12 @@ public: virtual AABB get_aabb() const override; - GPUParticlesAttractorBox(); - ~GPUParticlesAttractorBox(); + GPUParticlesAttractorBox3D(); + ~GPUParticlesAttractorBox3D(); }; -class GPUParticlesAttractorVectorField : public GPUParticlesAttractor3D { - GDCLASS(GPUParticlesAttractorVectorField, GPUParticlesAttractor3D); +class GPUParticlesAttractorVectorField3D : public GPUParticlesAttractor3D { + GDCLASS(GPUParticlesAttractorVectorField3D, GPUParticlesAttractor3D); Vector3 extents = Vector3(1, 1, 1); Ref<Texture3D> texture; @@ -333,8 +333,8 @@ public: virtual AABB get_aabb() const override; - GPUParticlesAttractorVectorField(); - ~GPUParticlesAttractorVectorField(); + GPUParticlesAttractorVectorField3D(); + ~GPUParticlesAttractorVectorField3D(); }; #endif // GPU_PARTICLES_COLLISION_3D_H diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fd6fb48412..3a926b3fb5 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2590,7 +2590,7 @@ Control *Control::get_focus_owner() const { void Control::warp_mouse(const Point2 &p_to_pos) { ERR_FAIL_COND(!is_inside_tree()); - get_viewport()->warp_mouse(get_screen_transform().xform(p_to_pos)); + get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos)); } bool Control::is_text_field() const { diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index f89623630d..dcd2c32a3b 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -49,10 +49,10 @@ Size2 ScrollContainer::get_minimum_size() const { } Size2 minsize = c->get_combined_minimum_size(); - if (!scroll_h) { + if (horizontal_scroll_mode == SCROLL_MODE_DISABLED) { min_size.x = MAX(min_size.x, minsize.x); } - if (!scroll_v) { + if (vertical_scroll_mode == SCROLL_MODE_DISABLED) { min_size.y = MAX(min_size.y, minsize.y); } } @@ -170,7 +170,7 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) { Vector2 motion = mm->get_relative(); drag_accum -= motion; - if (beyond_deadzone || (scroll_h && Math::abs(drag_accum.x) > deadzone) || (scroll_v && Math::abs(drag_accum.y) > deadzone)) { + if (beyond_deadzone || (horizontal_scroll_mode != SCROLL_MODE_DISABLED && Math::abs(drag_accum.x) > deadzone) || (vertical_scroll_mode != SCROLL_MODE_DISABLED && Math::abs(drag_accum.y) > deadzone)) { if (!beyond_deadzone) { propagate_notification(NOTIFICATION_SCROLL_BEGIN); emit_signal(SNAME("scroll_started")); @@ -180,12 +180,12 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) { drag_accum = -motion; } Vector2 diff = drag_from + drag_accum; - if (scroll_h) { + if (horizontal_scroll_mode != SCROLL_MODE_DISABLED) { h_scroll->set_value(diff.x); } else { drag_accum.x = 0; } - if (scroll_v) { + if (vertical_scroll_mode != SCROLL_MODE_DISABLED) { v_scroll->set_value(diff.y); } else { drag_accum.y = 0; @@ -286,7 +286,7 @@ void ScrollContainer::_update_dimensions() { child_max_size.y = MAX(child_max_size.y, minsize.y); Rect2 r = Rect2(-Size2(get_h_scroll(), get_v_scroll()), minsize); - if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) { + if (horizontal_scroll_mode == SCROLL_MODE_DISABLED || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) { r.position.x = 0; if (c->get_h_size_flags() & SIZE_EXPAND) { r.size.width = MAX(size.width, minsize.width); @@ -294,7 +294,7 @@ void ScrollContainer::_update_dimensions() { r.size.width = minsize.width; } } - if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) { + if (vertical_scroll_mode == SCROLL_MODE_DISABLED || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) { r.position.y = 0; if (c->get_v_size_flags() & SIZE_EXPAND) { r.size.height = MAX(size.height, minsize.height); @@ -364,10 +364,10 @@ void ScrollContainer::_notification(int p_what) { turnoff_v = true; } - if (scroll_h) { + if (horizontal_scroll_mode != SCROLL_MODE_DISABLED) { h_scroll->set_value(pos.x); } - if (scroll_v) { + if (vertical_scroll_mode != SCROLL_MODE_DISABLED) { v_scroll->set_value(pos.y); } @@ -413,17 +413,17 @@ void ScrollContainer::update_scrollbars() { Size2 hmin; Size2 vmin; - if (scroll_h) { + if (horizontal_scroll_mode != SCROLL_MODE_DISABLED) { hmin = h_scroll->get_combined_minimum_size(); } - if (scroll_v) { + if (vertical_scroll_mode != SCROLL_MODE_DISABLED) { vmin = v_scroll->get_combined_minimum_size(); } Size2 min = child_max_size; - bool hide_scroll_h = !scroll_h || min.width <= size.width || !h_scroll_visible; - bool hide_scroll_v = !scroll_v || min.height <= size.height || !v_scroll_visible; + bool hide_scroll_h = horizontal_scroll_mode != SCROLL_MODE_SHOW_ALWAYS && (horizontal_scroll_mode == SCROLL_MODE_DISABLED || horizontal_scroll_mode == SCROLL_MODE_SHOW_NEVER || (horizontal_scroll_mode == SCROLL_MODE_AUTO && min.width <= size.width)); + bool hide_scroll_v = vertical_scroll_mode != SCROLL_MODE_SHOW_ALWAYS && (vertical_scroll_mode == SCROLL_MODE_DISABLED || vertical_scroll_mode == SCROLL_MODE_SHOW_NEVER || (vertical_scroll_mode == SCROLL_MODE_AUTO && min.height <= size.height)); h_scroll->set_max(min.width); h_scroll->set_page(size.width - (hide_scroll_v ? 0 : vmin.width)); @@ -461,58 +461,32 @@ int ScrollContainer::get_v_scroll() const { return v_scroll->get_value(); } -void ScrollContainer::set_enable_h_scroll(bool p_enable) { - if (scroll_h == p_enable) { +void ScrollContainer::set_horizontal_scroll_mode(ScrollMode p_mode) { + if (horizontal_scroll_mode == p_mode) { return; } - scroll_h = p_enable; + horizontal_scroll_mode = p_mode; update_minimum_size(); queue_sort(); } -bool ScrollContainer::is_h_scroll_enabled() const { - return scroll_h; +ScrollContainer::ScrollMode ScrollContainer::get_horizontal_scroll_mode() const { + return horizontal_scroll_mode; } -void ScrollContainer::set_enable_v_scroll(bool p_enable) { - if (scroll_v == p_enable) { +void ScrollContainer::set_vertical_scroll_mode(ScrollMode p_mode) { + if (vertical_scroll_mode == p_mode) { return; } - scroll_v = p_enable; + vertical_scroll_mode = p_mode; update_minimum_size(); queue_sort(); } -bool ScrollContainer::is_v_scroll_enabled() const { - return scroll_v; -} - -void ScrollContainer::set_h_scroll_visible(bool p_visible) { - if (h_scroll_visible == p_visible) { - return; - } - - h_scroll_visible = p_visible; - update_scrollbars(); -} - -bool ScrollContainer::is_h_scroll_visible() const { - return h_scroll_visible; -} - -void ScrollContainer::set_v_scroll_visible(bool p_visible) { - if (v_scroll_visible == p_visible) { - return; - } - - v_scroll_visible = p_visible; - update_scrollbars(); -} - -bool ScrollContainer::is_v_scroll_visible() const { - return v_scroll_visible; +ScrollContainer::ScrollMode ScrollContainer::get_vertical_scroll_mode() const { + return vertical_scroll_mode; } int ScrollContainer::get_deadzone() const { @@ -575,17 +549,11 @@ void ScrollContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &ScrollContainer::set_v_scroll); ClassDB::bind_method(D_METHOD("get_v_scroll"), &ScrollContainer::get_v_scroll); - ClassDB::bind_method(D_METHOD("set_enable_h_scroll", "enable"), &ScrollContainer::set_enable_h_scroll); - ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled); - - ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll); - ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled); + ClassDB::bind_method(D_METHOD("set_horizontal_scroll_mode", "enable"), &ScrollContainer::set_horizontal_scroll_mode); + ClassDB::bind_method(D_METHOD("get_horizontal_scroll_mode"), &ScrollContainer::get_horizontal_scroll_mode); - ClassDB::bind_method(D_METHOD("set_h_scroll_visible", "visible"), &ScrollContainer::set_h_scroll_visible); - ClassDB::bind_method(D_METHOD("is_h_scroll_visible"), &ScrollContainer::is_h_scroll_visible); - - ClassDB::bind_method(D_METHOD("set_v_scroll_visible", "visible"), &ScrollContainer::set_v_scroll_visible); - ClassDB::bind_method(D_METHOD("is_v_scroll_visible"), &ScrollContainer::is_v_scroll_visible); + ClassDB::bind_method(D_METHOD("set_vertical_scroll_mode", "enable"), &ScrollContainer::set_vertical_scroll_mode); + ClassDB::bind_method(D_METHOD("get_vertical_scroll_mode"), &ScrollContainer::get_vertical_scroll_mode); ClassDB::bind_method(D_METHOD("set_deadzone", "deadzone"), &ScrollContainer::set_deadzone); ClassDB::bind_method(D_METHOD("get_deadzone"), &ScrollContainer::get_deadzone); @@ -605,12 +573,15 @@ void ScrollContainer::_bind_methods() { ADD_GROUP("Scroll", "scroll_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal"), "set_h_scroll", "get_h_scroll"); ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_vertical"), "set_v_scroll", "get_v_scroll"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_enabled"), "set_enable_h_scroll", "is_h_scroll_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_enabled"), "set_enable_v_scroll", "is_v_scroll_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_visible"), "set_h_scroll_visible", "is_h_scroll_visible"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_visible"), "set_v_scroll_visible", "is_v_scroll_visible"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show"), "set_horizontal_scroll_mode", "get_horizontal_scroll_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show"), "set_vertical_scroll_mode", "get_vertical_scroll_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_deadzone"), "set_deadzone", "get_deadzone"); + BIND_ENUM_CONSTANT(SCROLL_MODE_DISABLED); + BIND_ENUM_CONSTANT(SCROLL_MODE_AUTO); + BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_ALWAYS); + BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_NEVER); + GLOBAL_DEF("gui/common/default_scroll_deadzone", 0); }; diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index 9c87d07f66..0cec4db57a 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -38,6 +38,15 @@ class ScrollContainer : public Container { GDCLASS(ScrollContainer, Container); +public: + enum ScrollMode { + SCROLL_MODE_DISABLED = 0, + SCROLL_MODE_AUTO, + SCROLL_MODE_SHOW_ALWAYS, + SCROLL_MODE_SHOW_NEVER, + }; + +private: HScrollBar *h_scroll; VScrollBar *v_scroll; @@ -54,11 +63,8 @@ class ScrollContainer : public Container { bool drag_touching_deaccel = false; bool beyond_deadzone = false; - bool scroll_h = true; - bool scroll_v = true; - - bool h_scroll_visible = true; - bool v_scroll_visible = true; + ScrollMode horizontal_scroll_mode = SCROLL_MODE_AUTO; + ScrollMode vertical_scroll_mode = SCROLL_MODE_AUTO; int deadzone = 0; bool follow_focus = false; @@ -87,17 +93,11 @@ public: void set_v_scroll(int p_pos); int get_v_scroll() const; - void set_enable_h_scroll(bool p_enable); - bool is_h_scroll_enabled() const; - - void set_enable_v_scroll(bool p_enable); - bool is_v_scroll_enabled() const; + void set_horizontal_scroll_mode(ScrollMode p_mode); + ScrollMode get_horizontal_scroll_mode() const; - void set_h_scroll_visible(bool p_visible); - bool is_h_scroll_visible() const; - - void set_v_scroll_visible(bool p_visible); - bool is_v_scroll_visible() const; + void set_vertical_scroll_mode(ScrollMode p_mode); + ScrollMode get_vertical_scroll_mode() const; int get_deadzone() const; void set_deadzone(int p_deadzone); @@ -114,4 +114,6 @@ public: ScrollContainer(); }; +VARIANT_ENUM_CAST(ScrollContainer::ScrollMode); + #endif diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index b8442e7f70..b56cd18930 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -476,14 +476,14 @@ void register_scene_types() { GDREGISTER_VIRTUAL_CLASS(Lightmapper); GDREGISTER_CLASS(GPUParticles3D); GDREGISTER_VIRTUAL_CLASS(GPUParticlesCollision3D); - GDREGISTER_CLASS(GPUParticlesCollisionBox); - GDREGISTER_CLASS(GPUParticlesCollisionSphere); - GDREGISTER_CLASS(GPUParticlesCollisionSDF); - GDREGISTER_CLASS(GPUParticlesCollisionHeightField); + GDREGISTER_CLASS(GPUParticlesCollisionBox3D); + GDREGISTER_CLASS(GPUParticlesCollisionSphere3D); + GDREGISTER_CLASS(GPUParticlesCollisionSDF3D); + GDREGISTER_CLASS(GPUParticlesCollisionHeightField3D); GDREGISTER_VIRTUAL_CLASS(GPUParticlesAttractor3D); - GDREGISTER_CLASS(GPUParticlesAttractorBox); - GDREGISTER_CLASS(GPUParticlesAttractorSphere); - GDREGISTER_CLASS(GPUParticlesAttractorVectorField); + GDREGISTER_CLASS(GPUParticlesAttractorBox3D); + GDREGISTER_CLASS(GPUParticlesAttractorSphere3D); + GDREGISTER_CLASS(GPUParticlesAttractorVectorField3D); GDREGISTER_CLASS(CPUParticles3D); GDREGISTER_CLASS(Position3D); diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index 5acb1cb99c..d1085245c0 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -1858,7 +1858,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region, Ref<Image> img; img.instantiate(); for (uint32_t i = 0; i < cascade_size; i++) { - Vector<uint8_t> subarr = data.subarray(128 * 128 * i, 128 * 128 * (i + 1) - 1); + Vector<uint8_t> subarr = data.slice(128 * 128 * i, 128 * 128 * (i + 1)); img->create(cascade_size, cascade_size, false, Image::FORMAT_L8, subarr); img->save_png("res://cascade_sdf_" + itos(cascade) + "_" + itos(i) + ".png"); } @@ -1871,7 +1871,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region, Ref<Image> img; img.instantiate(); for (uint32_t i = 0; i < cascade_size; i++) { - Vector<uint8_t> subarr = data.subarray(128 * 128 * i * 2, 128 * 128 * (i + 1) * 2 - 1); + Vector<uint8_t> subarr = data.slice(128 * 128 * i * 2, 128 * 128 * (i + 1) * 2); img->createcascade_size, cascade_size, false, Image::FORMAT_RGB565, subarr); img->convert(Image::FORMAT_RGBA8); img->save_png("res://cascade_" + itos(cascade) + "_" + itos(i) + ".png"); diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index cd5d70e12f..f8d0aad4fa 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -1089,7 +1089,7 @@ Vector<Ref<Image>> RendererStorageRD::texture_3d_get(RID p_texture) const { const Texture::BufferSlice3D &bs = tex->buffer_slices_3d[i]; ERR_FAIL_COND_V(bs.offset >= (uint32_t)all_data.size(), Vector<Ref<Image>>()); ERR_FAIL_COND_V(bs.offset + bs.buffer_size > (uint32_t)all_data.size(), Vector<Ref<Image>>()); - Vector<uint8_t> sub_region = all_data.subarray(bs.offset, bs.offset + bs.buffer_size - 1); + Vector<uint8_t> sub_region = all_data.slice(bs.offset, bs.offset + bs.buffer_size); Ref<Image> img; img.instantiate(); diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index a23911e81a..23d3bf030f 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -1373,7 +1373,7 @@ Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_sur Array blend_shape_array; blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh)); for (uint32_t i = 0; i < blend_shape_count; i++) { - Vector<uint8_t> bs_data = blend_shape_data.subarray(i * divisor, (i + 1) * divisor - 1); + Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor); Vector<uint8_t> unused; blend_shape_array.set(i, _get_array_from_surface(bs_format, bs_data, unused, unused, sd.vertex_count, unused, 0)); } diff --git a/tests/core/templates/test_vector.h b/tests/core/templates/test_vector.h index 658ca5adf1..6ea865dacc 100644 --- a/tests/core/templates/test_vector.h +++ b/tests/core/templates/test_vector.h @@ -238,7 +238,7 @@ TEST_CASE("[Vector] To byte array") { CHECK(byte_array[15] == 59); } -TEST_CASE("[Vector] Subarray") { +TEST_CASE("[Vector] Slice") { Vector<int> vector; vector.push_back(0); vector.push_back(1); @@ -246,27 +246,27 @@ TEST_CASE("[Vector] Subarray") { vector.push_back(3); vector.push_back(4); - Vector<int> subarray1 = vector.subarray(1, 2); - CHECK(subarray1.size() == 2); - CHECK(subarray1[0] == 1); - CHECK(subarray1[1] == 2); - - Vector<int> subarray2 = vector.subarray(1, -1); - CHECK(subarray2.size() == 4); - CHECK(subarray2[0] == 1); - CHECK(subarray2[1] == 2); - CHECK(subarray2[2] == 3); - CHECK(subarray2[3] == 4); - - Vector<int> subarray3 = vector.subarray(-2, -1); - CHECK(subarray3.size() == 2); - CHECK(subarray3[0] == 3); - CHECK(subarray3[1] == 4); - - Vector<int> subarray4 = vector.subarray(-3, 3); - CHECK(subarray4.size() == 2); - CHECK(subarray4[0] == 2); - CHECK(subarray4[1] == 3); + Vector<int> slice1 = vector.slice(1, 3); + CHECK(slice1.size() == 2); + CHECK(slice1[0] == 1); + CHECK(slice1[1] == 2); + + Vector<int> slice2 = vector.slice(1, -1); + CHECK(slice2.size() == 4); + CHECK(slice2[0] == 1); + CHECK(slice2[1] == 2); + CHECK(slice2[2] == 3); + CHECK(slice2[3] == 4); + + Vector<int> slice3 = vector.slice(3, -1); + CHECK(slice3.size() == 2); + CHECK(slice3[0] == 3); + CHECK(slice3[1] == 4); + + Vector<int> slice4 = vector.slice(2, -2); + CHECK(slice4.size() == 2); + CHECK(slice4[0] == 2); + CHECK(slice4[1] == 3); } TEST_CASE("[Vector] Find, has") { diff --git a/tests/core/variant/test_array.h b/tests/core/variant/test_array.h index e2e84f2962..d02b3d0e39 100644 --- a/tests/core/variant/test_array.h +++ b/tests/core/variant/test_array.h @@ -246,6 +246,37 @@ TEST_CASE("[Array] max() and min()") { CHECK(min == 2); } +TEST_CASE("[Array] slice()") { + Array array; + array.push_back(0); + array.push_back(1); + array.push_back(2); + array.push_back(3); + array.push_back(4); + + Array slice1 = array.slice(1, 3); + CHECK(slice1.size() == 2); + CHECK(slice1[0] == Variant(1)); + CHECK(slice1[1] == Variant(2)); + + Array slice2 = array.slice(1, -1); + CHECK(slice2.size() == 4); + CHECK(slice2[0] == Variant(1)); + CHECK(slice2[1] == Variant(2)); + CHECK(slice2[2] == Variant(3)); + CHECK(slice2[3] == Variant(4)); + + Array slice3 = array.slice(3, -1); + CHECK(slice3.size() == 2); + CHECK(slice3[0] == Variant(3)); + CHECK(slice3[1] == Variant(4)); + + Array slice4 = array.slice(2, -2); + CHECK(slice4.size() == 2); + CHECK(slice4[0] == Variant(2)); + CHECK(slice4[1] == Variant(3)); +} + TEST_CASE("[Array] Duplicate array") { // a = [1, [2, 2], {3: 3}] Array a = build_array(1, build_array(2, 2), build_dictionary(3, 3)); |