AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ContactEventListener.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 #ifndef AGXSDK_CONTACTEVENTLISTENER_H
18 #define AGXSDK_CONTACTEVENTLISTENER_H
19 
20 #include <agxSDK/agxSDK.h>
21 
22 #include <agxCollide/Geometry.h>
23 #include <agxSDK/EventListener.h>
24 
25 #include <agx/TimeStamp.h>
26 #include <agxCollide/Contacts.h>
27 
28 #include <agxSDK/ExecuteFilter.h>
29 
30 namespace agxSDK
31 {
32 
46  {
47  public:
48 
51  IMPACT = 1 << 0,
52  CONTACT = 1 << 1,
53  SEPARATION = 1 << 2,
54  POST = 1 << 3,
55  DEFAULT = IMPACT | SEPARATION,
56  ALL = IMPACT | CONTACT | SEPARATION | POST
57  };
58 
62  REMOVE_CONTACT,
65  REMOVE_CONTACT_IMMEDIATELY
67  };
68 
70  virtual void setMask(int f);
71 
77  ContactEventListener(int m = DEFAULT, ExecuteFilter* filter = nullptr );
78 
79 
80  //=================== Override these methods:
89  virtual KeepContactPolicy impact(const agx::TimeStamp& time, agxCollide::GeometryContact *geometryContact);
90 
99  virtual KeepContactPolicy contact(const agx::TimeStamp& time, agxCollide::GeometryContact* geometryContact);
100 
109  virtual void separation(const agx::TimeStamp& time, agxCollide::GeometryPair& geometryPair);
110 
119  virtual void post(const agx::TimeStamp& time, agxCollide::GeometryContact* geometryContact);
120 
121  //=================== End Override
122 
124  void setFilter( ExecuteFilter* filter );
125 
127  ExecuteFilter* getFilter( );
128 
130  const ExecuteFilter* getFilter( ) const;
131 
132  protected:
133 
135  virtual ~ContactEventListener();
136 
138  };
139 
141 
142 
144  {
146  }
147 
149  {
151  }
152 
154 
156  {
157  }
158 
160  {
161  return m_executeFilter;
162  }
163 
165  {
166  return m_executeFilter;
167  }
168 
169 }
170 #endif
Derive from this class to implement a listener for Collision events.
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:63
Abstract base class that implements a filter that selects which events should trigger a Listener...
Definition: ExecuteFilter.h:34
A contact between two geometries.
Definition: Contacts.h:270
#define AGXPHYSICS_EXPORT
#define AGX_FORCE_INLINE
Definition: Object.h:62
agx::Real TimeStamp
Definition: TimeStamp.h:26
virtual void post(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called before agxSDK::StepEventListener::post now that the geometry contacts has contact forces from ...
ActivationMask
Defines the event states for which a listener will be activated, a mask can be bitwise OR:ed from the...
agx::ref_ptr< ContactEventListener > ContactEventListenerRef
virtual KeepContactPolicy impact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon impact event if getFilter() contain IMPACT.
KeepContactPolicy
Defines whether contact should be kept or removed after contact/impact methods returns.
virtual void separation(const agx::TimeStamp &time, agxCollide::GeometryPair &geometryPair)
Called upon separation event if getFilter() contain SEPARATION.
An EventListener can be associated to a Simulation and triggered upon various events.
Definition: EventListener.h:37
virtual KeepContactPolicy contact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon contact event if getFilter() contain CONTACT.