Expose Vector* component-wise and scalar min/max to scripting

This commit is contained in:
A Thousand Ships 2024-05-02 10:45:15 +02:00
parent a0b0b19043
commit 0f5e0d1637
No known key found for this signature in database
GPG key ID: 2033189A662F8BD7
17 changed files with 596 additions and 19 deletions

View file

@ -696,6 +696,7 @@
[codeblock]
max(1, 7, 3, -6, 5) # Returns 7
[/codeblock]
[b]Note:[/b] When using this on vectors it will [i]not[/i] perform component-wise maximum, and will pick the largest value when compared using [code]x < y[/code]. To perform component-wise maximum, use [method Vector2.max], [method Vector2i.max], [method Vector3.max], [method Vector3i.max], [method Vector4.max], and [method Vector4i.max].
</description>
</method>
<method name="maxf">
@ -729,6 +730,7 @@
[codeblock]
min(1, 7, 3, -6, 5) # Returns -6
[/codeblock]
[b]Note:[/b] When using this on vectors it will [i]not[/i] perform component-wise minimum, and will pick the smallest value when compared using [code]x &lt; y[/code]. To perform component-wise minimum, use [method Vector2.min], [method Vector2i.min], [method Vector3.min], [method Vector3i.min], [method Vector4.min], and [method Vector4i.min].
</description>
</method>
<method name="minf">

View file

@ -273,18 +273,46 @@
Returns the vector with a maximum length by limiting its length to [param length].
</description>
</method>
<method name="max" qualifiers="const">
<return type="Vector2" />
<param index="0" name="with" type="Vector2" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2(maxf(x, with.x), maxf(y, with.y))[/code].
</description>
</method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
<method name="maxf" qualifiers="const">
<return type="Vector2" />
<param index="0" name="with" type="float" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2(maxf(x, with), maxf(y, with))[/code].
</description>
</method>
<method name="min" qualifiers="const">
<return type="Vector2" />
<param index="0" name="with" type="Vector2" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2(minf(x, with.x), minf(y, with.y))[/code].
</description>
</method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Y].
</description>
</method>
<method name="minf" qualifiers="const">
<return type="Vector2" />
<param index="0" name="with" type="float" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2(minf(x, with), minf(y, with))[/code].
</description>
</method>
<method name="move_toward" qualifiers="const">
<return type="Vector2" />
<param index="0" name="to" type="Vector2" />

View file

@ -100,18 +100,46 @@
This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
<method name="max" qualifiers="const">
<return type="Vector2i" />
<param index="0" name="with" type="Vector2i" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2i(maxi(x, with.x), maxi(y, with.y))[/code].
</description>
</method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
<method name="maxi" qualifiers="const">
<return type="Vector2i" />
<param index="0" name="with" type="int" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector2i(maxi(x, with), maxi(y, with))[/code].
</description>
</method>
<method name="min" qualifiers="const">
<return type="Vector2i" />
<param index="0" name="with" type="Vector2i" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2i(mini(x, with.x), mini(y, with.y))[/code].
</description>
</method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Y].
</description>
</method>
<method name="mini" qualifiers="const">
<return type="Vector2i" />
<param index="0" name="with" type="int" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector2i(mini(x, with), mini(y, with))[/code].
</description>
</method>
<method name="sign" qualifiers="const">
<return type="Vector2i" />
<description>

View file

@ -242,18 +242,46 @@
Returns the vector with a maximum length by limiting its length to [param length].
</description>
</method>
<method name="max" qualifiers="const">
<return type="Vector3" />
<param index="0" name="with" type="Vector3" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z))[/code].
</description>
</method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
<method name="maxf" qualifiers="const">
<return type="Vector3" />
<param index="0" name="with" type="float" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3(maxf(x, with), maxf(y, with), maxf(z, with))[/code].
</description>
</method>
<method name="min" qualifiers="const">
<return type="Vector3" />
<param index="0" name="with" type="Vector3" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3(minf(x, with.x), minf(y, with.y), minf(z, with.z))[/code].
</description>
</method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z].
</description>
</method>
<method name="minf" qualifiers="const">
<return type="Vector3" />
<param index="0" name="with" type="float" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3(minf(x, with), minf(y, with), minf(z, with))[/code].
</description>
</method>
<method name="move_toward" qualifiers="const">
<return type="Vector3" />
<param index="0" name="to" type="Vector3" />

