Table of Contents

Class CapsuleShape

Namespace
Jitter2.Collision.Shapes
Assembly
Jitter2.dll

Represents a capsule shape defined by a radius and the length of its cylindrical section.

public class CapsuleShape : RigidBodyShape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportMappable, IRayCastable, ISweepTestable, IDistanceTestable, IDebugDrawable
Inheritance
CapsuleShape
Implements
Inherited Members

Constructors

CapsuleShape(float, float)

Initializes a new instance of the CapsuleShape class with the specified radius and length. The symmetry axis of the capsule is aligned along the Y-axis.

public CapsuleShape(float radius = 0.5, float length = 1)

Parameters

radius float

The radius of the capsule.

length float

The length of the cylindrical part of the capsule, excluding the half-spheres at both ends.

Exceptions

ArgumentOutOfRangeException

Thrown when radius is less than or equal to zero or when length is negative.

Properties

Length

Gets or sets the length of the cylindrical part of the capsule, excluding the half-spheres on both ends.

public float Length { get; set; }

Property Value

float

Exceptions

ArgumentOutOfRangeException

Thrown when value is negative.

Radius

Gets or sets the radius of the capsule.

public float Radius { get; set; }

Property Value

float

Exceptions

ArgumentOutOfRangeException

Thrown when value is less than or equal to zero.

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(out JSymmetricMatrix, 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 JSymmetricMatrix inertia, out JVector com, out float mass)

Parameters

inertia JSymmetricMatrix
com JVector
mass float

Remarks

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

DebugDrawLocal<TSink>(ref TSink, in DebugDrawSettings)

Appends debug triangles in the coordinate system used by SupportMap(in JVector, out JVector).

protected override void DebugDrawLocal<TSink>(ref TSink triangleSink, in DebugDrawSettings settings) where TSink : ISink<JTriangle>

Parameters

triangleSink TSink

The destination for generated triangles.

settings DebugDrawSettings

The visualization settings.

Type Parameters

TSink

Remarks

Override this method to supply custom surface geometry. Rigid-body and affine transforms are applied by the caller. Use outward-facing triangles for closed surfaces. Without an override, the shape is drawn as an approximate surface.

GetCenter(out JVector)

Computes a representative point within the convex hull, used as an initial search point in GJK-based algorithms.

public override void GetCenter(out JVector point)

Parameters

point JVector

A point inside the convex hull.

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.