Module builtin
Expand description
Builtin 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 reimplemented
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 reexport 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 reexport 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.
 Mathrelated 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 floatliterals into the
real
type.  Array of reals.
 Access vector components in different order.
 Constructs
VariantArray
literals, similar to Rust’s standardvec!
macro.
Structs§
 Axisaligned 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 builtin type, in floatingpoint RGBA format.
 HSVA floatingnumber Color representation.
 Godot’s
Dictionary
type.  Godot’s reference counted string type.
 A preparsed scene tree path.
 Implements Godot’s
PackedByteArray
type, which is a spaceefficient array ofu8
s.  Implements Godot’s
PackedColorArray
type, which is a spaceefficient array ofColor
s.  Implements Godot’s
PackedFloat32Array
type, which is a spaceefficient array off32
s.  Implements Godot’s
PackedFloat64Array
type, which is a spaceefficient array off64
s.  Implements Godot’s
PackedInt32Array
type, which is a spaceefficient array ofi32
s.  Implements Godot’s
PackedInt64Array
type, which is a spaceefficient array ofi64
s.  Implements Godot’s
PackedStringArray
type, which is a spaceefficient array ofGString
s.  Implements Godot’s
PackedVector2Array
type, which is a spaceefficient array ofVector2
s.  Implements Godot’s
PackedVector3Array
type, which is a spaceefficient array ofVector3
s.  Implements Godot’s
PackedVector4Array
type, which is a spaceefficient array ofVector4
s.  3D plane in Hessian normal form.
 A 4x4 matrix used for 3D projective transformations.
 Unit quaternion to represent 3D rotations.
 2D axisaligned bounding box.
 2D axisaligned 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 headmounted 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.