Module godot::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§

  • Specialized types related to arrays.
  • Specialized types related to dictionaries.
  • Math-related functions and traits like ApproxEq.
  • Meta-information about variant types, properties and class names.
  • 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 an efficient array of u8s.
  • Implements Godot’s PackedColorArray type, which is an efficient array of Colors.
  • Implements Godot’s PackedFloat32Array type, which is an efficient array of f32s.
  • Implements Godot’s PackedFloat64Array type, which is an efficient array of f64s.
  • Implements Godot’s PackedInt32Array type, which is an efficient array of i32s.
  • Implements Godot’s PackedInt64Array type, which is an efficient array of i64s.
  • Implements Godot’s PackedStringArray type, which is an efficient array of GStrings.
  • Implements Godot’s PackedVector2Array type, which is an efficient array of Vector2s.
  • Implements Godot’s PackedVector3Array type, which is an efficient array of Vector3s.
  • Implements Godot’s PackedVector4Array type, which is an efficient array of Vector4s.
  • 3D plane in Hessian normal form.
  • A 4x4 matrix used for 3D projective transformations.
  • 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.
  • Vector used for 2D math using floating point coordinates.
  • Vector used for 2D math using integer coordinates.
  • Vector used for 3D math using floating point coordinates.
  • Vector used for 3D math using integer coordinates.
  • Vector used for 4D math using floating point coordinates.
  • Vector used for 4D math using integer coordinates.

Enums§

Traits§

  • Convenience conversion between real and f32/f64.
  • Represents a custom callable object defined in Rust.
  • Trait that allows conversion from tuples to vectors.

Type Aliases§

  • A Godot Array without an assigned type.
  • Floating point type used for many structs and functions in Godot.