AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ColliderUnitTestUtils.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
21#include <agxUnit/UnitMacros.h>
22#include <agx/Referenced.h>
23#include <agxCollide/Contacts.h>
24
26
27namespace agx
28{
29 class RigidBody;
30}
31
32namespace agxSDK {
33 class Simulation;
34}
35
36namespace agxCollide {
37
38 AGX_DECLARE_POINTER_TYPES(ContactTester);
39 class AGXPHYSICS_EXPORT ContactTester : public agx::Referenced
40 {
41 public:
42 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder)=0;
43
44 };
45
46
47 AGX_DECLARE_POINTER_TYPES(AnyContactTester);
48 class AGXPHYSICS_EXPORT AnyContactTester : public ContactTester
49 {
50 public:
51 AnyContactTester(size_t numAppearances = 1) :
52 m_numAppearances(numAppearances)
53 {
54 }
55
56 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
57
58 protected:
59 size_t m_numAppearances;
60 };
61
62 AGX_DECLARE_POINTER_TYPES(NormalAndDepthContainedTester);
63 class AGXPHYSICS_EXPORT NormalAndDepthContainedTester : public ContactTester
64 {
65 public:
66 NormalAndDepthContainedTester(const agx::Vec3& normal, agx::Real depth,
67 size_t numAppearances = 1) :
68 m_normal(normal), m_depth(depth),
69 m_numAppearances(numAppearances)
70 {
71 m_normal.normalize();
72 }
73
74 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
75
76 protected:
77 agx::Vec3 m_normal;
78 agx::Real m_depth;
79 size_t m_numAppearances;
80 };
81
82
83 AGX_DECLARE_POINTER_TYPES(NormalTester);
84 class AGXPHYSICS_EXPORT NormalTester : public ContactTester
85 {
86 public:
87 NormalTester(const agx::Vec3& normal, size_t numAppearances = 1) :
88 m_normal(normal), m_numAppearances(numAppearances)
89 {
90 m_normal.normalize();
91 }
92
93 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
94
95 protected:
96 agx::Vec3 m_normal;
97 size_t m_numAppearances;
98 };
99
100
101 AGX_DECLARE_POINTER_TYPES(NormalDotProductTester);
103 class AGXPHYSICS_EXPORT NormalDotProductTester : public ContactTester
104 {
105 public:
106 NormalDotProductTester(const agx::Vec3& normal, agx::Real dotProduct, size_t numAppearances = 1) :
107 m_normal(normal), m_dotProduct(dotProduct), m_numAppearances(numAppearances)
108 {
109 m_normal.normalize();
110 }
111
112 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
113
114 protected:
115 agx::Vec3 m_normal;
116 agx::Real m_dotProduct;
117 size_t m_numAppearances;
118 };
119
120
121 AGX_DECLARE_POINTER_TYPES(AllNormalDotProductTester);
122 class AGXPHYSICS_EXPORT AllNormalDotProductTester : public ContactTester
123 {
124 public:
125 AllNormalDotProductTester(const agx::Vec3& normal, agx::Real dotProduct) :
126 m_normal(normal), m_dotProduct(dotProduct)
127 {
128 m_normal.normalize();
129 }
130
131 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
132
133 protected:
134 agx::Vec3 m_normal;
135 agx::Real m_dotProduct;
136 };
137
138
139 AGX_DECLARE_POINTER_TYPES(AllSameNormalsTester);
140 class AGXPHYSICS_EXPORT AllSameNormalsTester : public ContactTester
141 {
142 public:
143 AllSameNormalsTester(const agx::Vec3& normal) :
144 m_normal(normal)
145 {
146 m_normal.normalize();
147 }
148
149 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
150
151 protected:
152 agx::Vec3 m_normal;
153 };
154
155
156 AGX_DECLARE_POINTER_TYPES(NoContactTester);
157 class AGXPHYSICS_EXPORT NoContactTester : public ContactTester
158 {
159 public:
160 NoContactTester(){}
161
162 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
163 };
164
165
166 AGX_DECLARE_POINTER_TYPES(AllTester);
167 class AGXPHYSICS_EXPORT AllTester : public ContactTester {
168 public:
169 AllTester(const agx::Vec3& point, const agx::Vec3& normal, agx::Real depth) :
170 m_point(point), m_normal(normal), m_depth(depth)
171 {
172 m_normal.normalize();
173 }
174
175 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
176
177 protected:
178 agx::Vec3 m_point;
179 agx::Vec3 m_normal;
180 agx::Real m_depth;
181 };
182
183
184 AGX_DECLARE_POINTER_TYPES(NormalOrOppositeAndDepthContainedTester);
185 class AGXPHYSICS_EXPORT NormalOrOppositeAndDepthContainedTester : public ContactTester {
186 public:
187 NormalOrOppositeAndDepthContainedTester(const agx::Vec3& normal, agx::Real depth,
188 size_t numAppearances = 1) :
189 m_normal(normal), m_depth(depth),
190 m_numAppearances(numAppearances)
191 {
192 m_normal.normalize();
193 }
194
195 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
196
197 protected:
198 agx::Vec3 m_normal;
199 agx::Real m_depth;
200 size_t m_numAppearances;
201 };
202
203
204 AGX_DECLARE_POINTER_TYPES(OrthoNormalAndDepthContainedTester);
205 class AGXPHYSICS_EXPORT OrthoNormalAndDepthContainedTester : public ContactTester {
206 public:
207 OrthoNormalAndDepthContainedTester(const agx::Vec3& normal, agx::Real depth,
208 size_t numAppearances = 1) :
209 m_normal(normal), m_depth(depth),
210 m_numAppearances(numAppearances)
211 {
212 m_normal.normalize();
213 }
214
215 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
216
217 protected:
218 agx::Vec3 m_normal;
219 agx::Real m_depth;
220 size_t m_numAppearances;
221 };
222
223
224
225
226 AGX_DECLARE_POINTER_TYPES(MeshTriangleTester);
227 class AGXPHYSICS_EXPORT MeshTriangleTester : public ContactTester {
228 public:
229 enum ContactsToTest {TEST_FOR_ONE, TEST_FOR_ALL};
230
231 MeshTriangleTester( ContactsToTest toTest) :
232 m_toTest(toTest)
233 {}
234
240 void addContact(agx::UInt32 triangleNr, agx::UInt8 voronoiRegion, agx::UInt8 shapeNr)
241 {
242 m_triangleNrs.push_back(triangleNr);
243 m_voronoiRegions.push_back(voronoiRegion);
244 agxAssert( shapeNr < 2);
245 m_shapeNumbers.push_back(shapeNr);
246 }
247
248 virtual void testContacts(agxCollide::LocalGeometryContact* result, bool inversedOrder) override;
249
250 protected:
251 agx::UInt32Vector m_triangleNrs;
252 agx::UInt8Vector m_voronoiRegions;
253 agx::UInt8Vector m_shapeNumbers;
254 ContactsToTest m_toTest;
255 };
256
257
259 agxSDK::Simulation* simulation,
260 const agx::RigidBodyPtrVector& bodies,
261 const char* groupName,
262 const char* testName,
263 agx::Real preTestingTime = agx::Real(1.0),
264 bool onlyForDoublePrecision = false);
265
266 inline bool testResting(
267 agxSDK::Simulation* simulation,
268 agx::RigidBody* body,
269 const char* groupName,
270 const char* testName,
271 agx::Real preTestingTime = agx::Real(1.0),
272 bool onlyForDoublePrecision = false)
273 {
275 bodies.push_back( body );
276 return testResting( simulation, bodies, groupName, testName, preTestingTime, onlyForDoublePrecision );
277 }
278
279
280 AGXPHYSICS_EXPORT bool testContacts(
281 agxSDK::Simulation* simulation,
282 const char* groupName,
283 const char* testName,
284 ContactTester* tester,
285 bool onlyForDoublePrecision = false);
286
296 AGXPHYSICS_EXPORT bool testColliderRespectsOtherResults(
298}
299
301
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXPHYSICS_EXPORT
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Base class providing referencing counted objects.
Definition Referenced.h:120
The rigid body class, combining a geometric model and a frame of reference.
Definition RigidBody.h:52
void push_back(const T &value)
#define agxAssert(expr)
Definition debug.h:143
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
AGXOSG_EXPORT osg::Group * testResting(agxSDK::Simulation *simulation, agxOSG::ExampleApplication *application, OneBodyRestingScenePtr restingScene, const char *groupName, const char *testName, agx::Real preTestingTime=agx::Real(1))
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition Integer.h:32
double Real
Definition Real.h:42
uint8_t UInt8
Definition Integer.h:30