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

A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compound shape. More...

#include <SubShapeID.h>

Public Types

using Type = uint32
 Underlying storage type.
 
using BiggerType = uint64
 Type that is bigger than the underlying storage type for operations that would otherwise overflow.
 

Public Member Functions

 SubShapeID ()=default
 Constructor.
 
Type PopID (uint inBits, SubShapeID &outRemainder) const
 Get the next id in the chain of ids (pops parents before children)
 
Type GetValue () const
 Get the value of the path to the sub shape ID.
 
void SetValue (Type inValue)
 Set the value of the sub shape ID (use with care!)
 
bool IsEmpty () const
 
bool operator== (const SubShapeID &inRHS) const
 Check equal.
 
bool operator!= (const SubShapeID &inRHS) const
 Check not-equal.
 

Static Public Attributes

static constexpr uint MaxBits = 8 * sizeof(Type)
 How many bits we can store in this ID.
 

Friends

class SubShapeIDCreator
 

Detailed Description

A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compound shape.

Each sub shape knows how many bits it needs to encode its ID, so knows how many bits to take from the sub shape ID.

For example:

  • We have a CompoundShape A with 5 child shapes (identify sub shape using 3 bits AAA)
  • One of its child shapes is CompoundShape B which has 3 child shapes (identify sub shape using 2 bits BB)
  • One of its child shapes is MeshShape C which contains enough triangles to need 7 bits to identify a triangle (identify sub shape using 7 bits CCCCCCC, note that MeshShape is block based and sorts triangles spatially, you can't assume that the first triangle will have bit pattern 0000000).

The bit pattern of the sub shape ID to identify a triangle in MeshShape C will then be CCCCCCCBBAAA.

A sub shape ID will become invalid when the structure of the shape changes. For example, if a child shape is removed from a compound shape, the sub shape ID will no longer be valid. This can be a problem when caching sub shape IDs from one frame to the next. See comments at ContactListener::OnContactPersisted / OnContactRemoved.

Member Typedef Documentation

◆ BiggerType

Type that is bigger than the underlying storage type for operations that would otherwise overflow.

◆ Type

Underlying storage type.

Constructor & Destructor Documentation

◆ SubShapeID()

SubShapeID::SubShapeID ( )
default

Constructor.

Member Function Documentation

◆ GetValue()

Type SubShapeID::GetValue ( ) const
inline

Get the value of the path to the sub shape ID.

◆ IsEmpty()

bool SubShapeID::IsEmpty ( ) const
inline

Check if there is any bits of subshape ID left. Note that this is not a 100% guarantee as the subshape ID could consist of all 1 bits. Use for asserts only.

◆ operator!=()

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

Check not-equal.

◆ operator==()

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

Check equal.

◆ PopID()

Type SubShapeID::PopID ( uint  inBits,
SubShapeID outRemainder 
) const
inline

Get the next id in the chain of ids (pops parents before children)

◆ SetValue()

void SubShapeID::SetValue ( Type  inValue)
inline

Set the value of the sub shape ID (use with care!)

Friends And Related Symbol Documentation

◆ SubShapeIDCreator

friend class SubShapeIDCreator
friend

Member Data Documentation

◆ MaxBits

constexpr uint SubShapeID::MaxBits = 8 * sizeof(Type)
staticconstexpr

How many bits we can store in this ID.


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