Table of Contents

Struct ConvexHull

Namespace
BepuPhysics.Collidables
Assembly
BepuPhysics.dll
public struct ConvexHull : IConvexShape, IDisposableShape, IShape
Implements
Inherited Members

Constructors

ConvexHull(Span<Vector3>, BufferPool, out Vector3)

Creates a convex hull from a point set.

public ConvexHull(Span<Vector3> points, BufferPool pool, out Vector3 center)

Parameters

points Span<Vector3>

Points to compute the convex hull of.

pool BufferPool

Pool in which to allocate the convex hull and any temporary resources needed to compute the hull.

center Vector3

Computed center of the convex hull before the hull was recentered.

Fields

BoundingPlanes

Bundled bounding planes associated with the convex hull's faces.

public Buffer<HullBoundingPlanes> BoundingPlanes

Field Value

Buffer<HullBoundingPlanes>

FaceToVertexIndicesStart

Start indices of faces in the FaceVertexIndices.

public Buffer<int> FaceToVertexIndicesStart

Field Value

Buffer<int>

FaceVertexIndices

Combined set of vertices used by each face. Use FaceToVertexIndicesStart to index into this for a particular face. Indices stored in counterclockwise winding in right handed space, clockwise in left handed space.

public Buffer<HullVertexIndex> FaceVertexIndices

Field Value

Buffer<HullVertexIndex>

Id

Type id of convex hull shapes.

public const int Id = 5

Field Value

int

Points

Bundled points of the convex hull.

public Buffer<Vector3Wide> Points

Field Value

Buffer<Vector3Wide>

Properties

TypeId

Unique type id for this shape type.

public static int TypeId { get; }

Property Value

int

Methods

ComputeAngularExpansionData(out float, out float)

Computes information about how the bounding box should be expanded in response to angular velocity.

public readonly void ComputeAngularExpansionData(out float maximumRadius, out float maximumAngularExpansion)

Parameters

maximumRadius float
maximumAngularExpansion float

Remarks

This is typically used in the engine for predicting bounding boxes at the beginning of the frame. Velocities are used to expand the bounding box so that likely future collisions will be detected. Linear velocity expands the bounding box in a direct and simple way, but angular expansion requires more information about the shape. Imagine a long and thin capsule versus a sphere: high angular velocity may require significant expansion on the capsule, but spheres are rotationally invariant.

ComputeBounds(Quaternion, out Vector3, out Vector3)

Computes the bounding box of a shape given an orientation.

public readonly void ComputeBounds(Quaternion orientation, out Vector3 min, out Vector3 max)

Parameters

orientation Quaternion

Orientation of the shape to use when computing the bounding box.

min Vector3

Minimum corner of the bounding box.

max Vector3

Maximum corner of the bounding box.

ComputeInertia(float)

Computes the inertia for a body given a mass.

public readonly BodyInertia ComputeInertia(float mass)

Parameters

mass float

Mass to use to compute the body's inertia.

Returns

BodyInertia

Inertia for the body.

Remarks

Note that the BodyInertia returned by this stores the inverse mass and inverse inertia tensor. This is because the most high frequency use of body inertia most naturally uses the inverse.

CreateShapeBatch(BufferPool, int, Shapes)

Creates a shape batch for this type of shape.

public static ShapeBatch CreateShapeBatch(BufferPool pool, int initialCapacity, Shapes shapeBatches)

Parameters

pool BufferPool

Buffer pool used to create the batch.

initialCapacity int

Initial capacity to allocate within the batch.

shapeBatches Shapes

The set of shapes to contain this batch.

Returns

ShapeBatch

Shape batch for the shape type.

Remarks

This is typically used internally to initialize new shape collections in response to shapes being added. It is not likely to be useful outside of the engine.

Dispose(BufferPool)

Returns all resources used by the shape instance to the given pool.

public void Dispose(BufferPool bufferPool)

Parameters

bufferPool BufferPool

GetPoint(HullVertexIndex, out Vector3)

public readonly void GetPoint(HullVertexIndex pointIndex, out Vector3 point)

Parameters

pointIndex HullVertexIndex
point Vector3

GetPoint(int, out Vector3)

public readonly void GetPoint(int pointIndex, out Vector3 point)

Parameters

pointIndex int
point Vector3

GetVertexIndicesForFace(int, out Buffer<HullVertexIndex>)

public readonly void GetVertexIndicesForFace(int faceIndex, out Buffer<HullVertexIndex> faceVertexIndices)

Parameters

faceIndex int
faceVertexIndices Buffer<HullVertexIndex>

RayTest(in RigidPose, Vector3, Vector3, out float, out Vector3)

Tests a ray against the shape.

public readonly bool RayTest(in RigidPose pose, Vector3 origin, Vector3 direction, out float t, out Vector3 normal)

Parameters

pose RigidPose

Pose of the shape during the ray test.

origin Vector3

Origin of the ray to test against the shape relative to the shape.

direction Vector3

Direction of the ray to test against the shape.

t float

Distance along the ray direction to the hit point, if any, in units of the ray direction's length. In other words, hitLocation = origin + direction * t.

normal Vector3

Normal of the impact surface, if any.

Returns

bool

True if the ray intersected the shape, false otherwise.