Table of Contents

Class PointCloudShape

Namespace
Jitter2.Collision.Shapes
Assembly
Jitter2.dll

Represents a convex hull shape defined by a point cloud. Unlike ConvexHullShape, it is not necessary for the points to lie on the convex hull. For performance optimization, this shape should ideally be used for a small number of points (~300).

public class PointCloudShape : RigidBodyShape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportMappable, IRayCastable, ISweepTestable, IDistanceTestable, ICloneableShape<PointCloudShape>
Inheritance
PointCloudShape
Implements
Inherited Members

Constructors

PointCloudShape(VertexSupportMap)

Initializes a new instance of the PointCloudShape class.

public PointCloudShape(VertexSupportMap supportMap)

Parameters

supportMap VertexSupportMap

PointCloudShape(IEnumerable<JVector>)

Initializes a new instance of the PointCloudShape class.

public PointCloudShape(IEnumerable<JVector> vertices)

Parameters

vertices IEnumerable<JVector>

All vertices that define the convex hull.

Exceptions

ArgumentException

Thrown when vertices is empty.

PointCloudShape(ReadOnlySpan<JVector>)

Initializes a new instance of the PointCloudShape class.

public PointCloudShape(ReadOnlySpan<JVector> vertices)

Parameters

vertices ReadOnlySpan<JVector>

All vertices that define the convex hull.

Exceptions

ArgumentException

Thrown when vertices is empty.

Properties

Shift

Gets or sets the shift value for the shape. This property can be used when constructing a rigid body that contains one or more shapes.

public JVector Shift { get; set; }

Property Value

JVector

Methods

CalculateBoundingBox(in JQuaternion, in JVector, out JBoundingBox)

public override void CalculateBoundingBox(in JQuaternion orientation, in JVector position, out JBoundingBox box)

Parameters

orientation JQuaternion
position JVector
box JBoundingBox

CalculateMassInertia()

Recalculates the mass, center of mass, and inertia tensor.

public void CalculateMassInertia()

CalculateMassInertia(out JMatrix, out JVector, out float)

Calculates the mass and inertia of the shape. Can be overridden by child classes to improve performance or accuracy. The default implementation relies on an approximation of the shape constructed using the support map function.

public override void CalculateMassInertia(out JMatrix inertia, out JVector com, out float mass)

Parameters

inertia JMatrix
com JVector
mass float

Remarks

The inertia tensor is computed relative to the coordinate system origin (0,0,0), not the center of mass.

Clone()

Creates a copy of this shape. The underlying data structure is shared among the instances.

public PointCloudShape Clone()

Returns

PointCloudShape

GetCenter(out JVector)

Computes a point deep within the shape, used as an initial search point in GJK-based algorithms.

public override void GetCenter(out JVector point)

Parameters

point JVector

A point guaranteed to be inside the convex hull, typically the center of mass.

SupportMap(in JVector, out JVector)

Computes the point on the shape that is furthest in the specified direction.

public override void SupportMap(in JVector direction, out JVector result)

Parameters

direction JVector

The search direction in local space. Does not need to be normalized.

result JVector

The point on the shape's surface furthest along direction.

UpdateShape()

Updates the shape's cached mass, inertia, and bounding box.

public void UpdateShape()