Struct Shape
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
A piece of collision geometry attached to a Box3D.Shape.Body.
public readonly record struct Shape : IEquatable<Shape>Implements
Inherited Members
Extension Methods
Examples
Shape ground = body.AddBox(new Box(new Vector3(50.0f, 0.5f, 50.0f)));
ground.Friction = 0.8f;
// A shape from an event may already be gone.
foreach (ref readonly var touch in world.Events.ContactEnd)
{
if (touch.ShapeA.IsValid)
{
Handle(touch.ShapeA);
}
}
Remarks
A shape is a handle, not an object: it is a small value identifying geometry the world owns. Copying one is free and copies refer to the same shape. Because it owns nothing it is not System.IDisposable; call Box3D.Shape.Destroy(System.Boolean) to remove it, and note that destroying the body or the world removes its shapes too.
Handles carry a generation counter, so a handle to a destroyed shape is detected rather than silently addressing whatever took its place. Use Box3D.Shape.IsValid after anything that might have destroyed it, in particular when reading shapes out of end-touch events.
Properties
- Body
-
Gets the body this shape is attached to.
- Bounds
-
Gets the world-space bounding box of this shape.
- ContactEventsEnabled
-
Gets or sets a value indicating whether this shape reports begin and end touch events.
- Density
-
Gets the density, usually in kilograms per cubic metre.
- Filter
-
Gets the collision filtering rules.
- Friction
-
Gets or sets the friction coefficient.
- HitEventsEnabled
-
Gets or sets a value indicating whether this shape reports hit events.
- IsSensor
-
Gets a value indicating whether this shape reports overlaps instead of colliding.
- IsValid
-
Gets a value indicating whether this handle refers to a live shape.
- Material
-
Gets or sets the surface properties.
- Restitution
-
Gets or sets the bounciness.
- SensorEventsEnabled
-
Gets or sets a value indicating whether this shape reports sensor overlaps.
- Type
-
Gets the kind of geometry backing this shape.
- UserData
-
Gets or sets the application identifier attached to this shape.
- World
-
Gets the world this shape belongs to.
Methods
- ApplyWind(Vector3, float, float, float, bool)
-
Applies an aerodynamic force to the body, based on this shape's area facing the wind.
- ClosestPointTo(Vector3)
-
Gets the closest point on this shape to a world-space target.
- Destroy(bool)
-
Removes this shape from its body.
- Raycast(Vector3, Vector3)
-
Casts a ray directly against this shape, skipping the broad phase.
- SetDensity(float, bool)
-
Sets the density, optionally deferring the body mass update.
- SetFilter(CollisionFilter, bool)
-
Sets the collision filtering rules.