Struct ShapeDefinition
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
Everything needed to attach a shape to a body, other than the geometry itself.
public readonly record struct ShapeDefinition : IEquatable<ShapeDefinition>Implements
Inherited Members
Examples
// A heavy, grippy shape that reports its collisions.
var def = ShapeDefinition.Default with
{
Density = 2000.0f,
Material = PhysicsMaterial.Default with { Friction = 0.9f },
EnableContactEvents = true,
};
body.AddSphere(new Sphere(Vector3.Zero, 0.5f), def);
A trigger volume, which reports overlaps but never pushes anything:
var trigger = ShapeDefinition.Default with
{
IsSensor = true,
EnableSensorEvents = true,
Density = 0.0f,
};
Remarks
Start from Box3D.ShapeDefinition.Default; a zeroed definition has no density and no collision mask, and the engine rejects it.
Attaching a shape moves the body's centre of mass, which changes its linear velocity if it is already spinning. Build bodies before you start simulating them where you can.
Properties
- Default
-
Gets the engine's default shape definition.
- Density
-
Gets the density, usually in kilograms per cubic metre.
- EnableContactEvents
-
Gets a value indicating whether this shape reports begin and end touch events.
- EnableHitEvents
-
Gets a value indicating whether this shape reports hit events for collisions above the world's hit threshold.
- EnableSensorEvents
-
Gets a value indicating whether this shape reports sensor overlaps.
- Filter
-
Gets the collision filtering rules.
- InvokeContactCreation
-
Gets a value indicating whether the shape scans for contacts on the next step.
- IsSensor
-
Gets a value indicating whether this shape reports overlaps instead of colliding.
- Material
-
Gets the surface properties.
- Name
-
Gets an optional name, used when debugging and drawing.
- UpdateBodyMass
-
Gets a value indicating whether the body recomputes its mass when this shape is attached.