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

Contains the creation settings of a set of bodies. More...

#include <PhysicsScene.h>

Inheritance diagram for PhysicsScene:
RefTarget< PhysicsScene >

Classes

class  ConnectedConstraint
 A constraint and how it is connected to the bodies in the scene. More...
 

Public Types

using PhysicsSceneResult = Result< Ref< PhysicsScene > >
 

Public Member Functions

void AddBody (const BodyCreationSettings &inBody)
 Add a body to the scene. More...
 
void AddConstraint (const TwoBodyConstraintSettings *inConstraint, uint32 inBody1, uint32 inBody2)
 
void AddSoftBody (const SoftBodyCreationSettings &inSoftBody)
 Add a soft body to the scene. More...
 
size_t GetNumBodies () const
 Get number of bodies in this scene. More...
 
const Array< BodyCreationSettings > & GetBodies () const
 Access to the body settings for this scene. More...
 
Array< BodyCreationSettings > & GetBodies ()
 
size_t GetNumConstraints () const
 Get number of constraints in this scene. More...
 
const Array< ConnectedConstraint > & GetConstraints () const
 Access to the constraints for this scene. More...
 
Array< ConnectedConstraint > & GetConstraints ()
 
size_t GetNumSoftBodies () const
 Get number of bodies in this scene. More...
 
const Array< SoftBodyCreationSettings > & GetSoftBodies () const
 Access to the soft body settings for this scene. More...
 
Array< SoftBodyCreationSettings > & GetSoftBodies ()
 
bool CreateBodies (PhysicsSystem *inSystem) const
 Instantiate all bodies, returns false if not all bodies could be created. More...
 
bool FixInvalidScales ()
 
void SaveBinaryState (StreamOut &inStream, bool inSaveShapes, bool inSaveGroupFilter) const
 
void FromPhysicsSystem (const PhysicsSystem *inSystem)
 For debugging purposes: Construct a scene from the current state of the physics system. More...
 
- Public Member Functions inherited from RefTarget< PhysicsScene >
 RefTarget ()=default
 Constructor. More...
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us More...
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator. More...
 
uint32 GetRefCount () const
 Get current refcount of this object. More...
 
void AddRef () const
 Add or release a reference to this object. More...
 
void Release () const
 

Static Public Member Functions

static PhysicsSceneResult sRestoreFromBinaryState (StreamIn &inStream)
 Restore a saved scene from inStream. More...
 
- Static Public Member Functions inherited from RefTarget< PhysicsScene >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION. More...
 

Static Public Attributes

static constexpr uint32 cFixedToWorld = 0xffffffff
 Body constant to use to indicate that the constraint is attached to the fixed world. More...
 

Additional Inherited Members

- Protected Attributes inherited from RefTarget< PhysicsScene >
atomic< uint32mRefCount
 Current reference count. More...
 
- Static Protected Attributes inherited from RefTarget< PhysicsScene >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded. More...
 

Detailed Description

Contains the creation settings of a set of bodies.

Member Typedef Documentation

◆ PhysicsSceneResult

Member Function Documentation

◆ AddBody()

void PhysicsScene::AddBody ( const BodyCreationSettings inBody)

Add a body to the scene.

◆ AddConstraint()

void PhysicsScene::AddConstraint ( const TwoBodyConstraintSettings inConstraint,
uint32  inBody1,
uint32  inBody2 
)

Add a constraint to the scene

Parameters
inConstraintConstraint settings
inBody1Index in the bodies list of first body to attach constraint to
inBody2Index in the bodies list of the second body to attach constraint to

◆ AddSoftBody()

void PhysicsScene::AddSoftBody ( const SoftBodyCreationSettings inSoftBody)

Add a soft body to the scene.

◆ CreateBodies()

bool PhysicsScene::CreateBodies ( PhysicsSystem inSystem) const

Instantiate all bodies, returns false if not all bodies could be created.

◆ FixInvalidScales()

bool PhysicsScene::FixInvalidScales ( )

Go through all body creation settings and fix shapes that are scaled incorrectly (note this will change the scene a bit).

Returns
False when not all scales could be fixed.

◆ FromPhysicsSystem()

void PhysicsScene::FromPhysicsSystem ( const PhysicsSystem inSystem)

For debugging purposes: Construct a scene from the current state of the physics system.

◆ GetBodies() [1/2]

Array< BodyCreationSettings > & PhysicsScene::GetBodies ( )
inline

◆ GetBodies() [2/2]

const Array< BodyCreationSettings > & PhysicsScene::GetBodies ( ) const
inline

Access to the body settings for this scene.

◆ GetConstraints() [1/2]

Array< ConnectedConstraint > & PhysicsScene::GetConstraints ( )
inline

◆ GetConstraints() [2/2]

const Array< ConnectedConstraint > & PhysicsScene::GetConstraints ( ) const
inline

Access to the constraints for this scene.

◆ GetNumBodies()

size_t PhysicsScene::GetNumBodies ( ) const
inline

Get number of bodies in this scene.

◆ GetNumConstraints()

size_t PhysicsScene::GetNumConstraints ( ) const
inline

Get number of constraints in this scene.

◆ GetNumSoftBodies()

size_t PhysicsScene::GetNumSoftBodies ( ) const
inline

Get number of bodies in this scene.

◆ GetSoftBodies() [1/2]

Array< SoftBodyCreationSettings > & PhysicsScene::GetSoftBodies ( )
inline

◆ GetSoftBodies() [2/2]

const Array< SoftBodyCreationSettings > & PhysicsScene::GetSoftBodies ( ) const
inline

Access to the soft body settings for this scene.

◆ SaveBinaryState()

void PhysicsScene::SaveBinaryState ( StreamOut inStream,
bool  inSaveShapes,
bool  inSaveGroupFilter 
) const

Saves the state of this object in binary form to inStream.

Parameters
inStreamThe stream to save the state to
inSaveShapesIf the shapes should be saved as well (these could be shared between physics scenes, in which case the calling application may want to write custom code to restore them)
inSaveGroupFilterIf the group filter should be saved as well (these could be shared)

◆ sRestoreFromBinaryState()

PhysicsScene::PhysicsSceneResult PhysicsScene::sRestoreFromBinaryState ( StreamIn inStream)
static

Restore a saved scene from inStream.

Member Data Documentation

◆ cFixedToWorld

constexpr uint32 PhysicsScene::cFixedToWorld = 0xffffffff
staticconstexpr

Body constant to use to indicate that the constraint is attached to the fixed world.


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