Module builtin
Expand description
Built-in types like Vector2
, GString
and Variant
.
§Background on the design of vector algebra types
The basic vector algebra types like Vector2
, Matrix4
and Quaternion
are re-implemented
here, with an API similar to that in the Godot engine itself. There are other approaches, but
they all have their disadvantages:
-
We could invoke API methods from the engine. The implementations could be generated, but it is slower and prevents inlining.
-
We could re-export types from an existing vector algebra crate, like
glam
. This removes the duplication, but it would create a strong dependency on a volatile API outside our control. Thegdnative
crate started out this way, using types fromeuclid
, but found it impractical. Moreover, the API would not match Godot’s own, which would make porting from GDScript (slightly) harder. -
We could opaquely wrap types from an existing vector algebra crate. This protects users of
gdextension
from changes in the wrapped crate. However, direct field access using.x
,.y
,.z
is no longer possible. Instead ofv.y += a;
you would have to writev.set_y(v.get_y() + a);
. (Aunion
could be used to add these fields in the public API, but would make every field access unsafe, which is also not great.) -
We could re-export types from the
mint
crate, which was explicitly designed to solve this problem. However, it falls short because operator overloading would become impossible.
Modules§
- Iterator types for arrays and dictionaries.
- Math-related functions and traits like
ApproxEq
. - Specialized types related to Godot’s various string implementations.
Macros§
- Constructs
Array
literals, similar to Rust’s standardvec!
macro. - Constructs
Dictionary
literals, close to Godot’s own syntax. - A macro to coerce float-literals into the
real
type. - Array of reals.
- Access vector components in different order.
- Constructs
VariantArray
literals, similar to Rust’s standardvec!
macro.
Structs§
- Axis-aligned bounding box in 3D space.
- Godot’s
Array
type. - A 3x3 matrix, typically used as an orthogonal basis for
Transform3D
. - A
Callable
represents a function in Godot. - Color built-in type, in floating-point RGBA format.
- HSVA floating-number Color representation.
- Godot’s
Dictionary
type. - Godot’s reference counted string type.
- A pre-parsed scene tree path.
- Implements Godot’s
PackedByteArray
type, which is a space-efficient array ofu8
s. - Implements Godot’s
PackedColorArray
type, which is a space-efficient array ofColor
s. - Implements Godot’s
PackedFloat32Array
type, which is a space-efficient array off32
s. - Implements Godot’s
PackedFloat64Array
type, which is a space-efficient array off64
s. - Implements Godot’s
PackedInt32Array
type, which is a space-efficient array ofi32
s. - Implements Godot’s
PackedInt64Array
type, which is a space-efficient array ofi64
s. - Implements Godot’s
PackedStringArray
type, which is a space-efficient array ofGString
s. - Implements Godot’s
PackedVector2Array
type, which is a space-efficient array ofVector2
s. - Implements Godot’s
PackedVector3Array
type, which is a space-efficient array ofVector3
s. - Implements Godot’s
PackedVector4Array
type, which is a space-efficient array ofVector4
s. - 3D plane in Hessian normal form.
- A 4x4 matrix used for 3D projective transformations.
- Unit quaternion to represent 3D rotations.
- 2D axis-aligned bounding box.
- 2D axis-aligned integer bounding box.
- A
Signal
represents a signal of an Object instance in Godot. - A string optimized for unique names.
- Affine 2D transform (2x3 matrix).
- Affine 3D transform (3x4 matrix).
- Godot variant type, able to store a variety of different types.
- Godot enum name:
Variant.Operator
. - Godot enum name:
Variant.Type
. - Vector used for 2D math using floating point coordinates.
- Vector used for 3D math using floating point coordinates.
- Vector used for 4D math using floating point coordinates.
- Vector used for 2D math using integer coordinates.
- Vector used for 3D math using integer coordinates.
- Vector used for 4D math using integer coordinates.
Enums§
- Defines how individual color channels are laid out in memory.
- This enum is exhaustive; you should not expect future Godot versions to add new enumerators.
- This enum is exhaustive; you should not expect future Godot versions to add new enumerators.
- The eye to create a projection for, when creating a projection adjusted for head-mounted displays.
- A projection’s clipping plane.
- A RID (“resource ID”) is an opaque handle that refers to a Godot
Resource
. - This enum is exhaustive; you should not expect future Godot versions to add new enumerators.
- Enumerates the axes in a
Vector2
. - Enumerates the axes in a
Vector3
. - Enumerates the axes in a
Vector4
.
Traits§
- Convenience conversion between
real
andf32
/f64
. - Represents a custom callable object defined in Rust.
Type Aliases§
- A Godot
Array
without an assigned type. - Floating point type used for many structs and functions in Godot.