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 during broadphase. 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 during narrowphase. 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 *contact_container)=0
 Report contacts (fill the provided 'contact container'). More...
 
virtual void ReportProximities (ChProximityContainer *proximity_container)=0
 Report proximities (fill in the provided 'proximity container'). More...
 
void RegisterBroadphaseCallback (std::shared_ptr< BroadphaseCallback > callback)
 Register a broadphase callback object.
 
void RegisterNarrowphaseCallback (std::shared_ptr< NarrowphaseCallback > callback)
 Register a narrowphase callback object.
 
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.

◆ ReportContacts()

virtual void chrono::ChCollisionSystem::ReportContacts ( ChContactContainer contact_container)
pure virtual

Report contacts (fill the provided 'contact container').

This function, which should only be called after Run(), must add to the contact container contacts corresponding to all detected pairwise collisions. The basic behavior of the implementation should call in sequence the ChContactContainer functions BeginAddContact(), AddContact() (multiple times), and EndAddContact().

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

◆ ReportProximities()

virtual void chrono::ChCollisionSystem::ReportProximities ( ChProximityContainer proximity_container)
pure virtual

Report proximities (fill in the provided 'proximity container').

This function, which should only be called after Run(), must add to the contact container contacts corresponding to all detected pairwise collisions. The basic behavior of the implementation should call in sequence the ChContactContainer functions BeginAddProximities(), AddProximity() (multiple times), and EndAddProximities().

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