godot

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. The gdnative crate started out this way, using types from euclid, 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 of v.y += a; you would have to write v.set_y(v.get_y() + a);. (A union 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 standard vec! 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 standard vec! 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 of u8s.
  • Implements Godot’s PackedColorArray type, which is a space-efficient array of Colors.
  • Implements Godot’s PackedFloat32Array type, which is a space-efficient array of f32s.
  • Implements Godot’s PackedFloat64Array type, which is a space-efficient array of f64s.
  • Implements Godot’s PackedInt32Array type, which is a space-efficient array of i32s.
  • Implements Godot’s PackedInt64Array type, which is a space-efficient array of i64s.
  • Implements Godot’s PackedStringArray type, which is a space-efficient array of GStrings.
  • Implements Godot’s PackedVector2Array type, which is a space-efficient array of Vector2s.
  • Implements Godot’s PackedVector3Array type, which is a space-efficient array of Vector3s.
  • Implements Godot’s PackedVector4Array type, which is a space-efficient array of Vector4s.
  • 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 and f32/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.