AGX Dynamics  2.38.0.2
ContactEventListener.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 
134  virtual ~ContactEventListener();
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 }
agxSDK::ContactEventListener::separation
virtual void separation(const agx::TimeStamp &time, agxCollide::GeometryPair &geometryPair)
Called upon separation event if getFilter() contain SEPARATION.
Definition: ContactEventListener.h:152
agxData::GeometryPair
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:65
EventListener.h
agxSDK::EventListener
An EventListener can be associated to a Simulation and triggered upon various events.
Definition: EventListener.h:40
Geometry.h
agxSDK::ContactEventListener::KEEP_CONTACT
@ KEEP_CONTACT
Keep the contact.
Definition: ContactEventListener.h:60
agxSDK::ExecuteFilter
Abstract base class that implements a filter that selects which events should trigger a Listener.
Definition: ExecuteFilter.h:33
agxSDK::ContactEventListener::ActivationMask
ActivationMask
Defines the event states for which a listener will be activated, a mask can be bitwise OR:ed from the...
Definition: ContactEventListener.h:49
agxSDK::ContactEventListener::post
virtual void post(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called before agxSDK::StepEventListener::post now that the geometry contacts has contact forces from ...
Definition: ContactEventListener.h:154
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxSDK::ContactEventListener::m_executeFilter
ExecuteFilterRef m_executeFilter
Definition: ContactEventListener.h:136
agx::ref_ptr< ExecuteFilter >
agxSDK::ContactEventListener::KeepContactPolicy
KeepContactPolicy
Defines whether contact should be kept or removed after contact/impact methods returns.
Definition: ContactEventListener.h:59
agxSDK::ContactEventListener::contact
virtual KeepContactPolicy contact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon contact event if getFilter() contain CONTACT.
Definition: ContactEventListener.h:147
agxSDK::ContactEventListener::impact
virtual KeepContactPolicy impact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon impact event if getFilter() contain IMPACT.
Definition: ContactEventListener.h:142
agxCollide::GeometryContact
A contact between two geometries.
Definition: Contacts.h:270
agx::TimeStamp
agx::Real TimeStamp
Definition: TimeStamp.h:26
Contacts.h
agxSDK::ContactEventListener::getFilter
ExecuteFilter * getFilter()
Definition: ContactEventListener.h:158
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agxSDK::ContactEventListenerRef
agx::ref_ptr< ContactEventListener > ContactEventListenerRef
Definition: ContactEventListener.h:139
ExecuteFilter.h
TimeStamp.h
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxSDK.h
agxSDK::ContactEventListener
Derive from this class to implement a listener for Collision events.
Definition: ContactEventListener.h:44