Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Body Class Reference

#include <Body.h>

Inheritance diagram for Body:
NonCopyable BodyWithMotionProperties SoftBodyWithMotionPropertiesAndShape

Public Member Functions

JPH_OVERRIDE_NEW_DELETE Body ()=default
 Default constructor. More...
 
 ~Body ()
 Destructor. More...
 
const BodyIDGetID () const
 Get the id of this body. More...
 
EBodyType GetBodyType () const
 Get the type of body (rigid or soft) More...
 
bool IsRigidBody () const
 Check if this body is a rigid body. More...
 
bool IsSoftBody () const
 Check if this body is a soft body. More...
 
bool IsActive () const
 If this body is currently actively simulating (true) or sleeping (false) More...
 
bool IsStatic () const
 Check if this body is static (not movable) More...
 
bool IsKinematic () const
 Check if this body is kinematic (keyframed), which means that it will move according to its current velocity, but forces don't affect it. More...
 
bool IsDynamic () const
 Check if this body is dynamic, which means that it moves and forces can act on it. More...
 
bool CanBeKinematicOrDynamic () const
 Check if a body could be made kinematic or dynamic (if it was created dynamic or with mAllowDynamicOrKinematic set to true) More...
 
void SetIsSensor (bool inIsSensor)
 
bool IsSensor () const
 Check if this body is a sensor. More...
 
void SetCollideKinematicVsNonDynamic (bool inCollide)
 
bool GetCollideKinematicVsNonDynamic () const
 Check if kinematic objects can generate contact points against other kinematic or static objects. More...
 
void SetUseManifoldReduction (bool inUseReduction)
 
bool GetUseManifoldReduction () const
 Check if this body can use manifold reduction. More...
 
bool GetUseManifoldReductionWithBody (const Body &inBody2) const
 Checks if the combination of this body and inBody2 should use manifold reduction. More...
 
