Skip to content

Commit

Permalink
Merge pull request #40501 from aaronfranke/core-docs-cs
Browse files Browse the repository at this point in the history
Update core documentation to match recent C# changes
  • Loading branch information
akien-mga authored Jul 21, 2020
2 parents 60fab23 + 83e324d commit bb2c0d3
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 236 deletions.
4 changes: 4 additions & 0 deletions core/math/aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class AABB {
_FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const;
_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */

_FORCE_INLINE_ AABB abs() const {
return AABB(Vector3(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0), position.z + MIN(size.z, 0)), size.abs());
}

operator String() const;

_FORCE_INLINE_ AABB() {}
Expand Down
2 changes: 1 addition & 1 deletion core/math/geometry_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes

Vector<Vector3> vertices;

Vector3 center = p.get_any_point();
Vector3 center = p.center();
// make a quad clockwise
vertices.push_back(center - up * subplane_size + right * subplane_size);
vertices.push_back(center - up * subplane_size - right * subplane_size);
Expand Down
4 changes: 0 additions & 4 deletions core/math/plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ Plane Plane::normalized() const {
return p;
}

Vector3 Plane::get_any_point() const {
return get_normal() * d;
}

Vector3 Plane::get_any_perpendicular_normal() const {
static const Vector3 p1 = Vector3(1, 0, 0);
static const Vector3 p2 = Vector3(0, 1, 0);
Expand Down
1 change: 0 additions & 1 deletion core/math/plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Plane {
/* Plane-Point operations */

_FORCE_INLINE_ Vector3 center() const { return normal * d; }
Vector3 get_any_point() const;
Vector3 get_any_perpendicular_normal() const;

_FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
Expand Down
4 changes: 2 additions & 2 deletions core/variant_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ struct _VariantCall {

VCALL_LOCALMEM0R(Plane, normalized);
VCALL_LOCALMEM0R(Plane, center);
VCALL_LOCALMEM0R(Plane, get_any_point);
VCALL_LOCALMEM1R(Plane, is_equal_approx);
VCALL_LOCALMEM1R(Plane, is_point_over);
VCALL_LOCALMEM1R(Plane, distance_to);
Expand Down Expand Up @@ -843,6 +842,7 @@ struct _VariantCall {
#define VCALL_PTR5R(m_type, m_method) \
static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }

VCALL_PTR0R(AABB, abs);
VCALL_PTR0R(AABB, get_area);
VCALL_PTR0R(AABB, has_no_area);
VCALL_PTR0R(AABB, has_no_surface);
Expand Down Expand Up @@ -1980,7 +1980,6 @@ void register_variant_methods() {

ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray());
ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray());
ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray());
ADDFUNC1R(PLANE, BOOL, Plane, is_equal_approx, PLANE, "plane", varray());
ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray());
ADDFUNC1R(PLANE, FLOAT, Plane, distance_to, VECTOR3, "point", varray());
Expand Down Expand Up @@ -2220,6 +2219,7 @@ void register_variant_methods() {

//pointerbased

ADDFUNC0R(AABB, AABB, AABB, abs, varray());
ADDFUNC0R(AABB, FLOAT, AABB, get_area, varray());
ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray());
ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray());
Expand Down
16 changes: 12 additions & 4 deletions doc/classes/AABB.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
<argument index="1" name="size" type="Vector3">
</argument>
<description>
Optional constructor, accepts position and size.
Constructs an [AABB] from a position and size.
</description>
</method>
<method name="abs">
<return type="AABB">
</return>
<description>
Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive.
</description>
</method>
<method name="encloses">
Expand Down Expand Up @@ -197,13 +204,14 @@
</methods>
<members>
<member name="end" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
Ending corner. This is calculated as [code]position + size[/code]. Changing this property changes [member size] accordingly.
Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
</member>
<member name="position" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
Beginning corner.
Beginning corner. Typically has values lower than [member end].
</member>
<member name="size" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
Size from position to end.
Size from [member position] to [member end]. Typically all components are positive.
If the size is negative, you can use [method abs] to fix it.
</member>
</members>
<constants>
Expand Down
35 changes: 21 additions & 14 deletions doc/classes/Basis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
3×3 matrix datatype.
</brief_description>
<description>
3×3 matrix used for 3D rotation and scale. Contains 3 vector fields X, Y and Z as its columns, which can be interpreted as the local basis vectors of a transformation. Can also be accessed as array of 3D vectors. These vectors are orthogonal to each other, but are not necessarily normalized (due to scaling). Almost always used as an orthogonal basis for a [Transform].
For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S).
3×3 matrix used for 3D rotation and scale. Almost always used as an orthogonal basis for a Transform.
Contains 3 vector fields X, Y and Z as its columns, which are typically interpreted as the local basis vectors of a transformation. For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S).
Can also be accessed as array of 3D vectors. These vectors are normally orthogonal to each other, but are not necessarily normalized (due to scaling).
For more information, read the "Matrices and transforms" documentation article.
</description>
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/math/matrices_and_transforms.html</link>
<link>https://docs.godotengine.org/en/latest/tutorials/3d/using_transforms.html</link>
</tutorials>
<methods>
Expand All @@ -17,7 +20,7 @@
<argument index="0" name="from" type="Quat">
</argument>
<description>
Create a rotation matrix from the given quaternion.
Constructs a pure rotation basis matrix from the given quaternion.
</description>
</method>
<method name="Basis">
Expand All @@ -26,7 +29,8 @@
<argument index="0" name="from" type="Vector3">
</argument>
<description>
Create a rotation matrix (in the YXZ convention: first Z, then X, and Y last) from the specified Euler angles, given in the vector format as (X angle, Y angle, Z angle).
Constructs a pure rotation basis matrix from the given Euler angles (in the YXZ convention: when *composing*, first Y, then X, and Z last), given in the vector format as (X angle, Y angle, Z angle).
Consider using the [Quat] constructor instead, which uses a quaternion instead of Euler angles.
</description>
</method>
<method name="Basis">
Expand All @@ -37,7 +41,7 @@
<argument index="1" name="phi" type="float">
</argument>
<description>
Create a rotation matrix which rotates around the given axis by the specified angle, in radians. The axis must be a normalized vector.
Constructs a pure rotation basis matrix, rotated around the given [code]axis[/code] by [code]phi[/code], in radians. The axis must be a normalized vector.
</description>
</method>
<method name="Basis">
Expand All @@ -50,28 +54,30 @@
<argument index="2" name="z_axis" type="Vector3">
</argument>
<description>
Create a matrix from 3 axis vectors.
Constructs a basis matrix from 3 axis vectors (matrix columns).
</description>
</method>
<method name="determinant">
<return type="float">
</return>
<description>
Returns the determinant of the matrix.
Returns the determinant of the basis matrix. If the basis is uniformly scaled, its determinant is the square of the scale.
A negative determinant means the basis has a negative scale. A zero determinant means the basis isn't invertible, and is usually considered invalid.
</description>
</method>
<method name="get_euler">
<return type="Vector3">
</return>
<description>
Returns the basis's rotation in the form of Euler angles (in the YXZ convention: first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). See [method get_rotation_quat] if you need a quaternion instead.
Returns the basis's rotation in the form of Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
Consider using the [method get_rotation_quat] method instead, which returns a [Quat] quaternion instead of Euler angles.
</description>
</method>
<method name="get_orthogonal_index">
<return type="int">
</return>
<description>
This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index of the point best representing the orientation of the object. It is mainly used by the grid map editor. For further details, refer to the Godot source code.
This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index of the point best representing the orientation of the object. It is mainly used by the [GridMap] editor. For further details, refer to the Godot source code.
</description>
</method>
<method name="get_rotation_quat">
Expand Down Expand Up @@ -193,25 +199,26 @@
<argument index="0" name="v" type="Vector3">
</argument>
<description>
Returns a vector transformed (multiplied) by the transposed matrix.
Returns a vector transformed (multiplied) by the transposed basis matrix.
[b]Note:[/b] This results in a multiplication by the inverse of the matrix only if it represents a rotation-reflection.
</description>
</method>
</methods>
<members>
<member name="x" type="Vector3" setter="" getter="" default="Vector3( 1, 0, 0 )">
The basis matrix's X vector.
The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code].
</member>
<member name="y" type="Vector3" setter="" getter="" default="Vector3( 0, 1, 0 )">
The basis matrix's Y vector.
The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code].
</member>
<member name="z" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 1 )">
The basis matrix's Z vector.
The basis matrix's Z vector (column 2). Equivalent to array index [code]2[/code].
</member>
</members>
<constants>
<constant name="IDENTITY" value="Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )">
The identity basis. This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer.
The identity basis, with no rotation or scaling applied.
This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer, and for consistency with C#.
</constant>
<constant name="FLIP_X" value="Basis( -1, 0, 0, 0, 1, 0, 0, 0, 1 )">
The basis that will flip something along the X axis when used in a transformation.
Expand Down
26 changes: 13 additions & 13 deletions doc/classes/Color.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Color" version="4.0">
<brief_description>
Color in RGBA format with some support for ARGB format.
Color in RGBA format using floats on the range of 0 to 1.
</brief_description>
<description>
A color is represented by red, green, and blue [code](r, g, b)[/code] components. Additionally, [code]a[/code] represents the alpha component, often used for transparency. Values are in floating-point and usually range from 0 to 1. Some properties (such as [member CanvasItem.modulate]) may accept values greater than 1.
A color represented by red, green, blue, and alpha (RGBA) components. The alpha component is often used for transparency. Values are in floating-point and usually range from 0 to 1. Some properties (such as CanvasItem.modulate) may accept values greater than 1 (overbright or HDR colors).
You can also create a color from standardized color names by using [method @GDScript.ColorN] or directly using the color constants defined here. The standardized color set is based on the [url=https://en.wikipedia.org/wiki/X11_color_names]X11 color names[/url].
If you want to supply values in a range of 0 to 255, you should use [method @GDScript.Color8].
[b]Note:[/b] In a boolean context, a Color will evaluate to [code]false[/code] if it's equal to [code]Color(0, 0, 0, 1)[/code] (opaque black). Otherwise, a Color will always evaluate to [code]true[/code].
Expand Down Expand Up @@ -277,37 +277,37 @@
</methods>
<members>
<member name="a" type="float" setter="" getter="" default="1.0">
Alpha value (range 0 to 1).
The color's alpha (transparency) component, typically on the range of 0 to 1.
</member>
<member name="a8" type="int" setter="" getter="" default="255">
Alpha value (range 0 to 255).
Wrapper for [member a] that uses the range 0 to 255 instead of 0 to 1.
</member>
<member name="b" type="float" setter="" getter="" default="0.0">
Blue value (range 0 to 1).
The color's blue component, typically on the range of 0 to 1.
</member>
<member name="b8" type="int" setter="" getter="" default="0">
Blue value (range 0 to 255).
Wrapper for [member b] that uses the range 0 to 255 instead of 0 to 1.
</member>
<member name="g" type="float" setter="" getter="" default="0.0">
Green value (range 0 to 1).
The color's green component, typically on the range of 0 to 1.
</member>
<member name="g8" type="int" setter="" getter="" default="0">
Green value (range 0 to 255).
Wrapper for [member g] that uses the range 0 to 255 instead of 0 to 1.
</member>
<member name="h" type="float" setter="" getter="" default="0.0">
HSV hue value (range 0 to 1).
The HSV hue of this color, on the range 0 to 1.
</member>
<member name="r" type="float" setter="" getter="" default="0.0">
Red value (range 0 to 1).
The color's red component, typically on the range of 0 to 1.
</member>
<member name="r8" type="int" setter="" getter="" default="0">
Red value (range 0 to 255).
Wrapper for [member r] that uses the range 0 to 255 instead of 0 to 1.
</member>
<member name="s" type="float" setter="" getter="" default="0.0">
HSV saturation value (range 0 to 1).
The HSV saturation of this color, on the range 0 to 1.
</member>
<member name="v" type="float" setter="" getter="" default="0.0">
HSV value (range 0 to 1).
The HSV value (brightness) of this color, on the range 0 to 1.
</member>
</members>
<constants>
Expand Down
29 changes: 12 additions & 17 deletions doc/classes/Plane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@
Returns the shortest distance from the plane to the position [code]point[/code].
</description>
</method>
<method name="get_any_point">
<return type="Vector3">
</return>
<description>
Returns a point on the plane.
</description>
</method>
<method name="has_point">
<return type="bool">
</return>
Expand All @@ -80,7 +73,7 @@
<argument index="1" name="epsilon" type="float" default="1e-05">
</argument>
<description>
Returns [code]true[/code] if [code]point[/code] is inside the plane (by a very minimum [code]epsilon[/code] threshold).
Returns [code]true[/code] if [code]point[/code] is inside the plane. Comparison uses a custom minimum [code]epsilon[/code] threshold.
</description>
</method>
<method name="intersect_3">
Expand Down Expand Up @@ -147,36 +140,38 @@
<argument index="0" name="point" type="Vector3">
</argument>
<description>
Returns the orthogonal projection of point [code]p[/code] into a point in the plane.
Returns the orthogonal projection of [code]point[/code] into a point in the plane.
</description>
</method>
</methods>
<members>
<member name="d" type="float" setter="" getter="" default="0.0">
Distance from the origin to the plane, in the direction of [member normal].
The distance from the origin to the plane, in the direction of [member normal]. This value is typically non-negative.
In the scalar equation of the plane [code]ax + by + cz = d[/code], this is [code]d[/code], while the [code](a, b, c)[/code] coordinates are represented by the [member normal] property.
</member>
<member name="normal" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
The normal of the plane. "Over" or "Above" the plane is considered the side of the plane towards where the normal is pointing.
The normal of the plane, which must be normalized.
In the scalar equation of the plane [code]ax + by + cz = d[/code], this is the vector [code](a, b, c)[/code], where [code]d[/code] is the [member d] property.
</member>
<member name="x" type="float" setter="" getter="" default="0.0">
The [member normal]'s X component.
The X component of the plane's [member normal] vector.
</member>
<member name="y" type="float" setter="" getter="" default="0.0">
The [member normal]'s Y component.
The Y component of the plane's [member normal] vector.
</member>
<member name="z" type="float" setter="" getter="" default="0.0">
The [member normal]'s Z component.
The Z component of the plane's [member normal] vector.
</member>
</members>
<constants>
<constant name="PLANE_YZ" value="Plane( 1, 0, 0, 0 )">
A plane that extends in the Y and Z axes.
A plane that extends in the Y and Z axes (normal vector points +X).
</constant>
<constant name="PLANE_XZ" value="Plane( 0, 1, 0, 0 )">
A plane that extends in the X and Z axes.
A plane that extends in the X and Z axes (normal vector points +Y).
</constant>
<constant name="PLANE_XY" value="Plane( 0, 0, 1, 0 )">
A plane that extends in the X and Y axes.
A plane that extends in the X and Y axes (normal vector points +Z).
</constant>
</constants>
</class>
Loading

0 comments on commit bb2c0d3

Please sign in to comment.