Class CapsuleShape
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
- 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
radiusfloatThe radius of the capsule.
lengthfloatThe length of the cylindrical part of the capsule, excluding the half-spheres at both ends.
Exceptions
- ArgumentOutOfRangeException
Thrown when
radiusis less than or equal to zero or whenlengthis 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
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis negative.
Radius
Gets or sets the radius of the capsule.
public float Radius { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis 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
orientationJQuaternionpositionJVectorboxJBoundingBox
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
Remarks
The inertia tensor is computed relative to the coordinate system origin (0,0,0), not the center of mass.
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
pointJVectorA 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)