AGXDynamics  2.35.0.2
ColliderTable.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 #ifndef AGX_COLLIDERTABLE_H
18 #define AGX_COLLIDERTABLE_H
19 
20 #include <agxCollide/Shape.h>
22 #include <agx/Initializer.h>
23 
24 namespace agxCollide
25 {
26 
27 
29  public:
30 
31  private:
32  friend class ColliderTable;
33 
35 
37  };
38 
39 
41  {
42  public:
47  static ShapeCollider *getCollider( const Shape *a, const Shape *b );
48  static ShapeCollider *getCollider( unsigned typeA, unsigned typeB );
49 
53  static void setCollider( unsigned typeA, unsigned typeB, ShapeCollider *collider );
54  static void setCollider( Shape *a, Shape *b, ShapeCollider *collider );
55 
57  static void init();
58 
59 
60  private:
61  friend class ColliderTableCleanup;
62 
63  static void wipe();
64 
65  static ShapeCollider *s_colliders[Shape::NUM_TYPES * Shape::NUM_TYPES];
66  static bool s_collidersInitialized;
67  static ColliderTableCleanup s_colliderTableCleanup;
68  };
69 
70 
71  /* Implementation */
72 
73  #define CalcPairId(id1, id2) (std::min(id1, id2) * Shape::NUM_TYPES + std::max(id1, id2))
74 
75 
76  AGX_FORCE_INLINE ShapeCollider *ColliderTable::getCollider( const Shape *a, const Shape *b )
77  {
78  return s_colliders[CalcPairId(a->getType(), b->getType())];
79  }
80 
81  AGX_FORCE_INLINE ShapeCollider *ColliderTable::getCollider( unsigned typeA, unsigned typeB )
82  {
83  return s_colliders[CalcPairId(typeA, typeB)];
84  }
85 
86 }
87 
88 #endif /* _COLLIDERTABLE_H_ */
Shape.h
agxCollide::ColliderTable
Definition: ColliderTable.h:40
agxCollide::Shape::getType
agx::UInt8 getType() const
Definition: Shape.h:378
Initializer.h
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
ShapeCollider.h
agxCollide::Shape
Base class for a shape.
Definition: Shape.h:53
agxCollide::ColliderTableCleanup
Definition: ColliderTable.h:28
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxCollide::Shape::NUM_TYPES
@ NUM_TYPES
Definition: Shape.h:73
agxCollide::ColliderTable::getCollider
static ShapeCollider * getCollider(const Shape *a, const Shape *b)
Get a shape collider for testing two shapes against each other.
Definition: ColliderTable.h:76
agx::init
void AGXPHYSICS_EXPORT init()
Initialize agx.
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
CalcPairId
#define CalcPairId(id1, id2)
Definition: ColliderTable.h:73