AGX Dynamics  2.35.0.1
ContactEventListener.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxSDK/agxSDK.h>
20 
21 #include <agxCollide/Geometry.h>
22 #include <agxSDK/EventListener.h>
23 
24 #include <agx/TimeStamp.h>
25 #include <agxCollide/Contacts.h>
26 
27 #include <agxSDK/ExecuteFilter.h>
28 
29 namespace agxSDK
30 {
31 
45  {
46  public:
47 
50  IMPACT = 1 << 0,
51  CONTACT = 1 << 1,
52  SEPARATION = 1 << 2,
53  POST = 1 << 3,
54  DEFAULT = IMPACT | SEPARATION,
55  ALL = IMPACT | CONTACT | SEPARATION | POST
56  };
57 
61  REMOVE_CONTACT,
64  REMOVE_CONTACT_IMMEDIATELY
66  };
67 
69  virtual void setMask(int f);
70 
76  ContactEventListener(int m = DEFAULT, ExecuteFilter* filter = nullptr );
77 
78 
79  //=================== Override these methods:
88  virtual KeepContactPolicy impact(const agx::TimeStamp& time, agxCollide::GeometryContact *geometryContact);
89 
98  virtual KeepContactPolicy contact(const agx::TimeStamp& time, agxCollide::GeometryContact* geometryContact);
99 
108  virtual void separation(const agx::TimeStamp& time, agxCollide::GeometryPair& geometryPair);
109 
118  virtual void post(const agx::TimeStamp& time, agxCollide::GeometryContact* geometryContact);
119 
120  //=================== End Override
121 
123  void setFilter( ExecuteFilter* filter );
124 
126  ExecuteFilter* getFilter( );
127 
129  const ExecuteFilter* getFilter( ) const;
130 
131  protected:
132 
135 
137  };
138 
140 
141 
143  {
145  }
146 
148  {
150  }
151 
153 
155  {
156  }
157 
159  {
160  return m_executeFilter;
161  }
162 
164  {
165  return m_executeFilter;
166  }
167 
168 }
#define AGXPHYSICS_EXPORT
A contact between two geometries.
Definition: Contacts.h:270
Derive from this class to implement a listener for Collision events.
ContactEventListener(int m=DEFAULT, ExecuteFilter *filter=nullptr)
Default constructor, sets the activation mask by default to Impact and Separation.
ActivationMask
Defines the event states for which a listener will be activated, a mask can be bitwise OR:ed from the...
virtual void post(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called before agxSDK::StepEventListener::post now that the geometry contacts has contact forces from ...
virtual void separation(const agx::TimeStamp &time, agxCollide::GeometryPair &geometryPair)
Called upon separation event if getFilter() contain SEPARATION.
void setFilter(ExecuteFilter *filter)
Replaces the current filter with a new one.
virtual ~ContactEventListener()
Destructor.
virtual void setMask(int f)
Specifies a bit mask which determines which event types that will activate this listener.
KeepContactPolicy
Defines whether contact should be kept or removed after contact/impact methods returns.
virtual KeepContactPolicy impact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon impact event if getFilter() contain IMPACT.
virtual KeepContactPolicy contact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon contact event if getFilter() contain CONTACT.
An EventListener can be associated to a Simulation and triggered upon various events.
Definition: EventListener.h:41
Abstract base class that implements a filter that selects which events should trigger a Listener.
Definition: ExecuteFilter.h:35
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:66
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
agx::ref_ptr< ContactEventListener > ContactEventListenerRef
agx::Real TimeStamp
Definition: TimeStamp.h:26