AGX Dynamics  2.37.3.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 }
Derive from this class to implement a listener for Collision events.
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:66
Abstract base class that implements a filter that selects which events should trigger a Listener...
Definition: ExecuteFilter.h:33
A contact between two geometries.
Definition: Contacts.h:270
#define AGXPHYSICS_EXPORT
#define AGX_FORCE_INLINE
Definition: Object.h:59
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:40
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
virtual KeepContactPolicy contact(const agx::TimeStamp &time, agxCollide::GeometryContact *geometryContact)
Called upon contact event if getFilter() contain CONTACT.