Table of Contents

Class CompoundBuilder

Namespace
Box3D
Assembly
Box3D.NET.dll

Collects the children of a baked compound.

public sealed class CompoundBuilder

Inheritance

Inherited Members

Examples

using var rock = ConvexHull.Rock(0.4f);

var builder = new CompoundBuilder();
foreach (Vector3 position in wallPositions)
{
    builder.AddHull(rock, position, Quaternion.Identity);
}

using CompoundGeometry wall = builder.Build();
// The hull may be disposed here; the compound holds its own copy.

using (var world = new PhysicsWorld())
{
    Body body = world.CreateStaticBody();
    body.AddCompound(wall);

    Simulate(world);
}
// World first, compound second.

Remarks

A builder rather than a factory method, because a compound is heterogeneous: Box3D wants its spheres, capsules, hulls and meshes in four separate arrays, and asking a caller to assemble those is asking them to do the bookkeeping this exists to do.

The builder holds the geometry it was given rather than a pointer into it, so disposing a hull before Box3D.CompoundBuilder.Build raises System.ObjectDisposedException instead of reading freed memory.

Properties

ChildCount

Gets how many children have been added so far.

Methods

AddCapsule(Capsule, PhysicsMaterial?)

Adds a capsule.

AddHull(ConvexHull, Vector3, Quaternion?, PhysicsMaterial?)

Adds a convex hull at a transform.

AddMesh(CollisionMesh, Vector3, Quaternion?, Vector3?, PhysicsMaterial?)

Adds a triangle mesh at a transform.

AddSphere(Sphere, PhysicsMaterial?)

Adds a sphere.

Build()

Bakes the children into a compound.