Vixen
02b45cc4
csharp
public readonly record struct ShapeDescription

What a collision volume is, without being one yet.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A description is a value: two boxes with the same half extents are equal, hash the same, and PhysicsShapes hands them the same ShapeId and the same native shape. That is what makes ten thousand crates cost one BoxShape rather than ten thousand, and it is why this is a struct with an equality contract rather than a class hierarchy with reference identity.

The vertex data is not in here. A hull or a mesh carries arrays, and putting them in the value would make equality mean "the same array instance" or else make it O(n) on every registration. Instead a hull, a mesh or a compound is registered by its data once and the description holds the resulting ShapeId's underlying index — so the value stays sixteen bytes wide, comparable and blittable, which is what lets a Collider component hold one without becoming a managed component.

Fields and properties (6)

  • public ShapeKind Kind

    What kind of shape this is.

  • public Vector3 Extents

    The size, meaning whatever the kind says: half extents for a box, the plane's normal for a plane, and nothing for the kinds whose data lives in the registry.

  • public float Radius

    The primary radius: the sphere's, the capsule's, the cylinder's, or the plane's distance from the origin along its normal.

  • public float HalfHeight

    Half the height of the straight part of a capsule, or half a cylinder's total height.

  • public int DataIndex

    Which blob of vertex, index or child data in the registry this shape reads.

  • public bool CanBeDynamic

    Whether this kind can be given to a body that moves under the solver.

Methods (7)

  • public static ShapeDescription Sphere(float radius)

    A sphere.

  • public static ShapeDescription Box(Vector3 halfExtents)

    A box, given as half its extents.

  • public static ShapeDescription Box(float halfExtent)

    A cube.

  • public static ShapeDescription Capsule(float halfHeight, float radius)

    A capsule standing on the Y axis.

  • public static ShapeDescription Cylinder(float halfHeight, float radius)

    A cylinder standing on the Y axis.

  • public static ShapeDescription Plane(Vector3 normal, float distance = 0)

    An infinite half-space, solid on the side the normal points away from.

  • public override string ToString()

    Renders the kind and its distinguishing measurement.

Used by (5)

  • HeightFieldShapeTestsVixen.Physics.Tests
  • PhysicsDebugDrawVixen.Physics
  • PhysicsShapesVixen.Physics
  • PhysicsWorldVixen.Physics
  • Vixen_Physics_Shapes_ShapeDescriptionSerializerVixen.Physics