diff options
85 files changed, 1804 insertions, 1031 deletions
diff --git a/core/math/vector4.cpp b/core/math/vector4.cpp index 4697c311b4..1dd5adad2b 100644 --- a/core/math/vector4.cpp +++ b/core/math/vector4.cpp @@ -91,6 +91,10 @@ real_t Vector4::distance_to(const Vector4 &p_to) const { return (p_to - *this).length(); } +real_t Vector4::distance_squared_to(const Vector4 &p_to) const { + return (p_to - *this).length_squared(); +} + Vector4 Vector4::direction_to(const Vector4 &p_to) const { Vector4 ret(p_to.x - x, p_to.y - y, p_to.z - z, p_to.w - w); ret.normalize(); diff --git a/core/math/vector4.h b/core/math/vector4.h index 373a6a1218..d26fe15941 100644 --- a/core/math/vector4.h +++ b/core/math/vector4.h @@ -79,6 +79,7 @@ struct _NO_DISCARD_ Vector4 { bool is_normalized() const; real_t distance_to(const Vector4 &p_to) const; + real_t distance_squared_to(const Vector4 &p_to) const; Vector4 direction_to(const Vector4 &p_to) const; Vector4 abs() const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 5c298f9b3b..eba12b68bb 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1746,6 +1746,7 @@ static void _register_variant_builtin_methods() { bind_method(Vector4, is_normalized, sarray(), varray()); bind_method(Vector4, direction_to, sarray("to"), varray()); bind_method(Vector4, distance_to, sarray("to"), varray()); + bind_method(Vector4, distance_squared_to, sarray("to"), varray()); bind_method(Vector4, dot, sarray("with"), varray()); bind_method(Vector4, inverse, sarray(), varray()); bind_method(Vector4, is_equal_approx, sarray("with"), varray()); @@ -2067,6 +2068,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedByteArray, fill, sarray("value"), varray()); bind_methodv(PackedByteArray, resize, &PackedByteArray::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedByteArray, clear, sarray(), varray()); bind_method(PackedByteArray, has, sarray("value"), varray()); bind_method(PackedByteArray, reverse, sarray(), varray()); bind_method(PackedByteArray, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2131,6 +2133,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt32Array, fill, sarray("value"), varray()); bind_methodv(PackedInt32Array, resize, &PackedInt32Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedInt32Array, clear, sarray(), varray()); bind_method(PackedInt32Array, has, sarray("value"), varray()); bind_method(PackedInt32Array, reverse, sarray(), varray()); bind_method(PackedInt32Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2154,6 +2157,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt64Array, fill, sarray("value"), varray()); bind_methodv(PackedInt64Array, resize, &PackedInt64Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedInt64Array, clear, sarray(), varray()); bind_method(PackedInt64Array, has, sarray("value"), varray()); bind_method(PackedInt64Array, reverse, sarray(), varray()); bind_method(PackedInt64Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2177,6 +2181,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat32Array, fill, sarray("value"), varray()); bind_methodv(PackedFloat32Array, resize, &PackedFloat32Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedFloat32Array, clear, sarray(), varray()); bind_method(PackedFloat32Array, has, sarray("value"), varray()); bind_method(PackedFloat32Array, reverse, sarray(), varray()); bind_method(PackedFloat32Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2200,6 +2205,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat64Array, fill, sarray("value"), varray()); bind_methodv(PackedFloat64Array, resize, &PackedFloat64Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedFloat64Array, clear, sarray(), varray()); bind_method(PackedFloat64Array, has, sarray("value"), varray()); bind_method(PackedFloat64Array, reverse, sarray(), varray()); bind_method(PackedFloat64Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2223,6 +2229,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedStringArray, fill, sarray("value"), varray()); bind_method(PackedStringArray, resize, sarray("new_size"), varray()); + bind_method(PackedStringArray, clear, sarray(), varray()); bind_method(PackedStringArray, has, sarray("value"), varray()); bind_method(PackedStringArray, reverse, sarray(), varray()); bind_method(PackedStringArray, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2246,6 +2253,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector2Array, fill, sarray("value"), varray()); bind_method(PackedVector2Array, resize, sarray("new_size"), varray()); + bind_method(PackedVector2Array, clear, sarray(), varray()); bind_method(PackedVector2Array, has, sarray("value"), varray()); bind_method(PackedVector2Array, reverse, sarray(), varray()); bind_method(PackedVector2Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2269,6 +2277,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector3Array, fill, sarray("value"), varray()); bind_method(PackedVector3Array, resize, sarray("new_size"), varray()); + bind_method(PackedVector3Array, clear, sarray(), varray()); bind_method(PackedVector3Array, has, sarray("value"), varray()); bind_method(PackedVector3Array, reverse, sarray(), varray()); bind_method(PackedVector3Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2292,6 +2301,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedColorArray, fill, sarray("value"), varray()); bind_method(PackedColorArray, resize, sarray("new_size"), varray()); + bind_method(PackedColorArray, clear, sarray(), varray()); bind_method(PackedColorArray, has, sarray("value"), varray()); bind_method(PackedColorArray, reverse, sarray(), varray()); bind_method(PackedColorArray, slice, sarray("begin", "end"), varray(INT_MAX)); diff --git a/doc/classes/AudioStreamPlayer2D.xml b/doc/classes/AudioStreamPlayer2D.xml index 4c3e675c41..ee71651b42 100644 --- a/doc/classes/AudioStreamPlayer2D.xml +++ b/doc/classes/AudioStreamPlayer2D.xml @@ -4,7 +4,8 @@ Plays positional sound in 2D space. </brief_description> <description> - Plays audio that dampens with distance from screen center. + Plays audio that dampens with distance from a given position. + By default, audio is heard from the screen center. This can be changed by adding an [AudioListener2D] node to the scene and enabling it by calling [method AudioListener2D.make_current] on it. See also [AudioStreamPlayer] to play a sound non-positionally. [b]Note:[/b] Hiding an [AudioStreamPlayer2D] node does not disable its audio output. To temporarily disable an [AudioStreamPlayer2D]'s audio output, set [member volume_db] to a very low value like [code]-100[/code] (which isn't audible to human hearing). </description> diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml index 9b86a93e74..0219562eca 100644 --- a/doc/classes/AudioStreamPlayer3D.xml +++ b/doc/classes/AudioStreamPlayer3D.xml @@ -5,7 +5,7 @@ </brief_description> <description> Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space. For greater realism, a low-pass filter is automatically applied to distant sounds. This can be disabled by setting [member attenuation_filter_cutoff_hz] to [code]20500[/code]. - By default, audio is heard from the camera position. This can be changed by adding a [AudioListener3D] node to the scene and enabling it by calling [method AudioListener3D.make_current] on it. + By default, audio is heard from the camera position. This can be changed by adding an [AudioListener3D] node to the scene and enabling it by calling [method AudioListener3D.make_current] on it. See also [AudioStreamPlayer] to play a sound non-positionally. [b]Note:[/b] Hiding an [AudioStreamPlayer3D] node does not disable its audio output. To temporarily disable an [AudioStreamPlayer3D]'s audio output, set [member unit_db] to a very low value like [code]-100[/code] (which isn't audible to human hearing). </description> diff --git a/doc/classes/KinematicCollision2D.xml b/doc/classes/KinematicCollision2D.xml index ca6aa05316..045480f17c 100644 --- a/doc/classes/KinematicCollision2D.xml +++ b/doc/classes/KinematicCollision2D.xml @@ -53,6 +53,12 @@ Returns the colliding body's velocity. </description> </method> + <method name="get_depth" qualifiers="const"> + <return type="float" /> + <description> + Returns the colliding body's length of overlap along the collision normal. + </description> + </method> <method name="get_local_shape" qualifiers="const"> <return type="Object" /> <description> diff --git a/doc/classes/KinematicCollision3D.xml b/doc/classes/KinematicCollision3D.xml index 08ceebdf91..31fbbc8d0a 100644 --- a/doc/classes/KinematicCollision3D.xml +++ b/doc/classes/KinematicCollision3D.xml @@ -66,6 +66,12 @@ Returns the number of detected collisions. </description> </method> + <method name="get_depth" qualifiers="const"> + <return type="float" /> + <description> + Returns the colliding body's length of overlap along the collision normal. + </description> + </method> <method name="get_local_shape" qualifiers="const"> <return type="Object" /> <param index="0" name="collision_index" type="int" default="0" /> diff --git a/doc/classes/Label3D.xml b/doc/classes/Label3D.xml index 56690d484d..e4dc24d0b5 100644 --- a/doc/classes/Label3D.xml +++ b/doc/classes/Label3D.xml @@ -53,7 +53,7 @@ <member name="font" type="Font" setter="set_font" getter="get_font"> Font configuration used to display text. </member> - <member name="font_size" type="int" setter="set_font_size" getter="get_font_size" default="16"> + <member name="font_size" type="int" setter="set_font_size" getter="get_font_size" default="32"> Font size of the [Label3D]'s text. </member> <member name="horizontal_alignment" type="int" setter="set_horizontal_alignment" getter="get_horizontal_alignment" enum="HorizontalAlignment" default="1"> @@ -82,10 +82,10 @@ [b]Note:[/b] This only applies if [member alpha_cut] is set to [constant ALPHA_CUT_DISABLED] (default value). [b]Note:[/b] This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority). </member> - <member name="outline_size" type="int" setter="set_outline_size" getter="get_outline_size" default="0"> + <member name="outline_size" type="int" setter="set_outline_size" getter="get_outline_size" default="12"> Text outline size. </member> - <member name="pixel_size" type="float" setter="set_pixel_size" getter="get_pixel_size" default="0.01"> + <member name="pixel_size" type="float" setter="set_pixel_size" getter="get_pixel_size" default="0.005"> The size of one pixel's width on the label to scale it in 3D. </member> <member name="render_priority" type="int" setter="set_render_priority" getter="get_render_priority" default="0"> diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml index f7210122e6..36372fbe54 100644 --- a/doc/classes/PackedByteArray.xml +++ b/doc/classes/PackedByteArray.xml @@ -54,6 +54,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="compress" qualifiers="const"> <return type="PackedByteArray" /> <param index="0" name="compression_mode" type="int" default="0" /> diff --git a/doc/classes/PackedColorArray.xml b/doc/classes/PackedColorArray.xml index dd9ada44fb..390adfa5a6 100644 --- a/doc/classes/PackedColorArray.xml +++ b/doc/classes/PackedColorArray.xml @@ -54,6 +54,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="Color" /> diff --git a/doc/classes/PackedFloat32Array.xml b/doc/classes/PackedFloat32Array.xml index ee5497cb1b..f5d5b4566b 100644 --- a/doc/classes/PackedFloat32Array.xml +++ b/doc/classes/PackedFloat32Array.xml @@ -55,6 +55,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="float" /> diff --git a/doc/classes/PackedFloat64Array.xml b/doc/classes/PackedFloat64Array.xml index 2cc8eff059..dfac2c80e8 100644 --- a/doc/classes/PackedFloat64Array.xml +++ b/doc/classes/PackedFloat64Array.xml @@ -55,6 +55,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="float" /> diff --git a/doc/classes/PackedInt32Array.xml b/doc/classes/PackedInt32Array.xml index 70f3f1d180..b29b1b1bd0 100644 --- a/doc/classes/PackedInt32Array.xml +++ b/doc/classes/PackedInt32Array.xml @@ -55,6 +55,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="int" /> diff --git a/doc/classes/PackedInt64Array.xml b/doc/classes/PackedInt64Array.xml index 5d590f02a4..2a33238677 100644 --- a/doc/classes/PackedInt64Array.xml +++ b/doc/classes/PackedInt64Array.xml @@ -55,6 +55,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="int" /> diff --git a/doc/classes/PackedStringArray.xml b/doc/classes/PackedStringArray.xml index 0e6afec2d9..364142f0b6 100644 --- a/doc/classes/PackedStringArray.xml +++ b/doc/classes/PackedStringArray.xml @@ -61,6 +61,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="String" /> diff --git a/doc/classes/PackedVector2Array.xml b/doc/classes/PackedVector2Array.xml index 97ed8cdc57..632680e739 100644 --- a/doc/classes/PackedVector2Array.xml +++ b/doc/classes/PackedVector2Array.xml @@ -55,6 +55,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="Vector2" /> diff --git a/doc/classes/PackedVector3Array.xml b/doc/classes/PackedVector3Array.xml index 102d68a22c..014e7d5aa5 100644 --- a/doc/classes/PackedVector3Array.xml +++ b/doc/classes/PackedVector3Array.xml @@ -54,6 +54,12 @@ [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> + <method name="clear"> + <return type="void" /> + <description> + Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. + </description> + </method> <method name="count" qualifiers="const"> <return type="int" /> <param index="0" name="value" type="Vector3" /> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index a808a996b7..c7fc78c1d3 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -47,7 +47,7 @@ <return type="Tween" /> <param index="0" name="node" type="Node" /> <description> - Binds this [Tween] with the given [code]node[/code]. [Tween]s are processed directly by the [SceneTree], so they run independently of the animated nodes. When you bind a [Node] with the [Tween], the [Tween] will halt the animation when the object is not inside tree and the [Tween] will be automatically killed when the bound object is freed. Also [constant TWEEN_PAUSE_BOUND] will make the pausing behavior dependent on the bound node. + Binds this [Tween] with the given [param node]. [Tween]s are processed directly by the [SceneTree], so they run independently of the animated nodes. When you bind a [Node] with the [Tween], the [Tween] will halt the animation when the object is not inside tree and the [Tween] will be automatically killed when the bound object is freed. Also [constant TWEEN_PAUSE_BOUND] will make the pausing behavior dependent on the bound node. For a shorter way to create and bind a [Tween], you can use [method Node.create_tween]. </description> </method> @@ -67,7 +67,7 @@ <return type="bool" /> <param index="0" name="delta" type="float" /> <description> - Processes the [Tween] by the given [code]delta[/code] value, in seconds. This is mostly useful for manual control when the [Tween] is paused. It can also be used to end the [Tween] animation immediately, by setting [code]delta[/code] longer than the whole duration of the [Tween] animation. + Processes the [Tween] by the given [param delta] value, in seconds. This is mostly useful for manual control when the [Tween] is paused. It can also be used to end the [Tween] animation immediately, by setting [param delta] longer than the whole duration of the [Tween] animation. Returns [code]true[/code] if the [Tween] still has [Tweener]s that haven't finished. [b]Note:[/b] The [Tween] will become invalid in the next processing frame after its animation finishes. Calling [method stop] after performing [method custom_step] instead keeps and resets the [Tween]. </description> @@ -89,11 +89,11 @@ <param index="5" name="ease_type" type="int" enum="Tween.EaseType" /> <description> This method can be used for manual interpolation of a value, when you don't want [Tween] to do animating for you. It's similar to [method @GlobalScope.lerp], but with support for custom transition and easing. - [code]initial_value[/code] is the starting value of the interpolation. - [code]delta_value[/code] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code]. - [code]elapsed_time[/code] is the time in seconds that passed after the interpolation started and it's used to control the position of the interpolation. E.g. when it's equal to half of the [code]duration[/code], the interpolated value will be halfway between initial and final values. This value can also be greater than [code]duration[/code] or lower than 0, which will extrapolate the value. - [code]duration[/code] is the total time of the interpolation. - [b]Note:[/b] If [code]duration[/code] is equal to [code]0[/code], the method will always return the final value, regardless of [code]elapsed_time[/code] provided. + [param initial_value] is the starting value of the interpolation. + [param delta_value] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code]. + [param elapsed_time] is the time in seconds that passed after the interpolation started and it's used to control the position of the interpolation. E.g. when it's equal to half of the [param duration], the interpolated value will be halfway between initial and final values. This value can also be greater than [param duration] or lower than 0, which will extrapolate the value. + [param duration] is the total time of the interpolation. + [b]Note:[/b] If [param duration] is equal to [code]0[/code], the method will always return the final value, regardless of [param elapsed_time] provided. </description> </method> <method name="is_running"> @@ -160,7 +160,7 @@ <return type="Tween" /> <param index="0" name="parallel" type="bool" default="true" /> <description> - If [code]parallel[/code] is [code]true[/code], the [Tweener]s appended after this method will by default run simultaneously, as opposed to sequentially. + If [param parallel] is [code]true[/code], the [Tweener]s appended after this method will by default run simultaneously, as opposed to sequentially. </description> </method> <method name="set_pause_mode"> @@ -221,7 +221,7 @@ <return type="IntervalTweener" /> <param index="0" name="time" type="float" /> <description> - Creates and appends an [IntervalTweener]. This method can be used to create delays in the tween animation, as an alternative to using the delay in other [Tweener]s, or when there's no animation (in which case the [Tween] acts as a timer). [code]time[/code] is the length of the interval, in seconds. + Creates and appends an [IntervalTweener]. This method can be used to create delays in the tween animation, as an alternative to using the delay in other [Tweener]s, or when there's no animation (in which case the [Tween] acts as a timer). [param time] is the length of the interval, in seconds. Example: creating an interval in code execution. [codeblock] # ... some code @@ -247,7 +247,7 @@ <param index="2" name="to" type="Variant" /> <param index="3" name="duration" type="float" /> <description> - Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [code]from[/code] and [code]to[/code] over the time specified by [code]duration[/code], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening. + Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [param from] and [param to] over the time specified by [param duration], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening. Example: making a 3D object look from one point to another point. [codeblock] var tween = create_tween() @@ -271,7 +271,7 @@ <param index="2" name="final_val" type="Variant" /> <param index="3" name="duration" type="float" /> <description> - Creates and appends a [PropertyTweener]. This method tweens a [code]property[/code] of an [code]object[/code] between an initial value and [code]final_val[/code] in a span of time equal to [code]duration[/code], in seconds. The initial value by default is the property's value at the time the tweening of the [PropertyTweener] starts. For example: + Creates and appends a [PropertyTweener]. This method tweens a [param property] of an [param object] between an initial value and [param final_val] in a span of time equal to [param duration], in seconds. The initial value by default is the property's value at the time the tweening of the [PropertyTweener] starts. For example: [codeblock] var tween = create_tween() tween.tween_property($Sprite, "position", Vector2(100, 200), 1) diff --git a/doc/classes/UDPServer.xml b/doc/classes/UDPServer.xml index 49dee4d132..c3a3a49a80 100644 --- a/doc/classes/UDPServer.xml +++ b/doc/classes/UDPServer.xml @@ -146,7 +146,7 @@ <param index="0" name="port" type="int" /> <param index="1" name="bind_address" type="String" default=""*"" /> <description> - Starts the server by opening a UDP socket listening on the given port. You can optionally specify a [code]bind_address[/code] to only listen for packets sent to that address. See also [method PacketPeerUDP.bind]. + Starts the server by opening a UDP socket listening on the given [param port]. You can optionally specify a [param bind_address] to only listen for packets sent to that address. See also [method PacketPeerUDP.bind]. </description> </method> <method name="poll"> diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml index 4c955a7322..3ef59b1c39 100644 --- a/doc/classes/UndoRedo.xml +++ b/doc/classes/UndoRedo.xml @@ -67,7 +67,7 @@ <param index="0" name="object" type="Object" /> <param index="1" name="method" type="StringName" /> <description> - Register a method that will be called when the action is committed. + Register a [param method] that will be called when the action is committed. </description> </method> <method name="add_do_property"> @@ -76,7 +76,7 @@ <param index="1" name="property" type="StringName" /> <param index="2" name="value" type="Variant" /> <description> - Register a property value change for "do". + Register a [param property] that would change its value to [param value] when the action is committed. </description> </method> <method name="add_do_reference"> @@ -91,7 +91,7 @@ <param index="0" name="object" type="Object" /> <param index="1" name="method" type="StringName" /> <description> - Register a method that will be called when the action is undone. + Register a [param method] that will be called when the action is undone. </description> </method> <method name="add_undo_property"> @@ -100,7 +100,7 @@ <param index="1" name="property" type="StringName" /> <param index="2" name="value" type="Variant" /> <description> - Register a property value change for "undo". + Register a [param property] that would change its value to [param value] when the action is undone. </description> </method> <method name="add_undo_reference"> @@ -115,14 +115,14 @@ <param index="0" name="increase_version" type="bool" default="true" /> <description> Clear the undo/redo history and associated references. - Passing [code]false[/code] to [code]increase_version[/code] will prevent the version number to be increased from this. + Passing [code]false[/code] to [param increase_version] will prevent the version number from increasing when the history is cleared. </description> </method> <method name="commit_action"> <return type="void" /> <param index="0" name="execute" type="bool" default="true" /> <description> - Commit the action. If [code]execute[/code] is true (default), all "do" methods/properties are called/set when this function is called. + Commit the action. If [param execute] is [code]true[/code] (which it is by default), all "do" methods/properties are called/set when this function is called. </description> </method> <method name="create_action"> @@ -131,7 +131,7 @@ <param index="1" name="merge_mode" type="int" enum="UndoRedo.MergeMode" default="0" /> <description> Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property], and [method add_undo_property], then commit the action with [method commit_action]. - The way actions are merged is dictated by the [code]merge_mode[/code] argument. See [enum MergeMode] for details. + The way actions are merged is dictated by [param merge_mode]. See [enum MergeMode] for details. </description> </method> <method name="end_force_keep_in_merge_ends"> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 56c107f5cd..904fc6d9e9 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -42,7 +42,7 @@ <param index="0" name="x" type="float" /> <param index="1" name="y" type="float" /> <description> - Constructs a new [Vector2] from the given [code]x[/code] and [code]y[/code]. + Constructs a new [Vector2] from the given [param x] and [param y]. </description> </constructor> </constructors> @@ -92,7 +92,7 @@ <param index="2" name="end" type="Vector2" /> <param index="3" name="t" type="float" /> <description> - Returns the point at the given [code]t[/code] on the [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bezier curve[/url] defined by this vector and the given [code]control_1[/code], [code]control_2[/code], and [code]end[/code] points. + Returns the point at the given [param t] on the [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bezier curve[/url] defined by this vector and the given [param control_1], [param control_2], and [param end] points. </description> </method> <method name="bounce" qualifiers="const"> @@ -113,14 +113,14 @@ <param index="0" name="min" type="Vector2" /> <param index="1" name="max" type="Vector2" /> <description> - Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. + Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="cross" qualifiers="const"> <return type="float" /> <param index="0" name="with" type="Vector2" /> <description> - Returns the 2D analog of the cross product for this vector and [code]with[/code]. + Returns the 2D analog of the cross product for this vector and [param with]. This is the signed area of the parallelogram formed by the two vectors. If the second vector is clockwise from the first vector, then the cross product is the positive area. If counter-clockwise, the cross product is the negative area. [b]Note:[/b] Cross product is not defined in 2D mathematically. This method embeds the 2D vectors in the XY plane of 3D space and uses their cross product's Z component as the analog. </description> @@ -132,21 +132,21 @@ <param index="2" name="post_b" type="Vector2" /> <param index="3" name="weight" type="float" /> <description> - Cubically interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Cubically interpolates between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to" qualifiers="const"> <return type="Vector2" /> <param index="0" name="to" type="Vector2" /> <description> - Returns the normalized vector pointing from this vector to [code]to[/code]. This is equivalent to using [code](b - a).normalized()[/code]. + Returns the normalized vector pointing from this vector to [param to]. This is equivalent to using [code](b - a).normalized()[/code]. </description> </method> <method name="distance_squared_to" qualifiers="const"> <return type="float" /> <param index="0" name="to" type="Vector2" /> <description> - Returns the squared distance between this vector and [code]to[/code]. + Returns the squared distance between this vector and [param to]. This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> @@ -154,14 +154,14 @@ <return type="float" /> <param index="0" name="to" type="Vector2" /> <description> - Returns the distance between this vector and [code]to[/code]. + Returns the distance between this vector and [param to]. </description> </method> <method name="dot" qualifiers="const"> <return type="float" /> <param index="0" name="with" type="Vector2" /> <description> - Returns the dot product of this vector and [code]with[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. + Returns the dot product of this vector and [param with]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned. [b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code]. @@ -177,7 +177,7 @@ <return type="Vector2" /> <param index="0" name="angle" type="float" /> <description> - Creates a unit [Vector2] rotated to the given [code]angle[/code] in radians. This is equivalent to doing [code]Vector2(cos(angle), sin(angle))[/code] or [code]Vector2.RIGHT.rotated(angle)[/code]. + Creates a unit [Vector2] rotated to the given [param angle] in radians. This is equivalent to doing [code]Vector2(cos(angle), sin(angle))[/code] or [code]Vector2.RIGHT.rotated(angle)[/code]. [codeblock] print(Vector2.from_angle(0)) # Prints (1, 0). print(Vector2(1, 0).angle()) # Prints 0, which is the angle used above. @@ -216,14 +216,14 @@ <param index="0" name="to" type="Vector2" /> <param index="1" name="weight" type="float" /> <description> - Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Returns the result of the linear interpolation between this vector and [param to] by amount [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="limit_length" qualifiers="const"> <return type="Vector2" /> <param index="0" name="length" type="float" default="1.0" /> <description> - Returns the vector with a maximum length by limiting its length to [code]length[/code]. + Returns the vector with a maximum length by limiting its length to [param length]. </description> </method> <method name="max_axis_index" qualifiers="const"> @@ -243,7 +243,7 @@ <param index="0" name="to" type="Vector2" /> <param index="1" name="delta" type="float" /> <description> - Returns a new vector moved toward [code]to[/code] by the fixed [code]delta[/code] amount. Will not go past the final value. + Returns a new vector moved toward [param to] by the fixed [param delta] amount. Will not go past the final value. </description> </method> <method name="normalized" qualifiers="const"> @@ -262,14 +262,14 @@ <return type="Vector2" /> <param index="0" name="mod" type="float" /> <description> - Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]mod[/code]. + Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod]. </description> </method> <method name="posmodv" qualifiers="const"> <return type="Vector2" /> <param index="0" name="modv" type="Vector2" /> <description> - Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]modv[/code]'s components. + Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components. </description> </method> <method name="project" qualifiers="const"> @@ -283,14 +283,14 @@ <return type="Vector2" /> <param index="0" name="n" type="Vector2" /> <description> - Returns the vector reflected (i.e. mirrored, or symmetric) over a line defined by the given direction vector [code]n[/code]. + Returns the vector reflected (i.e. mirrored, or symmetric) over a line defined by the given direction vector [param n]. </description> </method> <method name="rotated" qualifiers="const"> <return type="Vector2" /> <param index="0" name="angle" type="float" /> <description> - Returns the vector rotated by [code]angle[/code] (in radians). See also [method @GlobalScope.deg2rad]. + Returns the vector rotated by [param angle] (in radians). See also [method @GlobalScope.deg2rad]. </description> </method> <method name="round" qualifiers="const"> @@ -310,7 +310,7 @@ <param index="0" name="to" type="Vector2" /> <param index="1" name="weight" type="float" /> <description> - Returns the result of spherical linear interpolation between this vector and [code]to[/code], by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Returns the result of spherical linear interpolation between this vector and [param to], by amount [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like [method lerp]. </description> </method> @@ -325,7 +325,7 @@ <return type="Vector2" /> <param index="0" name="step" type="Vector2" /> <description> - Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. + Returns this vector with each component snapped to the nearest multiple of [param step]. This can also be used to round to an arbitrary number of decimals. </description> </method> </methods> @@ -454,14 +454,14 @@ <return type="bool" /> <param index="0" name="right" type="Vector2" /> <description> - Compares two [Vector2] vectors by first checking if the X value of the left vector is less than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2] vectors by first checking if the X value of the left vector is less than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator <="> <return type="bool" /> <param index="0" name="right" type="Vector2" /> <description> - Compares two [Vector2] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator =="> @@ -476,21 +476,21 @@ <return type="bool" /> <param index="0" name="right" type="Vector2" /> <description> - Compares two [Vector2] vectors by first checking if the X value of the left vector is greater than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2] vectors by first checking if the X value of the left vector is greater than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator >="> <return type="bool" /> <param index="0" name="right" type="Vector2" /> <description> - Compares two [Vector2] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator []"> <return type="float" /> <param index="0" name="index" type="int" /> <description> - Access vector components using their index. [code]v[0][/code] is equivalent to [code]v.x[/code], and [code]v[1][/code] is equivalent to [code]v.y[/code]. + Access vector components using their [param index]. [code]v[0][/code] is equivalent to [code]v.x[/code], and [code]v[1][/code] is equivalent to [code]v.y[/code]. </description> </operator> <operator name="operator unary+"> diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml index a60fd09a48..eab880e57f 100644 --- a/doc/classes/Vector2i.xml +++ b/doc/classes/Vector2i.xml @@ -39,7 +39,7 @@ <param index="0" name="x" type="int" /> <param index="1" name="y" type="int" /> <description> - Constructs a new [Vector2i] from the given [code]x[/code] and [code]y[/code]. + Constructs a new [Vector2i] from the given [param x] and [param y]. </description> </constructor> </constructors> @@ -61,7 +61,7 @@ <param index="0" name="min" type="Vector2i" /> <param index="1" name="max" type="Vector2i" /> <description> - Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. + Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="length" qualifiers="const"> @@ -236,14 +236,14 @@ <return type="bool" /> <param index="0" name="right" type="Vector2i" /> <description> - Compares two [Vector2i] vectors by first checking if the X value of the left vector is less than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2i] vectors by first checking if the X value of the left vector is less than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator <="> <return type="bool" /> <param index="0" name="right" type="Vector2i" /> <description> - Compares two [Vector2i] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2i] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator =="> @@ -257,21 +257,21 @@ <return type="bool" /> <param index="0" name="right" type="Vector2i" /> <description> - Compares two [Vector2i] vectors by first checking if the X value of the left vector is greater than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2i] vectors by first checking if the X value of the left vector is greater than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator >="> <return type="bool" /> <param index="0" name="right" type="Vector2i" /> <description> - Compares two [Vector2i] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. + Compares two [Vector2i] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors. </description> </operator> <operator name="operator []"> <return type="int" /> <param index="0" name="index" type="int" /> <description> - Access vector components using their index. [code]v[0][/code] is equivalent to [code]v.x[/code], and [code]v[1][/code] is equivalent to [code]v.y[/code]. + Access vector components using their [param index]. [code]v[0][/code] is equivalent to [code]v.x[/code], and [code]v[1][/code] is equivalent to [code]v.y[/code]. </description> </operator> <operator name="operator unary+"> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 49aeb3e754..208e9935e3 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -68,7 +68,7 @@ <param index="2" name="end" type="Vector3" /> <param index="3" name="t" type="float" /> <description> - Returns the point at the given [code]t[/code] on the [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bezier curve[/url] defined by this vector and the given [code]control_1[/code], [code]control_2[/code], and [code]end[/code] points. + Returns the point at the given [param t] on the [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bezier curve[/url] defined by this vector and the given [param control_1], [param control_2], and [param end] points. </description> </method> <method name="bounce" qualifiers="const"> @@ -89,14 +89,14 @@ <param index="0" name="min" type="Vector3" /> <param index="1" name="max" type="Vector3" /> <description> - Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. + Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="cross" qualifiers="const"> <return type="Vector3" /> <param index="0" name="with" type="Vector3" /> <description> - Returns the cross product of this vector and [code]with[/code]. + Returns the cross product of this vector and [param with]. </description> </method> <method name="cubic_interpolate" qualifiers="const"> @@ -106,21 +106,21 @@ <param index="2" name="post_b" type="Vector3" /> <param index="3" name="weight" type="float" /> <description> - Performs a cubic interpolation between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Performs a cubic interpolation between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to" qualifiers="const"> <return type="Vector3" /> <param index="0" name="to" type="Vector3" /> <description> - Returns the normalized vector pointing from this vector to [code]to[/code]. This is equivalent to using [code](b - a).normalized()[/code]. + Returns the normalized vector pointing from this vector to [param to]. This is equivalent to using [code](b - a).normalized()[/code]. </description> </method> <method name="distance_squared_to" qualifiers="const"> <return type="float" /> <param index="0" name="to" type="Vector3" /> <description> - Returns the squared distance between this vector and [code]to[/code]. + Returns the squared distance between this vector and [param to]. This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> @@ -128,14 +128,14 @@ <return type="float" /> <param index="0" name="to" type="Vector3" /> <description> - Returns the distance between this vector and [code]to[/code]. + Returns the distance between this vector and [param to]. </description> </method> <method name="dot" qualifiers="const"> <return type="float" /> <param index="0" name="with" type="Vector3" /> <description> - Returns the dot product of this vector and [code]with[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. + Returns the dot product of this vector and [param with]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned. [b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code]. @@ -157,7 +157,7 @@ <return type="bool" /> <param index="0" name="to" type="Vector3" /> <description> - Returns [code]true[/code] if this vector and [code]v[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. + Returns [code]true[/code] if this vector and [param to] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="is_normalized" qualifiers="const"> @@ -184,14 +184,14 @@ <param index="0" name="to" type="Vector3" /> <param index="1" name="weight" type="float" /> <description> - Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Returns the result of the linear interpolation between this vector and [param to] by amount [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="limit_length" qualifiers="const"> <return type="Vector3" /> <param index="0" name="length" type="float" default="1.0" /> <description> - Returns the vector with a maximum length by limiting its length to [code]length[/code]. + Returns the vector with a maximum length by limiting its length to [param length]. </description> </method> <method name="max_axis_index" qualifiers="const"> @@ -211,7 +211,7 @@ <param index="0" name="to" type="Vector3" /> <param index="1" name="delta" type="float" /> <description> - Returns a new vector moved toward [code]to[/code] by the fixed [code]delta[/code] amount. Will not go past the final value. + Returns a new vector moved toward [param to] by the fixed [param delta] amount. Will not go past the final value. </description> </method> <method name="normalized" qualifiers="const"> @@ -235,28 +235,28 @@ <return type="Basis" /> <param index="0" name="with" type="Vector3" /> <description> - Returns the outer product with [code]with[/code]. + Returns the outer product with [param with]. </description> </method> <method name="posmod" qualifiers="const"> <return type="Vector3" /> <param index="0" name="mod" type="float" /> <description> - Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]mod[/code]. + Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod]. </description> </method> <method name="posmodv" qualifiers="const"> <return type="Vector3" /> <param index="0" name="modv" type="Vector3" /> <description> - Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]modv[/code]'s components. + Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components. </description> </method> <method name="project" qualifiers="const"> <return type="Vector3" /> <param index="0" name="b" type="Vector3" /> <description> - Returns this vector projected onto the vector [code]b[/code]. + Returns this vector projected onto the vector [param b]. </description> </method> <method name="reflect" qualifiers="const"> @@ -271,7 +271,7 @@ <param index="0" name="axis" type="Vector3" /> <param index="1" name="angle" type="float" /> <description> - Rotates this vector around a given axis by [code]angle[/code] (in radians). The axis must be a normalized vector. + Rotates this vector around a given axis by [param angle] (in radians). The axis must be a normalized vector. </description> </method> <method name="round" qualifiers="const"> @@ -291,7 +291,7 @@ <param index="0" name="to" type="Vector3" /> <param index="1" name="axis" type="Vector3" /> <description> - Returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the [code]axis[/code]. + Returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the [param axis]. </description> </method> <method name="slerp" qualifiers="const"> @@ -299,7 +299,7 @@ <param index="0" name="to" type="Vector3" /> <param index="1" name="weight" type="float" /> <description> - Returns the result of spherical linear interpolation between this vector and [code]to[/code], by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Returns the result of spherical linear interpolation between this vector and [param to], by amount [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like [method lerp]. </description> </method> @@ -314,7 +314,7 @@ <return type="Vector3" /> <param index="0" name="step" type="Vector3" /> <description> - Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. + Returns this vector with each component snapped to the nearest multiple of [param step]. This can also be used to round to an arbitrary number of decimals. </description> </method> </methods> @@ -469,14 +469,14 @@ <return type="bool" /> <param index="0" name="right" type="Vector3" /> <description> - Compares two [Vector3] vectors by first checking if the X value of the left vector is less than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3] vectors by first checking if the X value of the left vector is less than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator <="> <return type="bool" /> <param index="0" name="right" type="Vector3" /> <description> - Compares two [Vector3] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator =="> @@ -491,21 +491,21 @@ <return type="bool" /> <param index="0" name="right" type="Vector3" /> <description> - Compares two [Vector3] vectors by first checking if the X value of the left vector is greater than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3] vectors by first checking if the X value of the left vector is greater than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator >="> <return type="bool" /> <param index="0" name="right" type="Vector3" /> <description> - Compares two [Vector3] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator []"> <return type="float" /> <param index="0" name="index" type="int" /> <description> - Access vector components using their index. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], and [code]v[2][/code] is equivalent to [code]v.z[/code]. + Access vector components using their [param index]. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], and [code]v[2][/code] is equivalent to [code]v.z[/code]. </description> </operator> <operator name="operator unary+"> diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml index 6c61bf8736..1c2a033f7a 100644 --- a/doc/classes/Vector3i.xml +++ b/doc/classes/Vector3i.xml @@ -56,7 +56,7 @@ <param index="0" name="min" type="Vector3i" /> <param index="1" name="max" type="Vector3i" /> <description> - Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. + Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="length" qualifiers="const"> @@ -243,14 +243,14 @@ <return type="bool" /> <param index="0" name="right" type="Vector3i" /> <description> - Compares two [Vector3i] vectors by first checking if the X value of the left vector is less than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3i] vectors by first checking if the X value of the left vector is less than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator <="> <return type="bool" /> <param index="0" name="right" type="Vector3i" /> <description> - Compares two [Vector3i] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3i] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator =="> @@ -264,21 +264,21 @@ <return type="bool" /> <param index="0" name="right" type="Vector3i" /> <description> - Compares two [Vector3i] vectors by first checking if the X value of the left vector is greater than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3i] vectors by first checking if the X value of the left vector is greater than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator >="> <return type="bool" /> <param index="0" name="right" type="Vector3i" /> <description> - Compares two [Vector3i] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. + Compares two [Vector3i] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator []"> <return type="int" /> <param index="0" name="index" type="int" /> <description> - Access vector components using their index. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], and [code]v[2][/code] is equivalent to [code]v.z[/code]. + Access vector components using their [param index]. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], and [code]v[2][/code] is equivalent to [code]v.z[/code]. </description> </operator> <operator name="operator unary+"> diff --git a/doc/classes/Vector4.xml b/doc/classes/Vector4.xml index b5658f074a..46005f8373 100644 --- a/doc/classes/Vector4.xml +++ b/doc/classes/Vector4.xml @@ -60,7 +60,7 @@ <param index="0" name="min" type="Vector4" /> <param index="1" name="max" type="Vector4" /> <description> - Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. + Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="cubic_interpolate" qualifiers="const"> @@ -70,28 +70,36 @@ <param index="2" name="post_b" type="Vector4" /> <param index="3" name="weight" type="float" /> <description> - Performs a cubic interpolation between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. + Performs a cubic interpolation between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to" qualifiers="const"> <return type="Vector4" /> <param index="0" name="to" type="Vector4" /> <description> - Returns the normalized vector pointing from this vector to [code]to[/code]. This is equivalent to using [code](b - a).normalized()[/code]. + Returns the normalized vector pointing from this vector to [param to]. This is equivalent to using [code](b - a).normalized()[/code]. + </description> + </method> + <method name="distance_squared_to" qualifiers="const"> + <return type="float" /> + <param index="0" name="to" type="Vector4" /> + <description> + Returns the squared distance between this vector and [code]to[/code]. + This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="distance_to" qualifiers="const"> <return type="float" /> <param index="0" name="to" type="Vector4" /> <description> - Returns the distance between this vector and [code]to[/code]. + Returns the distance between this vector and [param to]. </description> </method> <method name="dot" qualifiers="const"> <return type="float" /> <param index="0" name="with" type="Vector4" /> <description> - Returns the dot product of this vector and [code]with[/code]. + Returns the dot product of this vector and [param with]. </description> </method> <method name="floor" qualifiers="const"> @@ -110,7 +118,7 @@ <return type="bool" /> <param index="0" name="with" type="Vector4" /> <description> - Returns [code]true[/code] if this vector and [code]v[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. + Returns [code]true[/code] if this vector and [param with] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="is_normalized" qualifiers="const"> @@ -136,7 +144,7 @@ <param index="0" name="to" type="Vector4" /> <param index="1" name="weight" type="float" /> <description> - Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]weight[/code]. [code]weight[/code] is on the range of [code]0.0[/code] to [code]1.0[/code], representing the amount of interpolation. + Returns the result of the linear interpolation between this vector and [param to] by amount [param weight]. [param weight] is on the range of [code]0.0[/code] to [code]1.0[/code], representing the amount of interpolation. </description> </method> <method name="max_axis_index" qualifiers="const"> @@ -161,14 +169,14 @@ <return type="Vector4" /> <param index="0" name="mod" type="float" /> <description> - Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]mod[/code]. + Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod]. </description> </method> <method name="posmodv" qualifiers="const"> <return type="Vector4" /> <param index="0" name="modv" type="Vector4" /> <description> - Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]modv[/code]'s components. + Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components. </description> </method> <method name="round" qualifiers="const"> @@ -187,7 +195,7 @@ <return type="Vector4" /> <param index="0" name="step" type="Vector4" /> <description> - Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. + Returns this vector with each component snapped to the nearest multiple of [param step]. This can also be used to round to an arbitrary number of decimals. </description> </method> </methods> @@ -322,14 +330,14 @@ <return type="bool" /> <param index="0" name="right" type="Vector4" /> <description> - Compares two [Vector4] vectors by first checking if the X value of the left vector is less than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. + Compares two [Vector4] vectors by first checking if the X value of the left vector is less than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator <="> <return type="bool" /> <param index="0" name="right" type="Vector4" /> <description> - Compares two [Vector4] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. + Compares two [Vector4] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator =="> @@ -344,21 +352,21 @@ <return type="bool" /> <param index="0" name="right" type="Vector4" /> <description> - Compares two [Vector4] vectors by first checking if the X value of the left vector is greater than the X value of the [code]right[/code] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. + Compares two [Vector4] vectors by first checking if the X value of the left vector is greater than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator >="> <return type="bool" /> <param index="0" name="right" type="Vector4" /> <description> - Access vector components using their index. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], and [code]v[2][/code] is equivalent to [code]v.z[/code]. + Compares two [Vector4] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors. </description> </operator> <operator name="operator []"> <return type="float" /> <param index="0" name="index" type="int" /> <description> - Access vector components using their index. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], [code]v[2][/code] is equivalent to [code]v.z[/code], and [code]v[3][/code] is equivalent to [code]v.w[/code]. + Access vector components using their [param index]. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], [code]v[2][/code] is equivalent to [code]v.z[/code], and [code]v[3][/code] is equivalent to [code]v.w[/code]. </description> </operator> <operator name="operator unary+"> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index f3db437b79..2e43d2d96f 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -142,7 +142,6 @@ <return type="void" /> <param index="0" name="text" type="String" /> <description> - Returns [code]true[/code] if the viewport is currently embedding windows. </description> </method> <method name="push_unhandled_input"> diff --git a/doc/classes/VisualInstance3D.xml b/doc/classes/VisualInstance3D.xml index 3e23996173..9574686506 100644 --- a/doc/classes/VisualInstance3D.xml +++ b/doc/classes/VisualInstance3D.xml @@ -58,7 +58,7 @@ <param index="0" name="layer_number" type="int" /> <param index="1" name="value" type="bool" /> <description> - Based on [code]value[/code], enables or disables the specified layer in the [member layers], given a [code]layer_number[/code] between 1 and 20. + Based on [param value], enables or disables the specified layer in the [member layers], given a [param layer_number] between 1 and 20. </description> </method> </methods> diff --git a/doc/classes/VisualShader.xml b/doc/classes/VisualShader.xml index bf95a414f6..558b1086b7 100644 --- a/doc/classes/VisualShader.xml +++ b/doc/classes/VisualShader.xml @@ -17,7 +17,7 @@ <param index="2" name="position" type="Vector2" /> <param index="3" name="id" type="int" /> <description> - Adds the specified node to the shader. + Adds the specified [param node] to the shader. </description> </method> <method name="add_varying"> @@ -77,7 +77,7 @@ <param index="0" name="type" type="int" enum="VisualShader.Type" /> <param index="1" name="id" type="int" /> <description> - Returns the shader node instance with specified [code]type[/code] and [code]id[/code]. + Returns the shader node instance with specified [param type] and [param id]. </description> </method> <method name="get_node_connections" qualifiers="const"> diff --git a/doc/classes/VisualShaderNode.xml b/doc/classes/VisualShaderNode.xml index 6ab9c3717a..1f3397f39c 100644 --- a/doc/classes/VisualShaderNode.xml +++ b/doc/classes/VisualShaderNode.xml @@ -26,14 +26,14 @@ <return type="Variant" /> <param index="0" name="port" type="int" /> <description> - Returns the default value of the input [code]port[/code]. + Returns the default value of the input [param port]. </description> </method> <method name="remove_input_port_default_value"> <return type="void" /> <param index="0" name="port" type="int" /> <description> - Removes the default value of the input [code]port[/code]. + Removes the default value of the input [param port]. </description> </method> <method name="set_default_input_values"> @@ -49,7 +49,7 @@ <param index="1" name="value" type="Variant" /> <param index="2" name="prev_value" type="Variant" default="null" /> <description> - Sets the default value for the selected input [code]port[/code]. + Sets the default [param value] for the selected input [param port]. </description> </method> </methods> diff --git a/doc/classes/VisualShaderNodeCustom.xml b/doc/classes/VisualShaderNodeCustom.xml index 8a2f607b75..9813b4778d 100644 --- a/doc/classes/VisualShaderNodeCustom.xml +++ b/doc/classes/VisualShaderNodeCustom.xml @@ -31,9 +31,9 @@ <param index="3" name="type" type="int" enum="VisualShader.Type" /> <description> Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience). - The [code]input_vars[/code] and [code]output_vars[/code] arrays contain the string names of the various input and output variables, as defined by [code]_get_input_*[/code] and [code]_get_output_*[/code] virtual methods in this class. + The [param input_vars] and [param output_vars] arrays contain the string names of the various input and output variables, as defined by [code]_get_input_*[/code] and [code]_get_output_*[/code] virtual methods in this class. The output ports can be assigned values in the shader code. For example, [code]return output_vars[0] + " = " + input_vars[0] + ";"[/code]. - You can customize the generated code based on the shader [code]mode[/code] (see [enum Shader.Mode]) and/or [code]type[/code] (see [enum VisualShader.Type]). + You can customize the generated code based on the shader [param mode] (see [enum Shader.Mode]) and/or [param type] (see [enum VisualShader.Type]). Defining this method is [b]required[/b]. </description> </method> @@ -51,7 +51,7 @@ <description> Override this method to add a shader code to the beginning of each shader function (once). The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience). If there are multiple custom nodes of different types which use this feature the order of each insertion is undefined. - You can customize the generated code based on the shader [code]mode[/code] (see [enum Shader.Mode]) and/or [code]type[/code] (see [enum VisualShader.Type]). + You can customize the generated code based on the shader [param mode] (see [enum Shader.Mode]) and/or [param type] (see [enum VisualShader.Type]). Defining this method is [b]optional[/b]. </description> </method> @@ -61,7 +61,7 @@ <description> Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience). Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names. - You can customize the generated code based on the shader [code]mode[/code] (see [enum Shader.Mode]). + You can customize the generated code based on the shader [param mode] (see [enum Shader.Mode]). Defining this method is [b]optional[/b]. </description> </method> @@ -130,7 +130,7 @@ <param index="0" name="mode" type="int" enum="Shader.Mode" /> <param index="1" name="type" type="int" enum="VisualShader.Type" /> <description> - Override this method to prevent the node to be visible in the member dialog for the certain [code]mode[/code] (see [enum Shader.Mode]) and/or [code]type[/code] (see [enum VisualShader.Type]). + Override this method to prevent the node to be visible in the member dialog for the certain [param mode] (see [enum Shader.Mode]) and/or [param type] (see [enum VisualShader.Type]). Defining this method is [b]optional[/b]. If not overridden, it's [code]true[/code]. </description> </method> diff --git a/doc/classes/VisualShaderNodeGroupBase.xml b/doc/classes/VisualShaderNodeGroupBase.xml index 9508aaba27..450629a73f 100644 --- a/doc/classes/VisualShaderNodeGroupBase.xml +++ b/doc/classes/VisualShaderNodeGroupBase.xml @@ -15,7 +15,7 @@ <param index="1" name="type" type="int" /> <param index="2" name="name" type="String" /> <description> - Adds an input port with the specified [code]type[/code] (see [enum VisualShaderNode.PortType]) and [code]name[/code]. + Adds an input port with the specified [param type] (see [enum VisualShaderNode.PortType]) and [param name]. </description> </method> <method name="add_output_port"> @@ -24,7 +24,7 @@ <param index="1" name="type" type="int" /> <param index="2" name="name" type="String" /> <description> - Adds an output port with the specified [code]type[/code] (see [enum VisualShaderNode.PortType]) and [code]name[/code]. + Adds an output port with the specified [param type] (see [enum VisualShaderNode.PortType]) and [param name]. </description> </method> <method name="clear_input_ports"> diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 3ceff8a6ed..ce7ad1e64e 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -32,7 +32,7 @@ <return type="bool" /> <param index="0" name="flag" type="int" enum="Window.Flags" /> <description> - Returns [code]true[/code] if the flag is set. + Returns [code]true[/code] if the [param flag] is set. </description> </method> <method name="get_layout_direction" qualifiers="const"> @@ -52,7 +52,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns the [Color] at [code]name[/code] if the theme has [code]theme_type[/code]. + Returns the [Color] at [param name] if the theme has [param theme_type]. See [method Control.get_theme_color] for more details. </description> </method> @@ -61,7 +61,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns the constant at [code]name[/code] if the theme has [code]theme_type[/code]. + Returns the constant at [param name] if the theme has [param theme_type]. See [method Control.get_theme_color] for more details. </description> </method> @@ -91,7 +91,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns the [Font] at [code]name[/code] if the theme has [code]theme_type[/code]. + Returns the [Font] at [param name] if the theme has [param theme_type]. See [method Control.get_theme_color] for more details. </description> </method> @@ -100,7 +100,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns the font size at [code]name[/code] if the theme has [code]theme_type[/code]. + Returns the font size at [param name] if the theme has [param theme_type]. See [method Control.get_theme_color] for more details. </description> </method> @@ -109,7 +109,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns the icon at [code]name[/code] if the theme has [code]theme_type[/code]. + Returns the icon at [param name] if the theme has [param theme_type]. See [method Control.get_theme_color] for more details. </description> </method> @@ -118,7 +118,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns the [StyleBox] at [code]name[/code] if the theme has [code]theme_type[/code]. + Returns the [StyleBox] at [param name] if the theme has [param theme_type]. See [method Control.get_theme_color] for more details. </description> </method> @@ -139,7 +139,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if [Color] with [code]name[/code] is in [code]theme_type[/code]. + Returns [code]true[/code] if [Color] with [param name] is in [param theme_type]. </description> </method> <method name="has_theme_constant" qualifiers="const"> @@ -147,7 +147,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if constant with [code]name[/code] is in [code]theme_type[/code]. + Returns [code]true[/code] if constant with [param name] is in [param theme_type]. </description> </method> <method name="has_theme_font" qualifiers="const"> @@ -155,7 +155,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if [Font] with [code]name[/code] is in [code]theme_type[/code]. + Returns [code]true[/code] if [Font] with [param name] is in [param theme_type]. </description> </method> <method name="has_theme_font_size" qualifiers="const"> @@ -163,7 +163,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if font size with [code]name[/code] is in [code]theme_type[/code]. + Returns [code]true[/code] if font size with [param name] is in [param theme_type]. </description> </method> <method name="has_theme_icon" qualifiers="const"> @@ -171,7 +171,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if icon with [code]name[/code] is in [code]theme_type[/code]. + Returns [code]true[/code] if icon with [param name] is in [param theme_type]. </description> </method> <method name="has_theme_stylebox" qualifiers="const"> @@ -179,7 +179,7 @@ <param index="0" name="name" type="StringName" /> <param index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if [StyleBox] with [code]name[/code] is in [code]theme_type[/code]. + Returns [code]true[/code] if [StyleBox] with [param name] is in [param theme_type]. </description> </method> <method name="hide"> @@ -222,7 +222,7 @@ <return type="void" /> <param index="0" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" /> <description> - Shows the [Window] and makes it transient (see [member transient]). If [code]rect[/code] is provided, it will be set as the [Window]'s size. + Shows the [Window] and makes it transient (see [member transient]). If [param rect] is provided, it will be set as the [Window]'s size. Fails if called on the main window. </description> </method> @@ -247,7 +247,7 @@ <return type="void" /> <param index="0" name="ratio" type="float" default="0.8" /> <description> - Popups the [Window] centered inside its parent [Window] and sets its size as a [code]ratio[/code] of parent's size. + Popups the [Window] centered inside its parent [Window] and sets its size as a [param ratio] of parent's size. </description> </method> <method name="popup_on_parent"> @@ -282,7 +282,7 @@ <return type="void" /> <param index="0" name="active" type="bool" /> <description> - If [code]active[/code] is [code]true[/code], enables system's native IME (Input Method Editor). + If [param active] is [code]true[/code], enables system's native IME (Input Method Editor). </description> </method> <method name="set_ime_position"> diff --git a/doc/classes/X509Certificate.xml b/doc/classes/X509Certificate.xml index 3082274123..d8f54d0ec5 100644 --- a/doc/classes/X509Certificate.xml +++ b/doc/classes/X509Certificate.xml @@ -14,14 +14,14 @@ <return type="int" enum="Error" /> <param index="0" name="path" type="String" /> <description> - Loads a certificate from [code]path[/code] ("*.crt" file). + Loads a certificate from [param path] ("*.crt" file). </description> </method> <method name="save"> <return type="int" enum="Error" /> <param index="0" name="path" type="String" /> <description> - Saves a certificate to the given [code]path[/code] (should be a "*.crt" file). + Saves a certificate to the given [param path] (should be a "*.crt" file). </description> </method> </methods> diff --git a/doc/classes/XMLParser.xml b/doc/classes/XMLParser.xml index ce58257817..69544f4895 100644 --- a/doc/classes/XMLParser.xml +++ b/doc/classes/XMLParser.xml @@ -19,14 +19,14 @@ <return type="String" /> <param index="0" name="idx" type="int" /> <description> - Gets the name of the attribute specified by the index in [code]idx[/code] argument. + Gets the name of the attribute specified by the [param idx] index. </description> </method> <method name="get_attribute_value" qualifiers="const"> <return type="String" /> <param index="0" name="idx" type="int" /> <description> - Gets the value of the attribute specified by the index in [code]idx[/code] argument. + Gets the value of the attribute specified by the [param idx] index. </description> </method> <method name="get_current_line" qualifiers="const"> @@ -39,14 +39,14 @@ <return type="String" /> <param index="0" name="name" type="String" /> <description> - Gets the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute. + Gets the value of a certain attribute of the current element by [param name]. This will raise an error if the element has no such attribute. </description> </method> <method name="get_named_attribute_value_safe" qualifiers="const"> <return type="String" /> <param index="0" name="name" type="String" /> <description> - Gets the value of a certain attribute of the current element by name. This will return an empty [String] if the attribute is not found. + Gets the value of a certain attribute of the current element by [param name]. This will return an empty [String] if the attribute is not found. </description> </method> <method name="get_node_data" qualifiers="const"> @@ -90,14 +90,14 @@ <return type="int" enum="Error" /> <param index="0" name="file" type="String" /> <description> - Opens an XML file for parsing. This returns an error code. + Opens an XML [param file] for parsing. This returns an error code. </description> </method> <method name="open_buffer"> <return type="int" enum="Error" /> <param index="0" name="buffer" type="PackedByteArray" /> <description> - Opens an XML raw buffer for parsing. This returns an error code. + Opens an XML raw [param buffer] for parsing. This returns an error code. </description> </method> <method name="read"> diff --git a/doc/classes/XRController3D.xml b/doc/classes/XRController3D.xml index b1f498c8e3..9e192177e5 100644 --- a/doc/classes/XRController3D.xml +++ b/doc/classes/XRController3D.xml @@ -17,7 +17,7 @@ <return type="Vector2" /> <param index="0" name="name" type="StringName" /> <description> - Returns a [Vector2] for the input with the given [code]name[/code]. This is used for thumbsticks and thumbpads found on many controllers. + Returns a [Vector2] for the input with the given [param name]. This is used for thumbsticks and thumbpads found on many controllers. </description> </method> <method name="get_tracker_hand" qualifiers="const"> @@ -30,14 +30,14 @@ <return type="float" /> <param index="0" name="name" type="StringName" /> <description> - Returns a numeric value for the input with the given [code]name[/code]. This is used for triggers and grip sensors. + Returns a numeric value for the input with the given [param name]. This is used for triggers and grip sensors. </description> </method> <method name="is_button_pressed" qualifiers="const"> <return type="bool" /> <param index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if the button with the given [code]name[/code] is pressed. + Returns [code]true[/code] if the button with the given [param name] is pressed. </description> </method> </methods> diff --git a/doc/classes/XRInterface.xml b/doc/classes/XRInterface.xml index 1fd62fc8a6..6296b95e6c 100644 --- a/doc/classes/XRInterface.xml +++ b/doc/classes/XRInterface.xml @@ -93,8 +93,8 @@ <param index="5" name="delay_sec" type="float" /> <description> Triggers a haptic pulse on a device associated with this interface. - [code]action_name[/code] is the name of the action for this pulse. - [code]tracker_name[/code] is optional and can be used to direct the pulse to a specific device provided that device is bound to this haptic. + [param action_name] is the name of the action for this pulse. + [param tracker_name] is optional and can be used to direct the pulse to a specific device provided that device is bound to this haptic. </description> </method> <method name="uninitialize"> diff --git a/doc/classes/XRNode3D.xml b/doc/classes/XRNode3D.xml index 21d0d20b3f..1507a3fe45 100644 --- a/doc/classes/XRNode3D.xml +++ b/doc/classes/XRNode3D.xml @@ -36,7 +36,7 @@ <param index="4" name="delay_sec" type="float" /> <description> Triggers a haptic pulse on a device associated with this interface. - [code]action_name[/code] is the name of the action for this pulse. + [param action_name] is the name of the action for this pulse. </description> </method> </methods> diff --git a/doc/classes/XRPositionalTracker.xml b/doc/classes/XRPositionalTracker.xml index 5f116de529..db2910f25e 100644 --- a/doc/classes/XRPositionalTracker.xml +++ b/doc/classes/XRPositionalTracker.xml @@ -23,14 +23,14 @@ <return type="XRPose" /> <param index="0" name="name" type="StringName" /> <description> - Returns the current [XRPose] state object for the bound [code]pose[/code]. + Returns the current [XRPose] state object for the bound [param name] pose. </description> </method> <method name="has_pose" qualifiers="const"> <return type="bool" /> <param index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if the bound [code]tracker[/code] is available and is currently tracking the bound [code]pose[/code]. + Returns [code]true[/code] if the tracker is available and is currently tracking the bound [param name] pose. </description> </method> <method name="invalidate_pose"> diff --git a/doc/classes/XRServer.xml b/doc/classes/XRServer.xml index 3be252617c..7e96b33edd 100644 --- a/doc/classes/XRServer.xml +++ b/doc/classes/XRServer.xml @@ -41,7 +41,7 @@ <return type="XRInterface" /> <param index="0" name="name" type="String" /> <description> - Finds an interface by its name. For instance, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it. + Finds an interface by its [param name]. For instance, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it. </description> </method> <method name="get_hmd_transform"> @@ -54,7 +54,7 @@ <return type="XRInterface" /> <param index="0" name="idx" type="int" /> <description> - Returns the interface registered at a given index in our list of interfaces. + Returns the interface registered at the given [param idx] index in the list of interfaces. </description> </method> <method name="get_interface_count" qualifiers="const"> @@ -79,28 +79,28 @@ <return type="XRPositionalTracker" /> <param index="0" name="tracker_name" type="StringName" /> <description> - Returns the positional tracker with this name. + Returns the positional tracker with the given [param tracker_name]. </description> </method> <method name="get_trackers"> <return type="Dictionary" /> <param index="0" name="tracker_types" type="int" /> <description> - Returns a dictionary of trackers for this type. + Returns a dictionary of trackers for [param tracker_types]. </description> </method> <method name="remove_interface"> <return type="void" /> <param index="0" name="interface" type="XRInterface" /> <description> - Removes this interface. + Removes this [param interface]. </description> </method> <method name="remove_tracker"> <return type="void" /> <param index="0" name="tracker" type="XRPositionalTracker" /> <description> - Removes this positional tracker. + Removes this positional [param tracker]. </description> </method> </methods> diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 89daa2af64..bcb6092d87 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -46,7 +46,7 @@ static const uint32_t SMALL_ALLOCATION_MAX_SIZE = 4096; -// Get the Vulkan object information and possible stage access types (bitwise OR'd with incoming values) +// Get the Vulkan object information and possible stage access types (bitwise OR'd with incoming values). RenderingDeviceVulkan::Buffer *RenderingDeviceVulkan::_get_buffer_from_owner(RID p_buffer, VkPipelineStageFlags &r_stage_mask, VkAccessFlags &r_access_mask, uint32_t p_post_barrier) { Buffer *buffer = nullptr; if (vertex_buffer_owner.owns(p_buffer)) { @@ -108,8 +108,8 @@ RenderingDeviceVulkan::Buffer *RenderingDeviceVulkan::_get_buffer_from_owner(RID } static void update_external_dependency_for_store(VkSubpassDependency2KHR &dependency, bool is_sampled, bool is_storage, bool is_depth) { - // Transitioning from write to read, protect the shaders that may use this next - // Allow for copies/image layout transitions + // Transitioning from write to read, protect the shaders that may use this next. + // Allow for copies/image layout transitions. dependency.dstStageMask |= VK_PIPELINE_STAGE_TRANSFER_BIT; dependency.dstAccessMask |= VK_ACCESS_TRANSFER_READ_BIT; @@ -125,7 +125,7 @@ static void update_external_dependency_for_store(VkSubpassDependency2KHR &depend } if (is_depth) { - // Depth resources have additional stages that may be interested in them + // Depth resources have additional stages that may be interested in them. dependency.dstStageMask |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; dependency.dstAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; } @@ -146,7 +146,7 @@ void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) { } void RenderingDeviceVulkan::_free_dependencies(RID p_id) { - //direct dependencies must be freed + // Direct dependencies must be freed. HashMap<RID, HashSet<RID>>::Iterator E = dependency_map.find(p_id); if (E) { @@ -156,7 +156,7 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) { dependency_map.remove(E); } - //reverse dependencies must be unreferenced + // Reverse dependencies must be unreferenced. E = reverse_dependency_map.find(p_id); if (E) { @@ -860,7 +860,7 @@ uint32_t RenderingDeviceVulkan::get_image_format_pixel_size(DataFormat p_format) case DATA_FORMAT_D24_UNORM_S8_UINT: return 4; case DATA_FORMAT_D32_SFLOAT_S8_UINT: - return 5; //? + return 5; // ? case DATA_FORMAT_BC1_RGB_UNORM_BLOCK: case DATA_FORMAT_BC1_RGB_SRGB_BLOCK: case DATA_FORMAT_BC1_RGBA_UNORM_BLOCK: @@ -995,7 +995,7 @@ void RenderingDeviceVulkan::get_compressed_image_format_block_dimensions(DataFor case DATA_FORMAT_EAC_R11_SNORM_BLOCK: case DATA_FORMAT_EAC_R11G11_UNORM_BLOCK: case DATA_FORMAT_EAC_R11G11_SNORM_BLOCK: - case DATA_FORMAT_ASTC_4x4_UNORM_BLOCK: //again, not sure about astc + case DATA_FORMAT_ASTC_4x4_UNORM_BLOCK: // Again, not sure about astc. case DATA_FORMAT_ASTC_4x4_SRGB_BLOCK: case DATA_FORMAT_ASTC_5x4_UNORM_BLOCK: case DATA_FORMAT_ASTC_5x4_SRGB_BLOCK: @@ -1073,7 +1073,7 @@ uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(Data case DATA_FORMAT_EAC_R11G11_UNORM_BLOCK: case DATA_FORMAT_EAC_R11G11_SNORM_BLOCK: return 16; - case DATA_FORMAT_ASTC_4x4_UNORM_BLOCK: //again, not sure about astc + case DATA_FORMAT_ASTC_4x4_UNORM_BLOCK: // Again, not sure about astc. case DATA_FORMAT_ASTC_4x4_SRGB_BLOCK: case DATA_FORMAT_ASTC_5x4_UNORM_BLOCK: case DATA_FORMAT_ASTC_5x4_SRGB_BLOCK: @@ -1101,7 +1101,7 @@ uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(Data case DATA_FORMAT_ASTC_12x10_SRGB_BLOCK: case DATA_FORMAT_ASTC_12x12_UNORM_BLOCK: case DATA_FORMAT_ASTC_12x12_SRGB_BLOCK: - return 8; //wrong + return 8; // Wrong. default: { } } @@ -1110,7 +1110,7 @@ uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(Data uint32_t RenderingDeviceVulkan::get_compressed_image_format_pixel_rshift(DataFormat p_format) { switch (p_format) { - case DATA_FORMAT_BC1_RGB_UNORM_BLOCK: //these formats are half byte size, so rshift is 1 + case DATA_FORMAT_BC1_RGB_UNORM_BLOCK: // These formats are half byte size, so rshift is 1. case DATA_FORMAT_BC1_RGB_SRGB_BLOCK: case DATA_FORMAT_BC1_RGBA_UNORM_BLOCK: case DATA_FORMAT_BC1_RGBA_SRGB_BLOCK: @@ -1184,7 +1184,7 @@ uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_form } uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uint32_t p_height, uint32_t p_depth) { - //formats and block size don't really matter here since they can all go down to 1px (even if block is larger) + // Formats and block size don't really matter here since they can all go down to 1px (even if block is larger). uint32_t w = p_width; uint32_t h = p_height; uint32_t d = p_depth; @@ -1402,16 +1402,16 @@ Error RenderingDeviceVulkan::_insert_staging_block() { } Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_t p_required_align, uint32_t &r_alloc_offset, uint32_t &r_alloc_size, bool p_can_segment) { - //determine a block to use + // Determine a block to use. r_alloc_size = p_amount; while (true) { r_alloc_offset = 0; - //see if we can use current block + // See if we can use current block. if (staging_buffer_blocks[staging_buffer_current].frame_used == frames_drawn) { - //we used this block this frame, let's see if there is still room + // We used this block this frame, let's see if there is still room. uint32_t write_from = staging_buffer_blocks[staging_buffer_current].fill_amount; @@ -1425,107 +1425,107 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_ int32_t available_bytes = int32_t(staging_buffer_block_size) - int32_t(write_from); if ((int32_t)p_amount < available_bytes) { - //all is good, we should be ok, all will fit + // All is good, we should be ok, all will fit. r_alloc_offset = write_from; } else if (p_can_segment && available_bytes >= (int32_t)p_required_align) { - //ok all won't fit but at least we can fit a chunkie - //all is good, update what needs to be written to + // Ok all won't fit but at least we can fit a chunkie. + // All is good, update what needs to be written to. r_alloc_offset = write_from; r_alloc_size = available_bytes - (available_bytes % p_required_align); } else { - //can't fit it into this buffer. - //will need to try next buffer + // Can't fit it into this buffer. + // Will need to try next buffer. staging_buffer_current = (staging_buffer_current + 1) % staging_buffer_blocks.size(); - // before doing anything, though, let's check that we didn't manage to fill all blocks - // possible in a single frame + // Before doing anything, though, let's check that we didn't manage to fill all blocks. + // Possible in a single frame. if (staging_buffer_blocks[staging_buffer_current].frame_used == frames_drawn) { - //guess we did.. ok, let's see if we can insert a new block.. + // Guess we did.. ok, let's see if we can insert a new block. if ((uint64_t)staging_buffer_blocks.size() * staging_buffer_block_size < staging_buffer_max_size) { - //we can, so we are safe + // We can, so we are safe. Error err = _insert_staging_block(); if (err) { return err; } - //claim for this frame + // Claim for this frame. staging_buffer_blocks.write[staging_buffer_current].frame_used = frames_drawn; } else { // Ok, worst case scenario, all the staging buffers belong to this frame // and this frame is not even done. - // If this is the main thread, it means the user is likely loading a lot of resources at once, - // otherwise, the thread should just be blocked until the next frame (currently unimplemented) + // If this is the main thread, it means the user is likely loading a lot of resources at once,. + // Otherwise, the thread should just be blocked until the next frame (currently unimplemented). - if (false) { //separate thread from render + if (false) { // Separate thread from render. //block_until_next_frame() continue; } else { - //flush EVERYTHING including setup commands. IF not immediate, also need to flush the draw commands + // Flush EVERYTHING including setup commands. IF not immediate, also need to flush the draw commands. _flush(true); - //clear the whole staging buffer + // Clear the whole staging buffer. for (int i = 0; i < staging_buffer_blocks.size(); i++) { staging_buffer_blocks.write[i].frame_used = 0; staging_buffer_blocks.write[i].fill_amount = 0; } - //claim current + // Claim current. staging_buffer_blocks.write[staging_buffer_current].frame_used = frames_drawn; } } } else { - //not from current frame, so continue and try again + // Not from current frame, so continue and try again. continue; } } } else if (staging_buffer_blocks[staging_buffer_current].frame_used <= frames_drawn - frame_count) { - //this is an old block, which was already processed, let's reuse + // This is an old block, which was already processed, let's reuse. staging_buffer_blocks.write[staging_buffer_current].frame_used = frames_drawn; staging_buffer_blocks.write[staging_buffer_current].fill_amount = 0; } else { - //this block may still be in use, let's not touch it unless we have to, so.. can we create a new one? + // This block may still be in use, let's not touch it unless we have to, so.. can we create a new one? if ((uint64_t)staging_buffer_blocks.size() * staging_buffer_block_size < staging_buffer_max_size) { - //we are still allowed to create a new block, so let's do that and insert it for current pos + // We are still allowed to create a new block, so let's do that and insert it for current pos. Error err = _insert_staging_block(); if (err) { return err; } - //claim for this frame + // Claim for this frame. staging_buffer_blocks.write[staging_buffer_current].frame_used = frames_drawn; } else { - // oops, we are out of room and we can't create more. - // let's flush older frames. + // Oops, we are out of room and we can't create more. + // Let's flush older frames. // The logic here is that if a game is loading a lot of data from the main thread, it will need to be stalled anyway. // If loading from a separate thread, we can block that thread until next frame when more room is made (not currently implemented, though). if (false) { - //separate thread from render + // Separate thread from render. //block_until_next_frame() - continue; //and try again + continue; // And try again. } else { _flush(false); for (int i = 0; i < staging_buffer_blocks.size(); i++) { - //clear all blocks but the ones from this frame + // Clear all blocks but the ones from this frame. int block_idx = (i + staging_buffer_current) % staging_buffer_blocks.size(); if (staging_buffer_blocks[block_idx].frame_used == frames_drawn) { - break; //ok, we reached something from this frame, abort + break; // Ok, we reached something from this frame, abort. } staging_buffer_blocks.write[block_idx].frame_used = 0; staging_buffer_blocks.write[block_idx].fill_amount = 0; } - //claim for current frame + // Claim for current frame. staging_buffer_blocks.write[staging_buffer_current].frame_used = frames_drawn; } } } - //all was good, break + // All was good, break. break; } @@ -1535,7 +1535,7 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_ } Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, const uint8_t *p_data, size_t p_data_size, bool p_use_draw_command_buffer, uint32_t p_required_align) { - //submitting may get chunked for various reasons, so convert this to a task + // Submitting may get chunked for various reasons, so convert this to a task. size_t to_submit = p_data_size; size_t submit_from = 0; @@ -1548,7 +1548,7 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c return err; } - //map staging buffer (It's CPU and coherent) + // Map staging buffer (It's CPU and coherent). void *data_ptr = nullptr; { @@ -1556,12 +1556,12 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + "."); } - //copy to staging buffer + // Copy to staging buffer. memcpy(((uint8_t *)data_ptr) + block_write_offset, p_data + submit_from, block_write_amount); - //unmap + // Unmap. vmaUnmapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation); - //insert a command to copy this + // Insert a command to copy this. VkBufferCopy region; region.srcOffset = block_write_offset; @@ -1587,13 +1587,13 @@ void RenderingDeviceVulkan::_memory_barrier(VkPipelineStageFlags p_src_stage_mas mem_barrier.dstAccessMask = p_dst_sccess; if (p_src_stage_mask == 0 || p_dst_stage_mask == 0) { - return; //no barrier, since this is invalid + return; // No barrier, since this is invalid. } vkCmdPipelineBarrier(p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, p_src_stage_mask, p_dst_stage_mask, 0, 1, &mem_barrier, 0, nullptr, 0, nullptr); } void RenderingDeviceVulkan::_full_barrier(bool p_sync_with_draw) { - //used for debug + // Used for debug. _memory_barrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_INDEX_READ_BIT | @@ -1662,8 +1662,8 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T #ifndef ANDROID_ENABLED // vkCreateImage fails with format list on Android (VK_ERROR_OUT_OF_HOST_MEMORY) - VkImageFormatListCreateInfoKHR format_list_create_info; //keep out of the if, needed for creation - Vector<VkFormat> allowed_formats; //keep out of the if, needed for creation + VkImageFormatListCreateInfoKHR format_list_create_info; // Keep out of the if, needed for creation. + Vector<VkFormat> allowed_formats; // Keep out of the if, needed for creation. #endif if (p_format.shareable_formats.size()) { image_create_info.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; @@ -1736,7 +1736,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T image_create_info.samples = rasterization_sample_count[p_format.samples]; image_create_info.tiling = (p_format.usage_bits & TEXTURE_USAGE_CPU_READ_BIT) ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL; - //usage + // Usage. image_create_info.usage = 0; if (p_format.usage_bits & TEXTURE_USAGE_SAMPLING_BIT) { @@ -1800,7 +1800,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T } { - //validate that this image is supported for the intended use + // Validate that this image is supported for the intended use. VkFormatProperties properties; vkGetPhysicalDeviceFormatProperties(context->get_physical_device(), image_create_info.format, &properties); VkFormatFeatureFlags flags; @@ -1841,7 +1841,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T } } - //some view validation + // Some view validation. if (p_view.format_override != DATA_FORMAT_MAX) { ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID()); @@ -1851,7 +1851,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T ERR_FAIL_INDEX_V(p_view.swizzle_b, TEXTURE_SWIZZLE_MAX, RID()); ERR_FAIL_INDEX_V(p_view.swizzle_a, TEXTURE_SWIZZLE_MAX, RID()); - //allocate memory + // Allocate memory. uint32_t width, height; uint32_t image_size = get_image_format_required_size(p_format.format, p_format.width, p_format.height, p_format.depth, p_format.mipmaps, &width, &height); @@ -1888,19 +1888,19 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T texture.samples = p_format.samples; texture.allowed_shared_formats = p_format.shareable_formats; - //set base layout based on usage priority + // Set base layout based on usage priority. if (p_format.usage_bits & TEXTURE_USAGE_SAMPLING_BIT) { - //first priority, readable + // First priority, readable. texture.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } else if (p_format.usage_bits & TEXTURE_USAGE_STORAGE_BIT) { - //second priority, storage + // Second priority, storage. texture.layout = VK_IMAGE_LAYOUT_GENERAL; } else if (p_format.usage_bits & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) { - //third priority, color or depth + // Third priority, color or depth. texture.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; @@ -1925,7 +1925,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T texture.bound = false; - //create view + // Create view. VkImageViewCreateInfo image_view_create_info; image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; @@ -1982,7 +1982,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T ERR_FAIL_V_MSG(RID(), "vkCreateImageView failed with error " + itos(err) + "."); } - //barrier to set layout + // Barrier to set layout. { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -2022,13 +2022,13 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID Texture *src_texture = texture_owner.get_or_null(p_with_texture); ERR_FAIL_COND_V(!src_texture, RID()); - if (src_texture->owner.is_valid()) { //ahh this is a share + if (src_texture->owner.is_valid()) { // Ahh this is a share. p_with_texture = src_texture->owner; src_texture = texture_owner.get_or_null(src_texture->owner); - ERR_FAIL_COND_V(!src_texture, RID()); //this is a bug + ERR_FAIL_COND_V(!src_texture, RID()); // This is a bug. } - //create view + // Create view. Texture texture = *src_texture; @@ -2089,7 +2089,7 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID usage_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO; usage_info.pNext = nullptr; if (p_view.format_override != DATA_FORMAT_MAX) { - //need to validate usage with vulkan + // Need to validate usage with vulkan. usage_info.usage = 0; @@ -2151,9 +2151,9 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat Texture texture; texture.image = image; - // if we leave texture.allocation as a nullptr, would that be enough to detect we don't "own" the image? - // also leave texture.allocation_info alone - // we'll set texture.view later on + // If we leave texture.allocation as a nullptr, would that be enough to detect we don't "own" the image? + // Also leave texture.allocation_info alone. + // We'll set texture.view later on. texture.type = p_type; texture.format = p_format; texture.samples = p_samples; @@ -2161,14 +2161,14 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat texture.height = p_height; texture.depth = p_depth; texture.layers = p_layers; - texture.mipmaps = 0; // maybe make this settable too? + texture.mipmaps = 0; // Maybe make this settable too? texture.usage_flags = p_flags; texture.base_mipmap = 0; texture.base_layer = 0; texture.allowed_shared_formats.push_back(RD::DATA_FORMAT_R8G8B8A8_UNORM); texture.allowed_shared_formats.push_back(RD::DATA_FORMAT_R8G8B8A8_SRGB); - // Do we need to do something with texture.layout ? + // Do we need to do something with texture.layout? if (texture.usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { texture.read_aspect_mask = VK_IMAGE_ASPECT_DEPTH_BIT; @@ -2182,7 +2182,7 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat texture.barrier_aspect_mask = VK_IMAGE_ASPECT_COLOR_BIT; } - // Create a view for us to use + // Create a view for us to use. VkImageViewCreateInfo image_view_create_info; image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; @@ -2213,7 +2213,7 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat VK_COMPONENT_SWIZZLE_A }; - // hardcode for now, maybe make this settable from outside.. + // Hardcode for now, maybe make this settable from outside. image_view_create_info.components.r = component_swizzles[TEXTURE_SWIZZLE_R]; image_view_create_info.components.g = component_swizzles[TEXTURE_SWIZZLE_G]; image_view_create_info.components.b = component_swizzles[TEXTURE_SWIZZLE_B]; @@ -2236,7 +2236,7 @@ RID RenderingDeviceVulkan::texture_create_from_extension(TextureType p_type, Dat ERR_FAIL_V_MSG(RID(), "vkCreateImageView failed with error " + itos(err) + "."); } - //barrier to set layout + // Barrier to set layout. { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -2271,10 +2271,10 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p Texture *src_texture = texture_owner.get_or_null(p_with_texture); ERR_FAIL_COND_V(!src_texture, RID()); - if (src_texture->owner.is_valid()) { //ahh this is a share + if (src_texture->owner.is_valid()) { // Ahh this is a share. p_with_texture = src_texture->owner; src_texture = texture_owner.get_or_null(src_texture->owner); - ERR_FAIL_COND_V(!src_texture, RID()); //this is a bug + ERR_FAIL_COND_V(!src_texture, RID()); // This is a bug. } ERR_FAIL_COND_V_MSG(p_slice_type == TEXTURE_SLICE_CUBEMAP && (src_texture->type != TEXTURE_TYPE_CUBE && src_texture->type != TEXTURE_TYPE_CUBE_ARRAY), RID(), @@ -2286,7 +2286,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p ERR_FAIL_COND_V_MSG(p_slice_type == TEXTURE_SLICE_2D_ARRAY && (src_texture->type != TEXTURE_TYPE_2D_ARRAY), RID(), "Can only create an array slice from a 2D array mipmap"); - //create view + // Create view. ERR_FAIL_UNSIGNED_INDEX_V(p_mipmap, src_texture->mipmaps, RID()); ERR_FAIL_COND_V(p_mipmap + p_mipmaps > src_texture->mipmaps, RID()); @@ -2426,7 +2426,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co if (texture->owner != RID()) { p_texture = texture->owner; texture = texture_owner.get_or_null(texture->owner); - ERR_FAIL_COND_V(!texture, ERR_BUG); //this is a bug + ERR_FAIL_COND_V(!texture, ERR_BUG); // This is a bug. } ERR_FAIL_COND_V_MSG(texture->bound, ERR_CANT_ACQUIRE_RESOURCE, @@ -2448,7 +2448,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co if (required_align == 1) { required_align = get_image_format_pixel_size(texture->format); } - if ((required_align % 4) != 0) { //alignment rules are really strange + if ((required_align % 4) != 0) { // Alignment rules are really strange. required_align *= 4; } @@ -2461,7 +2461,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co VkCommandBuffer command_buffer = p_use_setup_queue ? frames[frame].setup_command_buffer : frames[frame].draw_command_buffer; - //barrier to transfer + // Barrier to transfer. { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -2495,7 +2495,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co const uint8_t *read_ptr_mipmap = r + mipmap_offset; image_size = image_total - mipmap_offset; - for (uint32_t z = 0; z < depth; z++) { //for 3D textures, depth may be > 0 + for (uint32_t z = 0; z < depth; z++) { // For 3D textures, depth may be > 0. const uint8_t *read_ptr = read_ptr_mipmap + image_size * z / depth; @@ -2517,7 +2517,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co uint8_t *write_ptr; - { //map + { // Map. void *data_ptr = nullptr; VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr); ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + "."); @@ -2532,11 +2532,11 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co ERR_FAIL_COND_V(region_h % block_h, ERR_BUG); if (block_w != 1 || block_h != 1) { - //compressed image (blocks) - //must copy a block region + // Compressed image (blocks). + // Must copy a block region. uint32_t block_size = get_compressed_image_format_block_byte_size(texture->format); - //re-create current variables in blocky format + // Re-create current variables in blocky format. uint32_t xb = x / block_w; uint32_t yb = y / block_h; uint32_t wb = width / block_w; @@ -2545,19 +2545,19 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co uint32_t region_hb = region_h / block_h; _copy_region(read_ptr, write_ptr, xb, yb, region_wb, region_hb, wb, block_size); } else { - //regular image (pixels) - //must copy a pixel region + // Regular image (pixels). + // Must copy a pixel region. _copy_region(read_ptr, write_ptr, x, y, region_w, region_h, width, pixel_size); } - { //unmap + { // Unmap. vmaUnmapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation); } VkBufferImageCopy buffer_image_copy; buffer_image_copy.bufferOffset = alloc_offset; - buffer_image_copy.bufferRowLength = 0; //tightly packed - buffer_image_copy.bufferImageHeight = 0; //tightly packed + buffer_image_copy.bufferRowLength = 0; // Tightly packed. + buffer_image_copy.bufferImageHeight = 0; // Tightly packed. buffer_image_copy.imageSubresource.aspectMask = texture->read_aspect_mask; buffer_image_copy.imageSubresource.mipLevel = mm_i; @@ -2584,7 +2584,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co logic_height = MAX(1u, logic_height >> 1); } - //barrier to restore layout + // Barrier to restore layout. { uint32_t barrier_flags = 0; uint32_t access_flags = 0; @@ -2671,7 +2671,7 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex const uint8_t *slice_read_ptr = ((uint8_t *)img_mem) + layout.offset + z * layout.depthPitch; if (block_size > 1) { - //compressed + // Compressed. uint32_t line_width = (block_size * (width / blockw)); for (uint32_t y = 0; y < height / blockh; y++) { const uint8_t *rptr = slice_read_ptr + y * layout.rowPitch; @@ -2681,7 +2681,7 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex } } else { - //uncompressed + // Uncompressed. for (uint32_t y = 0; y < height; y++) { const uint8_t *rptr = slice_read_ptr + y * layout.rowPitch; uint8_t *wptr = write_ptr + y * pixel_size * width; @@ -2717,19 +2717,19 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t ERR_FAIL_COND_V(p_layer >= layer_count, Vector<uint8_t>()); if (tex->usage_flags & TEXTURE_USAGE_CPU_READ_BIT) { - //does not need anything fancy, map and read. + // Does not need anything fancy, map and read. return _texture_get_data_from_image(tex, tex->image, tex->allocation, p_layer); } else { - //compute total image size + // Compute total image size. uint32_t width, height, depth; uint32_t buffer_size = get_image_format_required_size(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps, &width, &height, &depth); - //allocate buffer - VkCommandBuffer command_buffer = frames[frame].draw_command_buffer; //makes more sense to retrieve + // Allocate buffer. + VkCommandBuffer command_buffer = frames[frame].draw_command_buffer; // Makes more sense to retrieve. Buffer tmp_buffer; _buffer_allocate(&tmp_buffer, buffer_size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VMA_MEMORY_USAGE_AUTO_PREFER_HOST, VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT); - { //Source image barrier + { // Source image barrier. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -2785,7 +2785,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t offset += size; } - { //restore src + { // Restore src. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -2900,9 +2900,9 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, VkCommandBuffer command_buffer = frames[frame].draw_command_buffer; { - //PRE Copy the image + // PRE Copy the image. - { //Source + { // Source. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -2922,7 +2922,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } - { //Dest + { // Dest. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -2943,7 +2943,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } - //COPY + // COPY. { VkImageCopy image_copy_region; @@ -2970,7 +2970,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, vkCmdCopyImage(command_buffer, src_tex->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst_tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &image_copy_region); } - // RESTORE LAYOUT for SRC and DST + // RESTORE LAYOUT for SRC and DST. uint32_t barrier_flags = 0; uint32_t access_flags = 0; @@ -2991,7 +2991,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, barrier_flags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; } - { //restore src + { // Restore src. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -3011,7 +3011,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, barrier_flags, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } - { //make dst readable + { // Make dst readable. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -3078,9 +3078,9 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID VkCommandBuffer command_buffer = frames[frame].draw_command_buffer; { - //PRE Copy the image + // PRE Copy the image. - { //Source + { // Source. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -3100,7 +3100,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } - { //Dest + { // Dest. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -3121,7 +3121,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } - //COPY + // COPY. { VkImageResolve image_copy_region; @@ -3148,7 +3148,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID vkCmdResolveImage(command_buffer, src_tex->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst_tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &image_copy_region); } - // RESTORE LAYOUT for SRC and DST + // RESTORE LAYOUT for SRC and DST. uint32_t barrier_flags = 0; uint32_t access_flags = 0; @@ -3169,7 +3169,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID barrier_flags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; } - { //restore src + { // Restore src. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -3189,7 +3189,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, barrier_flags, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } - { //make dst readable + { // Make dst readable. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -3242,13 +3242,13 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, VkImageLayout clear_layout = (src_tex->layout == VK_IMAGE_LAYOUT_GENERAL) ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - // NOTE: Perhaps the valid stages/accesses for a given owner should be a property of the owner. (Here and places like _get_buffer_from_owner) + // NOTE: Perhaps the valid stages/accesses for a given owner should be a property of the owner. (Here and places like _get_buffer_from_owner.) const VkPipelineStageFlags valid_texture_stages = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; constexpr VkAccessFlags read_access = VK_ACCESS_SHADER_READ_BIT; constexpr VkAccessFlags read_write_access = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; const VkAccessFlags valid_texture_access = (src_tex->usage_flags & TEXTURE_USAGE_STORAGE_BIT) ? read_write_access : read_access; - { // Barrier from previous access with optional layout change (see clear_layout logic above) + { // Barrier from previous access with optional layout change (see clear_layout logic above). VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -3284,7 +3284,7 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, vkCmdClearColorImage(command_buffer, src_tex->image, clear_layout, &clear_color, 1, &range); - { // Barrier to post clear accesses (changing back the layout if needed) + { // Barrier to post clear accesses (changing back the layout if needed). uint32_t barrier_flags = 0; uint32_t access_flags = 0; @@ -3340,7 +3340,7 @@ bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_f _THREAD_SAFE_METHOD_ - //validate that this image is supported for the intended use + // Validate that this image is supported for the intended use. VkFormatProperties properties; vkGetPhysicalDeviceFormatProperties(context->get_physical_device(), vulkan_formats[p_format], &properties); VkFormatFeatureFlags flags; @@ -3384,12 +3384,12 @@ bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_f /********************/ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, InitialAction p_initial_action, FinalAction p_final_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, uint32_t p_view_count, Vector<TextureSamples> *r_samples) { - // Set up dependencies from/to external equivalent to the default (implicit) one, and then amend them + // Set up dependencies from/to external equivalent to the default (implicit) one, and then amend them. const VkPipelineStageFlags default_access_mask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | // From Section 7.1 of Vulkan API Spec v1.1.148 + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | // From Section 7.1 of Vulkan API Spec v1.1.148. VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR; VkPipelineStageFlags reading_stages = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT; @@ -3432,20 +3432,20 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF bool is_depth = p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; // We can setup a framebuffer where we write to our VRS texture to set it up. - // We make the assumption here that if our texture is actually used as our VRS attachment, - // it is used as such for each subpass. This is fairly certain seeing the restrictions on subpasses. + // We make the assumption here that if our texture is actually used as our VRS attachment. + // It is used as such for each subpass. This is fairly certain seeing the restrictions on subpasses. bool is_vrs = p_attachments[i].usage_flags & TEXTURE_USAGE_VRS_ATTACHMENT_BIT && i == p_passes[0].vrs_attachment; if (is_vrs) { - // For VRS we only read, there is no writing to this texture + // For VRS we only read, there is no writing to this texture. description.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; description.initialLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; } else { - // For each UNDEFINED, assume the prior use was a *read*, as we'd be discarding the output of a write - // Also, each UNDEFINED will do an immediate layout transition (write), s.t. we must ensure execution synchronization vs. + // For each UNDEFINED, assume the prior use was a *read*, as we'd be discarding the output of a write. + // Also, each UNDEFINED will do an immediate layout transition (write), s.t. we must ensure execution synchronization vs // the read. If this is a performance issue, one could track the actual last accessor of each resource, adding only that - // stage + // stage. switch (is_depth ? p_initial_depth_action : p_initial_action) { case INITIAL_ACTION_CLEAR_REGION: @@ -3462,7 +3462,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } else { description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. dependency_from_external.srcStageMask |= reading_stages; } } break; @@ -3479,7 +3479,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } else { description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. dependency_from_external.srcStageMask |= reading_stages; } } break; @@ -3490,13 +3490,13 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; dependency_from_external.srcStageMask |= reading_stages; } else { description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. dependency_from_external.srcStageMask |= reading_stages; } } break; @@ -3513,12 +3513,12 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } else { description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. dependency_from_external.srcStageMask |= reading_stages; } } break; default: { - ERR_FAIL_V(VK_NULL_HANDLE); //should never reach here + ERR_FAIL_V(VK_NULL_HANDLE); // Should never reach here. } } } @@ -3529,7 +3529,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF int last_pass = p_passes.size() - 1; if (is_depth) { - //likely missing depth resolve? + // Likely missing depth resolve? if (p_passes[last_pass].depth_attachment == i) { used_last = true; } @@ -3539,7 +3539,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } } else { if (p_passes[last_pass].resolve_attachments.size()) { - //if using resolve attachments, check resolve attachments + // If using resolve attachments, check resolve attachments. for (int j = 0; j < p_passes[last_pass].resolve_attachments.size(); j++) { if (p_passes[last_pass].resolve_attachments[j] == i) { used_last = true; @@ -3579,13 +3579,13 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } if (is_vrs) { - // We don't change our VRS texture during this process + // We don't change our VRS texture during this process. description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; description.finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - // TODO do we need to update our external dependency ? + // TODO: Do we need to update our external dependency? // update_external_dependency_for_store(dependency_to_external, is_sampled, is_storage, false); } else { switch (is_depth ? final_depth_action : final_action) { @@ -3603,8 +3603,8 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } else { description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there - // TODO: What does this mean about the next usage (and thus appropriate dependency masks + description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. + // TODO: What does this mean about the next usage (and thus appropriate dependency masks. } } break; case FINAL_ACTION_DISCARD: { @@ -3619,7 +3619,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } else { description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - description.finalLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.finalLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. } } break; case FINAL_ACTION_CONTINUE: { @@ -3634,12 +3634,12 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF } else { description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - description.finalLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there + description.finalLayout = VK_IMAGE_LAYOUT_UNDEFINED; // Don't care what is there. } } break; default: { - ERR_FAIL_V(VK_NULL_HANDLE); //should never reach here + ERR_FAIL_V(VK_NULL_HANDLE); // Should never reach here. } } } @@ -3723,7 +3723,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF reference.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; attachment_last_pass[attachment] = i; } - reference.aspectMask = 0; // TODO we need to set this here, possibly VK_IMAGE_ASPECT_COLOR_BIT ?? + reference.aspectMask = 0; // TODO: We need to set this here, possibly VK_IMAGE_ASPECT_COLOR_BIT? input_references.push_back(reference); } @@ -3749,7 +3749,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF bool multisample = p_attachments[attachment].samples > TEXTURE_SAMPLES_1; ERR_FAIL_COND_V_MSG(multisample, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), resolve attachments can't be multisample."); reference.attachment = attachment_remap[attachment]; - reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; // VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; // VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL attachment_last_pass[attachment] = i; } reference.aspectMask = 0; @@ -3818,7 +3818,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF ERR_FAIL_INDEX_V_MSG(attachment, p_attachments.size(), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), preserve attachment (" + itos(j) + ")."); if (attachment_last_pass[attachment] != i) { - //preserve can still be used to keep depth or color from being discarded after use + // Preserve can still be used to keep depth or color from being discarded after use. attachment_last_pass[attachment] = i; preserve_references.push_back(attachment); } @@ -3887,14 +3887,14 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF subpass_dependencies.push_back(dependency); } /* - // NOTE: Big Mallet Approach -- any layout transition causes a full barrier + // NOTE: Big Mallet Approach -- any layout transition causes a full barrier. if (reference.layout != description.initialLayout) { - // NOTE: this should be smarter based on the texture's knowledge of its previous role + // NOTE: This should be smarter based on the texture's knowledge of its previous role. dependency_from_external.srcStageMask |= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; dependency_from_external.srcAccessMask |= VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT; } if (reference.layout != description.finalLayout) { - // NOTE: this should be smarter based on the texture's knowledge of its subsequent role + // NOTE: This should be smarter based on the texture's knowledge of its subsequent role. dependency_to_external.dstStageMask |= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; dependency_to_external.dstAccessMask |= VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT; } @@ -3935,7 +3935,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF VkRenderPassMultiviewCreateInfo render_pass_multiview_create_info; if (p_view_count > 1) { - // this may no longer be needed with the new settings already including this + // This may no longer be needed with the new settings already including this. const VulkanContext::MultiviewCapabilities capabilities = context->get_multiview_capabilities(); @@ -3945,7 +3945,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF // Make sure we limit this to the number of views we support. ERR_FAIL_COND_V_MSG(p_view_count > capabilities.max_view_count, VK_NULL_HANDLE, "Hardware does not support requested number of views for Multiview render pass"); - // Set view masks for each subpass + // Set view masks for each subpass. for (uint32_t i = 0; i < subpasses.size(); i++) { view_masks.push_back(view_mask); } @@ -3993,14 +3993,14 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c const RBMap<FramebufferFormatKey, FramebufferFormatID>::Element *E = framebuffer_format_cache.find(key); if (E) { - //exists, return + // Exists, return. return E->get(); } Vector<TextureSamples> samples; - VkRenderPass render_pass = _render_pass_create(p_attachments, p_passes, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, p_view_count, &samples); //actions don't matter for this use case + VkRenderPass render_pass = _render_pass_create(p_attachments, p_passes, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, p_view_count, &samples); // Actions don't matter for this use case. - if (render_pass == VK_NULL_HANDLE) { //was likely invalid + if (render_pass == VK_NULL_HANDLE) { // Was likely invalid. return INVALID_ID; } FramebufferFormatID id = FramebufferFormatID(framebuffer_format_cache.size()) | (FramebufferFormatID(ID_TYPE_FRAMEBUFFER_FORMAT) << FramebufferFormatID(ID_BASE_SHIFT)); @@ -4021,7 +4021,7 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c const RBMap<FramebufferFormatKey, FramebufferFormatID>::Element *E = framebuffer_format_cache.find(key); if (E) { - //exists, return + // Exists, return. return E->get(); } @@ -4031,7 +4031,7 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c subpass.flags = 0; subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; subpass.viewMask = 0; - subpass.inputAttachmentCount = 0; //unsupported for now + subpass.inputAttachmentCount = 0; // Unsupported for now. subpass.pInputAttachments = nullptr; subpass.colorAttachmentCount = 0; subpass.pColorAttachments = nullptr; @@ -4058,7 +4058,7 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c ERR_FAIL_COND_V_MSG(res, 0, "vkCreateRenderPass2KHR for empty fb failed with error " + itos(res) + "."); - if (render_pass == VK_NULL_HANDLE) { //was likely invalid + if (render_pass == VK_NULL_HANDLE) { // Was likely invalid. return INVALID_ID; } @@ -4146,9 +4146,9 @@ RID RenderingDeviceVulkan::framebuffer_create_multipass(const Vector<RID> &p_tex size.height = texture->height; size_set = true; } else if (texture->usage_flags & TEXTURE_USAGE_VRS_ATTACHMENT_BIT) { - // If this is not the first attachement we assume this is used as the VRS attachment - // in this case this texture will be 1/16th the size of the color attachement. - // So we skip the size check + // If this is not the first attachement we assume this is used as the VRS attachment. + // In this case this texture will be 1/16th the size of the color attachement. + // So we skip the size check. } else { ERR_FAIL_COND_V_MSG((uint32_t)size.width != texture->width || (uint32_t)size.height != texture->height, RID(), "All textures in a framebuffer should be the same size."); @@ -4298,7 +4298,7 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vec return id; } -// Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated +// Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated. RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats) { _THREAD_SAFE_METHOD_ @@ -4310,7 +4310,7 @@ RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(cons return *idptr; } - //does not exist, create one and cache it + // Does not exist, create one and cache it. VertexDescriptionCache vdcache; vdcache.bindings = memnew_arr(VkVertexInputBindingDescription, p_vertex_formats.size()); vdcache.attributes = memnew_arr(VkVertexInputAttributeDescription, p_vertex_formats.size()); @@ -4366,25 +4366,25 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo vertex_array.vertex_count = p_vertex_count; vertex_array.description = p_vertex_format; - vertex_array.max_instances_allowed = 0xFFFFFFFF; //by default as many as you want + vertex_array.max_instances_allowed = 0xFFFFFFFF; // By default as many as you want. for (int i = 0; i < p_src_buffers.size(); i++) { Buffer *buffer = vertex_buffer_owner.get_or_null(p_src_buffers[i]); - //validate with buffer + // Validate with buffer. { const VertexAttribute &atf = vd.vertex_formats[i]; uint32_t element_size = get_format_vertex_size(atf.format); - ERR_FAIL_COND_V(element_size == 0, RID()); //should never happens since this was prevalidated + ERR_FAIL_COND_V(element_size == 0, RID()); // Should never happens since this was prevalidated. if (atf.frequency == VERTEX_FREQUENCY_VERTEX) { - //validate size for regular drawing + // Validate size for regular drawing. uint64_t total_size = uint64_t(atf.stride) * (p_vertex_count - 1) + atf.offset + element_size; ERR_FAIL_COND_V_MSG(total_size > buffer->size, RID(), "Attachment (" + itos(i) + ") will read past the end of the buffer."); } else { - //validate size for instances drawing + // Validate size for instances drawing. uint64_t available = buffer->size - atf.offset; ERR_FAIL_COND_V_MSG(available < element_size, RID(), "Attachment (" + itos(i) + ") uses instancing, but it's just too small."); @@ -4395,7 +4395,7 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo } vertex_array.buffers.push_back(buffer->buffer); - vertex_array.offsets.push_back(0); //offset unused, but passing anyway + vertex_array.offsets.push_back(0); // Offset unused, but passing anyway. } RID id = vertex_array_owner.make_rid(vertex_array); @@ -4430,7 +4430,7 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff const uint16_t *index16 = (const uint16_t *)r; for (uint32_t i = 0; i < p_index_count; i++) { if (p_use_restart_indices && index16[i] == 0xFFFF) { - continue; //restart index, ignore + continue; // Restart index, ignore. } index_buffer.max_index = MAX(index16[i], index_buffer.max_index); } @@ -4438,7 +4438,7 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff const uint32_t *index32 = (const uint32_t *)r; for (uint32_t i = 0; i < p_index_count; i++) { if (p_use_restart_indices && index32[i] == 0xFFFFFFFF) { - continue; //restart index, ignore + continue; // Restart index, ignore. } index_buffer.max_index = MAX(index32[i], index_buffer.max_index); } @@ -4537,7 +4537,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa case glslang::EbtSampler: { //print_line("DEBUG: IsSampler"); if (reflection.getType()->getSampler().dim == glslang::EsdBuffer) { - //texture buffers + // Texture buffers. if (reflection.getType()->getSampler().isCombined()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER; @@ -4637,7 +4637,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } break;*/ default: { if (reflection.getType()->getQualifier().hasOffset() || reflection.name.find(".") != std::string::npos) { - //member of uniform block? + // Member of uniform block? return true; } @@ -4674,10 +4674,10 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa uint32_t binding = reflection.getType()->getQualifier().layoutBinding; if (set < (uint32_t)bindings.size()) { - //check if this already exists + // Check if this already exists. for (int i = 0; i < bindings[set].size(); i++) { if (bindings[set][i].binding == binding) { - //already exists, verify that it's the same type + // Already exists, verify that it's the same type. if (bindings[set][i].descriptorType != layout_binding.descriptorType) { if (r_error) { *r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(binding) + " with different uniform type."; @@ -4685,7 +4685,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa return false; } - //also, verify that it's the same size + // Also, verify that it's the same size. if (bindings[set][i].descriptorCount != layout_binding.descriptorCount || uniform_infos[set][i].length != info.length) { if (r_error) { *r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(binding) + " with different uniform size."; @@ -4693,7 +4693,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa return false; } - //just append stage mask and return + // Just append stage mask and return. bindings.write[set].write[i].stageFlags |= shader_stage_masks[p_stage]; uniform_infos.write[set].write[i].stages |= 1 << p_stage; return true; @@ -4702,7 +4702,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } layout_binding.binding = binding; layout_binding.stageFlags = shader_stage_masks[p_stage]; - layout_binding.pImmutableSamplers = nullptr; //no support for this yet + layout_binding.pImmutableSamplers = nullptr; // No support for this yet. info.stages = 1 << p_stage; info.binding = binding; @@ -4721,9 +4721,9 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } #endif -//version 1: initial -//version 2: Added shader name -//version 3: Added writable +// Version 1: initial. +// Version 2: Added shader name. +// Version 3: Added writable. #define SHADER_BINARY_VERSION 3 @@ -4735,7 +4735,7 @@ struct RenderingDeviceVulkanShaderBinaryDataBinding { uint32_t type; uint32_t binding; uint32_t stages; - uint32_t length; //size of arrays (in total elements), or ubos (in bytes * total elements) + uint32_t length; // Size of arrays (in total elements), or ubos (in bytes * total elements). uint32_t writable; }; @@ -4776,7 +4776,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve binary_data.push_constant_size = 0; binary_data.push_constants_vk_stage = 0; - Vector<Vector<RenderingDeviceVulkanShaderBinaryDataBinding>> uniform_info; //set bindings + Vector<Vector<RenderingDeviceVulkanShaderBinaryDataBinding>> uniform_info; // Set bindings. Vector<RenderingDeviceVulkanShaderBinarySpecializationConstant> specialization_constants; uint32_t stages_processed = 0; @@ -4810,7 +4810,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve uint32_t stage = p_spirv[i].shader_stage; if (binding_count > 0) { - //Parse bindings + // Parse bindings. Vector<SpvReflectDescriptorBinding *> bindings; bindings.resize(binding_count); @@ -4917,23 +4917,23 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' uses a set (" + itos(set) + ") index larger than what is supported by the hardware (" + itos(limits.maxBoundDescriptorSets) + ")."); if (set < (uint32_t)uniform_info.size()) { - //check if this already exists + // Check if this already exists. bool exists = false; for (int k = 0; k < uniform_info[set].size(); k++) { if (uniform_info[set][k].binding == (uint32_t)info.binding) { - //already exists, verify that it's the same type + // Already exists, verify that it's the same type. ERR_FAIL_COND_V_MSG(uniform_info[set][k].type != info.type, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform type."); - //also, verify that it's the same size + // Also, verify that it's the same size. ERR_FAIL_COND_V_MSG(uniform_info[set][k].length != info.length, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform size."); - //also, verify that it has the same writability + // Also, verify that it has the same writability. ERR_FAIL_COND_V_MSG(uniform_info[set][k].writable != info.writable, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different writability."); - //just append stage mask and return + // Just append stage mask and return. uniform_info.write[set].write[k].stages |= 1 << stage; exists = true; break; @@ -4941,7 +4941,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve } if (exists) { - continue; //merged + continue; // Merged. } } @@ -4956,7 +4956,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve } { - //specialization constants + // Specialization constants. uint32_t sc_count = 0; result = spvReflectEnumerateSpecializationConstants(&module, &sc_count, nullptr); @@ -4977,7 +4977,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve SpvReflectSpecializationConstant *spc = spec_constants[j]; sconst.constant_id = spc->constant_id; - sconst.int_value = 0.0; // clear previous value JIC + sconst.int_value = 0.0; // Clear previous value JIC. switch (spc->constant_type) { case SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL: { sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; @@ -5027,7 +5027,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining input variables."); for (uint32_t j = 0; j < iv_count; j++) { - if (input_vars[j] && input_vars[j]->decoration_flags == 0) { //regular input + if (input_vars[j] && input_vars[j]->decoration_flags == 0) { // Regular input. binary_data.vertex_input_mask |= (1 << uint32_t(input_vars[j]->location)); } } @@ -5096,7 +5096,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve Vector<Vector<uint8_t>> compressed_stages; Vector<uint32_t> smolv_size; - Vector<uint32_t> zstd_size; //if 0, stdno t used + Vector<uint32_t> zstd_size; // If 0, zstd not used. uint32_t stages_binary_size = 0; @@ -5108,7 +5108,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve ERR_FAIL_V_MSG(Vector<uint8_t>(), "Error compressing shader stage :" + String(shader_stage_names[p_spirv[i].shader_stage])); } else { smolv_size.push_back(smolv.size()); - { //zstd + { // zstd. Vector<uint8_t> zstd; zstd.resize(Compression::get_max_compressed_buffer_size(smolv.size(), Compression::MODE_ZSTD)); int dst_size = Compression::compress(zstd.ptrw(), &smolv[0], smolv.size(), Compression::MODE_ZSTD); @@ -5121,7 +5121,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve Vector<uint8_t> smv; smv.resize(smolv.size()); memcpy(smv.ptrw(), &smolv[0], smolv.size()); - zstd_size.push_back(0); //not using zstd + zstd_size.push_back(0); // Not using zstd. compressed_stages.push_back(smv); } } @@ -5141,12 +5141,12 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve binary_data.shader_name_len = shader_name_utf.length(); - uint32_t total_size = sizeof(uint32_t) * 3; //header + version + main datasize; + uint32_t total_size = sizeof(uint32_t) * 3; // Header + version + main datasize;. total_size += sizeof(RenderingDeviceVulkanShaderBinaryData); total_size += binary_data.shader_name_len; - if ((binary_data.shader_name_len % 4) != 0) { //alignment rules are really strange + if ((binary_data.shader_name_len % 4) != 0) { // Alignment rules are really strange. total_size += 4 - (binary_data.shader_name_len % 4); } @@ -5157,7 +5157,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve total_size += sizeof(RenderingDeviceVulkanShaderBinarySpecializationConstant) * specialization_constants.size(); - total_size += compressed_stages.size() * sizeof(uint32_t) * 3; //sizes + total_size += compressed_stages.size() * sizeof(uint32_t) * 3; // Sizes. total_size += stages_binary_size; Vector<uint8_t> ret; @@ -5168,7 +5168,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve binptr[0] = 'G'; binptr[1] = 'V'; binptr[2] = 'B'; - binptr[3] = 'D'; //godot vulkan binary data + binptr[3] = 'D'; // Godot vulkan binary data. offset += 4; encode_uint32(SHADER_BINARY_VERSION, binptr + offset); offset += sizeof(uint32_t); @@ -5179,7 +5179,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve memcpy(binptr + offset, shader_name_utf.ptr(), binary_data.shader_name_len); offset += binary_data.shader_name_len; - if ((binary_data.shader_name_len % 4) != 0) { //alignment rules are really strange + if ((binary_data.shader_name_len % 4) != 0) { // Alignment rules are really strange. offset += 4 - (binary_data.shader_name_len % 4); } @@ -5227,7 +5227,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ uint32_t binsize = p_shader_binary.size(); uint32_t read_offset = 0; - //consistency check + // Consistency check. ERR_FAIL_COND_V(binsize < sizeof(uint32_t) * 3 + sizeof(RenderingDeviceVulkanShaderBinaryData), RID()); ERR_FAIL_COND_V(binptr[0] != 'G' || binptr[1] != 'V' || binptr[2] != 'B' || binptr[3] != 'D', RID()); @@ -5257,7 +5257,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ if (binary_data.shader_name_len) { name.parse_utf8((const char *)(binptr + read_offset), binary_data.shader_name_len); read_offset += binary_data.shader_name_len; - if ((binary_data.shader_name_len % 4) != 0) { //alignment rules are really strange + if ((binary_data.shader_name_len % 4) != 0) { // Alignment rules are really strange. read_offset += 4 - (binary_data.shader_name_len % 4); } } @@ -5374,7 +5374,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ const uint8_t *src_smolv = nullptr; if (zstd_size > 0) { - //decompress to smolv + // Decompress to smolv. smolv.resize(smolv_size); int dec_smolv_size = Compression::decompress(smolv.ptrw(), smolv.size(), binptr + read_offset, zstd_size, Compression::MODE_ZSTD); ERR_FAIL_COND_V(dec_smolv_size != (int32_t)smolv_size, RID()); @@ -5403,7 +5403,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ ERR_FAIL_COND_V(read_offset != binsize, RID()); - //all good, let's create modules + // All good, let's create modules. _THREAD_SAFE_METHOD_ @@ -5459,11 +5459,11 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ shader.pipeline_stages.push_back(shader_stage); } - //proceed to create descriptor sets + // Proceed to create descriptor sets. if (success) { for (int i = 0; i < set_bindings.size(); i++) { - //empty ones are fine if they were not used according to spec (binding count will be 0) + // Empty ones are fine if they were not used according to spec (binding count will be 0). VkDescriptorSetLayoutCreateInfo layout_create_info; layout_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; layout_create_info.pNext = nullptr; @@ -5482,13 +5482,13 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ Shader::Set set; set.descriptor_set_layout = layout; set.uniform_info = uniform_info[i]; - //sort and hash + // Sort and hash. set.uniform_info.sort(); - uint32_t format = 0; //no format, default + uint32_t format = 0; // No format, default. if (set.uniform_info.size()) { - //has data, needs an actual format; + // Has data, needs an actual format. UniformSetFormat usformat; usformat.uniform_info = set.uniform_info; RBMap<UniformSetFormat, uint32_t>::Element *E = uniform_set_format_cache.find(usformat); @@ -5506,7 +5506,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ } if (success) { - //create pipeline layout + // Create pipeline layout. VkPipelineLayoutCreateInfo pipeline_layout_create_info; pipeline_layout_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipeline_layout_create_info.pNext = nullptr; @@ -5545,7 +5545,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_ } if (!success) { - //clean up if failed + // Clean up if failed. for (int i = 0; i < shader.pipeline_stages.size(); i++) { vkDestroyShaderModule(device, shader.pipeline_stages[i].module, nullptr); } @@ -5668,7 +5668,7 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF ERR_FAIL_V_MSG(RID(), "Unable to create buffer view, error " + itos(res) + "."); } - //allocate the view + // Allocate the view. RID id = texture_buffer_owner.make_rid(texture_buffer); #ifdef DEV_ENABLED set_resource_name(id, "RID:" + itos(id.get_id())); @@ -5691,17 +5691,17 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a } if (!pool) { - //create a new one + // Create a new one. pool = memnew(DescriptorPool); pool->usage = 0; VkDescriptorPoolCreateInfo descriptor_pool_create_info; descriptor_pool_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; descriptor_pool_create_info.pNext = nullptr; - descriptor_pool_create_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; // can't think how somebody may NOT need this flag.. + descriptor_pool_create_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; // Can't think how somebody may NOT need this flag. descriptor_pool_create_info.maxSets = max_descriptors_per_pool; Vector<VkDescriptorPoolSize> sizes; - //here comes more vulkan API strangeness + // Here comes more vulkan API strangeness. if (p_key.uniform_type[UNIFORM_TYPE_SAMPLER]) { VkDescriptorPoolSize s; @@ -5801,7 +5801,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, ERR_FAIL_COND_V_MSG(p_shader_set >= (uint32_t)shader->sets.size() || shader->sets[p_shader_set].uniform_info.size() == 0, RID(), "Desired set (" + itos(p_shader_set) + ") not used by shader."); - //see that all sets in shader are satisfied + // See that all sets in shader are satisfied. const Shader::Set &set = shader->sets[p_shader_set]; @@ -5814,11 +5814,11 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, Vector<VkWriteDescriptorSet> writes; DescriptorPoolKey pool_key; - //to keep them alive until update call + // To keep them alive until update call. List<Vector<VkDescriptorBufferInfo>> buffer_infos; List<Vector<VkBufferView>> buffer_views; List<Vector<VkDescriptorImageInfo>> image_infos; - //used for verification to make sure a uniform set does not use a framebuffer bound texture + // Used for verification to make sure a uniform set does not use a framebuffer bound texture. LocalVector<UniformSet::AttachableTexture> attachable_textures; Vector<Texture *> mutable_sampled_textures; Vector<Texture *> mutable_storage_textures; @@ -5839,14 +5839,14 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, ERR_FAIL_COND_V_MSG(uniform.uniform_type != set_uniform.type, RID(), "Mismatch uniform type for binding (" + itos(set_uniform.binding) + "), set (" + itos(p_shader_set) + "). Expected '" + shader_uniform_names[set_uniform.type] + "', supplied: '" + shader_uniform_names[uniform.uniform_type] + "'."); - VkWriteDescriptorSet write; //common header + VkWriteDescriptorSet write; // Common header. write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; write.pNext = nullptr; - write.dstSet = VK_NULL_HANDLE; //will assign afterwards when everything is valid + write.dstSet = VK_NULL_HANDLE; // Will assign afterwards when everything is valid. write.dstBinding = set_uniform.binding; write.dstArrayElement = 0; write.descriptorCount = 0; - write.descriptorType = VK_DESCRIPTOR_TYPE_MAX_ENUM; //Invalid value. + write.descriptorType = VK_DESCRIPTOR_TYPE_MAX_ENUM; // Invalid value. write.pImageInfo = nullptr; write.pBufferInfo = nullptr; write.pTexelBufferView = nullptr; @@ -5919,12 +5919,12 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, } if (texture->usage_flags & TEXTURE_USAGE_STORAGE_BIT) { - //can also be used as storage, add to mutable sampled + // Can also be used as storage, add to mutable sampled. mutable_sampled_textures.push_back(texture); } if (texture->owner.is_valid()) { texture = texture_owner.get_or_null(texture->owner); - ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen + ERR_FAIL_COND_V(!texture, RID()); // Bug, should never happen. } img_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -5972,13 +5972,13 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, } if (texture->usage_flags & TEXTURE_USAGE_STORAGE_BIT) { - //can also be used as storage, add to mutable sampled + // Can also be used as storage, add to mutable sampled. mutable_sampled_textures.push_back(texture); } if (texture->owner.is_valid()) { texture = texture_owner.get_or_null(texture->owner); - ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen + ERR_FAIL_COND_V(!texture, RID()); // Bug, should never happen. } img_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -6020,13 +6020,13 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, img_info.imageView = texture->view; if (texture->usage_flags & TEXTURE_USAGE_SAMPLING_BIT) { - //can also be used as storage, add to mutable sampled + // Can also be used as storage, add to mutable sampled. mutable_storage_textures.push_back(texture); } if (texture->owner.is_valid()) { texture = texture_owner.get_or_null(texture->owner); - ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen + ERR_FAIL_COND_V(!texture, RID()); // Bug, should never happen. } img_info.imageLayout = VK_IMAGE_LAYOUT_GENERAL; @@ -6116,7 +6116,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, type_size = uniform.get_id_count() / 2; } break; case UNIFORM_TYPE_IMAGE_BUFFER: { - //todo + // Todo. } break; case UNIFORM_TYPE_UNIFORM_BUFFER: { @@ -6152,7 +6152,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, } ERR_FAIL_COND_V_MSG(!buffer, RID(), "Storage buffer supplied (binding: " + itos(uniform.binding) + ") is invalid."); - //if 0, then it's sized on link time + // If 0, then it's sized on link time. ERR_FAIL_COND_V_MSG(set_uniform.length > 0 && buffer->size != (uint32_t)set_uniform.length, RID(), "Storage buffer supplied (binding: " + itos(uniform.binding) + ") size (" + itos(buffer->size) + " does not match size of shader uniform: (" + itos(set_uniform.length) + ")."); @@ -6191,7 +6191,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, if (texture->owner.is_valid()) { texture = texture_owner.get_or_null(texture->owner); - ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen + ERR_FAIL_COND_V(!texture, RID()); // Bug, should never happen. } img_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -6219,7 +6219,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, pool_key.uniform_type[set_uniform.type] += type_size; } - //need a descriptor pool + // Need a descriptor pool. DescriptorPool *pool = _descriptor_pool_allocate(pool_key); ERR_FAIL_COND_V(!pool, RID()); @@ -6236,7 +6236,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, VkResult res = vkAllocateDescriptorSets(device, &descriptor_set_allocate_info, &descriptor_set); if (res) { - _descriptor_pool_free(pool_key, pool); // meh + _descriptor_pool_free(pool_key, pool); // Meh. ERR_FAIL_V_MSG(RID(), "Cannot allocate descriptor sets, error " + itos(res) + "."); } @@ -6255,7 +6255,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, #ifdef DEV_ENABLED set_resource_name(id, "RID:" + itos(id.get_id())); #endif - //add dependencies + // Add dependencies. _add_dependency(id, p_shader); for (uint32_t i = 0; i < uniform_count; i++) { const Uniform &uniform = uniforms[i]; @@ -6265,7 +6265,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, } } - //write the contents + // Write the contents. if (writes.size()) { for (int i = 0; i < writes.size(); i++) { writes.write[i].dstSet = descriptor_set; @@ -6298,7 +6298,7 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint VkPipelineStageFlags dst_stage_mask = 0; VkAccessFlags dst_access = 0; if (p_post_barrier & BARRIER_MASK_TRANSFER) { - // Protect subsequent updates... + // Protect subsequent updates. dst_stage_mask = VK_PIPELINE_STAGE_TRANSFER_BIT; dst_access = VK_ACCESS_TRANSFER_WRITE_BIT; } @@ -6310,7 +6310,7 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint ERR_FAIL_COND_V_MSG(p_offset + p_size > buffer->size, ERR_INVALID_PARAMETER, "Attempted to write buffer (" + itos((p_offset + p_size) - buffer->size) + " bytes) past the end."); - // no barrier should be needed here + // No barrier should be needed here. // _buffer_memory_barrier(buffer->buffer, p_offset, p_size, dst_stage_mask, VK_PIPELINE_STAGE_TRANSFER_BIT, dst_access, VK_ACCESS_TRANSFER_WRITE_BIT, true); Error err = _buffer_update(buffer, p_offset, (uint8_t *)p_data, p_size, p_post_barrier); @@ -6346,7 +6346,7 @@ Error RenderingDeviceVulkan::buffer_clear(RID p_buffer, uint32_t p_offset, uint3 VkPipelineStageFlags dst_stage_mask = 0; VkAccessFlags dst_access = 0; if (p_post_barrier & BARRIER_MASK_TRANSFER) { - // Protect subsequent updates... + // Protect subsequent updates. dst_stage_mask = VK_PIPELINE_STAGE_TRANSFER_BIT; dst_access = VK_ACCESS_TRANSFER_WRITE_BIT; } @@ -6359,7 +6359,7 @@ Error RenderingDeviceVulkan::buffer_clear(RID p_buffer, uint32_t p_offset, uint3 ERR_FAIL_COND_V_MSG(p_offset + p_size > buffer->size, ERR_INVALID_PARAMETER, "Attempted to write buffer (" + itos((p_offset + p_size) - buffer->size) + " bytes) past the end."); - // should not be needed + // Should not be needed. // _buffer_memory_barrier(buffer->buffer, p_offset, p_size, dst_stage_mask, VK_PIPELINE_STAGE_TRANSFER_BIT, dst_access, VK_ACCESS_TRANSFER_WRITE_BIT, p_post_barrier); vkCmdFillBuffer(frames[frame].draw_command_buffer, buffer->buffer, p_offset, p_size, 0); @@ -6380,10 +6380,10 @@ Error RenderingDeviceVulkan::buffer_clear(RID p_buffer, uint32_t p_offset, uint3 Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { _THREAD_SAFE_METHOD_ - // It could be this buffer was just created + // It could be this buffer was just created. VkPipelineShaderStageCreateFlags src_stage_mask = VK_PIPELINE_STAGE_TRANSFER_BIT; VkAccessFlags src_access_mask = VK_ACCESS_TRANSFER_WRITE_BIT; - // Get the vulkan buffer and the potential stage/access possible + // Get the vulkan buffer and the potential stage/access possible. Buffer *buffer = _get_buffer_from_owner(p_buffer, src_stage_mask, src_access_mask, BARRIER_MASK_ALL); if (!buffer) { ERR_FAIL_V_MSG(Vector<uint8_t>(), "Buffer is either invalid or this type of buffer can't be retrieved. Only Index and Vertex buffers allow retrieving."); @@ -6400,8 +6400,8 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { region.srcOffset = 0; region.dstOffset = 0; region.size = buffer->size; - vkCmdCopyBuffer(command_buffer, buffer->buffer, tmp_buffer.buffer, 1, ®ion); //dst buffer is in CPU, but I wonder if src buffer needs a barrier for this.. - //flush everything so memory can be safely mapped + vkCmdCopyBuffer(command_buffer, buffer->buffer, tmp_buffer.buffer, 1, ®ion); // Dst buffer is in CPU, but I wonder if src buffer needs a barrier for this. + // Flush everything so memory can be safely mapped. _flush(true); void *buffer_mem; @@ -6429,7 +6429,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass, const Vector<PipelineSpecializationConstant> &p_specialization_constants) { _THREAD_SAFE_METHOD_ - //needs a shader + // Needs a shader. Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND_V(!shader, RID()); @@ -6437,13 +6437,13 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma "Compute shaders can't be used in render pipelines"); if (p_framebuffer_format == INVALID_ID) { - //if nothing provided, use an empty one (no attachments) + // If nothing provided, use an empty one (no attachments). p_framebuffer_format = framebuffer_format_create(Vector<AttachmentFormat>()); } ERR_FAIL_COND_V(!framebuffer_formats.has(p_framebuffer_format), RID()); const FramebufferFormat &fb_format = framebuffer_formats[p_framebuffer_format]; - { //validate shader vs framebuffer + { // Validate shader vs framebuffer. ERR_FAIL_COND_V_MSG(p_for_render_pass >= uint32_t(fb_format.E->key().passes.size()), RID(), "Render pass requested for pipeline creation (" + itos(p_for_render_pass) + ") is out of bounds"); const FramebufferPass &pass = fb_format.E->key().passes[p_for_render_pass]; @@ -6456,17 +6456,17 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma ERR_FAIL_COND_V_MSG(shader->fragment_output_mask != output_mask, RID(), "Mismatch fragment shader output mask (" + itos(shader->fragment_output_mask) + ") and framebuffer color output mask (" + itos(output_mask) + ") when binding both in render pipeline."); } - //vertex + // Vertex. VkPipelineVertexInputStateCreateInfo pipeline_vertex_input_state_create_info; if (p_vertex_format != INVALID_ID) { - //uses vertices, else it does not + // Uses vertices, else it does not. ERR_FAIL_COND_V(!vertex_formats.has(p_vertex_format), RID()); const VertexDescriptionCache &vd = vertex_formats[p_vertex_format]; pipeline_vertex_input_state_create_info = vd.create_info; - //validate with inputs + // Validate with inputs. for (uint32_t i = 0; i < 32; i++) { if (!(shader->vertex_input_mask & (1UL << i))) { continue; @@ -6483,7 +6483,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma } } else { - //does not use vertices + // Does not use vertices. pipeline_vertex_input_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; pipeline_vertex_input_state_create_info.pNext = nullptr; pipeline_vertex_input_state_create_info.flags = 0; @@ -6495,7 +6495,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma ERR_FAIL_COND_V_MSG(shader->vertex_input_mask != 0, RID(), "Shader contains vertex inputs, but no vertex input description was provided for pipeline creation."); } - //input assembly + // Input assembly. ERR_FAIL_INDEX_V(p_render_primitive, RENDER_PRIMITIVE_MAX, RID()); @@ -6521,7 +6521,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma input_assembly_create_info.topology = topology_list[p_render_primitive]; input_assembly_create_info.primitiveRestartEnable = (p_render_primitive == RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_RESTART_INDEX); - //tessellation + // Tessellation. VkPipelineTessellationStateCreateInfo tessellation_create_info; tessellation_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; tessellation_create_info.pNext = nullptr; @@ -6533,12 +6533,12 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma viewport_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewport_state_create_info.pNext = nullptr; viewport_state_create_info.flags = 0; - viewport_state_create_info.viewportCount = 1; //if VR extensions are supported at some point, this will have to be customizable in the framebuffer format + viewport_state_create_info.viewportCount = 1; // If VR extensions are supported at some point, this will have to be customizable in the framebuffer format. viewport_state_create_info.pViewports = nullptr; viewport_state_create_info.scissorCount = 1; viewport_state_create_info.pScissors = nullptr; - //rasterization + // Rasterization. VkPipelineRasterizationStateCreateInfo rasterization_state_create_info; rasterization_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterization_state_create_info.pNext = nullptr; @@ -6561,7 +6561,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma rasterization_state_create_info.depthBiasSlopeFactor = p_rasterization_state.depth_bias_slope_factor; rasterization_state_create_info.lineWidth = p_rasterization_state.line_width; - //multisample + // Multisample. VkPipelineMultisampleStateCreateInfo multisample_state_create_info; multisample_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisample_state_create_info.pNext = nullptr; @@ -6572,7 +6572,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma multisample_state_create_info.minSampleShading = p_multisample_state.min_sample_shading; Vector<VkSampleMask> sample_mask; if (p_multisample_state.sample_mask.size()) { - //use sample mask + // Use sample mask. const int rasterization_sample_mask_expected_size[TEXTURE_SAMPLES_MAX] = { 1, 2, 4, 8, 16, 32, 64 }; @@ -6590,7 +6590,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma multisample_state_create_info.alphaToCoverageEnable = p_multisample_state.enable_alpha_to_coverage; multisample_state_create_info.alphaToOneEnable = p_multisample_state.enable_alpha_to_one; - //depth stencil + // Depth stencil. VkPipelineDepthStencilStateCreateInfo depth_stencil_state_create_info; depth_stencil_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; @@ -6630,7 +6630,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma depth_stencil_state_create_info.minDepthBounds = p_depth_stencil_state.depth_range_min; depth_stencil_state_create_info.maxDepthBounds = p_depth_stencil_state.depth_range_max; - //blend state + // Blend state. VkPipelineColorBlendStateCreateInfo color_blend_state_create_info; color_blend_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; color_blend_state_create_info.pNext = nullptr; @@ -6701,15 +6701,15 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma color_blend_state_create_info.blendConstants[2] = p_blend_state.blend_constant.b; color_blend_state_create_info.blendConstants[3] = p_blend_state.blend_constant.a; - //dynamic state + // Dynamic state. VkPipelineDynamicStateCreateInfo dynamic_state_create_info; dynamic_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; dynamic_state_create_info.pNext = nullptr; dynamic_state_create_info.flags = 0; - Vector<VkDynamicState> dynamic_states; //vulkan is weird.. + Vector<VkDynamicState> dynamic_states; // Vulkan is weird. - dynamic_states.push_back(VK_DYNAMIC_STATE_VIEWPORT); //viewport and scissor are always dynamic + dynamic_states.push_back(VK_DYNAMIC_STATE_VIEWPORT); // Viewport and scissor are always dynamic. dynamic_states.push_back(VK_DYNAMIC_STATE_SCISSOR); if (p_dynamic_state_flags & DYNAMIC_STATE_LINE_WIDTH) { @@ -6748,19 +6748,19 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma VkPipelineFragmentShadingRateStateCreateInfoKHR vrs_create_info; if (context->get_vrs_capabilities().attachment_vrs_supported) { // If VRS is used, this defines how the different VRS types are combined. - // combinerOps[0] decides how we use the output of pipeline and primitive (drawcall) VRS - // combinerOps[1] decides how we use the output of combinerOps[0] and our attachment VRS + // combinerOps[0] decides how we use the output of pipeline and primitive (drawcall) VRS. + // combinerOps[1] decides how we use the output of combinerOps[0] and our attachment VRS. vrs_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR; vrs_create_info.pNext = nullptr; vrs_create_info.fragmentSize = { 4, 4 }; - vrs_create_info.combinerOps[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; // We don't use pipeline/primitive VRS so this really doesn't matter - vrs_create_info.combinerOps[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR; // always use the outcome of attachment VRS if enabled + vrs_create_info.combinerOps[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; // We don't use pipeline/primitive VRS so this really doesn't matter. + vrs_create_info.combinerOps[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR; // Always use the outcome of attachment VRS if enabled. graphics_pipeline_nextptr = &vrs_create_info; } - //finally, pipeline create info + // Finally, pipeline create info. VkGraphicsPipelineCreateInfo graphics_pipeline_create_info; graphics_pipeline_create_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; @@ -6778,9 +6778,9 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma specialization_info.resize(pipeline_stages.size()); specialization_map_entries.resize(pipeline_stages.size()); for (int i = 0; i < shader->specialization_constants.size(); i++) { - //see if overridden + // See if overridden. const Shader::SpecializationConstant &sc = shader->specialization_constants[i]; - data_ptr[i] = sc.constant.int_value; //just copy the 32 bits + data_ptr[i] = sc.constant.int_value; // Just copy the 32 bits. for (int j = 0; j < p_specialization_constants.size(); j++) { const PipelineSpecializationConstant &psc = p_specialization_constants[j]; @@ -6875,12 +6875,12 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma }; pipeline.validation.primitive_minimum = primitive_minimum[p_render_primitive]; #endif - //create ID to associate with this pipeline + // Create ID to associate with this pipeline. RID id = render_pipeline_owner.make_rid(pipeline); #ifdef DEV_ENABLED set_resource_name(id, "RID:" + itos(id.get_id())); #endif - //now add all the dependencies + // Now add all the dependencies. _add_dependency(id, p_shader); return id; } @@ -6897,14 +6897,14 @@ bool RenderingDeviceVulkan::render_pipeline_is_valid(RID p_pipeline) { RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader, const Vector<PipelineSpecializationConstant> &p_specialization_constants) { _THREAD_SAFE_METHOD_ - //needs a shader + // Needs a shader. Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND_V(!shader, RID()); ERR_FAIL_COND_V_MSG(!shader->is_compute, RID(), "Non-compute shaders can't be used in compute pipelines"); - //finally, pipeline create info + // Finally, pipeline create info. VkComputePipelineCreateInfo compute_pipeline_create_info; compute_pipeline_create_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; @@ -6924,9 +6924,9 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader, const Vector<Pi specialization_constant_data.resize(shader->specialization_constants.size()); uint32_t *data_ptr = specialization_constant_data.ptrw(); for (int i = 0; i < shader->specialization_constants.size(); i++) { - //see if overridden + // See if overridden. const Shader::SpecializationConstant &sc = shader->specialization_constants[i]; - data_ptr[i] = sc.constant.int_value; //just copy the 32 bits + data_ptr[i] = sc.constant.int_value; // Just copy the 32 bits. for (int j = 0; j < p_specialization_constants.size(); j++) { const PipelineSpecializationConstant &psc = p_specialization_constants[j]; @@ -6967,12 +6967,12 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader, const Vector<Pi pipeline.local_group_size[1] = shader->compute_local_size[1]; pipeline.local_group_size[2] = shader->compute_local_size[2]; - //create ID to associate with this pipeline + // Create ID to associate with this pipeline. RID id = compute_pipeline_owner.make_rid(pipeline); #ifdef DEV_ENABLED set_resource_name(id, "RID:" + itos(id.get_id())); #endif - //now add all the dependencies + // Now add all the dependencies. _add_dependency(id, p_shader); return id; } @@ -7002,7 +7002,7 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuff _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V_MSG(local_device.is_valid(), INVALID_ID, "Local devices have no screen"); - //very hacky, but not used often per frame so I guess ok + // Very hacky, but not used often per frame so I guess ok. VkFormat vkformat = context->get_screen_format(); DataFormat format = DATA_FORMAT_MAX; for (int i = 0; i < DATA_FORMAT_MAX; i++) { @@ -7104,7 +7104,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu vk.view_count = p_framebuffer->view_count; if (!p_framebuffer->framebuffers.has(vk)) { - //need to create this version + // Need to create this version. Framebuffer::Version version; version.render_pass = _render_pass_create(framebuffer_formats[p_framebuffer->format_id].E->key().attachments, framebuffer_formats[p_framebuffer->format_id].E->key().passes, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, p_framebuffer->view_count); @@ -7180,7 +7180,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff } if (color_index < p_clear_colors.size() && texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) { - ERR_FAIL_INDEX_V(color_index, p_clear_colors.size(), ERR_BUG); //a bug + ERR_FAIL_INDEX_V(color_index, p_clear_colors.size(), ERR_BUG); // A bug. Color clear_color = p_clear_colors[color_index]; clear_value.color.float32[0] = clear_color.r; clear_value.color.float32[1] = clear_color.g; @@ -7211,7 +7211,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff ERR_CONTINUE_MSG(!(texture->usage_flags & TEXTURE_USAGE_STORAGE_BIT), "Supplied storage texture " + itos(i) + " for draw list is not set to be used for storage."); if (texture->usage_flags & TEXTURE_USAGE_SAMPLING_BIT) { - //must change layout to general + // Must change layout to general. VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; image_memory_barrier.pNext = nullptr; @@ -7239,7 +7239,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff vkCmdBeginRenderPass(command_buffer, &render_pass_begin, subpass_contents); - //mark textures as bound + // Mark textures as bound. draw_list_bound_textures.clear(); draw_list_unbind_color_textures = p_final_color_action != FINAL_ACTION_CONTINUE; draw_list_unbind_depth_textures = p_final_depth_action != FINAL_ACTION_CONTINUE; @@ -7316,7 +7316,7 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu bool needs_clear_color = false; bool needs_clear_depth = false; - if (p_region != Rect2() && p_region != Rect2(Vector2(), viewport_size)) { //check custom region + if (p_region != Rect2() && p_region != Rect2(Vector2(), viewport_size)) { // Check custom region. Rect2i viewport(viewport_offset, viewport_size); Rect2i regioni = p_region; if (!(regioni.position.x >= viewport.position.x) && (regioni.position.y >= viewport.position.y) && @@ -7345,13 +7345,13 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu } } - if (p_initial_color_action == INITIAL_ACTION_CLEAR || needs_clear_color) { //check clear values + if (p_initial_color_action == INITIAL_ACTION_CLEAR || needs_clear_color) { // Check clear values. int color_count = 0; for (int i = 0; i < framebuffer->texture_ids.size(); i++) { Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]); // We only check for our VRS usage bit if this is not the first texture id. // If it is the first we're likely populating our VRS texture. - // Bit dirty but.. + // Bit dirty but... if (!texture || (!(texture->usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) && !(i != 0 && texture->usage_flags & TEXTURE_USAGE_VRS_ATTACHMENT_BIT))) { color_count++; } @@ -7423,7 +7423,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p bool needs_clear_color = false; bool needs_clear_depth = false; - if (p_region != Rect2() && p_region != Rect2(Vector2(), viewport_size)) { //check custom region + if (p_region != Rect2() && p_region != Rect2(Vector2(), viewport_size)) { // Check custom region. Rect2i viewport(viewport_offset, viewport_size); Rect2i regioni = p_region; if (!(regioni.position.x >= viewport.position.x) && (regioni.position.y >= viewport.position.y) && @@ -7445,7 +7445,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p } } - if (p_initial_color_action == INITIAL_ACTION_CLEAR || needs_clear_color) { //check clear values + if (p_initial_color_action == INITIAL_ACTION_CLEAR || needs_clear_color) { // Check clear values. int color_count = 0; for (int i = 0; i < framebuffer->texture_ids.size(); i++) { @@ -7531,7 +7531,7 @@ RenderingDeviceVulkan::DrawList *RenderingDeviceVulkan::_get_draw_list_ptr(DrawL return nullptr; } - uint64_t index = p_id & ((DrawListID(1) << DrawListID(ID_BASE_SHIFT)) - 1); //mask + uint64_t index = p_id & ((DrawListID(1) << DrawListID(ID_BASE_SHIFT)) - 1); // Mask. if (index >= draw_list_count) { return nullptr; @@ -7557,7 +7557,7 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI #endif if (p_render_pipeline == dl->state.pipeline) { - return; //redundant state, return. + return; // Redundant state, return. } dl->state.pipeline = p_render_pipeline; @@ -7566,17 +7566,17 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI vkCmdBindPipeline(dl->command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->pipeline); if (dl->state.pipeline_shader != pipeline->shader) { - // shader changed, so descriptor sets may become incompatible. + // Shader changed, so descriptor sets may become incompatible. - //go through ALL sets, and unbind them (and all those above) if the format is different + // Go through ALL sets, and unbind them (and all those above) if the format is different. - uint32_t pcount = pipeline->set_formats.size(); //formats count in this pipeline + uint32_t pcount = pipeline->set_formats.size(); // Formats count in this pipeline. dl->state.set_count = MAX(dl->state.set_count, pcount); - const uint32_t *pformats = pipeline->set_formats.ptr(); //pipeline set formats + const uint32_t *pformats = pipeline->set_formats.ptr(); // Pipeline set formats. - bool sets_valid = true; //once invalid, all above become invalid + bool sets_valid = true; // Once invalid, all above become invalid. for (uint32_t i = 0; i < pcount; i++) { - //if a part of the format is different, invalidate it (and the rest) + // If a part of the format is different, invalidate it (and the rest). if (!sets_valid || dl->state.sets[i].pipeline_expected_format != pformats[i]) { dl->state.sets[i].bound = false; dl->state.sets[i].pipeline_expected_format = pformats[i]; @@ -7585,11 +7585,11 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI } for (uint32_t i = pcount; i < dl->state.set_count; i++) { - //unbind the ones above (not used) if exist + // Unbind the ones above (not used) if exist. dl->state.sets[i].bound = false; } - dl->state.set_count = pcount; //update set count + dl->state.set_count = pcount; // Update set count. if (pipeline->push_constant_size) { dl->state.pipeline_push_constant_stages = pipeline->push_constant_stages; @@ -7602,7 +7602,7 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI } #ifdef DEBUG_ENABLED - //update render pass pipeline info + // Update render pass pipeline info. dl->validation.pipeline_active = true; dl->validation.pipeline_dynamic_state = pipeline->validation.dynamic_state; dl->validation.pipeline_vertex_format = pipeline->validation.vertex_format; @@ -7632,8 +7632,8 @@ void RenderingDeviceVulkan::draw_list_bind_uniform_set(DrawListID p_list, RID p_ dl->state.set_count = p_index; } - dl->state.sets[p_index].descriptor_set = uniform_set->descriptor_set; //update set pointer - dl->state.sets[p_index].bound = false; //needs rebind + dl->state.sets[p_index].descriptor_set = uniform_set->descriptor_set; // Update set pointer. + dl->state.sets[p_index].bound = false; // Needs rebind. dl->state.sets[p_index].uniform_set_format = uniform_set->format; dl->state.sets[p_index].uniform_set = p_uniform_set; @@ -7651,7 +7651,7 @@ void RenderingDeviceVulkan::draw_list_bind_uniform_set(DrawListID p_list, RID p_ } #ifdef DEBUG_ENABLED - { //validate that textures bound are not attached as framebuffer bindings + { // Validate that textures bound are not attached as framebuffer bindings. uint32_t attachable_count = uniform_set->attachable_textures.size(); const UniformSet::AttachableTexture *attachable_ptr = uniform_set->attachable_textures.ptr(); uint32_t bound_count = draw_list_bound_textures.size(); @@ -7677,7 +7677,7 @@ void RenderingDeviceVulkan::draw_list_bind_vertex_array(DrawListID p_list, RID p ERR_FAIL_COND(!vertex_array); if (dl->state.vertex_array == p_vertex_array) { - return; //already set + return; // Already set. } dl->state.vertex_array = p_vertex_array; @@ -7701,7 +7701,7 @@ void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_ ERR_FAIL_COND(!index_array); if (dl->state.index_array == p_index_array) { - return; //already set + return; // Already set. } dl->state.index_array = p_index_array; @@ -7753,30 +7753,30 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices ERR_FAIL_COND_MSG(!dl->validation.pipeline_active, "No render pipeline was set before attempting to draw."); if (dl->validation.pipeline_vertex_format != INVALID_ID) { - //pipeline uses vertices, validate format + // Pipeline uses vertices, validate format. ERR_FAIL_COND_MSG(dl->validation.vertex_format == INVALID_ID, "No vertex array was bound, and render pipeline expects vertices."); - //make sure format is right + // Make sure format is right. ERR_FAIL_COND_MSG(dl->validation.pipeline_vertex_format != dl->validation.vertex_format, "The vertex format used to create the pipeline does not match the vertex format bound."); - //make sure number of instances is valid + // Make sure number of instances is valid. ERR_FAIL_COND_MSG(p_instances > dl->validation.vertex_max_instances_allowed, "Number of instances requested (" + itos(p_instances) + " is larger than the maximum number supported by the bound vertex array (" + itos(dl->validation.vertex_max_instances_allowed) + ")."); } if (dl->validation.pipeline_push_constant_size > 0) { - //using push constants, check that they were supplied + // Using push constants, check that they were supplied. ERR_FAIL_COND_MSG(!dl->validation.pipeline_push_constant_supplied, "The shader in this pipeline requires a push constant to be set before drawing, but it's not present."); } #endif - //Bind descriptor sets + // Bind descriptor sets. for (uint32_t i = 0; i < dl->state.set_count; i++) { if (dl->state.sets[i].pipeline_expected_format == 0) { - continue; //nothing expected by this pipeline + continue; // Nothing expected by this pipeline. } #ifdef DEBUG_ENABLED if (dl->state.sets[i].pipeline_expected_format != dl->state.sets[i].uniform_set_format) { @@ -7791,7 +7791,7 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices } #endif if (!dl->state.sets[i].bound) { - //All good, see if this requires re-binding + // All good, see if this requires re-binding. vkCmdBindDescriptorSets(dl->command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, dl->state.pipeline_layout, i, 1, &dl->state.sets[i].descriptor_set, 0, nullptr); dl->state.sets[i].bound = true; } @@ -7806,7 +7806,7 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices "Draw command requested indices, but no index buffer was set."); if (dl->validation.pipeline_vertex_format != INVALID_ID) { - //uses vertices, do some vertex validations + // Uses vertices, do some vertex validations. ERR_FAIL_COND_MSG(dl->validation.vertex_array_size < dl->validation.index_array_max_index, "Index array references (max index: " + itos(dl->validation.index_array_max_index) + ") indices beyond the vertex array size (" + itos(dl->validation.vertex_array_size) + ")."); } @@ -7932,7 +7932,7 @@ Error RenderingDeviceVulkan::draw_list_switch_to_next_pass_split(uint32_t p_spli } Error RenderingDeviceVulkan::_draw_list_allocate(const Rect2i &p_viewport, uint32_t p_splits, uint32_t p_subpass) { - // Lock while draw_list is active + // Lock while draw_list is active. _THREAD_SAFE_LOCK_ if (p_splits == 0) { @@ -7959,7 +7959,7 @@ Error RenderingDeviceVulkan::_draw_list_allocate(const Rect2i &p_viewport, uint3 VkCommandBuffer command_buffer; VkCommandBufferAllocateInfo cmdbuf; - //no command buffer exists, create it. + // No command buffer exists, create it. cmdbuf.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; cmdbuf.pNext = nullptr; cmdbuf.commandPool = split_draw_list_allocators[i].command_pool; @@ -7978,7 +7978,7 @@ Error RenderingDeviceVulkan::_draw_list_allocate(const Rect2i &p_viewport, uint3 draw_list_split = true; for (uint32_t i = 0; i < p_splits; i++) { - //take a command buffer and initialize it + // Take a command buffer and initialize it. VkCommandBuffer command_buffer = split_draw_list_allocators[i].command_buffers[frame]; VkCommandBufferInheritanceInfo inheritance_info; @@ -7988,7 +7988,7 @@ Error RenderingDeviceVulkan::_draw_list_allocate(const Rect2i &p_viewport, uint3 inheritance_info.subpass = p_subpass; inheritance_info.framebuffer = draw_list_vkframebuffer; inheritance_info.occlusionQueryEnable = false; - inheritance_info.queryFlags = 0; //? + inheritance_info.queryFlags = 0; // ? inheritance_info.pipelineStatistics = 0; VkCommandBufferBeginInfo cmdbuf_begin; @@ -8021,7 +8021,7 @@ Error RenderingDeviceVulkan::_draw_list_allocate(const Rect2i &p_viewport, uint3 void RenderingDeviceVulkan::_draw_list_free(Rect2i *r_last_viewport) { if (draw_list_split) { - //send all command buffers + // Send all command buffers. VkCommandBuffer *command_buffers = (VkCommandBuffer *)alloca(sizeof(VkCommandBuffer) * draw_list_count); for (uint32_t i = 0; i < draw_list_count; i++) { vkEndCommandBuffer(draw_list[i].command_buffer); @@ -8041,12 +8041,12 @@ void RenderingDeviceVulkan::_draw_list_free(Rect2i *r_last_viewport) { if (r_last_viewport) { *r_last_viewport = draw_list->viewport; } - //just end the list + // Just end the list. memdelete(draw_list); draw_list = nullptr; } - // draw_list is no longer active + // Draw_list is no longer active. _THREAD_SAFE_UNLOCK_ } @@ -8061,7 +8061,7 @@ void RenderingDeviceVulkan::draw_list_end(uint32_t p_post_barrier) { for (int i = 0; i < draw_list_bound_textures.size(); i++) { Texture *texture = texture_owner.get_or_null(draw_list_bound_textures[i]); - ERR_CONTINUE(!texture); //wtf + ERR_CONTINUE(!texture); // Wtf. if (draw_list_unbind_color_textures && (texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT)) { texture->bound = false; } @@ -8133,8 +8133,8 @@ void RenderingDeviceVulkan::draw_list_end(uint32_t p_post_barrier) { draw_list_storage_textures.clear(); // To ensure proper synchronization, we must make sure rendering is done before: - // * Some buffer is copied - // * Another render pass happens (since we may be done) + // * Some buffer is copied. + // * Another render pass happens (since we may be done). VkMemoryBarrier mem_barrier; mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; @@ -8159,7 +8159,7 @@ RenderingDevice::ComputeListID RenderingDeviceVulkan::compute_list_begin(bool p_ ERR_FAIL_COND_V_MSG(!p_allow_draw_overlap && draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time."); ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time."); - // Lock while compute_list is active + // Lock while compute_list is active. _THREAD_SAFE_LOCK_ compute_list = memnew(ComputeList); @@ -8179,7 +8179,7 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l ERR_FAIL_COND(!pipeline); if (p_compute_pipeline == cl->state.pipeline) { - return; //redundant state, return. + return; // Redundant state, return. } cl->state.pipeline = p_compute_pipeline; @@ -8188,17 +8188,17 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l vkCmdBindPipeline(cl->command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->pipeline); if (cl->state.pipeline_shader != pipeline->shader) { - // shader changed, so descriptor sets may become incompatible. + // Shader changed, so descriptor sets may become incompatible. - //go through ALL sets, and unbind them (and all those above) if the format is different + // Go through ALL sets, and unbind them (and all those above) if the format is different. - uint32_t pcount = pipeline->set_formats.size(); //formats count in this pipeline + uint32_t pcount = pipeline->set_formats.size(); // Formats count in this pipeline. cl->state.set_count = MAX(cl->state.set_count, pcount); - const uint32_t *pformats = pipeline->set_formats.ptr(); //pipeline set formats + const uint32_t *pformats = pipeline->set_formats.ptr(); // Pipeline set formats. - bool sets_valid = true; //once invalid, all above become invalid + bool sets_valid = true; // Once invalid, all above become invalid. for (uint32_t i = 0; i < pcount; i++) { - //if a part of the format is different, invalidate it (and the rest) + // If a part of the format is different, invalidate it (and the rest). if (!sets_valid || cl->state.sets[i].pipeline_expected_format != pformats[i]) { cl->state.sets[i].bound = false; cl->state.sets[i].pipeline_expected_format = pformats[i]; @@ -8207,11 +8207,11 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l } for (uint32_t i = pcount; i < cl->state.set_count; i++) { - //unbind the ones above (not used) if exist + // Unbind the ones above (not used) if exist. cl->state.sets[i].bound = false; } - cl->state.set_count = pcount; //update set count + cl->state.set_count = pcount; // Update set count. if (pipeline->push_constant_size) { cl->state.pipeline_push_constant_stages = pipeline->push_constant_stages; @@ -8227,7 +8227,7 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l } #ifdef DEBUG_ENABLED - //update compute pass pipeline info + // Update compute pass pipeline info. cl->validation.pipeline_active = true; cl->validation.pipeline_push_constant_size = pipeline->push_constant_size; #endif @@ -8255,8 +8255,8 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, cl->state.set_count = p_index; } - cl->state.sets[p_index].descriptor_set = uniform_set->descriptor_set; //update set pointer - cl->state.sets[p_index].bound = false; //needs rebind + cl->state.sets[p_index].descriptor_set = uniform_set->descriptor_set; // Update set pointer. + cl->state.sets[p_index].bound = false; // Needs rebind. cl->state.sets[p_index].uniform_set_format = uniform_set->format; cl->state.sets[p_index].uniform_set = p_uniform_set; @@ -8359,7 +8359,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, textures_to_storage[i]->layout = VK_IMAGE_LAYOUT_GENERAL; - cl->state.textures_to_sampled_layout.insert(textures_to_storage[i]); //needs to go back to sampled layout afterwards + cl->state.textures_to_sampled_layout.insert(textures_to_storage[i]); // Needs to go back to sampled layout afterwards. } } @@ -8372,7 +8372,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, } #if 0 - { //validate that textures bound are not attached as framebuffer bindings + { // Validate that textures bound are not attached as framebuffer bindings. uint32_t attachable_count = uniform_set->attachable_textures.size(); const RID *attachable_ptr = uniform_set->attachable_textures.ptr(); uint32_t bound_count = draw_list_bound_textures.size(); @@ -8432,18 +8432,18 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t ERR_FAIL_COND_MSG(!cl->validation.pipeline_active, "No compute pipeline was set before attempting to draw."); if (cl->validation.pipeline_push_constant_size > 0) { - //using push constants, check that they were supplied + // Using push constants, check that they were supplied. ERR_FAIL_COND_MSG(!cl->validation.pipeline_push_constant_supplied, "The shader in this pipeline requires a push constant to be set before drawing, but it's not present."); } #endif - //Bind descriptor sets + // Bind descriptor sets. for (uint32_t i = 0; i < cl->state.set_count; i++) { if (cl->state.sets[i].pipeline_expected_format == 0) { - continue; //nothing expected by this pipeline + continue; // Nothing expected by this pipeline. } #ifdef DEBUG_ENABLED if (cl->state.sets[i].pipeline_expected_format != cl->state.sets[i].uniform_set_format) { @@ -8458,7 +8458,7 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t } #endif if (!cl->state.sets[i].bound) { - //All good, see if this requires re-binding + // All good, see if this requires re-binding. vkCmdBindDescriptorSets(cl->command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, cl->state.pipeline_layout, i, 1, &cl->state.sets[i].descriptor_set, 0, nullptr); cl->state.sets[i].bound = true; } @@ -8484,7 +8484,7 @@ void RenderingDeviceVulkan::compute_list_dispatch_threads(ComputeListID p_list, ERR_FAIL_COND_MSG(!cl->validation.pipeline_active, "No compute pipeline was set before attempting to draw."); if (cl->validation.pipeline_push_constant_size > 0) { - //using push constants, check that they were supplied + // Using push constants, check that they were supplied. ERR_FAIL_COND_MSG(!cl->validation.pipeline_push_constant_supplied, "The shader in this pipeline requires a push constant to be set before drawing, but it's not present."); } @@ -8515,18 +8515,18 @@ void RenderingDeviceVulkan::compute_list_dispatch_indirect(ComputeListID p_list, ERR_FAIL_COND_MSG(!cl->validation.pipeline_active, "No compute pipeline was set before attempting to draw."); if (cl->validation.pipeline_push_constant_size > 0) { - //using push constants, check that they were supplied + // Using push constants, check that they were supplied. ERR_FAIL_COND_MSG(!cl->validation.pipeline_push_constant_supplied, "The shader in this pipeline requires a push constant to be set before drawing, but it's not present."); } #endif - //Bind descriptor sets + // Bind descriptor sets. for (uint32_t i = 0; i < cl->state.set_count; i++) { if (cl->state.sets[i].pipeline_expected_format == 0) { - continue; //nothing expected by this pipeline + continue; // Nothing expected by this pipeline. } #ifdef DEBUG_ENABLED if (cl->state.sets[i].pipeline_expected_format != cl->state.sets[i].uniform_set_format) { @@ -8541,7 +8541,7 @@ void RenderingDeviceVulkan::compute_list_dispatch_indirect(ComputeListID p_list, } #endif if (!cl->state.sets[i].bound) { - //All good, see if this requires re-binding + // All good, see if this requires re-binding. vkCmdBindDescriptorSets(cl->command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, cl->state.pipeline_layout, i, 1, &cl->state.sets[i].descriptor_set, 0, nullptr); cl->state.sets[i].bound = true; } @@ -8635,7 +8635,7 @@ void RenderingDeviceVulkan::compute_list_end(uint32_t p_post_barrier) { memdelete(compute_list); compute_list = nullptr; - // compute_list is no longer active + // Compute_list is no longer active. _THREAD_SAFE_UNLOCK_ } @@ -8728,7 +8728,7 @@ void RenderingDeviceVulkan::draw_list_render_secondary_to_framebuffer(ID p_frame "Draw list index (" + itos(i) + ") is created with a framebuffer format incompatible with this render pass."); if (dl->validation.active) { - //needs to be closed, so close it. + // Needs to be closed, so close it. vkEndCommandBuffer(dl->command_buffer); dl->validation.active = false; } @@ -8745,7 +8745,15 @@ void RenderingDeviceVulkan::draw_list_render_secondary_to_framebuffer(ID p_frame #endif void RenderingDeviceVulkan::_free_internal(RID p_id) { - //push everything so it's disposed of next time this frame index is processed (means, it's safe to do it) +#ifdef DEV_ENABLED + String resource_name; + if (resource_names.has(p_id)) { + resource_name = resource_names[p_id]; + resource_names.erase(p_id); + } +#endif + + // Push everything so it's disposed of next time this frame index is processed (means, it's safe to do it). if (texture_owner.owns(p_id)) { Texture *texture = texture_owner.get_or_null(p_id); frames[frame].textures_to_dispose_of.push_back(*texture); @@ -8814,30 +8822,34 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) { frames[frame].compute_pipelines_to_dispose_of.push_back(*pipeline); compute_pipeline_owner.free(p_id); } else { +#ifdef DEV_ENABLED + ERR_PRINT("Attempted to free invalid ID: " + itos(p_id.get_id()) + " " + resource_name); +#else ERR_PRINT("Attempted to free invalid ID: " + itos(p_id.get_id())); +#endif } } void RenderingDeviceVulkan::free(RID p_id) { _THREAD_SAFE_METHOD_ - _free_dependencies(p_id); //recursively erase dependencies first, to avoid potential API problems + _free_dependencies(p_id); // Recursively erase dependencies first, to avoid potential API problems. _free_internal(p_id); } -// The full list of resources that can be named is in the VkObjectType enum +// The full list of resources that can be named is in the VkObjectType enum. // We just expose the resources that are owned and can be accessed easily. void RenderingDeviceVulkan::set_resource_name(RID p_id, const String p_name) { if (texture_owner.owns(p_id)) { Texture *texture = texture_owner.get_or_null(p_id); if (texture->owner.is_null()) { - // Don't set the source texture's name when calling on a texture view + // Don't set the source texture's name when calling on a texture view. context->set_object_name(VK_OBJECT_TYPE_IMAGE, uint64_t(texture->image), p_name); } context->set_object_name(VK_OBJECT_TYPE_IMAGE_VIEW, uint64_t(texture->view), p_name + " View"); } else if (framebuffer_owner.owns(p_id)) { //Framebuffer *framebuffer = framebuffer_owner.get_or_null(p_id); - // Not implemented for now as the relationship between Framebuffer and RenderPass is very complex + // Not implemented for now as the relationship between Framebuffer and RenderPass is very complex. } else if (sampler_owner.owns(p_id)) { VkSampler *sampler = sampler_owner.get_or_null(p_id); context->set_object_name(VK_OBJECT_TYPE_SAMPLER, uint64_t(*sampler), p_name); @@ -8876,7 +8888,11 @@ void RenderingDeviceVulkan::set_resource_name(RID p_id, const String p_name) { context->set_object_name(VK_OBJECT_TYPE_PIPELINE_LAYOUT, uint64_t(pipeline->pipeline_layout), p_name + " Layout"); } else { ERR_PRINT("Attempted to name invalid ID: " + itos(p_id.get_id())); + return; } +#ifdef DEV_ENABLED + resource_names[p_id] = p_name; +#endif } void RenderingDeviceVulkan::draw_command_begin_label(String p_label_name, const Color p_color) { @@ -8920,17 +8936,17 @@ void RenderingDeviceVulkan::_finalize_command_bufers() { ERR_PRINT("Found open compute list at the end of the frame, this should never happen (further compute will likely not work)."); } - { //complete the setup buffer (that needs to be processed before anything else) + { // Complete the setup buffer (that needs to be processed before anything else). vkEndCommandBuffer(frames[frame].setup_command_buffer); vkEndCommandBuffer(frames[frame].draw_command_buffer); } } void RenderingDeviceVulkan::_begin_frame() { - //erase pending resources + // Erase pending resources. _free_pending_resources(frame); - //create setup command buffer and set as the setup buffer + // Create setup command buffer and set as the setup buffer. { VkCommandBufferBeginInfo cmdbuf_begin; @@ -8949,13 +8965,13 @@ void RenderingDeviceVulkan::_begin_frame() { if (local_device.is_null()) { context->append_command_buffer(frames[frame].draw_command_buffer); - context->set_setup_buffer(frames[frame].setup_command_buffer); //append now so it's added before everything else + context->set_setup_buffer(frames[frame].setup_command_buffer); // Append now so it's added before everything else. } } - //advance current frame + // Advance current frame. frames_drawn++; - //advance staging buffer if used + // Advance staging buffer if used. if (staging_buffer_used) { staging_buffer_current = (staging_buffer_current + 1) % staging_buffer_blocks.size(); staging_buffer_used = false; @@ -8980,7 +8996,7 @@ void RenderingDeviceVulkan::swap_buffers() { _finalize_command_bufers(); screen_prepared = false; - //swap buffers + // Swap buffers. context->swap_buffers(); frame = (frame + 1) % frame_count; @@ -9026,15 +9042,15 @@ VmaPool RenderingDeviceVulkan::_find_or_create_small_allocs_pool(uint32_t p_mem_ pci.pMemoryAllocateNext = nullptr; VmaPool pool = VK_NULL_HANDLE; VkResult res = vmaCreatePool(allocator, &pci, &pool); - small_allocs_pools[p_mem_type_index] = pool; // Don't try to create it again if failed the first time + small_allocs_pools[p_mem_type_index] = pool; // Don't try to create it again if failed the first time. ERR_FAIL_COND_V_MSG(res, pool, "vmaCreatePool failed with error " + itos(res) + "."); return pool; } void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { - //free in dependency usage order, so nothing weird happens - //pipelines + // Free in dependency usage order, so nothing weird happens. + // Pipelines. while (frames[p_frame].render_pipelines_to_dispose_of.front()) { RenderPipeline *pipeline = &frames[p_frame].render_pipelines_to_dispose_of.front()->get(); @@ -9051,7 +9067,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { frames[p_frame].compute_pipelines_to_dispose_of.pop_front(); } - //uniform sets + // Uniform sets. while (frames[p_frame].uniform_sets_to_dispose_of.front()) { UniformSet *uniform_set = &frames[p_frame].uniform_sets_to_dispose_of.front()->get(); @@ -9061,7 +9077,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { frames[p_frame].uniform_sets_to_dispose_of.pop_front(); } - //buffer views + // Buffer views. while (frames[p_frame].buffer_views_to_dispose_of.front()) { VkBufferView buffer_view = frames[p_frame].buffer_views_to_dispose_of.front()->get(); @@ -9070,19 +9086,19 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { frames[p_frame].buffer_views_to_dispose_of.pop_front(); } - //shaders + // Shaders. while (frames[p_frame].shaders_to_dispose_of.front()) { Shader *shader = &frames[p_frame].shaders_to_dispose_of.front()->get(); - //descriptor set layout for each set + // Descriptor set layout for each set. for (int i = 0; i < shader->sets.size(); i++) { vkDestroyDescriptorSetLayout(device, shader->sets[i].descriptor_set_layout, nullptr); } - //pipeline layout + // Pipeline layout. vkDestroyPipelineLayout(device, shader->pipeline_layout, nullptr); - //shaders themselves + // Shaders themselves. for (int i = 0; i < shader->pipeline_stages.size(); i++) { vkDestroyShaderModule(device, shader->pipeline_stages[i].module, nullptr); } @@ -9090,7 +9106,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { frames[p_frame].shaders_to_dispose_of.pop_front(); } - //samplers + // Samplers. while (frames[p_frame].samplers_to_dispose_of.front()) { VkSampler sampler = frames[p_frame].samplers_to_dispose_of.front()->get(); @@ -9099,12 +9115,12 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { frames[p_frame].samplers_to_dispose_of.pop_front(); } - //framebuffers + // Framebuffers. while (frames[p_frame].framebuffers_to_dispose_of.front()) { Framebuffer *framebuffer = &frames[p_frame].framebuffers_to_dispose_of.front()->get(); for (const KeyValue<Framebuffer::VersionKey, Framebuffer::Version> &E : framebuffer->framebuffers) { - //first framebuffer, then render pass because it depends on it + // First framebuffer, then render pass because it depends on it. vkDestroyFramebuffer(device, E.value.framebuffer, nullptr); vkDestroyRenderPass(device, E.value.render_pass, nullptr); } @@ -9112,7 +9128,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { frames[p_frame].framebuffers_to_dispose_of.pop_front(); } - //textures + // Textures. while (frames[p_frame].textures_to_dispose_of.front()) { Texture *texture = &frames[p_frame].textures_to_dispose_of.front()->get(); @@ -9121,14 +9137,14 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { } vkDestroyImageView(device, texture->view, nullptr); if (texture->owner.is_null()) { - //actually owns the image and the allocation too + // Actually owns the image and the allocation too. image_memory -= texture->allocation_info.size; vmaDestroyImage(allocator, texture->image, texture->allocation); } frames[p_frame].textures_to_dispose_of.pop_front(); } - //buffers + // Buffers. while (frames[p_frame].buffers_to_dispose_of.front()) { _buffer_free(&frames[p_frame].buffers_to_dispose_of.front()->get()); @@ -9160,9 +9176,9 @@ uint64_t RenderingDeviceVulkan::get_memory_usage(MemoryType p_type) const { void RenderingDeviceVulkan::_flush(bool p_current_frame) { if (local_device.is_valid() && !p_current_frame) { - return; //flushing previous frames has no effect with local device + return; // Flushing previous frames has no effect with local device. } - //not doing this crashes RADV (undefined behavior) + // Not doing this crashes RADV (undefined behavior). if (p_current_frame) { vkEndCommandBuffer(frames[frame].setup_command_buffer); vkEndCommandBuffer(frames[frame].draw_command_buffer); @@ -9186,7 +9202,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { } else { context->flush(p_current_frame, p_current_frame); - //re-create the setup command + // Re-create the setup command. if (p_current_frame) { VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; @@ -9196,7 +9212,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { VkResult err = vkBeginCommandBuffer(frames[frame].setup_command_buffer, &cmdbuf_begin); ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); - context->set_setup_buffer(frames[frame].setup_command_buffer); //append now so it's added before everything else + context->set_setup_buffer(frames[frame].setup_command_buffer); // Append now so it's added before everything else. } if (p_current_frame) { @@ -9214,7 +9230,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { } void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_device) { - // get our device capabilities + // Get our device capabilities. { device_capabilities.version_major = p_context->get_vulkan_major(); device_capabilities.version_minor = p_context->get_vulkan_minor(); @@ -9227,12 +9243,12 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de local_device = p_context->local_device_create(); device = p_context->local_device_get_vk_device(local_device); } else { - frame_count = p_context->get_swapchain_image_count() + 1; //always need one extra to ensure it's unused at any time, without having to use a fence for this. + frame_count = p_context->get_swapchain_image_count() + 1; // Always need one extra to ensure it's unused at any time, without having to use a fence for this. } limits = p_context->get_device_limits(); max_timestamp_query_elements = 256; - { //initialize allocator + { // Initialize allocator. VmaAllocatorCreateInfo allocatorInfo; memset(&allocatorInfo, 0, sizeof(VmaAllocatorCreateInfo)); @@ -9244,11 +9260,11 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de frames.resize(frame_count); frame = 0; - //create setup and frame buffers + // Create setup and frame buffers. for (int i = 0; i < frame_count; i++) { frames[i].index = 0; - { //create command pool, one per frame is recommended + { // Create command pool, one per frame is recommended. VkCommandPoolCreateInfo cmd_pool_info; cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; cmd_pool_info.pNext = nullptr; @@ -9259,10 +9275,10 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de ERR_FAIL_COND_MSG(res, "vkCreateCommandPool failed with error " + itos(res) + "."); } - { //create command buffers + { // Create command buffers. VkCommandBufferAllocateInfo cmdbuf; - //no command buffer exists, create it. + // No command buffer exists, create it. cmdbuf.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; cmdbuf.pNext = nullptr; cmdbuf.commandPool = frames[i].command_pool; @@ -9277,7 +9293,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de } { - //create query pool + // Create query pool. VkQueryPoolCreateInfo query_pool_create_info; query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; query_pool_create_info.flags = 0; @@ -9299,8 +9315,8 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de } { - //begin the first command buffer for the first frame, so - //setting up things can be done in the meantime until swap_buffers(), which is called before advance. + // Begin the first command buffer for the first frame, so + // setting up things can be done in the meantime until swap_buffers(), which is called before advance. VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; cmdbuf_begin.pNext = nullptr; @@ -9313,42 +9329,42 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de err = vkBeginCommandBuffer(frames[0].draw_command_buffer, &cmdbuf_begin); ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); if (local_device.is_null()) { - context->set_setup_buffer(frames[0].setup_command_buffer); //append now so it's added before everything else + context->set_setup_buffer(frames[0].setup_command_buffer); // Append now so it's added before everything else. context->append_command_buffer(frames[0].draw_command_buffer); } } - // Note: If adding new project settings here, also duplicate their definition in + // NOTE: If adding new project settings here, also duplicate their definition in // rendering_server.cpp for headless doctool. staging_buffer_block_size = GLOBAL_DEF("rendering/vulkan/staging_buffer/block_size_kb", 256); staging_buffer_block_size = MAX(4u, staging_buffer_block_size); - staging_buffer_block_size *= 1024; //kb -> bytes + staging_buffer_block_size *= 1024; // Kb -> bytes. staging_buffer_max_size = GLOBAL_DEF("rendering/vulkan/staging_buffer/max_size_mb", 128); staging_buffer_max_size = MAX(1u, staging_buffer_max_size); staging_buffer_max_size *= 1024 * 1024; if (staging_buffer_max_size < staging_buffer_block_size * 4) { - //validate enough blocks + // Validate enough blocks. staging_buffer_max_size = staging_buffer_block_size * 4; } texture_upload_region_size_px = GLOBAL_DEF("rendering/vulkan/staging_buffer/texture_upload_region_size_px", 64); texture_upload_region_size_px = nearest_power_of_2_templated(texture_upload_region_size_px); - frames_drawn = frame_count; //start from frame count, so everything else is immediately old + frames_drawn = frame_count; // Start from frame count, so everything else is immediately old. - //ensure current staging block is valid and at least one per frame exists + // Ensure current staging block is valid and at least one per frame exists. staging_buffer_current = 0; staging_buffer_used = false; for (int i = 0; i < frame_count; i++) { - //staging was never used, create a block + // Staging was never used, create a block. Error err = _insert_staging_block(); ERR_CONTINUE(err != OK); } max_descriptors_per_pool = GLOBAL_DEF("rendering/vulkan/descriptor_pools/max_descriptors_per_pool", 64); - //check to make sure DescriptorPoolKey is good + // Check to make sure DescriptorPoolKey is good. static_assert(sizeof(uint64_t) * 3 >= UNIFORM_TYPE_MAX * sizeof(uint16_t)); draw_list = nullptr; @@ -9369,6 +9385,11 @@ void RenderingDeviceVulkan::_free_rids(T &p_owner, const char *p_type) { WARN_PRINT(vformat("%d RIDs of type \"%s\" were leaked.", owned.size(), p_type)); } for (const RID &E : owned) { +#ifdef DEV_ENABLED + if (resource_names.has(E)) { + print_line(String(" - ") + resource_names[E]); + } +#endif free(E); } } @@ -9378,7 +9399,7 @@ void RenderingDeviceVulkan::capture_timestamp(const String &p_name) { ERR_FAIL_COND_MSG(draw_list != nullptr, "Capturing timestamps during draw list creation is not allowed. Offending timestamp was: " + p_name); ERR_FAIL_COND(frames[frame].timestamp_count >= max_timestamp_query_elements); - //this should be optional for profiling, else it will slow things down + // This should be optional for profiling, else it will slow things down. { VkMemoryBarrier memoryBarrier; @@ -9504,7 +9525,7 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R return uint64_t(render_pipeline->pipeline); } break; default: { - // not supported for this driver + // Not supported for this driver. return 0; } break; } @@ -9541,9 +9562,9 @@ static void mult64to128(uint64_t u, uint64_t v, uint64_t &h, uint64_t &l) { uint64_t RenderingDeviceVulkan::get_captured_timestamp_gpu_time(uint32_t p_index) const { ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0); - // this sucks because timestampPeriod multiplier is a float, while the timestamp is 64 bits nanosecs. - // so, in cases like nvidia which give you enormous numbers and 1 as multiplier, multiplying is next to impossible - // need to do 128 bits fixed point multiplication to get the right value + // This sucks because timestampPeriod multiplier is a float, while the timestamp is 64 bits nanosecs. + // So, in cases like nvidia which give you enormous numbers and 1 as multiplier, multiplying is next to impossible. + // Need to do 128 bits fixed point multiplication to get the right value. uint64_t shift_bits = 16; @@ -9656,7 +9677,7 @@ uint64_t RenderingDeviceVulkan::limit_get(Limit p_limit) const { } void RenderingDeviceVulkan::finalize() { - //free all resources + // Free all resources. _flush(false); @@ -9674,7 +9695,7 @@ void RenderingDeviceVulkan::finalize() { _free_rids(framebuffer_owner, "Framebuffer"); _free_rids(sampler_owner, "Sampler"); { - //for textures it's a bit more difficult because they may be shared + // For textures it's a bit more difficult because they may be shared. List<RID> owned; texture_owner.get_owned_list(&owned); if (owned.size()) { @@ -9683,23 +9704,33 @@ void RenderingDeviceVulkan::finalize() { } else { WARN_PRINT(vformat("%d RIDs of type \"Texture\" were leaked.", owned.size())); } - //free shared first + // Free shared first. for (List<RID>::Element *E = owned.front(); E;) { List<RID>::Element *N = E->next(); if (texture_is_shared(E->get())) { +#ifdef DEV_ENABLED + if (resource_names.has(E->get())) { + print_line(String(" - ") + resource_names[E->get()]); + } +#endif free(E->get()); owned.erase(E); } E = N; } - //free non shared second, this will avoid an error trying to free unexisting textures due to dependencies. + // Free non shared second, this will avoid an error trying to free unexisting textures due to dependencies. for (const RID &E : owned) { +#ifdef DEV_ENABLED + if (resource_names.has(E)) { + print_line(String(" - ") + resource_names[E]); + } +#endif free(E); } } } - //free everything pending + // Free everything pending. for (int i = 0; i < frame_count; i++) { int f = (frame + i) % frame_count; _free_pending_resources(f); @@ -9735,7 +9766,7 @@ void RenderingDeviceVulkan::finalize() { } framebuffer_formats.clear(); - //all these should be clear at this point + // All these should be clear at this point. ERR_FAIL_COND(descriptor_pools.size()); ERR_FAIL_COND(dependency_map.size()); ERR_FAIL_COND(reverse_dependency_map.size()); diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index d98ac1114b..6572de7c52 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -96,13 +96,13 @@ class RenderingDeviceVulkan : public RenderingDevice { ID_TYPE_SPLIT_DRAW_LIST, ID_TYPE_COMPUTE_LIST, ID_TYPE_MAX, - ID_BASE_SHIFT = 58 //5 bits for ID types + ID_BASE_SHIFT = 58 // 5 bits for ID types. }; VkDevice device = VK_NULL_HANDLE; - HashMap<RID, HashSet<RID>> dependency_map; //IDs to IDs that depend on it - HashMap<RID, HashSet<RID>> reverse_dependency_map; //same as above, but in reverse + HashMap<RID, HashSet<RID>> dependency_map; // IDs to IDs that depend on it. + HashMap<RID, HashSet<RID>> reverse_dependency_map; // Same as above, but in reverse. void _add_dependency(RID p_id, RID p_depends_on); void _free_dependencies(RID p_id); @@ -152,7 +152,7 @@ class RenderingDeviceVulkan : public RenderingDevice { uint32_t read_aspect_mask = 0; uint32_t barrier_aspect_mask = 0; - bool bound = false; //bound to framebffer + bool bound = false; // Bound to framebffer. RID owner; }; @@ -214,7 +214,7 @@ class RenderingDeviceVulkan : public RenderingDevice { uint32_t usage = 0; VkBuffer buffer = VK_NULL_HANDLE; VmaAllocation allocation = nullptr; - VkDescriptorBufferInfo buffer_info; //used for binding + VkDescriptorBufferInfo buffer_info; // Used for binding. Buffer() { } }; @@ -256,7 +256,7 @@ class RenderingDeviceVulkan : public RenderingDevice { const FramebufferPass *key_pass_ptr = p_key.passes.ptr(); for (uint32_t i = 0; i < pass_size; i++) { - { //compare color attachments + { // Compare color attachments. uint32_t attachment_size = pass_ptr[i].color_attachments.size(); uint32_t key_attachment_size = key_pass_ptr[i].color_attachments.size(); if (attachment_size != key_attachment_size) { @@ -271,7 +271,7 @@ class RenderingDeviceVulkan : public RenderingDevice { } } } - { //compare input attachments + { // Compare input attachments. uint32_t attachment_size = pass_ptr[i].input_attachments.size(); uint32_t key_attachment_size = key_pass_ptr[i].input_attachments.size(); if (attachment_size != key_attachment_size) { @@ -286,7 +286,7 @@ class RenderingDeviceVulkan : public RenderingDevice { } } } - { //compare resolve attachments + { // Compare resolve attachments. uint32_t attachment_size = pass_ptr[i].resolve_attachments.size(); uint32_t key_attachment_size = key_pass_ptr[i].resolve_attachments.size(); if (attachment_size != key_attachment_size) { @@ -301,7 +301,7 @@ class RenderingDeviceVulkan : public RenderingDevice { } } } - { //compare preserve attachments + { // Compare preserve attachments. uint32_t attachment_size = pass_ptr[i].preserve_attachments.size(); uint32_t key_attachment_size = key_pass_ptr[i].preserve_attachments.size(); if (attachment_size != key_attachment_size) { @@ -343,7 +343,7 @@ class RenderingDeviceVulkan : public RenderingDevice { } } - return false; //equal + return false; // Equal. } }; @@ -353,9 +353,9 @@ class RenderingDeviceVulkan : public RenderingDevice { RBMap<FramebufferFormatKey, FramebufferFormatID> framebuffer_format_cache; struct FramebufferFormat { const RBMap<FramebufferFormatKey, FramebufferFormatID>::Element *E; - VkRenderPass render_pass = VK_NULL_HANDLE; //here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec) + VkRenderPass render_pass = VK_NULL_HANDLE; // Here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec). Vector<TextureSamples> pass_samples; - uint32_t view_count = 1; // number of views + uint32_t view_count = 1; // Number of views. }; HashMap<FramebufferFormatID, FramebufferFormat> framebuffer_formats; @@ -397,7 +397,7 @@ class RenderingDeviceVulkan : public RenderingDevice { struct Version { VkFramebuffer framebuffer = VK_NULL_HANDLE; - VkRenderPass render_pass = VK_NULL_HANDLE; //this one is owned + VkRenderPass render_pass = VK_NULL_HANDLE; // This one is owned. uint32_t subpass_count = 1; }; @@ -454,7 +454,7 @@ class RenderingDeviceVulkan : public RenderingDevice { return false; } } - return true; //they are equal + return true; // They are equal. } } @@ -499,14 +499,14 @@ class RenderingDeviceVulkan : public RenderingDevice { int vertex_count = 0; uint32_t max_instances_allowed = 0; - Vector<VkBuffer> buffers; //not owned, just referenced + Vector<VkBuffer> buffers; // Not owned, just referenced. Vector<VkDeviceSize> offsets; }; RID_Owner<VertexArray, true> vertex_array_owner; struct IndexBuffer : public Buffer { - uint32_t max_index = 0; //used for validation + uint32_t max_index = 0; // Used for validation. uint32_t index_count = 0; VkIndexType index_type = VK_INDEX_TYPE_NONE_NV; bool supports_restart_indices = false; @@ -515,8 +515,8 @@ class RenderingDeviceVulkan : public RenderingDevice { RID_Owner<IndexBuffer, true> index_buffer_owner; struct IndexArray { - uint32_t max_index = 0; //remember the maximum index here too, for validation - VkBuffer buffer; //not owned, inherited from index buffer + uint32_t max_index = 0; // Remember the maximum index here too, for validation. + VkBuffer buffer; // Not owned, inherited from index buffer. uint32_t offset = 0; uint32_t indices = 0; VkIndexType index_type = VK_INDEX_TYPE_NONE_NV; @@ -550,7 +550,7 @@ class RenderingDeviceVulkan : public RenderingDevice { bool writable = false; int binding = 0; uint32_t stages = 0; - int length = 0; //size of arrays (in total elements), or ubos (in bytes * total elements) + int length = 0; // Size of arrays (in total elements), or ubos (in bytes * total elements). bool operator!=(const UniformInfo &p_info) const { return (binding != p_info.binding || type != p_info.type || writable != p_info.writable || stages != p_info.stages || length != p_info.length); @@ -622,7 +622,7 @@ class RenderingDeviceVulkan : public RenderingDevice { VkDescriptorSetLayout descriptor_set_layout = VK_NULL_HANDLE; }; - uint32_t vertex_input_mask = 0; //inputs used, this is mostly for validation + uint32_t vertex_input_mask = 0; // Inputs used, this is mostly for validation. uint32_t fragment_output_mask = 0; struct PushConstant { @@ -645,7 +645,7 @@ class RenderingDeviceVulkan : public RenderingDevice { Vector<VkPipelineShaderStageCreateInfo> pipeline_stages; Vector<SpecializationConstant> specialization_constants; VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; - String name; //used for debug + String name; // Used for debug. }; String _shader_uniform_debug(RID p_shader, int p_set = -1); @@ -717,7 +717,7 @@ class RenderingDeviceVulkan : public RenderingDevice { RID_Owner<Buffer, true> uniform_buffer_owner; RID_Owner<Buffer, true> storage_buffer_owner; - //texture buffer needs a view + // Texture buffer needs a view. struct TextureBuffer { Buffer buffer; VkBufferView view = VK_NULL_HANDLE; @@ -740,15 +740,15 @@ class RenderingDeviceVulkan : public RenderingDevice { DescriptorPool *pool = nullptr; DescriptorPoolKey pool_key; VkDescriptorSet descriptor_set = VK_NULL_HANDLE; - //VkPipelineLayout pipeline_layout; //not owned, inherited from shader + //VkPipelineLayout pipeline_layout; // Not owned, inherited from shader. struct AttachableTexture { uint32_t bind; RID texture; }; - LocalVector<AttachableTexture> attachable_textures; //used for validation - Vector<Texture *> mutable_sampled_textures; //used for layout change - Vector<Texture *> mutable_storage_textures; //used for layout change + LocalVector<AttachableTexture> attachable_textures; // Used for validation. + Vector<Texture *> mutable_sampled_textures; // Used for layout change. + Vector<Texture *> mutable_storage_textures; // Used for layout change. InvalidationCallback invalidated_callback = nullptr; void *invalidated_callback_userdata = nullptr; }; @@ -771,7 +771,7 @@ class RenderingDeviceVulkan : public RenderingDevice { // was not supplied as intended. struct RenderPipeline { - //Cached values for validation + // Cached values for validation. #ifdef DEBUG_ENABLED struct Validation { FramebufferFormatID framebuffer_format = 0; @@ -783,10 +783,10 @@ class RenderingDeviceVulkan : public RenderingDevice { uint32_t primitive_divisor = 0; } validation; #endif - //Actual pipeline + // Actual pipeline. RID shader; Vector<uint32_t> set_formats; - VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // not owned, needed for push constants + VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // Not owned, needed for push constants. VkPipeline pipeline = VK_NULL_HANDLE; uint32_t push_constant_size = 0; uint32_t push_constant_stages = 0; @@ -797,7 +797,7 @@ class RenderingDeviceVulkan : public RenderingDevice { struct ComputePipeline { RID shader; Vector<uint32_t> set_formats; - VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // not owned, needed for push constants + VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // Not owned, needed for push constants. VkPipeline pipeline = VK_NULL_HANDLE; uint32_t push_constant_size = 0; uint32_t push_constant_stages = 0; @@ -823,7 +823,7 @@ class RenderingDeviceVulkan : public RenderingDevice { struct SplitDrawListAllocator { VkCommandPool command_pool = VK_NULL_HANDLE; - Vector<VkCommandBuffer> command_buffers; //one for each frame + Vector<VkCommandBuffer> command_buffers; // One for each frame. }; Vector<SplitDrawListAllocator> split_draw_list_allocators; @@ -975,7 +975,7 @@ class RenderingDeviceVulkan : public RenderingDevice { // when the frame is cycled. struct Frame { - //list in usage order, from last to free to first to free + // List in usage order, from last to free to first to free. List<Buffer> buffers_to_dispose_of; List<Texture> textures_to_dispose_of; List<Framebuffer> framebuffers_to_dispose_of; @@ -987,8 +987,8 @@ class RenderingDeviceVulkan : public RenderingDevice { List<ComputePipeline> compute_pipelines_to_dispose_of; VkCommandPool command_pool = VK_NULL_HANDLE; - VkCommandBuffer setup_command_buffer = VK_NULL_HANDLE; //used at the beginning of every frame for set-up - VkCommandBuffer draw_command_buffer = VK_NULL_HANDLE; //used at the beginning of every frame for set-up + VkCommandBuffer setup_command_buffer = VK_NULL_HANDLE; // Used at the beginning of every frame for set-up. + VkCommandBuffer draw_command_buffer = VK_NULL_HANDLE; // Used at the beginning of every frame for set-up. struct Timestamp { String description; @@ -1009,9 +1009,9 @@ class RenderingDeviceVulkan : public RenderingDevice { uint32_t max_timestamp_query_elements = 0; - TightLocalVector<Frame> frames; //frames available, for main device they are cycled (usually 3), for local devices only 1 - int frame = 0; //current frame - int frame_count = 0; //total amount of frames + TightLocalVector<Frame> frames; // Frames available, for main device they are cycled (usually 3), for local devices only 1. + int frame = 0; // Current frame. + int frame_count = 0; // Total amount of frames. uint64_t frames_drawn = 0; RID local_device; bool local_device_processing = false; @@ -1038,6 +1038,10 @@ class RenderingDeviceVulkan : public RenderingDevice { void _finalize_command_bufers(); void _begin_frame(); +#ifdef DEV_ENABLED + HashMap<RID, String> resource_names; +#endif + public: virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data = Vector<Vector<uint8_t>>()); virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture); @@ -1085,7 +1089,7 @@ public: virtual RID vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>(), bool p_use_as_storage = false); - // Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated + // Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated. virtual VertexFormatID vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats); virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers); @@ -1116,7 +1120,7 @@ public: virtual bool uniform_set_is_valid(RID p_uniform_set); virtual void uniform_set_set_invalidation_callback(RID p_uniform_set, InvalidationCallback p_callback, void *p_userdata); - virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL); //works for any buffer + virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL); // Works for any buffer. virtual Error buffer_clear(RID p_buffer, uint32_t p_offset, uint32_t p_size, uint32_t p_post_barrier = BARRIER_MASK_ALL); virtual Vector<uint8_t> buffer_get_data(RID p_buffer); @@ -1214,10 +1218,10 @@ public: void initialize(VulkanContext *p_context, bool p_local_device = false); void finalize(); - virtual void swap_buffers(); //for main device + virtual void swap_buffers(); // For main device. - virtual void submit(); //for local device - virtual void sync(); //for local device + virtual void submit(); // For local device. + virtual void sync(); // For local device. virtual uint32_t get_frame_delay() const; diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index a9a8ce68ac..afc3e78372 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -237,7 +237,7 @@ Error VulkanContext::_get_preferred_validation_layers(uint32_t *count, const cha { "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_core_validation", "VK_LAYER_GOOGLE_unique_objects" } }; - // Clear out-arguments + // Clear out-arguments. *count = 0; if (names != nullptr) { *names = nullptr; @@ -441,7 +441,7 @@ String VulkanContext::SubgroupCapabilities::supported_stages_desc() const { res += ", STAGE_MESH_NV"; } - return res.substr(2); // Remove first ", " + return res.substr(2); // Remove first ", ". } uint32_t VulkanContext::SubgroupCapabilities::supported_operations_flags_rd() const { @@ -506,7 +506,7 @@ String VulkanContext::SubgroupCapabilities::supported_operations_desc() const { res += ", FEATURE_PARTITIONED_NV"; } - return res.substr(2); // Remove first ", " + return res.substr(2); // Remove first ", ". } Error VulkanContext::_check_capabilities() { @@ -641,8 +641,8 @@ Error VulkanContext::_check_capabilities() { subgroup_capabilities.supportedStages = subgroupProperties.supportedStages; subgroup_capabilities.supportedOperations = subgroupProperties.supportedOperations; // Note: quadOperationsInAllStages will be true if: - // - supportedStages has VK_SHADER_STAGE_ALL_GRAPHICS + VK_SHADER_STAGE_COMPUTE_BIT - // - supportedOperations has VK_SUBGROUP_FEATURE_QUAD_BIT + // - supportedStages has VK_SHADER_STAGE_ALL_GRAPHICS + VK_SHADER_STAGE_COMPUTE_BIT. + // - supportedOperations has VK_SUBGROUP_FEATURE_QUAD_BIT. subgroup_capabilities.quadOperationsInAllStages = subgroupProperties.quadOperationsInAllStages; if (vrs_capabilities.pipeline_vrs_supported || vrs_capabilities.primitive_vrs_supported || vrs_capabilities.attachment_vrs_supported) { @@ -654,7 +654,7 @@ Error VulkanContext::_check_capabilities() { print_verbose(" Primitive fragment shading rate"); } if (vrs_capabilities.attachment_vrs_supported) { - // TODO expose these somehow to the end user + // TODO expose these somehow to the end user. vrs_capabilities.min_texel_size.x = vrsProperties.minFragmentShadingRateAttachmentTexelSize.width; vrs_capabilities.min_texel_size.y = vrsProperties.minFragmentShadingRateAttachmentTexelSize.height; vrs_capabilities.max_texel_size.x = vrsProperties.maxFragmentShadingRateAttachmentTexelSize.width; @@ -731,7 +731,7 @@ Error VulkanContext::_create_instance() { VkDebugUtilsMessengerCreateInfoEXT dbg_messenger_create_info; VkDebugReportCallbackCreateInfoEXT dbg_report_callback_create_info{}; if (enabled_debug_utils) { - // VK_EXT_debug_utils style + // VK_EXT_debug_utils style. dbg_messenger_create_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; dbg_messenger_create_info.pNext = nullptr; dbg_messenger_create_info.flags = 0; @@ -902,8 +902,8 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) { } } else { // TODO: At least on Linux Laptops integrated GPUs fail with Vulkan in many instances. - // The device should really be a preference, but for now choosing a discrete GPU over the - // integrated one is better than the default. + // The device should really be a preference, but for now choosing a discrete GPU over the + // integrated one is better than the default. int type_selected = -1; print_verbose("Vulkan devices:"); @@ -1175,7 +1175,7 @@ Error VulkanContext::_create_device() { VkPhysicalDeviceFragmentShadingRateFeaturesKHR vrs_features; if (vrs_capabilities.pipeline_vrs_supported || vrs_capabilities.primitive_vrs_supported || vrs_capabilities.attachment_vrs_supported) { - // insert into our chain to enable these features if they are available + // Insert into our chain to enable these features if they are available. vrs_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR; vrs_features.pNext = nextptr; vrs_features.pipelineFragmentShadingRate = vrs_capabilities.pipeline_vrs_supported; @@ -1611,17 +1611,17 @@ Error VulkanContext::_update_swap_chain(Window *window) { // The FIFO present mode is guaranteed by the spec to be supported // and to have no tearing. It's a great default present mode to use. - // There are times when you may wish to use another present mode. The - // following code shows how to select them, and the comments provide some - // reasons you may wish to use them. + // There are times when you may wish to use another present mode. The + // following code shows how to select them, and the comments provide some + // reasons you may wish to use them. // // It should be noted that Vulkan 1.0 doesn't provide a method for - // synchronizing rendering with the presentation engine's display. There + // synchronizing rendering with the presentation engine's display. There // is a method provided for throttling rendering with the display, but // there are some presentation engines for which this method will not work. // If an application doesn't throttle its rendering, and if it renders much // faster than the refresh rate of the display, this can waste power on - // mobile devices. That is because power is being spent rendering images + // mobile devices. That is because power is being spent rendering images // that may never be seen. // VK_PRESENT_MODE_IMMEDIATE_KHR is for applications that don't care about @@ -1699,7 +1699,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { // If maxImageCount is 0, we can ask for as many images as we want; // otherwise we're limited to maxImageCount. if ((surfCapabilities.maxImageCount > 0) && (desiredNumOfSwapchainImages > surfCapabilities.maxImageCount)) { - // Application must settle for fewer images than desired: + // Application must settle for fewer images than desired. desiredNumOfSwapchainImages = surfCapabilities.maxImageCount; } @@ -2043,14 +2043,14 @@ Error VulkanContext::prepare_buffers() { } do { - // Get the index of the next available swapchain image: + // Get the index of the next available swapchain image. err = fpAcquireNextImageKHR(device, w->swapchain, UINT64_MAX, w->image_acquired_semaphores[frame_index], VK_NULL_HANDLE, &w->current_buffer); if (err == VK_ERROR_OUT_OF_DATE_KHR) { // Swapchain is out of date (e.g. the window was resized) and - // must be recreated: + // must be recreated. print_verbose("Vulkan: Early out of date swapchain, recreating."); // resize_notify(); _update_swap_chain(w); @@ -2083,7 +2083,7 @@ Error VulkanContext::swap_buffers() { #if 0 if (VK_GOOGLE_display_timing_enabled) { // Look at what happened to previous presents, and make appropriate - // adjustments in timing: + // adjustments in timing. DemoUpdateTargetIPD(demo); // Note: a real application would position its geometry to that it's in @@ -2246,7 +2246,7 @@ Error VulkanContext::swap_buffers() { uint64_t curtime = getTimeInNanoseconds(); if (curtime == 0) { // Since we didn't find out the current time, don't give a - // desiredPresentTime: + // desiredPresentTime. ptime.desiredPresentTime = 0; } else { ptime.desiredPresentTime = curtime + (target_IPD >> 1); @@ -2278,7 +2278,7 @@ Error VulkanContext::swap_buffers() { if (err == VK_ERROR_OUT_OF_DATE_KHR) { // Swapchain is out of date (e.g. the window was resized) and - // must be recreated: + // must be recreated. print_verbose("Vulkan: Swapchain is out of date, recreating."); resize_notify(); } else if (err == VK_SUBOPTIMAL_KHR) { diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index 35e7ce7db8..5cc3b515d9 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -70,9 +70,9 @@ public: }; struct VRSCapabilities { - bool pipeline_vrs_supported; // We can specify our fragment rate on a pipeline level - bool primitive_vrs_supported; // We can specify our fragment rate on each drawcall - bool attachment_vrs_supported; // We can provide a density map attachment on our framebuffer + bool pipeline_vrs_supported; // We can specify our fragment rate on a pipeline level. + bool primitive_vrs_supported; // We can specify our fragment rate on each drawcall. + bool attachment_vrs_supported; // We can provide a density map attachment on our framebuffer. Size2i min_texel_size; Size2i max_texel_size; @@ -107,7 +107,7 @@ private: bool device_initialized = false; bool inst_initialized = false; - // Vulkan 1.0 doesn't return version info so we assume this by default until we know otherwise + // Vulkan 1.0 doesn't return version info so we assume this by default until we know otherwise. uint32_t vulkan_major = 1; uint32_t vulkan_minor = 0; uint32_t vulkan_patch = 0; @@ -267,7 +267,7 @@ protected: Error _get_preferred_validation_layers(uint32_t *count, const char *const **names); public: - // Extension calls + // Extension calls. VkResult vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass); uint32_t get_vulkan_major() const { return vulkan_major; }; diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index ab9afda803..e10ed7e976 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -328,6 +328,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } } + Color dc = get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + Ref<Texture2D> remove = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); float remove_hpos = limit - hsep - remove->get_width(); @@ -402,7 +404,11 @@ void AnimationBezierTrackEdit::_notification(int p_what) { float icon_start_height = vofs + rect.size.y / 2; Rect2 remove_rect = Rect2(remove_hpos, icon_start_height - remove->get_height() / 2, remove->get_width(), remove->get_height()); - draw_texture(remove, remove_rect.position); + if (read_only) { + draw_texture(remove, remove_rect.position, dc); + } else { + draw_texture(remove, remove_rect.position); + } Rect2 lock_rect = Rect2(lock_hpos, icon_start_height - lock->get_height() / 2, lock->get_width(), lock->get_height()); if (locked_tracks.has(current_track)) { @@ -632,8 +638,9 @@ Ref<Animation> AnimationBezierTrackEdit::get_animation() const { return animation; } -void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) { +void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only) { animation = p_animation; + read_only = p_read_only; selected_track = p_track; update(); } @@ -715,7 +722,7 @@ void AnimationBezierTrackEdit::set_filtered(bool p_filtered) { continue; // Skip track due to not selected. } - set_animation_and_track(animation, i); + set_animation_and_track(animation, i, read_only); break; } } @@ -819,12 +826,16 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (p_event->is_pressed()) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->matches_event(p_event)) { - duplicate_selection(); + if (!read_only) { + duplicate_selection(); + } accept_event(); } if (ED_GET_SHORTCUT("animation_editor/delete_selection")->matches_event(p_event)) { - delete_selection(); + if (!read_only) { + delete_selection(); + } accept_event(); } } @@ -917,26 +928,28 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->get_button_index() == MouseButton::RIGHT && mb->is_pressed()) { menu_insert_key = mb->get_position(); if (menu_insert_key.x >= limit && menu_insert_key.x <= get_size().width) { - Vector2 popup_pos = get_screen_position() + mb->get_position(); + if (!read_only) { + Vector2 popup_pos = get_screen_position() + mb->get_position(); - menu->clear(); - if (!locked_tracks.has(selected_track) || locked_tracks.has(selected_track)) { - menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT); - } - if (selection.size()) { - menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); - menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); - menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesFree"), SNAME("EditorIcons")), TTR("Make Handles Free"), MENU_KEY_SET_HANDLE_FREE); - menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesBalanced"), SNAME("EditorIcons")), TTR("Make Handles Balanced"), MENU_KEY_SET_HANDLE_BALANCED); - } + menu->clear(); + if (!locked_tracks.has(selected_track) || locked_tracks.has(selected_track)) { + menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT); + } + if (selection.size()) { + menu->add_separator(); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); + menu->add_separator(); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); + menu->add_separator(); + menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesFree"), SNAME("EditorIcons")), TTR("Make Handles Free"), MENU_KEY_SET_HANDLE_FREE); + menu->add_icon_item(get_theme_icon(SNAME("BezierHandlesBalanced"), SNAME("EditorIcons")), TTR("Make Handles Balanced"), MENU_KEY_SET_HANDLE_BALANCED); + } - if (menu->get_item_count()) { - menu->reset_size(); - menu->set_position(popup_pos); - menu->popup(); + if (menu->get_item_count()) { + menu->reset_size(); + menu->set_position(popup_pos); + menu->popup(); + } } } } @@ -945,7 +958,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { for (const KeyValue<int, Rect2> &E : subtracks) { if (E.value.has_point(mb->get_position())) { if (!locked_tracks.has(E.key) && !hidden_tracks.has(E.key)) { - set_animation_and_track(animation, E.key); + set_animation_and_track(animation, E.key, read_only); _clear_selection(); } return; @@ -958,30 +971,32 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { for (const KeyValue<int, Rect2> &I : track_icons) { if (I.value.has_point(mb->get_position())) { if (I.key == REMOVE_ICON) { - undo_redo->create_action("Remove Bezier Track"); - - undo_redo->add_do_method(this, "_update_locked_tracks_after", track); - undo_redo->add_do_method(this, "_update_hidden_tracks_after", track); - - undo_redo->add_do_method(animation.ptr(), "remove_track", track); + if (!read_only) { + undo_redo->create_action("Remove Bezier Track"); + + undo_redo->add_do_method(this, "_update_locked_tracks_after", track); + undo_redo->add_do_method(this, "_update_hidden_tracks_after", track); + + undo_redo->add_do_method(animation.ptr(), "remove_track", track); + + undo_redo->add_undo_method(animation.ptr(), "add_track", Animation::TrackType::TYPE_BEZIER, track); + undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track)); + + for (int i = 0; i < animation->track_get_key_count(track); ++i) { + undo_redo->add_undo_method( + animation.ptr(), + "bezier_track_insert_key", + track, animation->track_get_key_time(track, i), + animation->bezier_track_get_key_value(track, i), + animation->bezier_track_get_key_in_handle(track, i), + animation->bezier_track_get_key_out_handle(track, i), + animation->bezier_track_get_key_handle_mode(track, i)); + } - undo_redo->add_undo_method(animation.ptr(), "add_track", Animation::TrackType::TYPE_BEZIER, track); - undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track)); + undo_redo->commit_action(); - for (int i = 0; i < animation->track_get_key_count(track); ++i) { - undo_redo->add_undo_method( - animation.ptr(), - "bezier_track_insert_key", - track, animation->track_get_key_time(track, i), - animation->bezier_track_get_key_value(track, i), - animation->bezier_track_get_key_in_handle(track, i), - animation->bezier_track_get_key_out_handle(track, i), - animation->bezier_track_get_key_handle_mode(track, i)); + selected_track = CLAMP(selected_track, 0, animation->get_track_count() - 1); } - - undo_redo->commit_action(); - - selected_track = CLAMP(selected_track, 0, animation->get_track_count() - 1); return; } else if (I.key == LOCK_ICON) { if (locked_tracks.has(track)) { @@ -991,7 +1006,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (selected_track == track) { for (int i = 0; i < animation->get_track_count(); ++i) { if (!locked_tracks.has(i) && animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { - set_animation_and_track(animation, i); + set_animation_and_track(animation, i, read_only); break; } } @@ -1007,7 +1022,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (selected_track == track) { for (int i = 0; i < animation->get_track_count(); ++i) { if (!hidden_tracks.has(i) && animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { - set_animation_and_track(animation, i); + set_animation_and_track(animation, i, read_only); break; } } @@ -1046,7 +1061,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } } - set_animation_and_track(animation, track); + set_animation_and_track(animation, track, read_only); solo_track = track; } update(); @@ -1087,7 +1102,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_selection_from_key = pair.second; moving_selection_from_track = pair.first; moving_selection_offset = Vector2(); - set_animation_and_track(animation, pair.first); + set_animation_and_track(animation, pair.first, read_only); selection.clear(); selection.insert(pair); update(); @@ -1096,24 +1111,26 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } } - if (edit_points[i].in_rect.has_point(mb->get_position())) { - moving_handle = -1; - moving_handle_key = edit_points[i].key; - moving_handle_track = edit_points[i].track; - moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); - moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); - update(); - return; - } + if (!read_only) { + if (edit_points[i].in_rect.has_point(mb->get_position())) { + moving_handle = -1; + moving_handle_key = edit_points[i].key; + moving_handle_track = edit_points[i].track; + moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); + moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); + update(); + return; + } - if (edit_points[i].out_rect.has_point(mb->get_position())) { - moving_handle = 1; - moving_handle_key = edit_points[i].key; - moving_handle_track = edit_points[i].track; - moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); - moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); - update(); - return; + if (edit_points[i].out_rect.has_point(mb->get_position())) { + moving_handle = 1; + moving_handle_key = edit_points[i].key; + moving_handle_track = edit_points[i].track; + moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); + moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); + update(); + return; + } } } @@ -1191,7 +1208,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { selection.insert(IntPair(edit_points[i].track, edit_points[i].key)); if (!track_set) { track_set = true; - set_animation_and_track(animation, edit_points[i].track); + set_animation_and_track(animation, edit_points[i].track, read_only); } } } @@ -1215,7 +1232,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { float track_height = _bezier_h_to_pixel(track_h); if (abs(mb->get_position().y - track_height) < 10) { - set_animation_and_track(animation, i); + set_animation_and_track(animation, i, read_only); break; } } @@ -1229,102 +1246,106 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } if (moving_handle != 0 && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - undo_redo->create_action(TTR("Move Bezier Points")); - undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", selected_track, moving_handle_key, moving_handle_left); - undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", selected_track, moving_handle_key, moving_handle_right); - undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", selected_track, moving_handle_key, animation->bezier_track_get_key_in_handle(selected_track, moving_handle_key)); - undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", selected_track, moving_handle_key, animation->bezier_track_get_key_out_handle(selected_track, moving_handle_key)); - undo_redo->commit_action(); + if (!read_only) { + undo_redo->create_action(TTR("Move Bezier Points")); + undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", selected_track, moving_handle_key, moving_handle_left); + undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", selected_track, moving_handle_key, moving_handle_right); + undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", selected_track, moving_handle_key, animation->bezier_track_get_key_in_handle(selected_track, moving_handle_key)); + undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", selected_track, moving_handle_key, animation->bezier_track_get_key_out_handle(selected_track, moving_handle_key)); + undo_redo->commit_action(); - moving_handle = 0; - update(); + moving_handle = 0; + update(); + } } if (moving_selection_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - if (moving_selection) { - //combit it + if (!read_only) { + if (moving_selection) { + //combit it - undo_redo->create_action(TTR("Move Bezier Points")); - - List<AnimMoveRestore> to_restore; - // 1-remove the keys - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->get().first, E->get().second); - } - // 2- remove overlapped keys - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - float newtime = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); + undo_redo->create_action(TTR("Move Bezier Points")); - int idx = animation->track_find_key(E->get().first, newtime, true); - if (idx == -1) { - continue; + List<AnimMoveRestore> to_restore; + // 1-remove the keys + for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { + undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->get().first, E->get().second); } + // 2- remove overlapped keys + for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { + float newtime = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - if (selection.has(IntPair(E->get().first, idx))) { - continue; //already in selection, don't save - } + int idx = animation->track_find_key(E->get().first, newtime, true); + if (idx == -1) { + continue; + } - undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newtime); - AnimMoveRestore amr; + if (selection.has(IntPair(E->get().first, idx))) { + continue; //already in selection, don't save + } - amr.key = animation->track_get_key_value(E->get().first, idx); - amr.track = E->get().first; - amr.time = newtime; + undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newtime); + AnimMoveRestore amr; - to_restore.push_back(amr); - } + amr.key = animation->track_get_key_value(E->get().first, idx); + amr.track = E->get().first; + amr.time = newtime; - // 3-move the keys (re insert them) - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - Array key = animation->track_get_key_value(E->get().first, E->get().second); - float h = key[0]; - h += moving_selection_offset.y; - key[0] = h; - undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->get().first, newpos, key, 1); - } + to_restore.push_back(amr); + } - // 4-(undo) remove inserted keys - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newpos); - } + // 3-move the keys (re insert them) + for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { + float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); + Array key = animation->track_get_key_value(E->get().first, E->get().second); + float h = key[0]; + h += moving_selection_offset.y; + key[0] = h; + undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->get().first, newpos, key, 1); + } - // 5-(undo) reinsert keys - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - float oldpos = animation->track_get_key_time(E->get().first, E->get().second); - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->get().first, oldpos, animation->track_get_key_value(E->get().first, E->get().second), 1); - } + // 4-(undo) remove inserted keys + for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { + float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newpos); + } - // 6-(undo) reinsert overlapped keys - for (const AnimMoveRestore &amr : to_restore) { - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); - } + // 5-(undo) reinsert keys + for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { + float oldpos = animation->track_get_key_time(E->get().first, E->get().second); + undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->get().first, oldpos, animation->track_get_key_value(E->get().first, E->get().second), 1); + } - undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); - undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); + // 6-(undo) reinsert overlapped keys + for (const AnimMoveRestore &amr : to_restore) { + undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); + } - // 7-reselect + undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); - for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { - float oldpos = animation->track_get_key_time(E->get().first, E->get().second); - float newpos = editor->snap_time(oldpos + moving_selection_offset.x); + // 7-reselect - undo_redo->add_do_method(this, "_select_at_anim", animation, E->get().first, newpos); - undo_redo->add_undo_method(this, "_select_at_anim", animation, E->get().first, oldpos); - } + for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { + float oldpos = animation->track_get_key_time(E->get().first, E->get().second); + float newpos = editor->snap_time(oldpos + moving_selection_offset.x); - undo_redo->commit_action(); + undo_redo->add_do_method(this, "_select_at_anim", animation, E->get().first, newpos); + undo_redo->add_undo_method(this, "_select_at_anim", animation, E->get().first, oldpos); + } - moving_selection = false; - } else if (select_single_attempt != IntPair(-1, -1)) { - selection.clear(); - selection.insert(select_single_attempt); - set_animation_and_track(animation, select_single_attempt.first); - } + undo_redo->commit_action(); - moving_selection_attempt = false; - update(); + moving_selection = false; + } else if (select_single_attempt != IntPair(-1, -1)) { + selection.clear(); + selection.insert(select_single_attempt); + set_animation_and_track(animation, select_single_attempt.first, read_only); + } + + moving_selection_attempt = false; + update(); + } } Ref<InputEventMouseMotion> mm = p_event; @@ -1337,7 +1358,9 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { float y = (get_size().height / 2 - mm->get_position().y) * v_zoom + v_scroll; float x = editor->snap_time(((mm->get_position().x - limit) / timeline->get_zoom_scale()) + timeline->get_value()); - moving_selection_offset = Vector2(x - animation->track_get_key_time(moving_selection_from_track, moving_selection_from_key), y - animation->bezier_track_get_key_value(moving_selection_from_track, moving_selection_from_key)); + if (!read_only) { + moving_selection_offset = Vector2(x - animation->track_get_key_time(moving_selection_from_track, moving_selection_from_key), y - animation->bezier_track_get_key_value(moving_selection_from_track, moving_selection_from_key)); + } update(); } @@ -1399,20 +1422,22 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { bool is_finishing_key_handle_drag = moving_handle != 0 && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT; if (is_finishing_key_handle_drag) { - undo_redo->create_action(TTR("Move Bezier Points")); - if (moving_handle == -1) { - double ratio = timeline->get_zoom_scale() * v_zoom; - undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", moving_handle_track, moving_handle_key, moving_handle_left, ratio); - undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_in_handle(moving_handle_track, moving_handle_key), ratio); - } else if (moving_handle == 1) { - double ratio = timeline->get_zoom_scale() * v_zoom; - undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, moving_handle_right, ratio); - undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_out_handle(moving_handle_track, moving_handle_key), ratio); - } - undo_redo->commit_action(); + if (!read_only) { + undo_redo->create_action(TTR("Move Bezier Points")); + if (moving_handle == -1) { + double ratio = timeline->get_zoom_scale() * v_zoom; + undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", moving_handle_track, moving_handle_key, moving_handle_left, ratio); + undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_in_handle(moving_handle_track, moving_handle_key), ratio); + } else if (moving_handle == 1) { + double ratio = timeline->get_zoom_scale() * v_zoom; + undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, moving_handle_right, ratio); + undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_out_handle(moving_handle_track, moving_handle_key), ratio); + } + undo_redo->commit_action(); - moving_handle = 0; - update(); + moving_handle = 0; + update(); + } } } diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index 22b58a6703..070a6589ad 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -54,6 +54,7 @@ class AnimationBezierTrackEdit : public Control { float play_position_pos = 0; Ref<Animation> animation; + bool read_only = false; int selected_track = 0; Vector<Rect2> view_rects; @@ -176,7 +177,7 @@ public: Ref<Animation> get_animation() const; - void set_animation_and_track(const Ref<Animation> &p_animation, int p_track); + void set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only); virtual Size2 get_minimum_size() const override; void set_undo_redo(UndoRedo *p_undo_redo); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 83047caf98..0db82551cb 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -48,6 +48,7 @@ class AnimationTrackKeyEdit : public Object { public: bool setting = false; + bool animation_read_only = false; bool _hide_script_from_inspector() { return true; @@ -57,12 +58,17 @@ public: return true; } + bool _read_only() { + return animation_read_only; + } + static void _bind_methods() { ClassDB::bind_method("_update_obj", &AnimationTrackKeyEdit::_update_obj); ClassDB::bind_method("_key_ofs_changed", &AnimationTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method("_hide_script_from_inspector", &AnimationTrackKeyEdit::_hide_script_from_inspector); ClassDB::bind_method("get_root_path", &AnimationTrackKeyEdit::get_root_path); ClassDB::bind_method("_dont_undo_redo", &AnimationTrackKeyEdit::_dont_undo_redo); + ClassDB::bind_method("_read_only", &AnimationTrackKeyEdit::_read_only); } void _fix_node_path(Variant &value) { @@ -703,6 +709,7 @@ class AnimationMultiTrackKeyEdit : public Object { public: bool setting = false; + bool animation_read_only = false; bool _hide_script_from_inspector() { return true; @@ -712,12 +719,17 @@ public: return true; } + bool _read_only() { + return animation_read_only; + } + static void _bind_methods() { ClassDB::bind_method("_update_obj", &AnimationMultiTrackKeyEdit::_update_obj); ClassDB::bind_method("_key_ofs_changed", &AnimationMultiTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method("_hide_script_from_inspector", &AnimationMultiTrackKeyEdit::_hide_script_from_inspector); ClassDB::bind_method("get_root_path", &AnimationMultiTrackKeyEdit::get_root_path); ClassDB::bind_method("_dont_undo_redo", &AnimationMultiTrackKeyEdit::_dont_undo_redo); + ClassDB::bind_method("_read_only", &AnimationMultiTrackKeyEdit::_read_only); } void _fix_node_path(Variant &value, NodePath &base) { @@ -1416,22 +1428,32 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { } void AnimationTimelineEdit::_anim_loop_pressed() { - undo_redo->create_action(TTR("Change Animation Loop")); - switch (animation->get_loop_mode()) { - case Animation::LOOP_NONE: { - undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_LINEAR); - } break; - case Animation::LOOP_LINEAR: { - undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_PINGPONG); - } break; - case Animation::LOOP_PINGPONG: { - undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_NONE); - } break; - default: - break; + if (!read_only) { + undo_redo->create_action(TTR("Change Animation Loop")); + switch (animation->get_loop_mode()) { + case Animation::LOOP_NONE: { + undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_LINEAR); + } break; + case Animation::LOOP_LINEAR: { + undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_PINGPONG); + } break; + case Animation::LOOP_PINGPONG: { + undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_NONE); + } break; + default: + break; + } + undo_redo->add_undo_method(animation.ptr(), "set_loop_mode", animation->get_loop_mode()); + undo_redo->commit_action(); + } else { + String base_path = animation->get_path(); + if (FileAccess::exists(base_path + ".import")) { + EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation instanced from imported scene.")); + } else { + EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation embedded in another scene.")); + } + update_values(); } - undo_redo->add_undo_method(animation.ptr(), "set_loop_mode", animation->get_loop_mode()); - undo_redo->commit_action(); } int AnimationTimelineEdit::get_buttons_width() const { @@ -1656,11 +1678,17 @@ void AnimationTimelineEdit::_notification(int p_what) { } } -void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) { +void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, bool p_read_only) { animation = p_animation; + read_only = p_read_only; + if (animation.is_valid()) { len_hb->show(); - add_track->show(); + if (read_only) { + add_track->hide(); + } else { + add_track->show(); + } play_position->show(); } else { len_hb->hide(); @@ -1982,6 +2010,8 @@ void AnimationTrackEdit::_notification(int p_what) { Color linecolor = color; linecolor.a = 0.2; + Color dc = get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + // NAMES AND ICONS // { @@ -2131,14 +2161,18 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += update_icon->get_width() + hsep / 2; update_mode_rect.size.x += hsep / 2; - if (animation->track_get_type(track) == Animation::TYPE_VALUE) { - draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); - update_mode_rect.size.x += down_icon->get_width(); - } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")); - update_mode_rect.size.x += down_icon->get_width(); + if (!read_only) { + if (animation->track_get_type(track) == Animation::TYPE_VALUE) { + draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); + update_mode_rect.size.x += down_icon->get_width(); + } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { + Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")); + update_mode_rect.size.x += down_icon->get_width(); - update_mode_rect = Rect2(); + update_mode_rect = Rect2(); + } else { + update_mode_rect = Rect2(); + } } else { update_mode_rect = Rect2(); } @@ -2169,7 +2203,7 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += icon->get_width() + hsep / 2; interp_mode_rect.size.x += hsep / 2; - if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) { + if (!read_only && !animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) { draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); interp_mode_rect.size.x += down_icon->get_width(); } else { @@ -2202,7 +2236,7 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += icon->get_width() + hsep / 2; loop_wrap_rect.size.x += hsep / 2; - if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) { + if (!read_only && !animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) { draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); loop_wrap_rect.size.x += down_icon->get_width(); } else { @@ -2223,7 +2257,11 @@ void AnimationTrackEdit::_notification(int p_what) { remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; remove_rect.size = icon->get_size(); - draw_texture(icon, remove_rect.position); + if (read_only) { + draw_texture(icon, remove_rect.position, dc); + } else { + draw_texture(icon, remove_rect.position); + } } } @@ -2439,8 +2477,10 @@ Ref<Animation> AnimationTrackEdit::get_animation() const { return animation; } -void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) { +void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only) { animation = p_animation; + read_only = p_read_only; + track = p_track; update(); @@ -2721,17 +2761,23 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (p_event->is_pressed()) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->matches_event(p_event)) { - emit_signal(SNAME("duplicate_request")); + if (!read_only) { + emit_signal(SNAME("duplicate_request")); + } accept_event(); } if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->matches_event(p_event)) { - emit_signal(SNAME("duplicate_transpose_request")); + if (!read_only) { + emit_signal(SNAME("duplicate_transpose_request")); + } accept_event(); } if (ED_GET_SHORTCUT("animation_editor/delete_selection")->matches_event(p_event)) { - emit_signal(SNAME("delete_request")); + if (!read_only) { + emit_signal(SNAME("delete_request")); + } accept_event(); } } @@ -2740,79 +2786,81 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { Point2 pos = mb->get_position(); - if (check_rect.has_point(pos)) { - undo_redo->create_action(TTR("Toggle Track Enabled")); - undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); - undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); - undo_redo->commit_action(); - update(); - accept_event(); - } + if (!read_only) { + if (check_rect.has_point(pos)) { + undo_redo->create_action(TTR("Toggle Track Enabled")); + undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); + undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); + undo_redo->commit_action(); + update(); + accept_event(); + } - // Don't overlap track keys if they start at 0. - if (path_rect.has_point(pos + Size2(type_icon->get_width(), 0))) { - clicking_on_name = true; - accept_event(); - } + // Don't overlap track keys if they start at 0. + if (path_rect.has_point(pos + Size2(type_icon->get_width(), 0))) { + clicking_on_name = true; + accept_event(); + } - if (update_mode_rect.has_point(pos)) { - if (!menu) { - menu = memnew(PopupMenu); - add_child(menu); - menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + if (update_mode_rect.has_point(pos)) { + if (!menu) { + menu = memnew(PopupMenu); + add_child(menu); + menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + } + menu->clear(); + menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); + menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); + menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); + menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); + menu->reset_size(); + + Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); + menu->set_position(popup_pos); + menu->popup(); + accept_event(); } - menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); - menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); - menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); - menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); - menu->reset_size(); - - Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); - menu->set_position(popup_pos); - menu->popup(); - accept_event(); - } - if (interp_mode_rect.has_point(pos)) { - if (!menu) { - menu = memnew(PopupMenu); - add_child(menu); - menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + if (interp_mode_rect.has_point(pos)) { + if (!menu) { + menu = memnew(PopupMenu); + add_child(menu); + menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + } + menu->clear(); + menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); + menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); + menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); + menu->reset_size(); + + Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); + menu->set_position(popup_pos); + menu->popup(); + accept_event(); } - menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); - menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); - menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); - menu->reset_size(); - - Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); - menu->set_position(popup_pos); - menu->popup(); - accept_event(); - } - if (loop_wrap_rect.has_point(pos)) { - if (!menu) { - menu = memnew(PopupMenu); - add_child(menu); - menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + if (loop_wrap_rect.has_point(pos)) { + if (!menu) { + menu = memnew(PopupMenu); + add_child(menu); + menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + } + menu->clear(); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); + menu->reset_size(); + + Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height); + menu->set_position(popup_pos); + menu->popup(); + accept_event(); } - menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); - menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); - menu->reset_size(); - - Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height); - menu->set_position(popup_pos); - menu->popup(); - accept_event(); - } - if (remove_rect.has_point(pos)) { - emit_signal(SNAME("remove_request"), track); - accept_event(); - return; + if (remove_rect.has_point(pos)) { + emit_signal(SNAME("remove_request"), track); + accept_event(); + return; + } } // Check keyframes. @@ -2872,6 +2920,11 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_selection_attempt = true; moving_selection_from_ofs = (mb->get_position().x - limit) / timeline->get_zoom_scale(); } + + if (read_only) { + moving_selection_attempt = false; + moving_selection_from_ofs = 0.0f; + } accept_event(); } } @@ -2883,33 +2936,35 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (pos.x >= timeline->get_name_limit() && pos.x <= get_size().width - timeline->get_buttons_width()) { // Can do something with menu too! show insert key. float offset = (pos.x - timeline->get_name_limit()) / timeline->get_zoom_scale(); - if (!menu) { - menu = memnew(PopupMenu); - add_child(menu); - menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); - } + if (!read_only) { + if (!menu) { + menu = memnew(PopupMenu); + add_child(menu); + menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); + } - menu->clear(); - menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT); - if (editor->is_selection_active()) { - menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); + menu->clear(); + menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT); + if (editor->is_selection_active()) { + menu->add_separator(); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); - AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player(); - if (!player->has_animation(SceneStringNames::get_singleton()->RESET) || animation != player->get_animation(SceneStringNames::get_singleton()->RESET)) { - menu->add_icon_item(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET); - } + AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player(); + if (!player->has_animation(SceneStringNames::get_singleton()->RESET) || animation != player->get_animation(SceneStringNames::get_singleton()->RESET)) { + menu->add_icon_item(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET); + } - menu->add_separator(); - menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); - } - menu->reset_size(); + menu->add_separator(); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); + } + menu->reset_size(); - menu->set_position(get_screen_position() + get_local_mouse_position()); - menu->popup(); + menu->set_position(get_screen_position() + get_local_mouse_position()); + menu->popup(); - insert_at_pos = offset + timeline->get_value(); - accept_event(); + insert_at_pos = offset + timeline->get_value(); + accept_event(); + } } } @@ -3354,7 +3409,7 @@ void AnimationTrackEditor::remove_track_edit_plugin(const Ref<AnimationTrackEdit track_edit_plugins.erase(p_plugin); } -void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { +void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_read_only) { if (animation != p_anim && _get_track_selected() >= 0) { track_edits[_get_track_selected()]->release_focus(); } @@ -3363,7 +3418,8 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { _clear_selection(); } animation = p_anim; - timeline->set_animation(p_anim); + read_only = p_read_only; + timeline->set_animation(p_anim, read_only); _cancel_bezier_edit(); _update_tracks(); @@ -3372,7 +3428,7 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { animation->connect("changed", callable_mp(this, &AnimationTrackEditor::_animation_changed)); hscroll->show(); - edit->set_disabled(false); + edit->set_disabled(read_only); step->set_block_signals(true); _update_step_spinbox(); @@ -3501,7 +3557,7 @@ void AnimationTrackEditor::set_state(const Dictionary &p_state) { } void AnimationTrackEditor::cleanup() { - set_animation(Ref<Animation>()); + set_animation(Ref<Animation>(), read_only); } void AnimationTrackEditor::_name_limit_changed() { @@ -4378,6 +4434,27 @@ void AnimationTrackEditor::_update_tracks() { return; } + bool read_only = false; + if (!animation->get_path().is_resource_file()) { + int srpos = animation->get_path().find("::"); + if (srpos != -1) { + String base = animation->get_path().substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + read_only = true; + } + } else { + if (FileAccess::exists(base + ".import")) { + read_only = true; + } + } + } + } else { + if (FileAccess::exists(animation->get_path() + ".import")) { + read_only = true; + } + } + RBMap<String, VBoxContainer *> group_sort; bool use_grouping = !view_group->is_pressed(); @@ -4506,7 +4583,7 @@ void AnimationTrackEditor::_update_tracks() { track_edit->set_undo_redo(undo_redo); track_edit->set_timeline(timeline); track_edit->set_root(root); - track_edit->set_animation_and_track(animation, i); + track_edit->set_animation_and_track(animation, i, read_only); track_edit->set_play_position(timeline->get_play_position()); track_edit->set_editor(this); @@ -5178,6 +5255,7 @@ void AnimationTrackEditor::_update_key_edit() { if (selection.size() == 1) { key_edit = memnew(AnimationTrackKeyEdit); key_edit->animation = animation; + key_edit->animation_read_only = read_only; key_edit->track = selection.front()->key().track; key_edit->use_fps = timeline->is_using_fps(); @@ -5194,6 +5272,7 @@ void AnimationTrackEditor::_update_key_edit() { } else if (selection.size() > 1) { multi_key_edit = memnew(AnimationMultiTrackKeyEdit); multi_key_edit->animation = animation; + multi_key_edit->animation_read_only = read_only; RBMap<int, List<float>> key_ofs_map; RBMap<int, NodePath> base_map; @@ -5473,7 +5552,7 @@ void AnimationTrackEditor::_cancel_bezier_edit() { void AnimationTrackEditor::_bezier_edit(int p_for_track) { _clear_selection(); // Bezier probably wants to use a separate selection mode. bezier_edit->set_root(root); - bezier_edit->set_animation_and_track(animation, p_for_track); + bezier_edit->set_animation_and_track(animation, p_for_track, read_only); scroll->hide(); bezier_edit->show(); // Search everything within the track and curve - edit it. diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index cb7d3c7d96..b0553c54a5 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -56,6 +56,8 @@ class AnimationTimelineEdit : public Range { GDCLASS(AnimationTimelineEdit, Range); Ref<Animation> animation; + bool read_only = false; + AnimationTrackEdit *track_edit = nullptr; int name_limit = 0; Range *zoom = nullptr; @@ -106,7 +108,7 @@ public: float get_zoom_scale() const; virtual Size2 get_minimum_size() const override; - void set_animation(const Ref<Animation> &p_animation); + void set_animation(const Ref<Animation> &p_animation, bool p_read_only); void set_track_edit(AnimationTrackEdit *p_track_edit); void set_zoom(Range *p_zoom); Range *get_zoom() const { return zoom; } @@ -159,6 +161,7 @@ class AnimationTrackEdit : public Control { NodePath node_path; Ref<Animation> animation; + bool read_only = false; int track = 0; Rect2 check_rect; @@ -232,7 +235,7 @@ public: AnimationTrackEditor *get_editor() const { return editor; } UndoRedo *get_undo_redo() const { return undo_redo; } NodePath get_path() const; - void set_animation_and_track(const Ref<Animation> &p_animation, int p_track); + void set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only); virtual Size2 get_minimum_size() const override; void set_undo_redo(UndoRedo *p_undo_redo); @@ -290,6 +293,7 @@ class AnimationTrackEditor : public VBoxContainer { GDCLASS(AnimationTrackEditor, VBoxContainer); Ref<Animation> animation; + bool read_only = false; Node *root = nullptr; MenuButton *edit = nullptr; @@ -533,7 +537,7 @@ public: void add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin); void remove_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin); - void set_animation(const Ref<Animation> &p_anim); + void set_animation(const Ref<Animation> &p_anim, bool p_read_only); Ref<Animation> get_current_animation() const; void set_root(Node *p_root); Node *get_root() const; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index b0eb384efc..9e72c8ec10 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1869,7 +1869,8 @@ CodeTextEditor::CodeTextEditor() { code_complete_func = nullptr; ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KeyModifierMask::CMD | Key::EQUAL); ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KeyModifierMask::CMD | Key::MINUS); - ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KeyModifierMask::CMD | Key::KEY_0); + ED_SHORTCUT_ARRAY("script_editor/reset_zoom", TTR("Reset Zoom"), + { int32_t(KeyModifierMask::CMD | Key::KEY_0), int32_t(KeyModifierMask::CMD | Key::KP_0) }); text_editor = memnew(CodeEdit); add_child(text_editor); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 2064b6f3a1..b4e36d568d 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2662,7 +2662,7 @@ void EditorInspector::update_tree() { _parse_added_editors(main_vbox, nullptr, ped); } - StringName type_name; + StringName doc_name; // Get the lists of editors for properties. for (List<PropertyInfo>::Element *E_property = plist.front(); E_property; E_property = E_property->next()) { @@ -2735,7 +2735,7 @@ void EditorInspector::update_tree() { String type = p.name; String label = p.name; - type_name = p.name; + doc_name = p.name; // Set the category icon. if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) { @@ -2746,6 +2746,10 @@ void EditorInspector::update_tree() { if (script.is_valid()) { base_type = script->get_instance_base_type(); name = EditorNode::get_editor_data().script_class_get_name(script->get_path()); + Vector<DocData::ClassDoc> docs = script->get_documentation(); + if (!docs.is_empty()) { + doc_name = docs[0].name; + } if (name != StringName() && label != name) { label = name; } @@ -2774,17 +2778,17 @@ void EditorInspector::update_tree() { if (use_doc_hints) { // Sets the category tooltip to show documentation. - if (!class_descr_cache.has(type_name)) { + if (!class_descr_cache.has(doc_name)) { String descr; DocTools *dd = EditorHelp::get_doc_data(); - HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(type_name); + HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(doc_name); if (E) { descr = DTR(E->value.brief_description); } - class_descr_cache[type_name] = descr; + class_descr_cache[doc_name] = descr; } - category->set_tooltip(p.name + "::" + (class_descr_cache[type_name].is_empty() ? "" : class_descr_cache[type_name])); + category->set_tooltip(p.name + "::" + (class_descr_cache[doc_name].is_empty() ? "" : class_descr_cache[doc_name])); } // Add editors at the start of a category. @@ -3082,7 +3086,7 @@ void EditorInspector::update_tree() { // Build the doc hint, to use as tooltip. // Get the class name. - StringName classname = type_name == "" ? object->get_class_name() : type_name; + StringName classname = doc_name == "" ? object->get_class_name() : doc_name; if (!object_class.is_empty()) { classname = object_class; } diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 34b407779e..b4d3973705 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -429,24 +429,21 @@ void EditorExportPlatform::_edit_filter_list(HashSet<String> &r_list, const Stri _edit_files_with_filter(da, filters, r_list, exclude); } -EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) const { +HashSet<String> EditorExportPlatform::get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const { Ref<EditorExportPlatform> platform = p_preset->get_platform(); List<String> feature_list; platform->get_platform_features(&feature_list); platform->get_preset_features(p_preset, &feature_list); - FeatureContainers result; + HashSet<String> result; for (const String &E : feature_list) { - result.features.insert(E); - result.features_pv.push_back(E); + result.insert(E); } if (p_debug) { - result.features.insert("debug"); - result.features_pv.push_back("debug"); + result.insert("debug"); } else { - result.features.insert("release"); - result.features_pv.push_back("release"); + result.insert("release"); } if (!p_preset->get_custom_features().is_empty()) { @@ -455,8 +452,7 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai for (int i = 0; i < tmp_custom_list.size(); i++) { String f = tmp_custom_list[i].strip_edges(); if (!f.is_empty()) { - result.features.insert(f); - result.features_pv.push_back(f); + result.insert(f); } } } @@ -465,14 +461,18 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai } EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { - FeatureContainers features = p_platform.get_feature_containers(p_preset, p_debug); + HashSet<String> features = p_platform.get_features(p_preset, p_debug); Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); //initial export plugin callback for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins.write[i]->_export_begin_script(features.features_pv, p_debug, p_path, p_flags); + PackedStringArray features_psa; + for (const String &feature : features) { + features_psa.push_back(feature); + } + export_plugins.write[i]->_export_begin_script(features_psa, p_debug, p_path, p_flags); } else { - export_plugins.write[i]->_export_begin(features.features, p_debug, p_path, p_flags); + export_plugins.write[i]->_export_begin(features, p_debug, p_path, p_flags); } } } @@ -621,9 +621,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & export_plugins.write[i]->_clear(); } - FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug); - HashSet<String> &features = feature_containers.features; - Vector<String> &features_pv = feature_containers.features_pv; + HashSet<String> features = get_features(p_preset, p_debug); //store everything in the export medium int idx = 0; @@ -709,7 +707,11 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & bool do_export = true; for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins.write[i]->_export_file_script(path, type, features_pv); + PackedStringArray features_psa; + for (const String &feature : features) { + features_psa.push_back(feature); + } + export_plugins.write[i]->_export_file_script(path, type, features_psa); } else { export_plugins.write[i]->_export_file(path, type, features); } diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 832a0cf846..ad1bcc1996 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -85,11 +85,6 @@ private: EditorProgress *ep = nullptr; }; - struct FeatureContainers { - HashSet<String> features; - Vector<String> features_pv; - }; - Vector<ExportMessage> messages; void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths); @@ -110,7 +105,7 @@ protected: ~ExportNotifier(); }; - FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) const; + HashSet<String> get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const; bool exists_export_template(String template_file_name, String *err) const; String find_export_template(String template_file_name, String *err = nullptr) const; diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index cb82cefbbb..76493d330f 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -219,6 +219,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { export_path->show(); duplicate_preset->set_disabled(false); delete_preset->set_disabled(false); + get_ok_button()->set_disabled(false); name->set_text(current->get_name()); List<String> extension_list = current->get_platform()->get_binary_extensions(current); @@ -265,7 +266,6 @@ void ProjectExportDialog::_edit_preset(int p_index) { export_warning->hide(); export_button->set_disabled(true); - get_ok_button()->set_disabled(true); } else { if (error != String()) { Vector<String> items = error.split("\n", false); @@ -285,7 +285,6 @@ void ProjectExportDialog::_edit_preset(int p_index) { export_error->hide(); export_templates_error->hide(); export_button->set_disabled(false); - get_ok_button()->set_disabled(false); } custom_features->set_text(current->get_custom_features()); diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index cae33edecb..c36ae1c521 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -149,13 +149,35 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { } switch (p_id) { case FILE_MENU_SAVE_LIBRARY: { - if (al->get_path().is_resource_file()) { + if (al->get_path().is_resource_file() && !FileAccess::exists(al->get_path() + ".import")) { EditorNode::get_singleton()->save_resource(al); break; } [[fallthrough]]; } case FILE_MENU_SAVE_AS_LIBRARY: { + // Check if we're allowed to save this + { + String al_path = al->get_path(); + if (!al_path.is_resource_file()) { + int srpos = al_path.find("::"); + if (srpos != -1) { + String base = al_path.substr(0, srpos); + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + error_dialog->set_text(TTR("This animation library can't be saved because it does not belong to the edited scene. Make it unique first.")); + error_dialog->popup_centered(); + return; + } + } + } else { + if (FileAccess::exists(al_path + ".import")) { + error_dialog->set_text(TTR("This animation library can't be saved because it was imported from another file. Make it unique first.")); + error_dialog->popup_centered(); + return; + } + } + } + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_title(TTR("Save Library")); if (al->get_path().is_resource_file()) { @@ -178,6 +200,9 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { Ref<AnimationLibrary> ald = al->duplicate(); + // TODO: should probably make all foreign animations assigned to this library + // unique too. + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); undo_redo->create_action(vformat(TTR("Make Animation Library Unique: %s"), lib_name)); undo_redo->add_do_method(player, "remove_animation_library", lib_name); @@ -188,19 +213,43 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { undo_redo->add_undo_method(this, "_update_editor", player); undo_redo->commit_action(); + update_tree(); + } break; case FILE_MENU_EDIT_LIBRARY: { EditorNode::get_singleton()->push_item(al.ptr()); } break; case FILE_MENU_SAVE_ANIMATION: { - if (anim->get_path().is_resource_file()) { + if (anim->get_path().is_resource_file() && !FileAccess::exists(anim->get_path() + ".import")) { EditorNode::get_singleton()->save_resource(anim); break; } [[fallthrough]]; } case FILE_MENU_SAVE_AS_ANIMATION: { + // Check if we're allowed to save this + { + String anim_path = al->get_path(); + if (!anim_path.is_resource_file()) { + int srpos = anim_path.find("::"); + if (srpos != -1) { + String base = anim_path.substr(0, srpos); + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + error_dialog->set_text(TTR("This animation can't be saved because it does not belong to the edited scene. Make it unique first.")); + error_dialog->popup_centered(); + return; + } + } + } else { + if (FileAccess::exists(anim_path + ".import")) { + error_dialog->set_text(TTR("This animation can't be saved because it was imported from another file. Make it unique first.")); + error_dialog->popup_centered(); + return; + } + } + } + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_title(TTR("Save Animation")); if (anim->get_path().is_resource_file()) { @@ -232,6 +281,8 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { undo_redo->add_do_method(this, "_update_editor", player); undo_redo->add_undo_method(this, "_update_editor", player); undo_redo->commit_action(); + + update_tree(); } break; case FILE_MENU_EDIT_ANIMATION: { EditorNode::get_singleton()->push_item(anim.ptr()); @@ -577,19 +628,45 @@ void AnimationLibraryEditor::update_tree() { } else { libitem->set_suffix(0, ""); } - libitem->set_editable(0, true); - libitem->set_metadata(0, K); - libitem->set_icon(0, get_theme_icon("AnimationLibrary", "EditorIcons")); - libitem->add_button(0, get_theme_icon("Add", "EditorIcons"), LIB_BUTTON_ADD, false, TTR("Add Animation to Library")); - libitem->add_button(0, get_theme_icon("Load", "EditorIcons"), LIB_BUTTON_LOAD, false, TTR("Load animation from file and add to library")); - libitem->add_button(0, get_theme_icon("ActionPaste", "EditorIcons"), LIB_BUTTON_PASTE, false, TTR("Paste Animation to Library from clipboard")); + Ref<AnimationLibrary> al = player->call("get_animation_library", K); - if (al->get_path().is_resource_file()) { - libitem->set_text(1, al->get_path().get_file()); - libitem->set_tooltip(1, al->get_path()); - } else { + bool animation_library_is_foreign = false; + String al_path = al->get_path(); + if (!al_path.is_resource_file()) { libitem->set_text(1, TTR("[built-in]")); + libitem->set_tooltip(1, al_path); + int srpos = al_path.find("::"); + if (srpos != -1) { + String base = al_path.substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + animation_library_is_foreign = true; + libitem->set_text(1, TTR("[foreign]")); + } + } else { + if (FileAccess::exists(base + ".import")) { + animation_library_is_foreign = true; + libitem->set_text(1, TTR("[imported]")); + } + } + } + } else { + if (FileAccess::exists(al_path + ".import")) { + animation_library_is_foreign = true; + libitem->set_text(1, TTR("[imported]")); + } else { + libitem->set_text(1, al_path.get_file()); + } } + + libitem->set_editable(0, !animation_library_is_foreign); + libitem->set_metadata(0, K); + libitem->set_icon(0, get_theme_icon("AnimationLibrary", "EditorIcons")); + + libitem->add_button(0, get_theme_icon("Add", "EditorIcons"), LIB_BUTTON_ADD, animation_library_is_foreign, TTR("Add Animation to Library")); + libitem->add_button(0, get_theme_icon("Load", "EditorIcons"), LIB_BUTTON_LOAD, animation_library_is_foreign, TTR("Load animation from file and add to library")); + libitem->add_button(0, get_theme_icon("ActionPaste", "EditorIcons"), LIB_BUTTON_PASTE, animation_library_is_foreign, TTR("Paste Animation to Library from clipboard")); + libitem->add_button(1, get_theme_icon("Save", "EditorIcons"), LIB_BUTTON_FILE, false, TTR("Save animation library to resource on disk")); libitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), LIB_BUTTON_DELETE, false, TTR("Remove animation library")); @@ -600,20 +677,38 @@ void AnimationLibraryEditor::update_tree() { for (const StringName &L : animations) { TreeItem *anitem = tree->create_item(libitem); anitem->set_text(0, L); - anitem->set_editable(0, true); + anitem->set_editable(0, !animation_library_is_foreign); anitem->set_metadata(0, L); anitem->set_icon(0, get_theme_icon("Animation", "EditorIcons")); - anitem->add_button(0, get_theme_icon("ActionCopy", "EditorIcons"), ANIM_BUTTON_COPY, false, TTR("Copy animation to clipboard")); - Ref<Animation> anim = al->get_animation(L); + anitem->add_button(0, get_theme_icon("ActionCopy", "EditorIcons"), ANIM_BUTTON_COPY, animation_library_is_foreign, TTR("Copy animation to clipboard")); - if (anim->get_path().is_resource_file()) { - anitem->set_text(1, anim->get_path().get_file()); - anitem->set_tooltip(1, anim->get_path()); - } else { + Ref<Animation> anim = al->get_animation(L); + String anim_path = anim->get_path(); + if (!anim_path.is_resource_file()) { anitem->set_text(1, TTR("[built-in]")); + anitem->set_tooltip(1, anim_path); + int srpos = anim_path.find("::"); + if (srpos != -1) { + String base = anim_path.substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + anitem->set_text(1, TTR("[foreign]")); + } + } else { + if (FileAccess::exists(base + ".import")) { + anitem->set_text(1, TTR("[imported]")); + } + } + } + } else { + if (FileAccess::exists(anim_path + ".import")) { + anitem->set_text(1, TTR("[imported]")); + } else { + anitem->set_text(1, anim_path.get_file()); + } } - anitem->add_button(1, get_theme_icon("Save", "EditorIcons"), ANIM_BUTTON_FILE, false, TTR("Save animation to resource on disk")); - anitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), ANIM_BUTTON_DELETE, false, TTR("Remove animation from Library")); + anitem->add_button(1, get_theme_icon("Save", "EditorIcons"), ANIM_BUTTON_FILE, animation_library_is_foreign, TTR("Save animation to resource on disk")); + anitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), ANIM_BUTTON_DELETE, animation_library_is_foreign, TTR("Remove animation from Library")); } } } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index ebd7525bb8..516079673d 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -55,7 +55,7 @@ void AnimationPlayerEditor::_node_removed(Node *p_node) { set_process(false); - track_editor->set_animation(Ref<Animation>()); + track_editor->set_animation(Ref<Animation>(), true); track_editor->set_root(nullptr); track_editor->show_select_node_warning(true); _update_player(); @@ -283,7 +283,28 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { Ref<Animation> anim = player->get_animation(current); { - track_editor->set_animation(anim); + bool animation_library_is_foreign = false; + if (!anim->get_path().is_resource_file()) { + int srpos = anim->get_path().find("::"); + if (srpos != -1) { + String base = anim->get_path().substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + animation_library_is_foreign = true; + } + } else { + if (FileAccess::exists(base + ".import")) { + animation_library_is_foreign = true; + } + } + } + } else { + if (FileAccess::exists(anim->get_path() + ".import")) { + animation_library_is_foreign = true; + } + } + + track_editor->set_animation(anim, animation_library_is_foreign); Node *root = player->get_node(player->get_root()); if (root) { track_editor->set_root(root); @@ -292,7 +313,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { frame->set_max((double)anim->get_length()); } else { - track_editor->set_animation(Ref<Animation>()); + track_editor->set_animation(Ref<Animation>(), true); track_editor->set_root(nullptr); } @@ -751,14 +772,36 @@ void AnimationPlayerEditor::_animation_edit() { String current = _get_current(); if (current != String()) { Ref<Animation> anim = player->get_animation(current); - track_editor->set_animation(anim); + + bool animation_library_is_foreign = false; + if (!anim->get_path().is_resource_file()) { + int srpos = anim->get_path().find("::"); + if (srpos != -1) { + String base = anim->get_path().substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + animation_library_is_foreign = true; + } + } else { + if (FileAccess::exists(base + ".import")) { + animation_library_is_foreign = true; + } + } + } + } else { + if (FileAccess::exists(anim->get_path() + ".import")) { + animation_library_is_foreign = true; + } + } + + track_editor->set_animation(anim, animation_library_is_foreign); Node *root = player->get_node(player->get_root()); if (root) { track_editor->set_root(root); } } else { - track_editor->set_animation(Ref<Animation>()); + track_editor->set_animation(Ref<Animation>(), true); track_editor->set_root(nullptr); } } @@ -812,13 +855,37 @@ void AnimationPlayerEditor::_update_player() { int active_idx = -1; bool no_anims_found = true; + bool foreign_global_anim_lib = false; for (const StringName &K : libraries) { if (K != StringName()) { animation->add_separator(K); } + // Check if the global library is foreign since we want to disable options for adding/remove/renaming animations if it is. Ref<AnimationLibrary> library = player->get_animation_library(K); + if (K == "") { + if (!library->get_path().is_resource_file()) { + int srpos = library->get_path().find("::"); + if (srpos != -1) { + String base = library->get_path().substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + foreign_global_anim_lib = true; + } + } else { + if (FileAccess::exists(base + ".import")) { + foreign_global_anim_lib = true; + } + } + } + } else { + if (FileAccess::exists(library->get_path() + ".import")) { + foreign_global_anim_lib = true; + } + } + } + List<StringName> animlist; library->get_animation_list(&animlist); @@ -835,7 +902,13 @@ void AnimationPlayerEditor::_update_player() { no_anims_found = false; } } -#define ITEM_CHECK_DISABLED(m_item) tool_anim->get_popup()->set_item_disabled(tool_anim->get_popup()->get_item_index(m_item), no_anims_found) +#define ITEM_CHECK_DISABLED(m_item) tool_anim->get_popup()->set_item_disabled(tool_anim->get_popup()->get_item_index(m_item), foreign_global_anim_lib) + + ITEM_CHECK_DISABLED(TOOL_NEW_ANIM); + +#undef ITEM_CHECK_DISABLED + +#define ITEM_CHECK_DISABLED(m_item) tool_anim->get_popup()->set_item_disabled(tool_anim->get_popup()->get_item_index(m_item), no_anims_found || foreign_global_anim_lib) ITEM_CHECK_DISABLED(TOOL_DUPLICATE_ANIM); ITEM_CHECK_DISABLED(TOOL_RENAME_ANIM); @@ -877,7 +950,29 @@ void AnimationPlayerEditor::_update_player() { if (!no_anims_found) { String current = animation->get_item_text(animation->get_selected()); Ref<Animation> anim = player->get_animation(current); - track_editor->set_animation(anim); + + bool animation_library_is_foreign = false; + if (!anim->get_path().is_resource_file()) { + int srpos = anim->get_path().find("::"); + if (srpos != -1) { + String base = anim->get_path().substr(0, srpos); + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { + animation_library_is_foreign = true; + } + } else { + if (FileAccess::exists(base + ".import")) { + animation_library_is_foreign = true; + } + } + } + } else { + if (FileAccess::exists(anim->get_path() + ".import")) { + animation_library_is_foreign = true; + } + } + + track_editor->set_animation(anim, animation_library_is_foreign); Node *root = player->get_node(player->get_root()); if (root) { track_editor->set_root(root); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ac85eb5e1b..fc70ace331 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5020,17 +5020,36 @@ CanvasItemEditor::CanvasItemEditor() { controls_vb->set_begin(Point2(5, 5)); // To ensure that scripts can parse the list of shortcuts correctly, we have to define - // those shortcuts one by one. Define shortcut before using it (by EditorZoomWidget) - ED_SHORTCUT("canvas_item_editor/zoom_3.125_percent", TTR("Zoom to 3.125%"), KeyModifierMask::SHIFT | Key::KEY_5); - ED_SHORTCUT("canvas_item_editor/zoom_6.25_percent", TTR("Zoom to 6.25%"), KeyModifierMask::SHIFT | Key::KEY_4); - ED_SHORTCUT("canvas_item_editor/zoom_12.5_percent", TTR("Zoom to 12.5%"), KeyModifierMask::SHIFT | Key::KEY_3); - ED_SHORTCUT("canvas_item_editor/zoom_25_percent", TTR("Zoom to 25%"), KeyModifierMask::SHIFT | Key::KEY_2); - ED_SHORTCUT("canvas_item_editor/zoom_50_percent", TTR("Zoom to 50%"), KeyModifierMask::SHIFT | Key::KEY_1); - ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_100_percent", TTR("Zoom to 100%"), { (int32_t)Key::KEY_1, (int32_t)(KeyModifierMask::CMD | Key::KEY_0) }); - ED_SHORTCUT("canvas_item_editor/zoom_200_percent", TTR("Zoom to 200%"), Key::KEY_2); - ED_SHORTCUT("canvas_item_editor/zoom_400_percent", TTR("Zoom to 400%"), Key::KEY_3); - ED_SHORTCUT("canvas_item_editor/zoom_800_percent", TTR("Zoom to 800%"), Key::KEY_4); - ED_SHORTCUT("canvas_item_editor/zoom_1600_percent", TTR("Zoom to 1600%"), Key::KEY_5); + // those shortcuts one by one. Define shortcut before using it (by EditorZoomWidget). + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_3.125_percent", TTR("Zoom to 3.125%"), + { int32_t(KeyModifierMask::SHIFT | Key::KEY_5), int32_t(KeyModifierMask::SHIFT | Key::KP_5) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_6.25_percent", TTR("Zoom to 6.25%"), + { int32_t(KeyModifierMask::SHIFT | Key::KEY_4), int32_t(KeyModifierMask::SHIFT | Key::KP_4) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_12.5_percent", TTR("Zoom to 12.5%"), + { int32_t(KeyModifierMask::SHIFT | Key::KEY_3), int32_t(KeyModifierMask::SHIFT | Key::KP_3) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_25_percent", TTR("Zoom to 25%"), + { int32_t(KeyModifierMask::SHIFT | Key::KEY_2), int32_t(KeyModifierMask::SHIFT | Key::KP_2) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_50_percent", TTR("Zoom to 50%"), + { int32_t(KeyModifierMask::SHIFT | Key::KEY_1), int32_t(KeyModifierMask::SHIFT | Key::KP_1) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_100_percent", TTR("Zoom to 100%"), + { int32_t(Key::KEY_1), int32_t(KeyModifierMask::CMD | Key::KEY_0), int32_t(Key::KP_1), int32_t(KeyModifierMask::CMD | Key::KP_0) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_200_percent", TTR("Zoom to 200%"), + { int32_t(Key::KEY_2), int32_t(Key::KP_2) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_400_percent", TTR("Zoom to 400%"), + { int32_t(Key::KEY_3), int32_t(Key::KP_3) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_800_percent", TTR("Zoom to 800%"), + { int32_t(Key::KEY_4), int32_t(Key::KP_4) }); + + ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_1600_percent", TTR("Zoom to 1600%"), + { int32_t(Key::KEY_5), int32_t(Key::KP_5) }); zoom_widget = memnew(EditorZoomWidget); controls_vb->add_child(zoom_widget); diff --git a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj index 69899cbe8d..467aa3ce83 100644 --- a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj +++ b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 1F1575721F582BE20003B888 /* dylibs in Resources */ = {isa = PBXBuildFile; fileRef = 1F1575711F582BE20003B888 /* dylibs */; }; DEADBEEF2F582BE20003B888 /* $binary.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEADBEEF1F582BE20003B888 /* $binary.xcframework */; }; $modules_buildfile + $swift_runtime_buildfile 1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */; }; D07CD44E1C5D589C00B7FB28 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D07CD44D1C5D589C00B7FB28 /* Images.xcassets */; }; 9039D3BE24C093AC0020482C /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9039D3BD24C093AC0020482C /* MoltenVK.xcframework */; }; @@ -37,6 +38,7 @@ 1F1575711F582BE20003B888 /* dylibs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dylibs; path = "$binary/dylibs"; sourceTree = "<group>"; }; DEADBEEF1F582BE20003B888 /* $binary.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = godot; path = "$binary.xcframework"; sourceTree = "<group>"; }; $modules_fileref + $swift_runtime_fileref 1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = "<group>"; }; 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = "<group>"; }; 9039D3BD24C093AC0020482C /* MoltenVK.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = MoltenVK; path = MoltenVK.xcframework; sourceTree = "<group>"; }; @@ -107,6 +109,7 @@ D07CD44D1C5D589C00B7FB28 /* Images.xcassets */, D0BCFE4218AEBDA2004A7AAE /* Supporting Files */, 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */, + $swift_runtime_binary_files ); path = "$binary"; sourceTree = "<group>"; @@ -152,6 +155,7 @@ TargetAttributes = { D0BCFE3318AEBDA2004A7AAE = { DevelopmentTeam = $team_id; + $swift_runtime_migration ProvisioningStyle = Automatic; SystemCapabilities = { }; @@ -198,6 +202,7 @@ buildActionMask = 2147483647; files = ( 1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */, + $swift_runtime_build_phase ); runOnlyForDeploymentPostprocessing = 0; }; @@ -329,6 +334,7 @@ TARGETED_DEVICE_FAMILY = "$targeted_device_family"; VALID_ARCHS = "arm64 x86_64"; WRAPPER_EXTENSION = app; + $swift_runtime_build_settings }; name = Debug; }; @@ -360,6 +366,7 @@ TARGETED_DEVICE_FAMILY = "$targeted_device_family"; VALID_ARCHS = "arm64 x86_64"; WRAPPER_EXTENSION = app; + $swift_runtime_build_settings }; name = Release; }; diff --git a/misc/dist/ios_xcode/godot_ios/dummy.h b/misc/dist/ios_xcode/godot_ios/dummy.h new file mode 100644 index 0000000000..ea6c0f78e4 --- /dev/null +++ b/misc/dist/ios_xcode/godot_ios/dummy.h @@ -0,0 +1,31 @@ +/*************************************************************************/ +/* dummy.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +// #import <Foundation/Foundation.h> diff --git a/misc/dist/ios_xcode/godot_ios/dummy.swift b/misc/dist/ios_xcode/godot_ios/dummy.swift new file mode 100644 index 0000000000..86c76b64d3 --- /dev/null +++ b/misc/dist/ios_xcode/godot_ios/dummy.swift @@ -0,0 +1,31 @@ +/*************************************************************************/ +/* dummy.swift */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +import Foundation diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index dc6bfbb034..8a5e93eeff 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -290,7 +290,9 @@ void GDScript::_get_script_method_list(List<MethodInfo> *r_list, bool p_include_ #endif mi.arguments.push_back(arginfo); } - +#ifdef TOOLS_ENABLED + mi.default_arguments.append_array(func->get_default_arg_values()); +#endif mi.return_val = func->get_return_type(); r_list->push_back(mi); } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index d943974ce4..c18412bc63 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -660,7 +660,13 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool } static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_function, int p_arg_idx) { - String arghint = p_function->get_datatype().to_string() + " " + p_function->identifier->name.operator String() + "("; + String arghint; + + if (p_function->get_datatype().builtin_type == Variant::NIL) { + arghint = "void " + p_function->identifier->name.operator String() + "("; + } else { + arghint = p_function->get_datatype().to_string() + " " + p_function->identifier->name.operator String() + "("; + } for (int i = 0; i < p_function->parameters.size(); i++) { if (i > 0) { @@ -671,7 +677,11 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio arghint += String::chr(0xFFFF); } const GDScriptParser::ParameterNode *par = p_function->parameters[i]; - arghint += par->identifier->name.operator String() + ": " + par->get_datatype().to_string(); + if (!par->get_datatype().is_hard_type()) { + arghint += par->identifier->name.operator String() + ": Variant"; + } else { + arghint += par->identifier->name.operator String() + ": " + par->get_datatype().to_string(); + } if (par->default_value) { String def_val = "<unknown>"; @@ -2517,39 +2527,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c GDScriptCompletionIdentifier connect_base; - if (Variant::has_utility_function(call->function_name)) { - MethodInfo info = Variant::get_utility_function_info(call->function_name); - r_arghint = _make_arguments_hint(info, p_argidx); - return; - } else if (GDScriptUtilityFunctions::function_exists(call->function_name)) { - MethodInfo info = GDScriptUtilityFunctions::get_function_info(call->function_name); - r_arghint = _make_arguments_hint(info, p_argidx); - return; - } else if (GDScriptParser::get_builtin_type(call->function_name) < Variant::VARIANT_MAX) { - // Complete constructor. - List<MethodInfo> constructors; - Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); - - int i = 0; - for (const MethodInfo &E : constructors) { - if (p_argidx >= E.arguments.size()) { - continue; - } - if (i > 0) { - r_arghint += "\n"; - } - r_arghint += _make_arguments_hint(E, p_argidx); - i++; - } - return; - } else if (call->is_super || callee_type == GDScriptParser::Node::IDENTIFIER) { - base = p_context.base; - - if (p_context.current_class) { - base_type = p_context.current_class->get_datatype(); - _static = !p_context.current_function || p_context.current_function->is_static; - } - } else if (callee_type == GDScriptParser::Node::SUBSCRIPT) { + if (callee_type == GDScriptParser::Node::SUBSCRIPT) { const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(call->callee); if (subscript->base != nullptr && subscript->base->type == GDScriptParser::Node::IDENTIFIER) { @@ -2589,6 +2567,38 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c _static = base_type.is_meta_type; } + } else if (Variant::has_utility_function(call->function_name)) { + MethodInfo info = Variant::get_utility_function_info(call->function_name); + r_arghint = _make_arguments_hint(info, p_argidx); + return; + } else if (GDScriptUtilityFunctions::function_exists(call->function_name)) { + MethodInfo info = GDScriptUtilityFunctions::get_function_info(call->function_name); + r_arghint = _make_arguments_hint(info, p_argidx); + return; + } else if (GDScriptParser::get_builtin_type(call->function_name) < Variant::VARIANT_MAX) { + // Complete constructor. + List<MethodInfo> constructors; + Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); + + int i = 0; + for (const MethodInfo &E : constructors) { + if (p_argidx >= E.arguments.size()) { + continue; + } + if (i > 0) { + r_arghint += "\n"; + } + r_arghint += _make_arguments_hint(E, p_argidx); + i++; + } + return; + } else if (call->is_super || callee_type == GDScriptParser::Node::IDENTIFIER) { + base = p_context.base; + + if (p_context.current_class) { + base_type = p_context.current_class->get_datatype(); + _static = !p_context.current_function || p_context.current_function->is_static; + } } else { return; } diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index a168e6108f..adf51ab59e 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -196,6 +196,8 @@ </member> <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]"> </member> + <member name="create_animations" type="bool" setter="set_create_animations" getter="get_create_animations" default="true"> + </member> <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()"> </member> <member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}"> diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp index 3fadec5167..161808aade 100644 --- a/modules/gltf/editor/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp @@ -60,6 +60,9 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t } return nullptr; } + if (p_options.has("animation/import")) { + state->set_create_animations(bool(p_options["animation/import"])); + } return doc->generate_scene(state, p_bake_fps); } diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7e90f198f6..d102970932 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -6899,7 +6899,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) { Node *root = gltf_root_node->get_parent(); ERR_FAIL_NULL_V(root, nullptr); _process_mesh_instances(state, root); - if (state->animations.size()) { + if (state->get_create_animations() && state->animations.size()) { AnimationPlayer *ap = memnew(AnimationPlayer); root->add_child(ap, true); ap->set_owner(root); diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index a5f7bcf9d6..8212e4c22f 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -79,6 +79,8 @@ void GLTFState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons); ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node); ClassDB::bind_method(D_METHOD("set_skeleton_to_node", "skeleton_to_node"), &GLTFState::set_skeleton_to_node); + ClassDB::bind_method(D_METHOD("get_create_animations"), &GLTFState::get_create_animations); + ClassDB::bind_method(D_METHOD("set_create_animations", "create_animations"), &GLTFState::set_create_animations); ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations); ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations); ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node); @@ -106,6 +108,7 @@ void GLTFState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>> ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // RBMap<GLTFSkeletonIndex, + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations"), "set_create_animations", "get_create_animations"); // bool ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>> } @@ -285,6 +288,14 @@ void GLTFState::set_skeleton_to_node(Dictionary p_skeleton_to_node) { GLTFTemplateConvert::set_from_dict(skeleton_to_node, p_skeleton_to_node); } +bool GLTFState::get_create_animations() { + return create_animations; +} + +void GLTFState::set_create_animations(bool p_create_animations) { + create_animations = p_create_animations; +} + Array GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index d2a4948f06..c08132f874 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -61,6 +61,7 @@ class GLTFState : public Resource { bool use_named_skin_binds = false; bool use_khr_texture_transform = false; bool discard_meshes_and_materials = false; + bool create_animations = true; Vector<Ref<GLTFNode>> nodes; Vector<Vector<uint8_t>> buffers; @@ -168,6 +169,9 @@ public: Dictionary get_skeleton_to_node(); void set_skeleton_to_node(Dictionary p_skeleton_to_node); + bool get_create_animations(); + void set_create_animations(bool p_create_animations); + Array get_animations(); void set_animations(Array p_animations); diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index 09f0ff32f0..518e2cf97d 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -896,10 +896,12 @@ void GridMapEditor::update_palette() { } if (selected != -1 && mesh_library_palette->get_item_count() > 0) { - mesh_library_palette->select(selected); + // Make sure that this variable is set correctly. + selected_palette = MIN(selected, mesh_library_palette->get_item_count() - 1); + mesh_library_palette->select(selected_palette); } - last_mesh_library = mesh_library.operator->(); + last_mesh_library = *mesh_library; } void GridMapEditor::edit(GridMap *p_gridmap) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs index 72fe9cb16f..4af817455c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -140,7 +140,6 @@ namespace Godot } } - /// <summary> /// Returns a new vector with all components in absolute values (i.e. positive). /// </summary> @@ -178,16 +177,59 @@ namespace Godot ); } + /// <summary> + /// Performs a cubic interpolation between vectors <paramref name="preA"/>, this vector, + /// <paramref name="b"/>, and <paramref name="postB"/>, by the given amount <paramref name="weight"/>. + /// </summary> + /// <param name="b">The destination vector.</param> + /// <param name="preA">A vector before this vector.</param> + /// <param name="postB">A vector after <paramref name="b"/>.</param> + /// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param> + /// <returns>The interpolated vector.</returns> + public Vector4 CubicInterpolate(Vector4 b, Vector4 preA, Vector4 postB, real_t weight) + { + return new Vector4 + ( + Mathf.CubicInterpolate(x, b.x, preA.x, postB.x, weight), + Mathf.CubicInterpolate(y, b.y, preA.y, postB.y, weight), + Mathf.CubicInterpolate(y, b.z, preA.z, postB.z, weight), + Mathf.CubicInterpolate(w, b.w, preA.w, postB.w, weight) + ); + } /// <summary> - /// Returns a new vector with all components rounded down (towards negative infinity). + /// Returns the normalized vector pointing from this vector to <paramref name="to"/>. /// </summary> - /// <returns>A vector with <see cref="Mathf.Floor"/> called on each component.</returns> - public Vector4 Floor() + /// <param name="to">The other vector to point towards.</param> + /// <returns>The direction from this vector to <paramref name="to"/>.</returns> + public Vector4 DirectionTo(Vector4 to) { - return new Vector4(Mathf.Floor(x), Mathf.Floor(y), Mathf.Floor(z), Mathf.Floor(w)); + Vector4 ret = new Vector4(to.x - x, to.y - y, to.z - z, to.w - w); + ret.Normalize(); + return ret; } + /// <summary> + /// Returns the squared distance between this vector and <paramref name="to"/>. + /// This method runs faster than <see cref="DistanceTo"/>, so prefer it if + /// you need to compare vectors or need the squared distance for some formula. + /// </summary> + /// <param name="to">The other vector to use.</param> + /// <returns>The squared distance between the two vectors.</returns> + public real_t DistanceSquaredTo(Vector4 to) + { + return (to - this).LengthSquared(); + } + + /// <summary> + /// Returns the distance between this vector and <paramref name="to"/>. + /// </summary> + /// <param name="to">The other vector to use.</param> + /// <returns>The distance between the two vectors.</returns> + public real_t DistanceTo(Vector4 to) + { + return (to - this).Length(); + } /// <summary> /// Returns the dot product of this vector and <paramref name="with"/>. @@ -200,6 +242,15 @@ namespace Godot } /// <summary> + /// Returns a new vector with all components rounded down (towards negative infinity). + /// </summary> + /// <returns>A vector with <see cref="Mathf.Floor"/> called on each component.</returns> + public Vector4 Floor() + { + return new Vector4(Mathf.Floor(x), Mathf.Floor(y), Mathf.Floor(z), Mathf.Floor(w)); + } + + /// <summary> /// Returns the inverse of this vector. This is the same as <c>new Vector4(1 / v.x, 1 / v.y, 1 / v.z, 1 / v.w)</c>. /// </summary> /// <returns>The inverse of this vector.</returns> @@ -318,6 +369,42 @@ namespace Godot } /// <summary> + /// Returns a vector composed of the <see cref="Mathf.PosMod(real_t, real_t)"/> of this vector's components + /// and <paramref name="mod"/>. + /// </summary> + /// <param name="mod">A value representing the divisor of the operation.</param> + /// <returns> + /// A vector with each component <see cref="Mathf.PosMod(real_t, real_t)"/> by <paramref name="mod"/>. + /// </returns> + public Vector4 PosMod(real_t mod) + { + return new Vector4( + Mathf.PosMod(x, mod), + Mathf.PosMod(y, mod), + Mathf.PosMod(z, mod), + Mathf.PosMod(w, mod) + ); + } + + /// <summary> + /// Returns a vector composed of the <see cref="Mathf.PosMod(real_t, real_t)"/> of this vector's components + /// and <paramref name="modv"/>'s components. + /// </summary> + /// <param name="modv">A vector representing the divisors of the operation.</param> + /// <returns> + /// A vector with each component <see cref="Mathf.PosMod(real_t, real_t)"/> by <paramref name="modv"/>'s components. + /// </returns> + public Vector4 PosMod(Vector4 modv) + { + return new Vector4( + Mathf.PosMod(x, modv.x), + Mathf.PosMod(y, modv.y), + Mathf.PosMod(z, modv.z), + Mathf.PosMod(w, modv.w) + ); + } + + /// <summary> /// Returns this vector with all components rounded to the nearest integer, /// with halfway cases rounded towards the nearest multiple of two. /// </summary> @@ -343,6 +430,21 @@ namespace Godot return v; } + /// <summary> + /// Returns this vector with each component snapped to the nearest multiple of <paramref name="step"/>. + /// This can also be used to round to an arbitrary number of decimals. + /// </summary> + /// <param name="step">A vector value representing the step size to snap to.</param> + public Vector4 Snapped(Vector4 step) + { + return new Vector4( + Mathf.Snapped(x, step.x), + Mathf.Snapped(y, step.y), + Mathf.Snapped(z, step.z), + Mathf.Snapped(w, step.w) + ); + } + // Constants private static readonly Vector4 _zero = new Vector4(0, 0, 0, 0); private static readonly Vector4 _one = new Vector4(1, 1, 1, 1); diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 2ac44ccf8b..001c9b803d 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -413,6 +413,35 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_ } } strnew += lines[i].replace("$pbx_locale_build_reference", locale_files); + } else if (lines[i].find("$swift_runtime_migration") != -1) { + String value = !p_config.use_swift_runtime ? "" : "LastSwiftMigration = 1250;"; + strnew += lines[i].replace("$swift_runtime_migration", value) + "\n"; + } else if (lines[i].find("$swift_runtime_build_settings") != -1) { + String value = !p_config.use_swift_runtime ? "" : R"( + CLANG_ENABLE_MODULES = YES; + SWIFT_OBJC_BRIDGING_HEADER = "$binary/dummy.h"; + SWIFT_VERSION = 5.0; + )"; + value = value.replace("$binary", p_config.binary_name); + strnew += lines[i].replace("$swift_runtime_build_settings", value) + "\n"; + } else if (lines[i].find("$swift_runtime_fileref") != -1) { + String value = !p_config.use_swift_runtime ? "" : R"( + 90B4C2AA2680BC560039117A /* dummy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dummy.h"; sourceTree = "<group>"; }; + 90B4C2B52680C7E90039117A /* dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "dummy.swift"; sourceTree = "<group>"; }; + )"; + strnew += lines[i].replace("$swift_runtime_fileref", value) + "\n"; + } else if (lines[i].find("$swift_runtime_binary_files") != -1) { + String value = !p_config.use_swift_runtime ? "" : R"( + 90B4C2AA2680BC560039117A /* dummy.h */, + 90B4C2B52680C7E90039117A /* dummy.swift */, + )"; + strnew += lines[i].replace("$swift_runtime_binary_files", value) + "\n"; + } else if (lines[i].find("$swift_runtime_buildfile") != -1) { + String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B4C2B52680C7E90039117A /* dummy.swift */; };"; + strnew += lines[i].replace("$swift_runtime_buildfile", value) + "\n"; + } else if (lines[i].find("$swift_runtime_build_phase") != -1) { + String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift */,"; + strnew += lines[i].replace("$swift_runtime_build_phase", value) + "\n"; } else { strnew += lines[i] + "\n"; } @@ -1298,6 +1327,10 @@ Error EditorExportPlatformIOS::_export_ios_plugins(const Ref<EditorExportPreset> plugin_initialization_cpp_code += "\t" + initialization_method; plugin_deinitialization_cpp_code += "\t" + deinitialization_method; + + if (plugin.use_swift_runtime) { + p_config_data.use_swift_runtime = true; + } } // Updating `Info.plist` @@ -1479,7 +1512,8 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p "", "", "", - Vector<String>() + Vector<String>(), + false }; Vector<IOSExportAsset> assets; diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index 07e30c1d00..e32aef82dd 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -79,6 +79,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { String modules_buildphase; String modules_buildgrp; Vector<String> capabilities; + bool use_swift_runtime; }; struct ExportArchitecture { String name; diff --git a/platform/ios/export/godot_plugin_config.cpp b/platform/ios/export/godot_plugin_config.cpp index 9118b95337..24a95a11a4 100644 --- a/platform/ios/export/godot_plugin_config.cpp +++ b/platform/ios/export/godot_plugin_config.cpp @@ -184,6 +184,7 @@ PluginConfigIOS PluginConfigIOS::load_plugin_config(Ref<ConfigFile> config_file, String config_base_dir = path.get_base_dir(); plugin_config.name = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_NAME_KEY, String()); + plugin_config.use_swift_runtime = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_USE_SWIFT_KEY, false); plugin_config.initialization_method = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_INITIALIZE_KEY, String()); plugin_config.deinitialization_method = config_file->get_value(PluginConfigIOS::CONFIG_SECTION, PluginConfigIOS::CONFIG_DEINITIALIZE_KEY, String()); diff --git a/platform/ios/export/godot_plugin_config.h b/platform/ios/export/godot_plugin_config.h index 5ca8b05b42..98e8456ed5 100644 --- a/platform/ios/export/godot_plugin_config.h +++ b/platform/ios/export/godot_plugin_config.h @@ -39,6 +39,7 @@ The `config` section and fields are required and defined as follow: - **name**: name of the plugin - **binary**: path to static `.a` library +- **use_swift_runtime**: optional boolean field used to determine if Swift runtime is used The `dependencies` and fields are optional. - **linked**: dependencies that should only be linked. @@ -57,6 +58,7 @@ struct PluginConfigIOS { inline static const char *CONFIG_SECTION = "config"; inline static const char *CONFIG_NAME_KEY = "name"; inline static const char *CONFIG_BINARY_KEY = "binary"; + inline static const char *CONFIG_USE_SWIFT_KEY = "use_swift_runtime"; inline static const char *CONFIG_INITIALIZE_KEY = "initialization"; inline static const char *CONFIG_DEINITIALIZE_KEY = "deinitialization"; @@ -93,6 +95,7 @@ struct PluginConfigIOS { // Required config section String name; String binary; + bool use_swift_runtime; String initialization_method; String deinitialization_method; diff --git a/platform/ios/platform_config.h b/platform/ios/platform_config.h index fed77d8932..3af08b0d65 100644 --- a/platform/ios/platform_config.h +++ b/platform/ios/platform_config.h @@ -32,8 +32,6 @@ #define OPENGL_INCLUDE_H <ES3/gl.h> -#define PLATFORM_REFCOUNT - #define PTHREAD_RENAME_SELF #define _weakify(var) __weak typeof(var) GDWeak_##var = var; diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index e306c1054b..197d31dc81 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -368,6 +368,7 @@ Vector<String> OS_LinuxBSD::get_system_fonts() const { FcPatternDestroy(pattern); } FcObjectSetDestroy(object_set); + FcConfigDestroy(config); for (const String &E : font_names) { ret.push_back(E); @@ -417,6 +418,8 @@ String OS_LinuxBSD::get_system_font_path(const String &p_font_name, bool p_bold, FcPatternDestroy(pattern); } FcObjectSetDestroy(object_set); + FcConfigDestroy(config); + return ret; #else ERR_FAIL_V_MSG(String(), "Godot was compiled without fontconfig, system font support is disabled."); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index ce22f32b01..2ead48c889 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1823,6 +1823,10 @@ real_t KinematicCollision2D::get_angle(const Vector2 &p_up_direction) const { return result.get_angle(p_up_direction); } +real_t KinematicCollision2D::get_depth() const { + return result.collision_depth; +} + Object *KinematicCollision2D::get_local_shape() const { if (!owner) { return nullptr; @@ -1874,6 +1878,7 @@ void KinematicCollision2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision2D::get_travel); ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision2D::get_remainder); ClassDB::bind_method(D_METHOD("get_angle", "up_direction"), &KinematicCollision2D::get_angle, DEFVAL(Vector2(0.0, -1.0))); + ClassDB::bind_method(D_METHOD("get_depth"), &KinematicCollision2D::get_depth); ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision2D::get_local_shape); ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision2D::get_collider); ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision2D::get_collider_id); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 7401fc7578..c762a832c4 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -473,6 +473,7 @@ public: Vector2 get_travel() const; Vector2 get_remainder() const; real_t get_angle(const Vector2 &p_up_direction = Vector2(0.0, -1.0)) const; + real_t get_depth() const; Object *get_local_shape() const; Object *get_collider() const; ObjectID get_collider_id() const; diff --git a/scene/3d/label_3d.h b/scene/3d/label_3d.h index 4498e89517..d4bfe743a6 100644 --- a/scene/3d/label_3d.h +++ b/scene/3d/label_3d.h @@ -55,7 +55,7 @@ public: }; private: - real_t pixel_size = 0.01; + real_t pixel_size = 0.005; bool flags[FLAG_MAX] = {}; AlphaCutMode alpha_cut = ALPHA_CUT_DISABLED; float alpha_scissor_threshold = 0.5; @@ -109,7 +109,7 @@ private: TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_OFF; float width = 500.0; - int font_size = 16; + int font_size = 32; Ref<Font> font_override; mutable Ref<Font> theme_font; Color modulate = Color(1, 1, 1, 1); @@ -117,7 +117,7 @@ private: int outline_render_priority = -1; int render_priority = 0; - int outline_size = 0; + int outline_size = 12; Color outline_modulate = Color(0, 0, 0, 1); float line_spacing = 0.f; diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 993608c306..cbdef02826 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -2057,6 +2057,10 @@ int KinematicCollision3D::get_collision_count() const { return result.collision_count; } +real_t KinematicCollision3D::get_depth() const { + return result.collision_depth; +} + Vector3 KinematicCollision3D::get_position(int p_collision_index) const { ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3()); return result.collisions[p_collision_index].position; @@ -2127,6 +2131,7 @@ Vector3 KinematicCollision3D::get_collider_velocity(int p_collision_index) const void KinematicCollision3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision3D::get_travel); ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision3D::get_remainder); + ClassDB::bind_method(D_METHOD("get_depth"), &KinematicCollision3D::get_depth); ClassDB::bind_method(D_METHOD("get_collision_count"), &KinematicCollision3D::get_collision_count); ClassDB::bind_method(D_METHOD("get_position", "collision_index"), &KinematicCollision3D::get_position, DEFVAL(0)); ClassDB::bind_method(D_METHOD("get_normal", "collision_index"), &KinematicCollision3D::get_normal, DEFVAL(0)); diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index e4a41be6c0..b9baba4d96 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -504,6 +504,7 @@ public: Vector3 get_travel() const; Vector3 get_remainder() const; int get_collision_count() const; + real_t get_depth() const; Vector3 get_position(int p_collision_index = 0) const; Vector3 get_normal(int p_collision_index = 0) const; real_t get_angle(int p_collision_index = 0, const Vector3 &p_up_direction = Vector3(0.0, 1.0, 0.0)) const; diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp index 5e9f1c824a..126bb08c94 100644 --- a/servers/navigation_server_2d.cpp +++ b/servers/navigation_server_2d.cpp @@ -158,6 +158,47 @@ void NavigationServer2D::_emit_map_changed(RID p_map) { emit_signal(SNAME("map_changed"), p_map); } +#ifdef DEBUG_ENABLED +void NavigationServer2D::set_debug_enabled(bool p_enabled) { + NavigationServer3D::get_singleton_mut()->set_debug_enabled(p_enabled); +} +bool NavigationServer2D::get_debug_enabled() const { + return NavigationServer3D::get_singleton()->get_debug_enabled(); +} + +void NavigationServer2D::set_debug_navigation_edge_connection_color(const Color &p_color) { + NavigationServer3D::get_singleton_mut()->set_debug_navigation_edge_connection_color(p_color); +} + +Color NavigationServer2D::get_debug_navigation_edge_connection_color() const { + return NavigationServer3D::get_singleton()->get_debug_navigation_edge_connection_color(); +} + +void NavigationServer2D::set_debug_navigation_geometry_face_color(const Color &p_color) { + NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_face_color(p_color); +} + +Color NavigationServer2D::get_debug_navigation_geometry_face_color() const { + return NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_color(); +} + +void NavigationServer2D::set_debug_navigation_geometry_face_disabled_color(const Color &p_color) { + NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_face_disabled_color(p_color); +} + +Color NavigationServer2D::get_debug_navigation_geometry_face_disabled_color() const { + return NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_disabled_color(); +} + +void NavigationServer2D::set_debug_navigation_enable_edge_connections(const bool p_value) { + NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_connections(p_value); +} + +bool NavigationServer2D::get_debug_navigation_enable_edge_connections() const { + return NavigationServer3D::get_singleton()->get_debug_navigation_enable_edge_connections(); +} +#endif // DEBUG_ENABLED + void NavigationServer2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_maps"), &NavigationServer2D::get_maps); diff --git a/servers/navigation_server_2d.h b/servers/navigation_server_2d.h index 1b15c7ff37..83271f990e 100644 --- a/servers/navigation_server_2d.h +++ b/servers/navigation_server_2d.h @@ -184,6 +184,23 @@ public: NavigationServer2D(); virtual ~NavigationServer2D(); + +#ifdef DEBUG_ENABLED + void set_debug_enabled(bool p_enabled); + bool get_debug_enabled() const; + + void set_debug_navigation_edge_connection_color(const Color &p_color); + Color get_debug_navigation_edge_connection_color() const; + + void set_debug_navigation_geometry_face_color(const Color &p_color); + Color get_debug_navigation_geometry_face_color() const; + + void set_debug_navigation_geometry_face_disabled_color(const Color &p_color); + Color get_debug_navigation_geometry_face_disabled_color() const; + + void set_debug_navigation_enable_edge_connections(const bool p_value); + bool get_debug_navigation_enable_edge_connections() const; +#endif // DEBUG_ENABLED }; #endif // NAVIGATION_SERVER_2D_H diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp index 52855c5931..115eda7b30 100644 --- a/servers/navigation_server_3d.cpp +++ b/servers/navigation_server_3d.cpp @@ -123,6 +123,12 @@ NavigationServer3D::NavigationServer3D() { debug_navigation_enable_edge_lines = GLOBAL_DEF("debug/shapes/navigation/enable_edge_lines", true); debug_navigation_enable_edge_lines_xray = GLOBAL_DEF("debug/shapes/navigation/enable_edge_lines_xray", true); debug_navigation_enable_geometry_face_random_color = GLOBAL_DEF("debug/shapes/navigation/enable_geometry_face_random_color", true); + + if (Engine::get_singleton()->is_editor_hint()) { + // enable NavigationServer3D when in Editor or else navmesh edge connections are invisible + // on runtime tests SceneTree has "Visible Navigation" set and main iteration takes care of this + set_debug_enabled(true); + } #endif // DEBUG_ENABLED } diff --git a/servers/physics_3d/godot_space_3d.cpp b/servers/physics_3d/godot_space_3d.cpp index 533d7605ce..13e9a89b2e 100644 --- a/servers/physics_3d/godot_space_3d.cpp +++ b/servers/physics_3d/godot_space_3d.cpp @@ -989,6 +989,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D:: r_result->collision_unsafe_fraction = unsafe; r_result->collision_count = rcd.result_count; + r_result->collision_depth = rcd.best_result.len; } collided = true; @@ -1002,6 +1003,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D:: r_result->collision_safe_fraction = 1.0; r_result->collision_unsafe_fraction = 1.0; + r_result->collision_depth = 0.0; } return collided; diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index 837073409a..12497c0bdf 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -550,6 +550,7 @@ public: struct MotionResult { Vector3 travel; Vector3 remainder; + real_t collision_depth = 0.0; real_t collision_safe_fraction = 0.0; real_t collision_unsafe_fraction = 0.0; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index e20a04ff2a..84427e1c93 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -416,7 +416,10 @@ TextureStorage::TextureStorage() { tformat.format = RD::DATA_FORMAT_R8_UINT; tformat.width = 4; tformat.height = 4; - tformat.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT; + tformat.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT; + if (RD::get_singleton()->has_feature(RD::SUPPORTS_ATTACHMENT_VRS)) { + tformat.usage_bits |= RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT; + } tformat.texture_type = RD::TEXTURE_TYPE_2D; Vector<uint8_t> pv; diff --git a/tests/core/math/test_vector4.h b/tests/core/math/test_vector4.h index 4b8759c0ca..ccf991401b 100644 --- a/tests/core/math/test_vector4.h +++ b/tests/core/math/test_vector4.h @@ -98,6 +98,9 @@ TEST_CASE("[Vector4] Length methods") { CHECK_MESSAGE( Math::is_equal_approx(vector1.distance_to(vector2), (real_t)54.772255750517), "Vector4 distance_to should work as expected."); + CHECK_MESSAGE( + Math::is_equal_approx(vector1.distance_squared_to(vector2), 3000), + "Vector4 distance_squared_to should work as expected."); } TEST_CASE("[Vector4] Limiting methods") { |