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

Test BroadPhase implementation that does not do anything to speed up the operations. Can be used as a reference implementation. More...

#include <BroadPhaseBruteForce.h>

Inheritance diagram for BroadPhaseBruteForce:
BroadPhase BroadPhaseQuery NonCopyable

Public Member Functions

virtual JPH_OVERRIDE_NEW_DELETE void AddBodiesFinalize (BodyID *ioBodies, int inNumber, AddState inAddState) override
 
virtual void RemoveBodies (BodyID *ioBodies, int inNumber) override
 
virtual void NotifyBodiesAABBChanged (BodyID *ioBodies, int inNumber, bool inTakeLock) override
 
virtual void NotifyBodiesLayerChanged (BodyID *ioBodies, int inNumber) override
 Call whenever the layer (and optionally the aabb as well) of a body changes (can change order of ioBodies array)
 
virtual void CastRay (const RayCast &inRay, RayCastBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Cast a ray and add any hits to ioCollector.
 
virtual void CollideAABox (const AABox &inBox, CollideShapeBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Get bodies intersecting with inBox and any hits to ioCollector.
 
virtual void CollideSphere (Vec3Arg inCenter, float inRadius, CollideShapeBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Get bodies intersecting with a sphere and any hits to ioCollector.
 
virtual void CollidePoint (Vec3Arg inPoint, CollideShapeBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Get bodies intersecting with a point and any hits to ioCollector.
 
virtual void CollideOrientedBox (const OrientedBox &inBox, CollideShapeBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Get bodies intersecting with an oriented box and any hits to ioCollector.
 
virtual void CastAABoxNoLock (const AABoxCast &inBox, CastShapeBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Same as BroadPhaseQuery::CastAABox but can be implemented in a way to take no broad phase locks.
 
virtual void CastAABox (const AABoxCast &inBox, CastShapeBodyCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter) const override
 Cast a box and add any hits to ioCollector.
 
virtual void FindCollidingPairs (BodyID *ioActiveBodies, int inNumActiveBodies, float inSpeculativeContactDistance, const ObjectVsBroadPhaseLayerFilter &inObjectVsBroadPhaseLayerFilter, const ObjectLayerPairFilter &inObjectLayerPairFilter, BodyPairCollector &ioPairCollector) const override
 
virtual AABox GetBounds () const override
 Get the bounding box of all objects in the broadphase.
 
- Public Member Functions inherited from BroadPhase
virtual void Init (BodyManager *inBodyManager, const BroadPhaseLayerInterface &inLayerInterface)
 
virtual void Optimize ()
 Should be called after many objects have been inserted to make the broadphase more efficient, usually done on startup only.
 
virtual void FrameSync ()
 Must be called just before updating the broadphase when none of the body mutexes are locked.
 
virtual void LockModifications ()
 Must be called before UpdatePrepare to prevent modifications from being made to the tree.
 
virtual UpdateState UpdatePrepare ()
 
virtual void UpdateFinalize (const UpdateState &inUpdateState)
 Finalizing the update will quickly apply the changes.
 
virtual void UnlockModifications ()
 Must be called after UpdateFinalize to allow modifications to the broadphase.
 
virtual AddState AddBodiesPrepare (BodyID *ioBodies, int inNumber)
 
virtual void AddBodiesAbort (BodyID *ioBodies, int inNumber, AddState inAddState)
 
- Public Member Functions inherited from BroadPhaseQuery
virtual ~BroadPhaseQuery ()=default
 Virtual destructor.
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Additional Inherited Members

- Public Types inherited from BroadPhase
using AddState = void *
 Handle used during adding bodies to the broadphase.
 
- Protected Attributes inherited from BroadPhase
BodyManagermBodyManager = nullptr
 Link to the body manager that manages the bodies in this broadphase.
 

Detailed Description

Test BroadPhase implementation that does not do anything to speed up the operations. Can be used as a reference implementation.

Member Function Documentation

◆ AddBodiesFinalize()

JPH_NAMESPACE_BEGIN void BroadPhaseBruteForce::AddBodiesFinalize ( BodyID ioBodies,
int  inNumber,
AddState  inAddState 
)
overridevirtual

Finalize adding bodies to the broadphase, supply the return value of AddBodiesPrepare in inAddState. Please ensure that the ioBodies array passed to AddBodiesPrepare is unmodified and passed again to this function.

Implements BroadPhase.

◆ CastAABox()

void BroadPhaseBruteForce::CastAABox ( const AABoxCast inBox,
CastShapeBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Cast a box and add any hits to ioCollector.

Implements BroadPhaseQuery.

◆ CastAABoxNoLock()

void BroadPhaseBruteForce::CastAABoxNoLock ( const AABoxCast inBox,
CastShapeBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Same as BroadPhaseQuery::CastAABox but can be implemented in a way to take no broad phase locks.

Implements BroadPhase.

◆ CastRay()

void BroadPhaseBruteForce::CastRay ( const RayCast inRay,
RayCastBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Cast a ray and add any hits to ioCollector.

Implements BroadPhaseQuery.

◆ CollideAABox()

void BroadPhaseBruteForce::CollideAABox ( const AABox inBox,
CollideShapeBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Get bodies intersecting with inBox and any hits to ioCollector.

Implements BroadPhaseQuery.

◆ CollideOrientedBox()

void BroadPhaseBruteForce::CollideOrientedBox ( const OrientedBox inBox,
CollideShapeBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Get bodies intersecting with an oriented box and any hits to ioCollector.

Implements BroadPhaseQuery.

◆ CollidePoint()

void BroadPhaseBruteForce::CollidePoint ( Vec3Arg  inPoint,
CollideShapeBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Get bodies intersecting with a point and any hits to ioCollector.

Implements BroadPhaseQuery.

◆ CollideSphere()

void BroadPhaseBruteForce::CollideSphere ( Vec3Arg  inCenter,
float  inRadius,
CollideShapeBodyCollector ioCollector,
const BroadPhaseLayerFilter inBroadPhaseLayerFilter,
const ObjectLayerFilter inObjectLayerFilter 
) const
overridevirtual

Get bodies intersecting with a sphere and any hits to ioCollector.

Implements BroadPhaseQuery.

◆ FindCollidingPairs()

void BroadPhaseBruteForce::FindCollidingPairs ( BodyID ioActiveBodies,
int  inNumActiveBodies,
float  inSpeculativeContactDistance,
const ObjectVsBroadPhaseLayerFilter inObjectVsBroadPhaseLayerFilter,
const ObjectLayerPairFilter inObjectLayerPairFilter,
BodyPairCollector ioPairCollector 
) const
overridevirtual

Find all colliding pairs between dynamic bodies Note that this function is very specifically tailored for the PhysicsSystem::Update function, hence it is not part of the BroadPhaseQuery interface. One of the assumptions it can make is that no locking is needed during the query as it will only be called during a very particular part of the update.

Parameters
ioActiveBodiesis a list of bodies for which we need to find colliding pairs (this function can change the order of the ioActiveBodies array). This can be a subset of the set of active bodies in the system.
inNumActiveBodiesis the size of the ioActiveBodies array.
inSpeculativeContactDistanceDistance at which speculative contact points will be created.
inObjectVsBroadPhaseLayerFilteris the filter that determines if an object can collide with a broadphase layer.
inObjectLayerPairFilteris the filter that determines if two objects can collide.
ioPairCollectorreceives callbacks for every body pair found.

Implements BroadPhase.

◆ GetBounds()

AABox BroadPhaseBruteForce::GetBounds ( ) const
overridevirtual

Get the bounding box of all objects in the broadphase.

Implements BroadPhase.

◆ NotifyBodiesAABBChanged()

void BroadPhaseBruteForce::NotifyBodiesAABBChanged ( BodyID ioBodies,
int  inNumber,
bool  inTakeLock 
)
overridevirtual

Call whenever the aabb of a body changes (can change order of ioBodies array) inTakeLock should be false if we're between LockModifications/UnlockModificiations in which case care needs to be taken to not call this between UpdatePrepare/UpdateFinalize

Implements BroadPhase.

◆ NotifyBodiesLayerChanged()

void BroadPhaseBruteForce::NotifyBodiesLayerChanged ( BodyID ioBodies,
int  inNumber 
)
overridevirtual

Call whenever the layer (and optionally the aabb as well) of a body changes (can change order of ioBodies array)

Implements BroadPhase.

◆ RemoveBodies()

void BroadPhaseBruteForce::RemoveBodies ( BodyID ioBodies,
int  inNumber 
)
overridevirtual

Remove inNumber bodies in ioBodies from the broadphase. ioBodies may be shuffled around by this function.

Implements BroadPhase.


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