Description

Base class for generic collision engine.

#include <ChCollisionSystem.h>

Inheritance diagram for chrono::ChCollisionSystem:
Collaboration diagram for chrono::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...
 
class  VisualizationCallback
 Class to be used as a callback interface for user-defined visualization of collision shapes. More...
 

Public Types

enum  Type { Type::BULLET, Type::MULTICORE }
 Supported collision systems. More...
 
enum  VisualizationModes {
  VIS_None = 0, VIS_Shapes = 1 << 0, VIS_Aabb = 1 << 1, VIS_Contacts = 1 << 2,
  VIS_MAX_MODES
}
 Enumeration of supported flags for collision debug visualization. More...
 

Public Member Functions

bool IsInitialized () const
 Test if the collision system was initialized.
 
virtual void Initialize ()
 Initialize the collision system. More...
 
virtual void BindAll ()
 Process all collision models in the associated Chrono system. More...
 
virtual void BindItem (std::shared_ptr< ChPhysicsItem > item)
 Process the collision models associated with the specified Chrono physics item. More...
 
void UnbindItem (std::shared_ptr< ChPhysicsItem > item)
 Remove any collision models associated with the specified physics item from the collision engine.
 
virtual void Clear ()=0
 Clears all data instanced by this algorithm if any.
 
virtual void Add (std::shared_ptr< ChCollisionModel > model)=0
 Add the specified collision model to the collision engine.
 
virtual void Remove (std::shared_ptr< ChCollisionModel > model)=0
 Remove the specified collision model from the collision engine.
 
virtual void PreProcess ()
 Optional synchronization operations, invoked before running the collision detection.
 
virtual void Run ()=0
 Run the collision detection and finds the contacts. More...
 
virtual void PostProcess ()
 Optional synchronization operations, invoked after running the collision detection.
 
virtual ChAABB GetBoundingBox () const =0
 Return an AABB bounding all collision shapes in the system.
 
virtual double GetTimerCollisionBroad () const =0
 Return the time (in seconds) for broadphase collision detection.
 
virtual double GetTimerCollisionNarrow () const =0
 Return the time (in seconds) for narrowphase collision detection.
 
virtual void ResetTimers ()
 Reset any timers associated with collision detection.
 
virtual void SetNumThreads (int nthreads)
 Set the number of OpenMP threads for collision detection. 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 (std::shared_ptr< 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 (std::shared_ptr< 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 ChVector3d &from, const ChVector3d &to, ChRayhitResult &result) const =0
 Perform a ray-hit test with the collision models.
 
virtual bool RayHit (const ChVector3d &from, const ChVector3d &to, ChCollisionModel *model, ChRayhitResult &result) const =0
 Perform a ray-hit test with the specified collision model.
 
virtual void RegisterVisualizationCallback (std::shared_ptr< VisualizationCallback > callback)
 Specify a callback object to be used for debug rendering of collision shapes.
 
virtual void Visualize (int flags)
 Method to trigger debug visualization of collision shapes. More...
 
virtual void ArchiveOut (ChArchiveOut &archive_out)
 Method to allow serialization of transient data to archives.
 
virtual void ArchiveIn (ChArchiveIn &archive_in)
 Method to allow de-serialization of transient data from archives.
 
void SetSystem (ChSystem *sys)
 Set associated Chrono system.
 

Protected Attributes

bool m_initialized
 
ChSystemm_system
 associated Chrono system
 
std::shared_ptr< BroadphaseCallbackbroad_callback
 user callback for each near-enough pair of shapes
 
std::shared_ptr< NarrowphaseCallbacknarrow_callback
 user callback for each collision pair
 
std::shared_ptr< VisualizationCallbackvis_callback
 user callback for debug visualization
 
int m_vis_flags
 

Member Enumeration Documentation

◆ Type

Supported collision systems.

Enumerator
BULLET 

Bullet-based collision detection system.

MULTICORE 

Chrono multicore collision detection system.

◆ VisualizationModes

Enumeration of supported flags for collision debug visualization.

Enumerator
VIS_None 

no debug collision visualization

VIS_Shapes 

wireframe representation of collision shapes

VIS_Aabb 

axis-aligned bounding boxes of collision shapes

VIS_Contacts 

contact points and normals

Member Function Documentation

◆ BindAll()

void chrono::ChCollisionSystem::BindAll ( )
virtual

Process all collision models in the associated Chrono system.

This function is called by default for a Chrono system attached to this collision system during initialization, but can also be called later if further modifications to collision models occur.

◆ BindItem()

void chrono::ChCollisionSystem::BindItem ( std::shared_ptr< ChPhysicsItem item)
virtual

Process the collision models associated with the specified Chrono physics item.

This function must be called if a new physics item is added to the system or if changes to its collision model occur after the collision system was initialized.

◆ Initialize()

void chrono::ChCollisionSystem::Initialize ( )
virtual

Initialize the collision system.

This call must trigger a parsing of the associated Chrono system to process all collision models.

◆ RegisterBroadphaseCallback()

void chrono::ChCollisionSystem::RegisterBroadphaseCallback ( std::shared_ptr< BroadphaseCallback callback)
inline

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.

◆ RegisterNarrowphaseCallback()

void chrono::ChCollisionSystem::RegisterNarrowphaseCallback ( std::shared_ptr< NarrowphaseCallback callback)
inline

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.

◆ ReportContacts()

virtual void chrono::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::ChCollisionSystemBullet, chrono::ChCollisionSystemMulticore, and chrono::ChCollisionSystemChronoMulticore.

◆ ReportProximities()

virtual void chrono::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::ChCollisionSystemMulticore, chrono::ChCollisionSystemBullet, and chrono::ChCollisionSystemChronoMulticore.

◆ Run()

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

Run the collision detection and finds the contacts.

This function will be called at each simulation step.

Implemented in chrono::ChCollisionSystemMulticore, and chrono::ChCollisionSystemBullet.

◆ SetNumThreads()

virtual void chrono::ChCollisionSystem::SetNumThreads ( int  nthreads)
inlinevirtual

Set the number of OpenMP threads for collision detection.

The default implementation does nothing. Derived classes implement this function as applicable.

Reimplemented in chrono::ChCollisionSystemMulticore, chrono::ChCollisionSystemBullet, and chrono::ChCollisionSystemChronoMulticore.

◆ Visualize()

virtual void chrono::ChCollisionSystem::Visualize ( int  flags)
inlinevirtual

Method to trigger debug visualization of collision shapes.

The 'flags' argument can be any of the VisualizationModes enums, or a combination thereof (using bit-wise operators). The calling program must invoke this function from within the simulation loop. A derived class should implement a no-op if a visualization callback was not specified.

Reimplemented in chrono::ChCollisionSystemMulticore, and chrono::ChCollisionSystemBullet.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/collision/ChCollisionSystem.h
  • /builds/uwsbel/chrono/src/chrono/collision/ChCollisionSystem.cpp