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

Settings for constructing a rigid body. More...

#include <BodyCreationSettings.h>

Inheritance diagram for BodyCreationSettings:
RagdollSettings::Part

Public Types

using GroupFilterToIDMap = StreamUtils::ObjectToIDMap< GroupFilter >
 
using IDToGroupFilterMap = StreamUtils::IDToObjectMap< GroupFilter >
 
using ShapeToIDMap = Shape::ShapeToIDMap
 
using IDToShapeMap = Shape::IDToShapeMap
 
using MaterialToIDMap = StreamUtils::ObjectToIDMap< PhysicsMaterial >
 
using IDToMaterialMap = StreamUtils::IDToObjectMap< PhysicsMaterial >
 
using BCSResult = Result< BodyCreationSettings >
 

Public Member Functions

 BodyCreationSettings ()=default
 Constructor.
 
 BodyCreationSettings (const ShapeSettings *inShape, RVec3Arg inPosition, QuatArg inRotation, EMotionType inMotionType, ObjectLayer inObjectLayer)
 
 BodyCreationSettings (const Shape *inShape, RVec3Arg inPosition, QuatArg inRotation, EMotionType inMotionType, ObjectLayer inObjectLayer)
 
const ShapeSettingsGetShapeSettings () const
 Access to the shape settings object. This contains serializable (non-runtime optimized) information about the Shape.
 
void SetShapeSettings (const ShapeSettings *inShape)
 
Shape::ShapeResult ConvertShapeSettings ()
 Convert ShapeSettings object into a Shape object. This will free the ShapeSettings object and make the object ready for runtime. Serialization is no longer possible after this.
 
const ShapeGetShape () const
 Access to the run-time shape object. Will convert from ShapeSettings object if needed.
 
void SetShape (const Shape *inShape)
 
bool HasMassProperties () const
 Check if the mass properties of this body will be calculated (only relevant for kinematic or dynamic objects that need a MotionProperties object)
 
MassProperties GetMassProperties () const
 Calculate (or return when overridden) the mass and inertia for this body.
 
void SaveBinaryState (StreamOut &inStream) const
 Saves the state of this object in binary form to inStream. Doesn't store the shape nor the group filter.
 
void RestoreBinaryState (StreamIn &inStream)
 Restore the state of this object from inStream. Doesn't restore the shape nor the group filter.
 
void SaveWithChildren (StreamOut &inStream, ShapeToIDMap *ioShapeMap, MaterialToIDMap *ioMaterialMap, GroupFilterToIDMap *ioGroupFilterMap) const
 

Static Public Member Functions

static BCSResult sRestoreWithChildren (StreamIn &inStream, IDToShapeMap &ioShapeMap, IDToMaterialMap &ioMaterialMap, IDToGroupFilterMap &ioGroupFilterMap)
 Restore body creation settings, its shape, materials and group filter. Pass in an empty map in ioShapeMap / ioMaterialMap / ioGroupFilterMap or reuse the same map while reading multiple shapes from the same stream in order to restore duplicates.
 

Public Attributes

RVec3 mPosition = RVec3::sZero()
 Position of the body (not of the center of mass)
 
Quat mRotation = Quat::sIdentity()
 Rotation of the body.
 
Vec3 mLinearVelocity = Vec3::sZero()
 World space linear velocity of the center of mass (m/s)
 
Vec3 mAngularVelocity = Vec3::sZero()
 World space angular velocity (rad/s)
 
uint64 mUserData = 0
 User data value (can be used by application)
 
Collision settings
ObjectLayer mObjectLayer = 0
 The collision layer this body belongs to (determines if two objects can collide)
 
CollisionGroup mCollisionGroup
 The collision group this body belongs to (determines if two objects can collide)
 
Simulation properties
EMotionType mMotionType = EMotionType::Dynamic
 Motion type, determines if the object is static, dynamic or kinematic.
 