void SetApplyGyroscopicForce (bool inApply)
 Set to indicate that the gyroscopic force should be applied to this body (aka Dzhanibekov effect, see https://en.wikipedia.org/wiki/Tennis_racket_theorem) More...
 
bool GetApplyGyroscopicForce () const
 Check if the gyroscopic force is being applied for this body. More...
 
void SetEnhancedInternalEdgeRemoval (bool inApply)
 Set to indicate that extra effort should be made to try to remove ghost contacts (collisions with internal edges of a mesh). This is more expensive but makes bodies move smoother over a mesh with convex edges. More...
 
bool GetEnhancedInternalEdgeRemoval () const
 Check if enhanced internal edge removal is turned on. More...
 
bool GetEnhancedInternalEdgeRemovalWithBody (const Body &inBody2) const
 Checks if the combination of this body and inBody2 should use enhanced internal edge removal. More...
 
EMotionType GetMotionType () const
 Get the bodies motion type. More...
 
void SetMotionType (EMotionType inMotionType)
 Set the motion type of this body. Consider using BodyInterface::SetMotionType instead of this function if the body may be active or if it needs to be activated. More...
 
BroadPhaseLayer GetBroadPhaseLayer () const
 Get broadphase layer, this determines in which broad phase sub-tree the object is placed. More...
 
ObjectLayer GetObjectLayer () const
 Get object layer, this determines which other objects it collides with. More...
 
const CollisionGroupGetCollisionGroup () const
 Collision group and sub-group ID, determines which other objects it collides with. More...
 
CollisionGroupGetCollisionGroup ()
 
void SetCollisionGroup (const CollisionGroup &inGroup)
 
bool GetAllowSleeping () const
 If this body can go to sleep. Note that disabling sleeping on a sleeping object will not wake it up. More...
 
void SetAllowSleeping (bool inAllow)
 
void ResetSleepTimer ()
 Resets the sleep timer. This does not wake up the body if it is sleeping, but allows resetting the system that detects when a body is sleeping. More...
 
float GetFriction () const
 Friction (dimensionless number, usually between 0 and 1, 0 = no friction, 1 = friction force equals force that presses the two bodies together). Note that bodies can have negative friction but the combined friction (see PhysicsSystem::SetCombineFriction) should never go below zero. More...
 
void SetFriction (float inFriction)
 
float GetRestitution () const
 Restitution (dimensionless number, usually between 0 and 1, 0 = completely inelastic collision response, 1 = completely elastic collision response). Note that bodies can have negative restitution but the combined restitution (see PhysicsSystem::SetCombineRestitution) should never go below zero. More...
 
void SetRestitution (float inRestitution)
 
Vec3 GetLinearVelocity () const
 Get world space linear velocity of the center of mass (unit: m/s) More...
 
void SetLinearVelocity (Vec3Arg inLinearVelocity)
 Set world space linear velocity of the center of mass (unit: m/s) More...
 
void SetLinearVelocityClamped (Vec3Arg inLinearVelocity)
 Set world space linear velocity of the center of mass, will make sure the value is clamped against the maximum linear velocity. More...
 
Vec3 GetAngularVelocity () const
 Get world space angular velocity of the center of mass (unit: rad/s) More...
 
void SetAngularVelocity (Vec3Arg inAngularVelocity)
 Set world space angular velocity of the center of mass (unit: rad/s) More...
 
void SetAngularVelocityClamped (Vec3Arg inAngularVelocity)
 Set world space angular velocity of the center of mass, will make sure the value is clamped against the maximum angular velocity. More...
 
Vec3 GetPointVelocityCOM (Vec3Arg inPointRelativeToCOM) const
 Velocity of point inPoint (in center of mass space, e.g. on the surface of the body) of the body (unit: m/s) More...
 
Vec3 GetPointVelocity (RVec3Arg inPoint) const
 Velocity of point inPoint (in world space, e.g. on the surface of the body) of the body (unit: m/s) More...
 
void AddForce (Vec3Arg inForce)
 Add force (unit: N) at center of mass for the next time step, will be reset after the next call to PhysicsSystem::Update. More...
 
void AddForce (Vec3Arg inForce, RVec3Arg inPosition)
 Add force (unit: N) at inPosition for the next time step, will be reset after the next call to PhysicsSystem::Update. More...
 
void AddTorque (Vec3Arg inTorque)
 Add torque (unit: N m) for the next time step, will be reset after the next call to PhysicsSystem::Update. More...
 
Vec3 GetAccumulatedForce () const
 
Vec3 GetAccumulatedTorque () const
 
JPH_INLINE void ResetForce ()
 
JPH_INLINE void ResetTorque ()
 
JPH_INLINE void ResetMotion ()
 
Mat44 GetInverseInertia () const
 Get inverse inertia tensor in world space. More...
 
void AddImpulse (Vec3Arg inImpulse)
 Add impulse to center of mass (unit: kg m/s) More...
 
void AddImpulse (Vec3Arg inImpulse, RVec3Arg inPosition)
 Add impulse to point in world space (unit: kg m/s) More...
 
void AddAngularImpulse (Vec3Arg inAngularImpulse)
 Add angular impulse in world space (unit: N m s) More...
 
void MoveKinematic (RVec3Arg inTargetPosition, QuatArg inTargetRotation, float inDeltaTime)
 Set velocity of body such that it will be positioned at inTargetPosition/Rotation in inDeltaTime seconds. More...
 
bool ApplyBuoyancyImpulse (RVec3Arg inSurfacePosition, Vec3Arg inSurfaceNormal, float inBuoyancy, float inLinearDrag, float inAngularDrag, Vec3Arg inFluidVelocity, Vec3Arg inGravity, float inDeltaTime)
 
bool IsInBroadPhase () const
 Check if this body has been added to the physics system. More...
 
bool IsCollisionCacheInvalid () const
 Check if this body has been changed in such a way that the collision cache should be considered invalid for any body interacting with this body. More...
 
const ShapeGetShape () const
 Get the shape of this body. More...
 
RVec3 GetPosition () const
 World space position of the body. More...
 
Quat GetRotation () const
 World space rotation of the body. More...
 
RMat44 GetWorldTransform () const
 Calculates the transform of this body. More...
 
RVec3 GetCenterOfMassPosition () const
 Gets the world space position of this body's center of mass. More...
 
RMat44 GetCenterOfMassTransform () const
 Calculates the transform for this body's center of mass. More...
 
RMat44 GetInverseCenterOfMassTransform () const
 Calculates the inverse of the transform for this body's center of mass. More...
 
const AABoxGetWorldSpaceBounds () const
 Get world space bounding box. More...
 
const MotionPropertiesGetMotionProperties () const
 Access to the motion properties. More...
 
MotionPropertiesGetMotionProperties ()
 
const MotionPropertiesGetMotionPropertiesUnchecked () const
 Access to the motion properties (version that does not check if the object is kinematic or dynamic) More...
 
MotionPropertiesGetMotionPropertiesUnchecked ()
 
uint64 GetUserData () const
 Access to the user data, can be used for anything by the application. More...
 
void SetUserData (uint64 inUserData)
 
Vec3 GetWorldSpaceSurfaceNormal (const SubShapeID &inSubShapeID, RVec3Arg inPosition) const
 Get surface normal of a particular sub shape and its world space surface position on this body. More...
 
TransformedShape GetTransformedShape () const
 Get the transformed shape of this body, which can be used to do collision detection outside of a body lock. More...
 
BodyCreationSettings GetBodyCreationSettings () const
 Debug function to convert a body back to a body creation settings object to be able to save/recreate the body later. More...
 
SoftBodyCreationSettings GetSoftBodyCreationSettings () const
 Debug function to convert a soft body back to a soft body creation settings object to be able to save/recreate the body later. More...
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Static Public Attributes

static Body sFixedToWorld
 A dummy body that can be used by constraints to attach a constraint to the world instead of another body. More...
 
static constexpr uint32 cInactiveIndex = MotionProperties::cInactiveIndex
 Constant indicating that body is not active. More...
 

Friends

class BodyManager
 

THESE FUNCTIONS ARE FOR INTERNAL USE ONLY AND SHOULD NOT BE CALLED BY THE APPLICATION

void AddPositionStep (Vec3Arg inLinearVelocityTimesDeltaTime)
 Update position using an Euler step (used during position integrate & constraint solving) More...
 
void SubPositionStep (Vec3Arg inLinearVelocityTimesDeltaTime)
 
void AddRotationStep (Vec3Arg inAngularVelocityTimesDeltaTime)
 Update rotation using an Euler step (using during position integrate & constraint solving) More...
 
void SubRotationStep (Vec3Arg inAngularVelocityTimesDeltaTime)
 
void SetInBroadPhaseInternal (bool inInBroadPhase)
 Flag if body is in the broadphase (should only be called by the BroadPhase) More...
 
bool InvalidateContactCacheInternal ()
 Invalidate the contact cache (should only be called by the BodyManager), will be reset the next simulation step. Returns true if the contact cache was still valid. More...
 
void ValidateContactCacheInternal ()
 Reset the collision cache invalid flag (should only be called by the BodyManager). More...
 
void CalculateWorldSpaceBoundsInternal ()
 Updates world space bounding box (should only be called by the PhysicsSystem) More...
 
void SetPositionAndRotationInternal (RVec3Arg inPosition, QuatArg inRotation, bool inResetSleepTimer=true)
 Function to update body's position (should only be called by the BodyInterface since it also requires updating the broadphase) More...
 
void UpdateCenterOfMassInternal (Vec3Arg inPreviousCenterOfMass, bool inUpdateMassProperties)
 
void SetShapeInternal (const Shape *inShape, bool inUpdateMassProperties)
 
uint32 GetIndexInActiveBodiesInternal () const
 Access to the index in the BodyManager::mActiveBodies list. More...
 
ECanSleep UpdateSleepStateInternal (float inDeltaTime, float inMaxMovement, float inTimeBeforeSleep)
 Update eligibility for sleeping. More...
 
void SaveState (StateRecorder &inStream) const
 Saving state for replay. More...
 
void RestoreState (StateRecorder &inStream)
 Restoring state for replay. More...
 
static bool sFindCollidingPairsCanCollide (const Body &inBody1, const Body &inBody2)
 

Detailed Description

A rigid body that can be simulated using the physics system

Note that internally all properties (position, velocity etc.) are tracked relative to the center of mass of the object to simplify the simulation of the object.

The offset between the position of the body and the center of mass position of the body is GetShape()->GetCenterOfMass(). The functions that get/set the position of the body all indicate if they are relative to the center of mass or to the original position in which the shape was created.

The linear velocity is also velocity of the center of mass, to correct for this: \(VelocityCOM = Velocity - AngularVelocity \times ShapeCOM\).

Constructor & Destructor Documentation

◆ Body()

JPH_OVERRIDE_NEW_DELETE Body::Body ( )
default

Default constructor.

◆ ~Body()

Body::~Body ( )
inline

Destructor.

Member Function Documentation

◆ AddAngularImpulse()

void Body::AddAngularImpulse ( Vec3Arg  inAngularImpulse)
inline

Add angular impulse in world space (unit: N m s)

◆ AddForce() [1/2]

void Body::AddForce ( Vec3Arg  inForce)
inline

Add force (unit: N) at center of mass for the next time step, will be reset after the next call to PhysicsSystem::Update.

◆ AddForce() [2/2]

void Body::AddForce ( Vec3Arg  inForce,
RVec3Arg  inPosition 
)
inline

Add force (unit: N) at inPosition for the next time step, will be reset after the next call to PhysicsSystem::Update.

◆ AddImpulse() [1/2]

void Body::AddImpulse ( Vec3Arg  inImpulse)
inline

Add impulse to center of mass (unit: kg m/s)

◆ AddImpulse() [2/2]

void Body::AddImpulse ( Vec3Arg  inImpulse,
RVec3Arg  inPosition 
)
inline

Add impulse to point in world space (unit: kg m/s)

◆ AddPositionStep()

void Body::AddPositionStep ( Vec3Arg  inLinearVelocityTimesDeltaTime)
inline

Update position using an Euler step (used during position integrate & constraint solving)

◆ AddRotationStep()

void Body::AddRotationStep ( Vec3Arg  inAngularVelocityTimesDeltaTime)
inline

Update rotation using an Euler step (using during position integrate & constraint solving)

◆ AddTorque()

void Body::AddTorque ( Vec3Arg  inTorque)
inline

Add torque (unit: N m) for the next time step, will be reset after the next call to PhysicsSystem::Update.

◆ ApplyBuoyancyImpulse()

bool Body::ApplyBuoyancyImpulse ( RVec3Arg  inSurfacePosition,
Vec3Arg  inSurfaceNormal,
float  inBuoyancy,
float  inLinearDrag,
float  inAngularDrag,
Vec3Arg  inFluidVelocity,
Vec3Arg  inGravity,
float  inDeltaTime 
)

Applies an impulse to the body that simulates fluid buoyancy and drag

Parameters
inSurfacePositionPosition of the fluid surface in world space
inSurfaceNormalNormal of the fluid surface (should point up)
inBuoyancyThe buoyancy factor for the body. 1 = neutral body, < 1 sinks, > 1 floats. Note that we don't use the fluid density since it is harder to configure than a simple number between [0, 2]
inLinearDragLinear drag factor that slows down the body when in the fluid (approx. 0.5)
inAngularDragAngular drag factor that slows down rotation when the body is in the fluid (approx. 0.01)
inFluidVelocityThe average velocity of the fluid (in m/s) in which the body resides
inGravityThe gravity vector (pointing down)
inDeltaTimeDelta time of the next simulation step (in s)
Returns
true if an impulse was applied, false if the body was not in the fluid

◆ CalculateWorldSpaceBoundsInternal()

void Body::CalculateWorldSpaceBoundsInternal ( )

Updates world space bounding box (should only be called by the PhysicsSystem)

◆ CanBeKinematicOrDynamic()

bool Body::CanBeKinematicOrDynamic ( ) const
inline

Check if a body could be made kinematic or dynamic (if it was created dynamic or with mAllowDynamicOrKinematic set to true)

◆ GetAccumulatedForce()

Vec3 Body::GetAccumulatedForce ( ) const
inline

◆ GetAccumulatedTorque()

Vec3 Body::GetAccumulatedTorque ( ) const
inline

◆ GetAllowSleeping()

bool Body::GetAllowSleeping ( ) const
inline

If this body can go to sleep. Note that disabling sleeping on a sleeping object will not wake it up.

◆ GetAngularVelocity()

Vec3 Body::GetAngularVelocity ( ) const
inline

Get world space angular velocity of the center of mass (unit: rad/s)

◆ GetApplyGyroscopicForce()

bool Body::GetApplyGyroscopicForce ( ) const
inline

Check if the gyroscopic force is being applied for this body.

◆ GetBodyCreationSettings()

BodyCreationSettings Body::GetBodyCreationSettings ( ) const

Debug function to convert a body back to a body creation settings object to be able to save/recreate the body later.

◆ GetBodyType()

EBodyType Body::GetBodyType ( ) const
inline

Get the type of body (rigid or soft)

◆ GetBroadPhaseLayer()

BroadPhaseLayer Body::GetBroadPhaseLayer ( ) const
inline

Get broadphase layer, this determines in which broad phase sub-tree the object is placed.

◆ GetCenterOfMassPosition()

RVec3 Body::GetCenterOfMassPosition ( ) const
inline

Gets the world space position of this body's center of mass.

◆ GetCenterOfMassTransform()

RMat44 Body::GetCenterOfMassTransform ( ) const
inline

Calculates the transform for this body's center of mass.

◆ GetCollideKinematicVsNonDynamic()

bool Body::GetCollideKinematicVsNonDynamic ( ) const
inline

Check if kinematic objects can generate contact points against other kinematic or static objects.

◆ GetCollisionGroup() [1/2]

CollisionGroup & Body::GetCollisionGroup ( )
inline

◆ GetCollisionGroup() [2/2]

const CollisionGroup & Body::GetCollisionGroup ( ) const
inline

Collision group and sub-group ID, determines which other objects it collides with.

◆ GetEnhancedInternalEdgeRemoval()

bool Body::GetEnhancedInternalEdgeRemoval ( ) const
inline

Check if enhanced internal edge removal is turned on.

◆ GetEnhancedInternalEdgeRemovalWithBody()

bool Body::GetEnhancedInternalEdgeRemovalWithBody ( const Body inBody2) const
inline

Checks if the combination of this body and inBody2 should use enhanced internal edge removal.

◆ GetFriction()

float Body::GetFriction ( ) const
inline

Friction (dimensionless number, usually between 0 and 1, 0 = no friction, 1 = friction force equals force that presses the two bodies together). Note that bodies can have negative friction but the combined friction (see PhysicsSystem::SetCombineFriction) should never go below zero.

◆ GetID()

const BodyID & Body::GetID ( ) const
inline

Get the id of this body.

◆ GetIndexInActiveBodiesInternal()

uint32 Body::GetIndexInActiveBodiesInternal ( ) const
inline

Access to the index in the BodyManager::mActiveBodies list.

◆ GetInverseCenterOfMassTransform()

RMat44 Body::GetInverseCenterOfMassTransform ( ) const
inline

Calculates the inverse of the transform for this body's center of mass.

◆ GetInverseInertia()

Mat44 Body::GetInverseInertia ( ) const
inline

Get inverse inertia tensor in world space.

◆ GetLinearVelocity()

Vec3 Body::GetLinearVelocity ( ) const
inline

Get world space linear velocity of the center of mass (unit: m/s)

◆ GetMotionProperties() [1/2]

MotionProperties * Body::GetMotionProperties ( )
inline

◆ GetMotionProperties() [2/2]

const MotionProperties * Body::GetMotionProperties ( ) const
inline

Access to the motion properties.

◆ GetMotionPropertiesUnchecked() [1/2]

MotionProperties * Body::GetMotionPropertiesUnchecked ( )
inline

◆ GetMotionPropertiesUnchecked() [2/2]

const MotionProperties * Body::GetMotionPropertiesUnchecked ( ) const
inline

Access to the motion properties (version that does not check if the object is kinematic or dynamic)

◆ GetMotionType()

EMotionType Body::GetMotionType ( ) const
inline

Get the bodies motion type.

◆ GetObjectLayer()

ObjectLayer Body::GetObjectLayer ( ) const
inline

Get object layer, this determines which other objects it collides with.

◆ GetPointVelocity()

Vec3 Body::GetPointVelocity ( RVec3Arg  inPoint) const
inline

Velocity of point inPoint (in world space, e.g. on the surface of the body) of the body (unit: m/s)

◆ GetPointVelocityCOM()

Vec3 Body::GetPointVelocityCOM ( Vec3Arg  inPointRelativeToCOM) const
inline

Velocity of point inPoint (in center of mass space, e.g. on the surface of the body) of the body (unit: m/s)

◆ GetPosition()

RVec3 Body::GetPosition ( ) const
inline

World space position of the body.

◆ GetRestitution()

float Body::GetRestitution ( ) const
inline

Restitution (dimensionless number, usually between 0 and 1, 0 = completely inelastic collision response, 1 = completely elastic collision response). Note that bodies can have negative restitution but the combined restitution (see PhysicsSystem::SetCombineRestitution) should never go below zero.

◆ GetRotation()

Quat Body::GetRotation ( ) const
inline

World space rotation of the body.

◆ GetShape()

const Shape * Body::GetShape ( ) const
inline

Get the shape of this body.

◆ GetSoftBodyCreationSettings()

SoftBodyCreationSettings Body::GetSoftBodyCreationSettings ( ) const

Debug function to convert a soft body back to a soft body creation settings object to be able to save/recreate the body later.

◆ GetTransformedShape()

TransformedShape Body::GetTransformedShape ( ) const
inline

Get the transformed shape of this body, which can be used to do collision detection outside of a body lock.

◆ GetUseManifoldReduction()

bool Body::GetUseManifoldReduction ( ) const
inline

Check if this body can use manifold reduction.

◆ GetUseManifoldReductionWithBody()

bool Body::GetUseManifoldReductionWithBody ( const Body inBody2) const
inline

Checks if the combination of this body and inBody2 should use manifold reduction.

◆ GetUserData()

uint64 Body::GetUserData ( ) const
inline

Access to the user data, can be used for anything by the application.

◆ GetWorldSpaceBounds()

const AABox & Body::GetWorldSpaceBounds ( ) const
inline

Get world space bounding box.

◆ GetWorldSpaceSurfaceNormal()

Vec3 Body::GetWorldSpaceSurfaceNormal ( const SubShapeID inSubShapeID,
RVec3Arg  inPosition 
) const
inline

Get surface normal of a particular sub shape and its world space surface position on this body.

◆ GetWorldTransform()

JPH_NAMESPACE_BEGIN RMat44 Body::GetWorldTransform ( ) const
inline

Calculates the transform of this body.

◆ InvalidateContactCacheInternal()

bool Body::InvalidateContactCacheInternal ( )
inline

Invalidate the contact cache (should only be called by the BodyManager), will be reset the next simulation step. Returns true if the contact cache was still valid.

◆ IsActive()

bool Body::IsActive ( ) const
inline

If this body is currently actively simulating (true) or sleeping (false)

◆ IsCollisionCacheInvalid()

bool Body::IsCollisionCacheInvalid ( ) const
inline

Check if this body has been changed in such a way that the collision cache should be considered invalid for any body interacting with this body.

◆ IsDynamic()

bool Body::IsDynamic ( ) const
inline

Check if this body is dynamic, which means that it moves and forces can act on it.

◆ IsInBroadPhase()

bool Body::IsInBroadPhase ( ) const
inline

Check if this body has been added to the physics system.

◆ IsKinematic()

bool Body::IsKinematic ( ) const
inline

Check if this body is kinematic (keyframed), which means that it will move according to its current velocity, but forces don't affect it.

◆ IsRigidBody()

bool Body::IsRigidBody ( ) const
inline

Check if this body is a rigid body.

◆ IsSensor()

bool Body::IsSensor ( ) const
inline

Check if this body is a sensor.

◆ IsSoftBody()

bool Body::IsSoftBody ( ) const
inline

Check if this body is a soft body.

◆ IsStatic()

bool Body::IsStatic ( ) const
inline

Check if this body is static (not movable)

◆ MoveKinematic()

void Body::MoveKinematic ( RVec3Arg  inTargetPosition,
QuatArg  inTargetRotation,
float  inDeltaTime 
)

Set velocity of body such that it will be positioned at inTargetPosition/Rotation in inDeltaTime seconds.

◆ ResetForce()

JPH_INLINE void Body::ResetForce ( )
inline

◆ ResetMotion()

JPH_INLINE void Body::ResetMotion ( )
inline

◆ ResetSleepTimer()

void Body::ResetSleepTimer ( )
inline

Resets the sleep timer. This does not wake up the body if it is sleeping, but allows resetting the system that detects when a body is sleeping.

◆ ResetTorque()

JPH_INLINE void Body::ResetTorque ( )
inline

◆ RestoreState()

void Body::RestoreState ( StateRecorder inStream)

Restoring state for replay.

◆ SaveState()

void Body::SaveState ( StateRecorder inStream) const

Saving state for replay.

◆ SetAllowSleeping()

void Body::SetAllowSleeping ( bool  inAllow)

◆ SetAngularVelocity()

void Body::SetAngularVelocity ( Vec3Arg  inAngularVelocity)
inline

Set world space angular velocity of the center of mass (unit: rad/s)

◆ SetAngularVelocityClamped()

void Body::SetAngularVelocityClamped ( Vec3Arg  inAngularVelocity)
inline

Set world space angular velocity of the center of mass, will make sure the value is clamped against the maximum angular velocity.

◆ SetApplyGyroscopicForce()

void Body::SetApplyGyroscopicForce ( bool  inApply)
inline

Set to indicate that the gyroscopic force should be applied to this body (aka Dzhanibekov effect, see https://en.wikipedia.org/wiki/Tennis_racket_theorem)

◆ SetCollideKinematicVsNonDynamic()

void Body::SetCollideKinematicVsNonDynamic ( bool  inCollide)
inline

If kinematic objects can generate contact points against other kinematic or static objects. Note that turning this on can be CPU intensive as much more collision detection work will be done without any effect on the simulation (kinematic objects are not affected by other kinematic/static objects). This can be used to make sensors detect static objects. Note that the sensor must be kinematic and active for it to detect static objects.

◆ SetCollisionGroup()

void Body::SetCollisionGroup ( const CollisionGroup inGroup)
inline

◆ SetEnhancedInternalEdgeRemoval()

void Body::SetEnhancedInternalEdgeRemoval ( bool  inApply)
inline

Set to indicate that extra effort should be made to try to remove ghost contacts (collisions with internal edges of a mesh). This is more expensive but makes bodies move smoother over a mesh with convex edges.

◆ SetFriction()

void Body::SetFriction ( float  inFriction)
inline

◆ SetInBroadPhaseInternal()

void Body::SetInBroadPhaseInternal ( bool  inInBroadPhase)
inline

Flag if body is in the broadphase (should only be called by the BroadPhase)

◆ SetIsSensor()

void Body::SetIsSensor ( bool  inIsSensor)
inline

Change the body to a sensor. A sensor will receive collision callbacks, but will not cause any collision responses and can be used as a trigger volume. The cheapest sensor (in terms of CPU usage) is a sensor with motion type Static (they can be moved around using BodyInterface::SetPosition/SetPositionAndRotation). These sensors will only detect collisions with active Dynamic or Kinematic bodies. As soon as a body go to sleep, the contact point with the sensor will be lost. If you make a sensor Dynamic or Kinematic and activate them, the sensor will be able to detect collisions with sleeping bodies too. An active sensor will never go to sleep automatically. When you make a Dynamic or Kinematic sensor, make sure it is in an ObjectLayer that does not collide with Static bodies or other sensors to avoid extra overhead in the broad phase.

◆ SetLinearVelocity()

void Body::SetLinearVelocity ( Vec3Arg  inLinearVelocity)
inline

Set world space linear velocity of the center of mass (unit: m/s)

◆ SetLinearVelocityClamped()

void Body::SetLinearVelocityClamped ( Vec3Arg  inLinearVelocity)
inline

Set world space linear velocity of the center of mass, will make sure the value is clamped against the maximum linear velocity.

◆ SetMotionType()

void Body::SetMotionType ( EMotionType  inMotionType)

Set the motion type of this body. Consider using BodyInterface::SetMotionType instead of this function if the body may be active or if it needs to be activated.

◆ SetPositionAndRotationInternal()

void Body::SetPositionAndRotationInternal ( RVec3Arg  inPosition,
QuatArg  inRotation,
bool  inResetSleepTimer = true 
)

Function to update body's position (should only be called by the BodyInterface since it also requires updating the broadphase)

◆ SetRestitution()

void Body::SetRestitution ( float  inRestitution)
inline

◆ SetShapeInternal()

void Body::SetShapeInternal ( const Shape inShape,
bool  inUpdateMassProperties 
)

Function to update a body's shape (should only be called by the BodyInterface since it also requires updating the broadphase)

Parameters
inShapeThe new shape for this body
inUpdateMassPropertiesWhen true, the mass and inertia tensor is recalculated

◆ SetUseManifoldReduction()

void Body::SetUseManifoldReduction ( bool  inUseReduction)
inline

If PhysicsSettings::mUseManifoldReduction is true, this allows turning off manifold reduction for this specific body. Manifold reduction by default will combine contacts with similar normals that come from different SubShapeIDs (e.g. different triangles in a mesh shape or different compound shapes). If the application requires tracking exactly which SubShapeIDs are in contact, you can turn off manifold reduction. Note that this comes at a performance cost. Consider using BodyInterface::SetUseManifoldReduction if the body could already be in contact with other bodies to ensure that the contact cache is invalidated and you get the correct contact callbacks.

◆ SetUserData()

void Body::SetUserData ( uint64  inUserData)
inline

◆ sFindCollidingPairsCanCollide()

bool Body::sFindCollidingPairsCanCollide ( const Body inBody1,
const Body inBody2 
)
inlinestatic

Helper function for BroadPhase::FindCollidingPairs that returns true when two bodies can collide It assumes that body 1 is dynamic and active and guarantees that it body 1 collides with body 2 that body 2 will not collide with body 1 in order to avoid finding duplicate collision pairs

◆ SubPositionStep()

void Body::SubPositionStep ( Vec3Arg  inLinearVelocityTimesDeltaTime)
inline

◆ SubRotationStep()

void Body::SubRotationStep ( Vec3Arg  inAngularVelocityTimesDeltaTime)
inline

◆ UpdateCenterOfMassInternal()

void Body::UpdateCenterOfMassInternal ( Vec3Arg  inPreviousCenterOfMass,
bool  inUpdateMassProperties 
)

Updates the center of mass and optionally mass properties after shifting the center of mass or changes to the shape (should only be called by the BodyInterface since it also requires updating the broadphase)

Parameters
inPreviousCenterOfMassCenter of mass of the shape before the alterations
inUpdateMassPropertiesWhen true, the mass and inertia tensor is recalculated

◆ UpdateSleepStateInternal()

ECanSleep Body::UpdateSleepStateInternal ( float  inDeltaTime,
float  inMaxMovement,
float  inTimeBeforeSleep 
)

Update eligibility for sleeping.

◆ ValidateContactCacheInternal()

void Body::ValidateContactCacheInternal ( )
inline

Reset the collision cache invalid flag (should only be called by the BodyManager).

Friends And Related Function Documentation

◆ BodyManager

friend class BodyManager
friend

Member Data Documentation

◆ cInactiveIndex

constexpr uint32 Body::cInactiveIndex = MotionProperties::cInactiveIndex
staticconstexpr

Constant indicating that body is not active.

◆ sFixedToWorld

Body Body::sFixedToWorld
static

A dummy body that can be used by constraints to attach a constraint to the world instead of another body.


The documentation for this class was generated from the following files: