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. Thegdnativecrate 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
gdextensionfrom changes in the wrapped crate. However, direct field access using.x,.y,.zis no longer possible. Instead ofv.y += a;you would have to writev.set_y(v.get_y() + a);. (Aunioncould 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
mintcrate, 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
Arrayliterals, similar to Rust’s standardvec!macro. - Constructs
Dictionaryliterals, close to Godot’s own syntax. - A macro to coerce float-literals into the
realtype. - Array of reals.
- Access vector components in different order.
- Constructs
VariantArrayliterals, similar to Rust’s standardvec!macro.
Structs§
- Axis-aligned bounding box in 3D space.
- Godot’s
Arraytype. - A 3x3 matrix, typically used as an orthogonal basis for
Transform3D. - A
Callablerepresents a function in Godot. - Color built-in type, in floating-point RGBA format.
- HSVA floating-number Color representation.
- Godot’s
Dictionarytype. - Godot’s reference counted string type.
- A pre-parsed scene tree path.
- Implements Godot’s
PackedByteArraytype, which is a space-efficient array ofu8s. - Implements Godot’s
PackedColorArraytype, which is a space-efficient array ofColors. - Implements Godot’s
PackedFloat32Arraytype, which is a space-efficient array off32s. - Implements Godot’s
PackedFloat64Arraytype, which is a space-efficient array off64s. - Implements Godot’s
PackedInt32Arraytype, which is a space-efficient array ofi32s. - Implements Godot’s
PackedInt64Arraytype, which is a space-efficient array ofi64s. - Implements Godot’s
PackedStringArraytype, which is a space-efficient array ofGStrings. - Implements Godot’s
PackedVector2Arraytype, which is a space-efficient array ofVector2s. - Implements Godot’s
PackedVector3Arraytype, which is a space-efficient array ofVector3s. - Implements Godot’s
PackedVector4Arraytype, which is a space-efficient array ofVector4s. - 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
Signalrepresents 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
realandf32/f64. - Represents a custom callable object defined in Rust.
Type Aliases§
- A Godot
Arraywithout an assigned type. - Floating point type used for many structs and functions in Godot.