AGXDynamics
2.31.1.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
MergeSplit.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 AGX_MERGESPLIT_H
18
#define AGX_MERGESPLIT_H
19
20
#include <
agx/TimeStamp.h
>
21
#include <
agxCollide/Space.h
>
22
#include <
agx/agxPhysics_export.h
>
23
#include <
agx/SleepThreshold.h
>
24
#include <
agx/MergeSplitBodyStorage.h
>
25
#include <
agxCollide/agxcollide_hash_types.h
>
26
27
namespace
agx
28
{
37
class
AGXPHYSICS_EXPORT
MergeSplit
:
public
agx::Referenced
,
public
agxStream::Serializable
38
{
39
public
:
40
42
MergeSplit
(
agxCollide::Space
*space=
nullptr
);
43
47
MergeSplitThreshold
*getThreshold();
48
52
const
MergeSplitThreshold
*getThreshold()
const
;
53
58
void
setEnable(
bool
flag );
59
70
void
setSplitInPost(
bool
flag );
71
73
bool
getSplitInPost()
const
;
74
76
bool
getEnable( )
const
;
77
79
bool
isEnabled( )
const
;
80
84
void
clear
();
85
90
void
split();
91
104
bool
split(
agxCollide::Geometry
* geometry,
bool
shouldUpdateContacts =
true
,
bool
forceSplit =
false
,
bool
splitImmediately=
true
);
105
110
void
merge();
111
113
void
setSpace(
agxCollide::Space
*space );
114
118
static
void
calculateSeparatingVelocityAcceleration(
agx::RigidBody
*body1,
agx::RigidBody
* body2,
agx::Real
& dVel,
agx::Real
& dOmega,
agx::Real
& dAcc,
agx::Real
& dAngularAcc );
119
120
AGXSTREAM_DECLARE_SERIALIZABLE
(
agx::MergeSplit
);
121
122
void
pre(
const
agx::TimeStamp
& t );
123
void
post(
const
agx::TimeStamp
& t );
124
134
bool
split(
agx::RigidBody
*bodyToBeSplit,
bool
forceSplit =
false
,
bool
splitImmediately=
true
);
135
136
151
bool
merge(
agx::RigidBody
*child,
agx::RigidBody
*parent );
152
159
class
Listener
:
public
agx::Referenced
160
{
161
public
:
162
Listener
() {}
163
173
virtual
bool
merge(
agx::RigidBody
*parent,
agx::RigidBody
*child ) = 0;
174
187
virtual
bool
split(
agx::RigidBody
*parent,
agx::RigidBody
*child,
agxCollide::GeometryContact
*contact ) = 0;
188
189
190
protected
:
191
virtual
~Listener
() {}
192
};
193
194
195
typedef
agx::ref_ptr<Listener>
ListenerRef
;
196
200
void
setListener(
Listener
*listener );
201
205
Listener
*getListener( );
206
210
const
Listener
*getListener( )
const
;
211
212
bool
validate ();
213
214
protected
:
215
friend
class
agxSDK::Simulation
;
216
void
registerGeometriesBodies(
agxSDK::Simulation
*sim );
217
218
bool
removeFromBodyStorage(
agx::RigidBody
*body );
219
220
221
bool
shouldMerge(
agx::RigidBody
*body1,
agx::RigidBody
*body2,
agxCollide::GeometryContact
*contact )
const
;
222
void
updateContacts(
const
agxCollide::GeometryContactPtrVector
& contacts,
bool
removeContacts =
false
)
const
;
223
234
bool
_split(
agx::RigidBody
*bodyToBeSplit,
agxCollide::GeometryContact
*contact,
bool
forceSplit =
false
,
bool
splitImmediately=
true
);
235
236
237
bool
sleep(
agx::RigidBody
*body1,
agx::RigidBody
*body2 );
238
bool
wake(
agx::RigidBody
*body1,
agx::RigidBody
*body2 );
239
240
241
bool
split(
const
agxCollide::GeometryContactPtrVector
& contacts );
242
243
bool
split(
agxCollide::Geometry
*geom1,
agxCollide::Geometry
*geom2,
agxCollide::GeometryContact
*contact=
nullptr
);
244
bool
split(
const
agxCollide::SeparationPairVector
& separations );
245
246
bool
merge(
const
agxCollide::GeometryContactPtrVector
& contacts );
247
bool
performMerge(
agx::RigidBody
*child,
agx::RigidBody
*parent );
248
249
//void transferGeometries( agx::RigidBody *child, const agxCollide::GeometryPtrVector& geometries, agx::RigidBody *parent );
250
void
transferGeometries(
agx::RigidBody
*child,
agxCollide::GeometryRefVector
geometries,
agx::RigidBody
*parent );
251
void
prepareForMerge(
agx::RigidBody
*body );
252
//bool verifyStorage();
253
254
void
addNotification();
255
void
removeNotification();
256
257
virtual
~
MergeSplit
();
258
259
MergeSplitBodyStorage
*getBodyStorage();
260
void
returnBodyStorage(
MergeSplitBodyStorage
*bodyStorage );
261
262
void
clearStats();
263
264
typedef
agx::HashVector<agxCollide::Geometry *, agx::ref_ptr<MergeSplitBodyStorage>
>
GeometryBodyHashVector
;
265
GeometryBodyHashVector
m_geometryBodyHash
;
266
267
size_t
m_numMerge
;
268
size_t
m_numSplit
;
269
270
agx::ref_ptr<SleepThreshold>
m_threshold
;
271
272
typedef
agx::Vector<agx::ref_ptr<MergeSplitBodyStorage>
>
MergeSplitBodyStorageRefVector
;
273
typedef
agx::Vector<MergeSplitBodyStorage * >
MergeSplitBodyStoragePtrVector
;
274
275
MergeSplitBodyStoragePtrVector
m_freeBodyStorage
;
276
MergeSplitBodyStorageRefVector
m_bodyStoragePool
;
277
agx::observer_ptr<agxCollide::Space>
m_space
;
278
279
bool
m_enabled
;
280
ListenerRef
m_listener
;
281
282
agx::RigidBodyObserverVector
m_bodiesToBeSplit
;
283
bool
m_splitInPost
;
284
};
285
286
typedef
agx::ref_ptr<MergeSplit>
MergeSplitRef
;
287
288
}
289
290
#endif
/* _AGX_MERGESPLIT_H_ */
agx::MergeSplit::m_threshold
agx::ref_ptr< SleepThreshold > m_threshold
Definition:
MergeSplit.h:270
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
agx::MergeSplit::m_listener
ListenerRef m_listener
Definition:
MergeSplit.h:280
MergeSplitBodyStorage.h
agx::observer_ptr< agxCollide::Space >
agx::MergeSplit::m_enabled
bool m_enabled
Definition:
MergeSplit.h:279
agx::MergeSplit::m_numSplit
size_t m_numSplit
Definition:
MergeSplit.h:268
Space.h
agxCollide::GeometryContact
A contact between two geometries.
Definition:
Contacts.h:270
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::MergeSplit::Listener::Listener
Listener()
Definition:
MergeSplit.h:162
agxPhysics_export.h
agx::TimeStamp
agx::Real TimeStamp
Definition:
TimeStamp.h:26
agx::MergeSplit::m_space
agx::observer_ptr< agxCollide::Space > m_space
Definition:
MergeSplit.h:277
agx::MergeSplit::m_numMerge
size_t m_numMerge
Definition:
MergeSplit.h:267
agx::Referenced
Base class providing referencing counted objects.
Definition:
Referenced.h:113
agx::MergeSplit::m_bodyStoragePool
MergeSplitBodyStorageRefVector m_bodyStoragePool
Definition:
MergeSplit.h:276
agx::MergeSplitRef
agx::ref_ptr< MergeSplit > MergeSplitRef
Definition:
MergeSplit.h:286
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition:
Geometry.h:88
agx::HashVector
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition:
HashVector.h:40
agx::Vector< agx::Physics::GeometryPairPtr, agxData::BufferProxyAllocator >
agx::MergeSplit
Class which will go through contacting/separating bodies and determine if the bodies can be merged (g...
Definition:
MergeSplit.h:37
agx::MergeSplit::Listener::~Listener
virtual ~Listener()
Definition:
MergeSplit.h:191
agx::VectorPOD< GeometryContact * >
agxCollide::Space
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition:
Space.h:81
agx::MergeSplit::m_splitInPost
bool m_splitInPost
Definition:
MergeSplit.h:283
agx::MergeSplit::m_geometryBodyHash
GeometryBodyHashVector m_geometryBodyHash
Definition:
MergeSplit.h:265
agx::MergeSplit::GeometryBodyHashVector
agx::HashVector< agxCollide::Geometry *, agx::ref_ptr< MergeSplitBodyStorage > > GeometryBodyHashVector
Definition:
MergeSplit.h:264
agx::ref_ptr< Listener >
agx::MergeSplit::ListenerRef
agx::ref_ptr< Listener > ListenerRef
Definition:
MergeSplit.h:195
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:52
agx::MergeSplitBodyStorage
Book keeping of a body which can be merged with other bodies.
Definition:
MergeSplitBodyStorage.h:35
agx::SleepThreshold
Definition:
SleepThreshold.h:28
AGXSTREAM_DECLARE_SERIALIZABLE
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition:
Serializable.h:206
agx::MergeSplit::m_freeBodyStorage
MergeSplitBodyStoragePtrVector m_freeBodyStorage
Definition:
MergeSplit.h:275
agx::MergeSplit::MergeSplitBodyStoragePtrVector
agx::Vector< MergeSplitBodyStorage * > MergeSplitBodyStoragePtrVector
Definition:
MergeSplit.h:273
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition:
Serializable.h:44
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition:
Simulation.h:121
TimeStamp.h
agx::Real
double Real
Definition:
Real.h:42
agxcollide_hash_types.h
agx::MergeSplit::MergeSplitBodyStorageRefVector
agx::Vector< agx::ref_ptr< MergeSplitBodyStorage > > MergeSplitBodyStorageRefVector
Definition:
MergeSplit.h:272
agx::MergeSplit::m_bodiesToBeSplit
agx::RigidBodyObserverVector m_bodiesToBeSplit
Definition:
MergeSplit.h:282
SleepThreshold.h
agx::MergeSplit::Listener
Class for intercepting merge/split events.
Definition:
MergeSplit.h:159
include
agx
MergeSplit.h
Generated on Mon Mar 21 2022 11:53:03 for AGXDynamics by
1.8.5