View file

@ -95,18 +95,46 @@
This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
<method name="max" qualifiers="const">
<return type="Vector3i" />
<param index="0" name="with" type="Vector3i" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3i(maxi(x, with.x), maxi(y, with.y), maxi(z, with.z))[/code].
</description>
</method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
<method name="maxi" qualifiers="const">
<return type="Vector3i" />
<param index="0" name="with" type="int" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector3i(maxi(x, with), maxi(y, with), maxi(z, with))[/code].
</description>
</method>
<method name="min" qualifiers="const">
<return type="Vector3i" />
<param index="0" name="with" type="Vector3i" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3i(mini(x, with.x), mini(y, with.y), mini(z, with.z))[/code].
</description>
</method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z].
</description>
</method>
<method name="mini" qualifiers="const">
<return type="Vector3i" />
<param index="0" name="with" type="int" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector3i(mini(x, with), mini(y, with), mini(z, with))[/code].
</description>
</method>
<method name="sign" qualifiers="const">
<return type="Vector3i" />
<description>

View file

@ -184,18 +184,46 @@
Returns the result of the linear interpolation between this vector and [param to] by amount [param weight]. [param weight] is on the range of [code]0.0[/code] to [code]1.0[/code], representing the amount of interpolation.
</description>
</method>
<method name="max" qualifiers="const">
<return type="Vector4" />
<param index="0" name="with" type="Vector4" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z), maxf(w, with.w))[/code].
</description>
</method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
<method name="maxf" qualifiers="const">
<return type="Vector4" />
<param index="0" name="with" type="float" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4(maxf(x, with), maxf(y, with), maxf(z, with), maxf(w, with))[/code].
</description>
</method>
<method name="min" qualifiers="const">
<return type="Vector4" />
<param index="0" name="with" type="Vector4" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4(minf(x, with.x), minf(y, with.y), minf(z, with.z), minf(w, with.w))[/code].
</description>
</method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_W].
</description>
</method>
<method name="minf" qualifiers="const">
<return type="Vector4" />
<param index="0" name="with" type="float" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4(minf(x, with), minf(y, with), minf(z, with), minf(w, with))[/code].
</description>
</method>
<method name="normalized" qualifiers="const">
<return type="Vector4" />
<description>

View file

@ -93,18 +93,46 @@
This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
<method name="max" qualifiers="const">
<return type="Vector4i" />
<param index="0" name="with" type="Vector4i" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4i(maxi(x, with.x), maxi(y, with.y), maxi(z, with.z), maxi(w, with.w))[/code].
</description>
</method>
<method name="max_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
</description>
</method>
<method name="maxi" qualifiers="const">
<return type="Vector4i" />
<param index="0" name="with" type="int" />
<description>
Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4i(maxi(x, with), maxi(y, with), maxi(z, with), maxi(w, with))[/code].
</description>
</method>
<method name="min" qualifiers="const">
<return type="Vector4i" />
<param index="0" name="with" type="Vector4i" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4i(mini(x, with.x), mini(y, with.y), mini(z, with.z), mini(w, with.w))[/code].
</description>
</method>
<method name="min_axis_index" qualifiers="const">
<return type="int" />
<description>
Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_W].
</description>
</method>
<method name="mini" qualifiers="const">
<return type="Vector4i" />
<param index="0" name="with" type="int" />
<description>
Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4i(mini(x, with), mini(y, with), mini(z, with), mini(w, with))[/code].
</description>
</method>
<method name="sign" qualifiers="const">
<return type="Vector4i" />
<description>