chrono::collision::ChCollisionSystem Class Referenceabstract

Description

Base class for generic collision engine.

Most methods are 'pure virtual': they need to be implemented by derived classes.

#include <ChCCollisionSystem.h>

Inheritance diagram for chrono::collision::ChCollisionSystem:
Collaboration diagram for chrono::collision::ChCollisionSystem:

Classes

class  BroadphaseCallback
 Class to be used as a callback interface for user-defined actions to be performed for each 'near enough' pair of collision shapes found by the broad-phase collision step. More...
 
struct  ChRayhitResult
 Recover results from RayHit() raycasting. More...
 
class  NarrowphaseCallback
 Class to be used as a callback interface for user-defined actions to be performed at each collision pair found during the narrow-phase collision step. More...
 

Public Member Functions

 ChCollisionSystem (unsigned int max_objects=16000, double scene_size=500)
 
virtual void Clear (void)=0
 Clears all data instanced by this algorithm if any (like persistent contact manifolds)
 
virtual void Add (ChCollisionModel *model)=0
 Adds a collision model to the collision engine (custom data may be allocated). More...
 
virtual void Remove (ChCollisionModel *model)=0
 Removes a collision model from the collision engine (custom data may be deallocated). More...
 
virtual void Run ()=0
 Removes all collision models from the collision engine (custom data may be deallocated). More...
 
virtual void ReportContacts (ChContactContainer *mcontactcontainer)=0
 After the Run() has completed, you can call this function to fill a 'contact container', that is an object inherited from class ChContactContainer. More...
 
virtual void ReportProximities (ChProximityContainer *mproximitycontainer)=0
 After the Run() has completed, you can call this function to fill a 'proximity container' (container of narrow phase pairs), that is an object inherited from class ChProximityContainer. More...
 
void RegisterBroadphaseCallback (BroadphaseCallback *callback)
 Specify a callback object to be used each time a pair of 'near enough' collision shapes is found by the broad-phase collision step. More...
 
void RegisterNarrowphaseCallback (NarrowphaseCallback *callback)
 Specify a callback object to be used each time a collision pair is found during the narrow-phase collision detection step. More...
 
virtual bool RayHit (const ChVector<> &from, const ChVector<> &to, ChRayhitResult &mresult)=0
 Perform a ray-hit test with the collision models.
 
virtual void ArchiveOUT (ChArchiveOut &marchive)
 
virtual void ArchiveIN (ChArchiveIn &marchive)
 

Protected Attributes

BroadphaseCallbackbroad_callback
 user callback for each near-enough pair of shapes
 
NarrowphaseCallbacknarrow_callback
 user callback for each collision pair
 

Member Function Documentation

virtual void chrono::collision::ChCollisionSystem::Add ( ChCollisionModel model)
pure virtual
void chrono::collision::ChCollisionSystem::RegisterBroadphaseCallback ( BroadphaseCallback callback)

Specify a callback object to be used each time a pair of 'near enough' collision shapes is found by the broad-phase collision step.

The OnBroadphase() method of the provided callback object will be called for each pair of 'near enough' shapes.

void chrono::collision::ChCollisionSystem::RegisterNarrowphaseCallback ( NarrowphaseCallback callback)

Specify a callback object to be used each time a collision pair is found during the narrow-phase collision detection step.

The OnNarrowphase() method of the provided callback object will be called for each collision pair found during narrow phase.

virtual void chrono::collision::ChCollisionSystem::Remove ( ChCollisionModel model)
pure virtual
virtual void chrono::collision::ChCollisionSystem::ReportContacts ( ChContactContainer mcontactcontainer)
pure virtual

After the Run() has completed, you can call this function to fill a 'contact container', that is an object inherited from class ChContactContainer.

For instance ChSystem, after each Run() collision detection, calls this method multiple times for all contact containers in the system, Children classes must implement this. The basic behavior of the implementation should be the following: collision system will call in sequence the functions BeginAddContact(), AddContact() (x n times), EndAddContact() of the contact container. In case a specialized implementation (ex. a GPU parallel collision engine) finds that the contact container is a specialized one (ex with a GPU buffer) it can call more performant methods to add directly the contacts in batches, for instance by recognizing that he can call, say, some special AddAllContactsAsGpuBuffer() instead of many AddContact().

Implemented in chrono::collision::ChCollisionSystemSpheres, chrono::collision::ChCollisionSystemBulletParallel, chrono::collision::ChCollisionSystemBulletParallel, chrono::collision::ChCollisionSystemParallel, chrono::collision::ChCollisionSystemBullet, and chrono::collision::ChCollisionSystemParallel.

virtual void chrono::collision::ChCollisionSystem::ReportProximities ( ChProximityContainer mproximitycontainer)
pure virtual

After the Run() has completed, you can call this function to fill a 'proximity container' (container of narrow phase pairs), that is an object inherited from class ChProximityContainer.

For instance ChSystem, after each Run() collision detection, calls this method multiple times for all proximity containers in the system, Children classes must implement this. The basic behavior of the implementation should be the following: collision system will call in sequence the functions BeginAddProximities(), AddProximity() (x n times), EndAddProximities() of the proximity container. In case a specialized implementation (ex. a GPU parallel collision engine) finds that the proximity container is a specialized one (ex with a GPU buffer) it can call more performant methods to add directly the proximities in batches, for instance by recognizing that he can call, say, some special AddAllProximitiesAsGpuBuffer() instead of many AddProximity().

Implemented in chrono::collision::ChCollisionSystemSpheres, chrono::collision::ChCollisionSystemBulletParallel, chrono::collision::ChCollisionSystemBulletParallel, chrono::collision::ChCollisionSystemParallel, chrono::collision::ChCollisionSystemBullet, and chrono::collision::ChCollisionSystemParallel.

virtual void chrono::collision::ChCollisionSystem::Run ( )
pure virtual

Removes all collision models from the collision engine (custom data may be deallocated).

RUN THE ALGORITHM and finds the contacts. This is the most important function - it will be called at each simulation step. Children classes must implement this.

Implemented in chrono::collision::ChCollisionSystemSpheres, chrono::collision::ChCollisionSystemBulletParallel, chrono::collision::ChCollisionSystemBulletParallel, chrono::collision::ChCollisionSystemParallel, chrono::collision::ChCollisionSystemBullet, and chrono::collision::ChCollisionSystemParallel.