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

ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding race conditions. More...

#include <BodyID.h>

Public Member Functions

 BodyID ()
 Construct invalid body ID. More...
 
 BodyID (uint32 inID)
 Construct from index and sequence number combined in a single uint32 (use with care!) More...
 
 BodyID (uint32 inID, uint8 inSequenceNumber)
 Construct from index and sequence number. More...
 
uint32 GetIndex () const
 Get index in body array. More...
 
uint8 GetSequenceNumber () const
 
uint32 GetIndexAndSequenceNumber () const
 Returns the index and sequence number combined in an uint32. More...
 
bool IsInvalid () const
 Check if the ID is valid. More...
 
bool operator== (const BodyID &inRHS) const
 Equals check. More...
 
bool operator!= (const BodyID &inRHS) const
 Not equals check. More...
 
bool operator< (const BodyID &inRHS) const
 Smaller than operator, can be used for sorting bodies. More...
 
bool operator> (const BodyID &inRHS) const
 Greater than operator, can be used for sorting bodies. More...
 

Static Public Attributes

static JPH_OVERRIDE_NEW_DELETE constexpr uint32 cInvalidBodyID = 0xffffffff
 The value for an invalid body ID. More...
 
static constexpr uint32 cBroadPhaseBit = 0x00800000
 This bit is used by the broadphase. More...
 
static constexpr uint32 cMaxBodyIndex = 0x7fffff
 Maximum value for body index (also the maximum amount of bodies supported - 1) More...
 
static constexpr uint8 cMaxSequenceNumber = 0xff
 Maximum value for the sequence number. More...
 

Detailed Description

ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding race conditions.

Constructor & Destructor Documentation

◆ BodyID() [1/3]

BodyID::BodyID ( )
inline

Construct invalid body ID.

◆ BodyID() [2/3]

BodyID::BodyID ( uint32  inID)
inlineexplicit

Construct from index and sequence number combined in a single uint32 (use with care!)

◆ BodyID() [3/3]

BodyID::BodyID ( uint32  inID,
uint8  inSequenceNumber 
)
inlineexplicit

Construct from index and sequence number.

Member Function Documentation

◆ GetIndex()

uint32 BodyID::GetIndex ( ) const
inline

Get index in body array.

◆ GetIndexAndSequenceNumber()

uint32 BodyID::GetIndexAndSequenceNumber ( ) const
inline

Returns the index and sequence number combined in an uint32.

◆ GetSequenceNumber()

uint8 BodyID::GetSequenceNumber ( ) const
inline

Get sequence number of body. The sequence number can be used to check if a body ID with the same body index has been reused by another body. It is mainly used in multi threaded situations where a body is removed and its body index is immediately reused by a body created from another thread. Functions querying the broadphase can (after acquiring a body lock) detect that the body has been removed (we assume that this won't happen more than 128 times in a row).

◆ IsInvalid()

bool BodyID::IsInvalid ( ) const
inline

Check if the ID is valid.

◆ operator!=()

bool BodyID::operator!= ( const BodyID inRHS) const
inline

Not equals check.

◆ operator<()

bool BodyID::operator< ( const BodyID inRHS) const
inline

Smaller than operator, can be used for sorting bodies.

◆ operator==()

bool BodyID::operator== ( const BodyID inRHS) const
inline

Equals check.

◆ operator>()

bool BodyID::operator> ( const BodyID inRHS) const
inline

Greater than operator, can be used for sorting bodies.

Member Data Documentation

◆ cBroadPhaseBit

constexpr uint32 BodyID::cBroadPhaseBit = 0x00800000
staticconstexpr

This bit is used by the broadphase.

◆ cInvalidBodyID

JPH_OVERRIDE_NEW_DELETE constexpr uint32 BodyID::cInvalidBodyID = 0xffffffff
staticconstexpr

The value for an invalid body ID.

◆ cMaxBodyIndex

constexpr uint32 BodyID::cMaxBodyIndex = 0x7fffff
staticconstexpr

Maximum value for body index (also the maximum amount of bodies supported - 1)

◆ cMaxSequenceNumber

constexpr uint8 BodyID::cMaxSequenceNumber = 0xff
staticconstexpr

Maximum value for the sequence number.


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