Class RigidBodyShape
Represents the abstract base class for shapes that can be attached to a rigid body.
public abstract class RigidBodyShape : Shape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportMappable, IRayCastable, ISweepTestable, IDistanceTestable
- Inheritance
-
RigidBodyShape
- Implements
- Derived
- Inherited Members
Properties
RigidBody
The instance of RigidBody to which this shape is attached.
public RigidBody RigidBody { get; }
Property Value
Velocity
Gets the velocity of the entity, used for bounding box expansion.
public override sealed JVector Velocity { get; }
Property Value
Methods
CalculateBoundingBox(in JQuaternion, in JVector, out JBoundingBox)
public virtual 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.
[ReferenceFrame(ReferenceFrame.Local)]
public virtual 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.
Distance<T>(in T, in JQuaternion, in JVector, out JVector, out JVector, out JVector, out float)
Finds the closest points between this object and the query shape.
[ReferenceFrame(ReferenceFrame.World)]
public override sealed bool Distance<T>(in T support, in JQuaternion orientation, in JVector position, out JVector pointA, out JVector pointB, out JVector normal, out float distance) where T : ISupportMappable
Parameters
supportTThe query shape.
orientationJQuaternionThe query shape orientation in world space.
positionJVectorThe query shape position in world space.
pointAJVectorClosest point on the query shape in world space. Undefined when the shapes overlap.
pointBJVectorClosest point on this object in world space. Undefined when the shapes overlap.
normalJVectorUnit direction from the query shape toward this object, or Zero when the shapes overlap. Do not use this to test whether a result was found.
distancefloatThe separation distance between the shapes. Zero when overlapping.
Returns
- bool
trueif the shapes are separated;falseif they overlap.
Type Parameters
TThe query support-map type.
LocalRayCast(in JVector, in JVector, out JVector, out float)
Performs a local ray cast against the shape, checking if a ray originating from a specified point and traveling in a specified direction intersects with the object. It does not take into account the transformation of the associated rigid body.
[ReferenceFrame(ReferenceFrame.Local)]
public virtual bool LocalRayCast(in JVector origin, in JVector direction, out JVector normal, out float lambda)
Parameters
originJVectorThe starting point of the ray.
directionJVectorThe direction of the ray. This vector does not need to be normalized.
normalJVectorWhen this method returns, contains the surface normal at the point of intersection, if an intersection occurs.
lambdafloatWhen this method returns, contains the scalar value representing the distance along the ray's direction vector from the
originto the intersection point. The hit point can be calculated as:origin + lambda * direction.
Returns
- bool
trueif the ray intersects with the object; otherwise,false.
RayCast(in JVector, in JVector, out JVector, out float)
Performs a ray cast against this object.
[ReferenceFrame(ReferenceFrame.World)]
public override sealed bool RayCast(in JVector origin, in JVector direction, out JVector normal, out float lambda)
Parameters
originJVectorThe starting point of the ray.
directionJVectorThe direction of the ray. Does not need to be normalized.
normalJVectorThe surface normal at the intersection point, or Zero if the ray origin is inside the object. Use the return value, not this parameter, to test whether a hit occurred.
lambdafloatThe distance along the ray to the intersection:
hitPoint = origin + lambda * direction. Zero when the ray origin is inside the object.
Returns
- bool
trueif the ray intersects with the object; otherwise,false. Also returnstruewhen the ray origin is inside the object, withlambdaset to zero andnormalset to Zero.
Sweep<T>(in T, in JQuaternion, in JVector, in JVector, out JVector, out JVector, out JVector, out float)
Performs a sweep test against this object.
[ReferenceFrame(ReferenceFrame.World)]
public override sealed bool Sweep<T>(in T support, in JQuaternion orientation, in JVector position, in JVector sweep, out JVector pointA, out JVector pointB, out JVector normal, out float lambda) where T : ISupportMappable
Parameters
supportTThe query shape.
orientationJQuaternionThe query shape orientation in world space.
positionJVectorThe query shape position in world space.
sweepJVectorThe query shape translation in world space.
pointAJVectorCollision point on the query shape in world space at the sweep origin. Undefined when the shapes already overlap.
pointBJVectorCollision point on this object in world space at the sweep origin. Undefined when the shapes already overlap.
normalJVectorCollision normal in world space, or Zero if the shapes already overlap. Use the return value to determine whether a hit occurred; do not rely on this being non-zero.
lambdafloatThe time of impact expressed in units of
sweep. Zero if the shapes already overlap.
Returns
- bool
trueif the query shape hits or already overlaps this object; otherwise,false.
Type Parameters
TThe query support-map type.
UpdateWorldBoundingBox(float)
Recomputes the world-space bounding box.
public override sealed void UpdateWorldBoundingBox(float dt = 0)
Parameters
dtfloatThe timestep for velocity-based expansion. Default is zero.