Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
GroupFilterTable Class Referencefinal

#include <GroupFilterTable.h>

Inheritance diagram for GroupFilterTable:
GroupFilter SerializableObject RefTarget< GroupFilter > NonCopyable

Public Member Functions

 GroupFilterTable (uint inNumSubGroups=0)
 Constructs the table with inNumSubGroups subgroups, initially all collision pairs are enabled except when the sub group ID is the same.
 
 GroupFilterTable (const GroupFilterTable &inRHS)
 Copy constructor.
 
void DisableCollision (SubGroupID inSubGroup1, SubGroupID inSubGroup2)
 Disable collision between two sub groups.
 
void EnableCollision (SubGroupID inSubGroup1, SubGroupID inSubGroup2)
 Enable collision between two sub groups.
 
bool IsCollisionEnabled (SubGroupID inSubGroup1, SubGroupID inSubGroup2) const
 Check if the collision between two subgroups is enabled.
 
virtual bool CanCollide (const CollisionGroup &inGroup1, const CollisionGroup &inGroup2) const override
 Checks if two CollisionGroups collide.
 
virtual void SaveBinaryState (StreamOut &inStream) const override
 Saves the contents of the group filter in binary form to inStream.
 
- Public Member Functions inherited from GroupFilter
virtual ~GroupFilter () override=default
 Virtual destructor.
 
- Public Member Functions inherited from SerializableObject
virtual ~SerializableObject ()=default
 Constructor.
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 
- Public Member Functions inherited from RefTarget< GroupFilter >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator.
 
uint32 GetRefCount () const
 Get current refcount of this object.
 
void AddRef () const
 Add or release a reference to this object.
 
void Release () const
 

Protected Member Functions

virtual void RestoreBinaryState (StreamIn &inStream) override
 This function should not be called directly, it is used by sRestoreFromBinaryState.
 

Additional Inherited Members

- Public Types inherited from GroupFilter
using GroupFilterResult = Result< Ref< GroupFilter > >
 
- Static Public Member Functions inherited from GroupFilter
static GroupFilterResult sRestoreFromBinaryState (StreamIn &inStream)
 Creates a GroupFilter of the correct type and restores its contents from the binary stream inStream.
 
- Static Public Member Functions inherited from RefTarget< GroupFilter >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Protected Attributes inherited from RefTarget< GroupFilter >
atomic< uint32mRefCount
 Current reference count.
 
- Static Protected Attributes inherited from RefTarget< GroupFilter >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

Implementation of GroupFilter that stores a bit table with one bit per sub shape ID pair to determine if they collide or not

The collision rules:

  • If one of the objects is in the cInvalidGroup the objects will collide.
  • If the objects are in different groups they will collide.
  • If they're in the same group but their collision filter is different they will not collide.
  • If they're in the same group and their collision filters match, we'll use the SubGroupID and the table below.

For N = 6 sub groups the table will look like:

            sub group 1 --->
sub group 2 x.....
     |      ox....
     |      oox...
     V      ooox..
            oooox.
            ooooox
  • 'x' means sub group 1 == sub group 2 and we define this to never collide.
  • 'o' is a bit that we have to store that defines if the sub groups collide or not.
  • '.' is a bit we don't need to store because the table is symmetric, we take care that group 2 > group 1 by swapping sub group 1 and sub group 2 if needed.

The total number of bits we need to store is (N * (N - 1)) / 2

Constructor & Destructor Documentation

◆ GroupFilterTable() [1/2]

GroupFilterTable::GroupFilterTable ( uint  inNumSubGroups = 0)
inlineexplicit

Constructs the table with inNumSubGroups subgroups, initially all collision pairs are enabled except when the sub group ID is the same.

◆ GroupFilterTable() [2/2]

GroupFilterTable::GroupFilterTable ( const GroupFilterTable inRHS)
inline

Copy constructor.

Member Function Documentation

◆ CanCollide()

virtual bool GroupFilterTable::CanCollide ( const CollisionGroup inGroup1,
const CollisionGroup inGroup2 
) const
inlineoverridevirtual

Checks if two CollisionGroups collide.

Implements GroupFilter.

◆ DisableCollision()

void GroupFilterTable::DisableCollision ( SubGroupID  inSubGroup1,
SubGroupID  inSubGroup2 
)
inline

Disable collision between two sub groups.

◆ EnableCollision()

void GroupFilterTable::EnableCollision ( SubGroupID  inSubGroup1,
SubGroupID  inSubGroup2 
)
inline

Enable collision between two sub groups.

◆ IsCollisionEnabled()

bool GroupFilterTable::IsCollisionEnabled ( SubGroupID  inSubGroup1,
SubGroupID  inSubGroup2 
) const
inline

Check if the collision between two subgroups is enabled.

◆ RestoreBinaryState()

void GroupFilterTable::RestoreBinaryState ( StreamIn inStream)
overrideprotectedvirtual

This function should not be called directly, it is used by sRestoreFromBinaryState.

Reimplemented from GroupFilter.

◆ SaveBinaryState()

void GroupFilterTable::SaveBinaryState ( StreamOut inStream) const
overridevirtual

Saves the contents of the group filter in binary form to inStream.

Reimplemented from GroupFilter.


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