EAllowedDOFs mAllowedDOFs = EAllowedDOFs::All
 Which degrees of freedom this body has (can be used to limit simulation to 2D)
 
bool mAllowDynamicOrKinematic = false
 When this body is created as static, this setting tells the system to create a MotionProperties object so that the object can be switched to kinematic or dynamic.
 
bool mIsSensor = false
 If this body is a sensor. A sensor will receive collision callbacks, but will not cause any collision responses and can be used as a trigger volume. See description at Body::SetIsSensor.
 
bool mCollideKinematicVsNonDynamic = false
 If kinematic objects can generate contact points against other kinematic or static objects. See description at Body::SetCollideKinematicVsNonDynamic.
 
bool mUseManifoldReduction = true
 If this body should use manifold reduction (see description at Body::SetUseManifoldReduction)
 
bool mApplyGyroscopicForce = false
 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)
 
EMotionQuality mMotionQuality = EMotionQuality::Discrete
 Motion quality, or how well it detects collisions when it has a high velocity.
 
bool mEnhancedInternalEdgeRemoval = false
 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.
 
bool mAllowSleeping = true
 If this body can go to sleep or not.
 
float mFriction = 0.2f
 Friction of the body (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.
 
float mRestitution = 0.0f
 Restitution of body (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.
 
float mLinearDamping = 0.05f
 Linear damping: dv/dt = -c * v. c must be between 0 and 1 but is usually close to 0.
 
float mAngularDamping = 0.05f
 Angular damping: dw/dt = -c * w. c must be between 0 and 1 but is usually close to 0.
 
float mMaxLinearVelocity = 500.0f
 Maximum linear velocity that this body can reach (m/s)
 
float mMaxAngularVelocity = 0.25f * JPH_PI * 60.0f
 Maximum angular velocity that this body can reach (rad/s)
 
float mGravityFactor = 1.0f
 Value to multiply gravity with for this body.
 
uint mNumVelocityStepsOverride = 0
 Used only when this body is dynamic and colliding. Override for the number of solver velocity iterations to run, 0 means use the default in PhysicsSettings::mNumVelocitySteps. The number of iterations to use is the max of all contacts and constraints in the island.
 
uint mNumPositionStepsOverride = 0
 Used only when this body is dynamic and colliding. Override for the number of solver position iterations to run, 0 means use the default in PhysicsSettings::mNumPositionSteps. The number of iterations to use is the max of all contacts and constraints in the island.
 

Mass properties of the body (by default calculated by the shape)

EOverrideMassProperties mOverrideMassProperties = EOverrideMassProperties::CalculateMassAndInertia
 Determines how mMassPropertiesOverride will be used.
 
float mInertiaMultiplier = 1.0f
 When calculating the inertia (not when it is provided) the calculated inertia will be multiplied by this value.
 
MassProperties mMassPropertiesOverride
 Contains replacement mass settings which override the automatically calculated values.
 

Detailed Description

Settings for constructing a rigid body.

Member Typedef Documentation

◆ BCSResult

◆ GroupFilterToIDMap

◆ IDToGroupFilterMap

◆ IDToMaterialMap

◆ IDToShapeMap

◆ MaterialToIDMap

◆ ShapeToIDMap

Constructor & Destructor Documentation

◆ BodyCreationSettings() [1/3]

BodyCreationSettings::BodyCreationSettings ( )
default

Constructor.

◆ BodyCreationSettings() [2/3]

BodyCreationSettings::BodyCreationSettings ( const ShapeSettings inShape,
RVec3Arg  inPosition,
QuatArg  inRotation,
EMotionType  inMotionType,
ObjectLayer  inObjectLayer 
)
inline

◆ BodyCreationSettings() [3/3]

BodyCreationSettings::BodyCreationSettings ( const Shape inShape,
RVec3Arg  inPosition,
QuatArg  inRotation,
EMotionType  inMotionType,
ObjectLayer  inObjectLayer 
)
inline

Member Function Documentation

◆ ConvertShapeSettings()

Shape::ShapeResult BodyCreationSettings::ConvertShapeSettings ( )

Convert ShapeSettings object into a Shape object. This will free the ShapeSettings object and make the object ready for runtime. Serialization is no longer possible after this.

◆ GetMassProperties()

MassProperties BodyCreationSettings::GetMassProperties ( ) const

Calculate (or return when overridden) the mass and inertia for this body.

◆ GetShape()

const Shape * BodyCreationSettings::GetShape ( ) const

Access to the run-time shape object. Will convert from ShapeSettings object if needed.

◆ GetShapeSettings()

const ShapeSettings * BodyCreationSettings::GetShapeSettings ( ) const
inline

Access to the shape settings object. This contains serializable (non-runtime optimized) information about the Shape.

◆ HasMassProperties()

bool BodyCreationSettings::HasMassProperties ( ) const
inline

Check if the mass properties of this body will be calculated (only relevant for kinematic or dynamic objects that need a MotionProperties object)

◆ RestoreBinaryState()

void BodyCreationSettings::RestoreBinaryState ( StreamIn inStream)

Restore the state of this object from inStream. Doesn't restore the shape nor the group filter.

◆ SaveBinaryState()

void BodyCreationSettings::SaveBinaryState ( StreamOut inStream) const

Saves the state of this object in binary form to inStream. Doesn't store the shape nor the group filter.

◆ SaveWithChildren()

void BodyCreationSettings::SaveWithChildren ( StreamOut inStream,
ShapeToIDMap ioShapeMap,
MaterialToIDMap ioMaterialMap,
GroupFilterToIDMap ioGroupFilterMap 
) const

Save body creation settings, its shape, materials and group filter. Pass in an empty map in ioShapeMap / ioMaterialMap / ioGroupFilterMap or reuse the same map while saving multiple shapes to the same stream in order to avoid writing duplicates. Pass nullptr to ioShapeMap and ioMaterial map to skip saving shapes Pass nullptr to ioGroupFilterMap to skip saving group filters

◆ SetShape()

void BodyCreationSettings::SetShape ( const Shape inShape)
inline

◆ SetShapeSettings()

void BodyCreationSettings::SetShapeSettings ( const ShapeSettings inShape)
inline

◆ sRestoreWithChildren()

BodyCreationSettings::BCSResult BodyCreationSettings::sRestoreWithChildren ( StreamIn inStream,
IDToShapeMap ioShapeMap,
IDToMaterialMap ioMaterialMap,
IDToGroupFilterMap ioGroupFilterMap 
)
static

Restore body creation settings, its shape, materials and group filter. Pass in an empty map in ioShapeMap / ioMaterialMap / ioGroupFilterMap or reuse the same map while reading multiple shapes from the same stream in order to restore duplicates.

Member Data Documentation

◆ mAllowDynamicOrKinematic

bool BodyCreationSettings::mAllowDynamicOrKinematic = false

When this body is created as static, this setting tells the system to create a MotionProperties object so that the object can be switched to kinematic or dynamic.

◆ mAllowedDOFs

EAllowedDOFs BodyCreationSettings::mAllowedDOFs = EAllowedDOFs::All

Which degrees of freedom this body has (can be used to limit simulation to 2D)

◆ mAllowSleeping

bool BodyCreationSettings::mAllowSleeping = true

If this body can go to sleep or not.

◆ mAngularDamping

float BodyCreationSettings::mAngularDamping = 0.05f

Angular damping: dw/dt = -c * w. c must be between 0 and 1 but is usually close to 0.

◆ mAngularVelocity

Vec3 BodyCreationSettings::mAngularVelocity = Vec3::sZero()

World space angular velocity (rad/s)

◆ mApplyGyroscopicForce

bool BodyCreationSettings::mApplyGyroscopicForce = false

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)

◆ mCollideKinematicVsNonDynamic

bool BodyCreationSettings::mCollideKinematicVsNonDynamic = false

If kinematic objects can generate contact points against other kinematic or static objects. See description at Body::SetCollideKinematicVsNonDynamic.

◆ mCollisionGroup

CollisionGroup BodyCreationSettings::mCollisionGroup

The collision group this body belongs to (determines if two objects can collide)

◆ mEnhancedInternalEdgeRemoval

bool BodyCreationSettings::mEnhancedInternalEdgeRemoval = false

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.

◆ mFriction

float BodyCreationSettings::mFriction = 0.2f

Friction of the body (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.

◆ mGravityFactor

float BodyCreationSettings::mGravityFactor = 1.0f

Value to multiply gravity with for this body.

◆ mInertiaMultiplier

float BodyCreationSettings::mInertiaMultiplier = 1.0f

When calculating the inertia (not when it is provided) the calculated inertia will be multiplied by this value.

◆ mIsSensor

bool BodyCreationSettings::mIsSensor = false

If this body is a sensor. A sensor will receive collision callbacks, but will not cause any collision responses and can be used as a trigger volume. See description at Body::SetIsSensor.

◆ mLinearDamping

float BodyCreationSettings::mLinearDamping = 0.05f

Linear damping: dv/dt = -c * v. c must be between 0 and 1 but is usually close to 0.

◆ mLinearVelocity

Vec3 BodyCreationSettings::mLinearVelocity = Vec3::sZero()

World space linear velocity of the center of mass (m/s)

◆ mMassPropertiesOverride

MassProperties BodyCreationSettings::mMassPropertiesOverride

Contains replacement mass settings which override the automatically calculated values.

◆ mMaxAngularVelocity

float BodyCreationSettings::mMaxAngularVelocity = 0.25f * JPH_PI * 60.0f

Maximum angular velocity that this body can reach (rad/s)

◆ mMaxLinearVelocity

float BodyCreationSettings::mMaxLinearVelocity = 500.0f

Maximum linear velocity that this body can reach (m/s)

◆ mMotionQuality

EMotionQuality BodyCreationSettings::mMotionQuality = EMotionQuality::Discrete

Motion quality, or how well it detects collisions when it has a high velocity.

◆ mMotionType

EMotionType BodyCreationSettings::mMotionType = EMotionType::Dynamic

Motion type, determines if the object is static, dynamic or kinematic.

◆ mNumPositionStepsOverride

uint BodyCreationSettings::mNumPositionStepsOverride = 0

Used only when this body is dynamic and colliding. Override for the number of solver position iterations to run, 0 means use the default in PhysicsSettings::mNumPositionSteps. The number of iterations to use is the max of all contacts and constraints in the island.

◆ mNumVelocityStepsOverride

uint BodyCreationSettings::mNumVelocityStepsOverride = 0

Used only when this body is dynamic and colliding. Override for the number of solver velocity iterations to run, 0 means use the default in PhysicsSettings::mNumVelocitySteps. The number of iterations to use is the max of all contacts and constraints in the island.

◆ mObjectLayer

ObjectLayer BodyCreationSettings::mObjectLayer = 0

The collision layer this body belongs to (determines if two objects can collide)

◆ mOverrideMassProperties

EOverrideMassProperties BodyCreationSettings::mOverrideMassProperties = EOverrideMassProperties::CalculateMassAndInertia

Determines how mMassPropertiesOverride will be used.

◆ mPosition

RVec3 BodyCreationSettings::mPosition = RVec3::sZero()

Position of the body (not of the center of mass)

◆ mRestitution

float BodyCreationSettings::mRestitution = 0.0f

Restitution of body (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.

◆ mRotation

Quat BodyCreationSettings::mRotation = Quat::sIdentity()

Rotation of the body.

◆ mUseManifoldReduction

bool BodyCreationSettings::mUseManifoldReduction = true

If this body should use manifold reduction (see description at Body::SetUseManifoldReduction)

◆ mUserData

uint64 BodyCreationSettings::mUserData = 0

User data value (can be used by application)


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