AGXDynamics
2.35.0.3
WireSimplifyController.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
#pragma once
18
19
#include <
agxWire/Node.h
>
20
#include <
agxSDK/Simulation.h
>
21
#include <
agx/Referenced.h
>
22
23
DOXYGEN_START_INTERNAL_BLOCK
()
24
25
namespace
agx
26
{
27
class
MergedBody;
28
}
29
30
namespace
agxWire
31
{
32
class
Wire;
33
34
typedef
agx::ref_ptr< class WireSimplifyInterface >
WireSimplifyInterfaceRef;
35
39
class
AGXPHYSICS_EXPORT
WireSimplifyInterface :
public
agx::Referenced
40
{
41
public
:
42
typedef
agx::Vector< WireSimplifyInterfaceRef >
SimplifyCallbackContainer;
44
public
:
51
virtual
bool
simplify(
const
agx::Frame
* parentFrame );
52
57
virtual
bool
unsimplify();
58
64
virtual
void
reset();
65
66
public
:
75
virtual
void
preCollide(
const
agxSDK::Simulation
* simulation );
76
84
virtual
void
pre(
const
agxSDK::Simulation
* simulation );
85
93
virtual
void
post(
const
agxSDK::Simulation
* simulation );
94
95
public
:
100
void
add( agxWire::WireSimplifyInterfaceRef simplifyCallback );
101
106
void
remove( agxWire::WireSimplifyInterfaceRef simplifyCallback );
107
111
void
removeAllCallbacks();
112
116
const
SimplifyCallbackContainer& getCallbacks()
const
;
117
121
agxSDK::Simulation
* getSimplifiedFrom()
const
;
122
123
protected
:
127
WireSimplifyInterface();
128
132
virtual
~WireSimplifyInterface();
133
138
void
setLastTransform(
const
agx::AffineMatrix4x4
& matrix );
139
143
const
agx::AffineMatrix4x4
& getLastTransform()
const
;
144
150
void
setSimplifiedFrom(
agxSDK::Simulation
* simulation );
151
152
protected
:
153
agx::FrameConstRef
m_parentFrame;
154
155
private
:
156
agx::AffineMatrix4x4
m_lastTransform;
157
SimplifyCallbackContainer m_callbacks;
158
agxSDK::SimulationObserver
m_simplifiedFrom;
159
};
160
161
/*
162
Wire simplify.
163
164
A wire will keep its current state when removed from a simulation:
165
166
simulation->remove( wire );
167
...
168
// Keep rendering.
169
for ( auto i = wire->getRenderBeginIterator()... )
170
171
Adding the wire to the simulation again will 'enable' it again (unsimplify).
172
173
So, it's possible to simply remove a wire from the simulation, and for
174
example keep rendering it, for easiest and most effective simplification. Note
175
that the nodes wont be updated automatically.
176
177
If one want the wire to support all types of actions (cut, merge, contacts etc etc),
178
and move/follow a parent frame, this class can be used. Note that this class is
179
member of agxWire::Wire (accessed agxWire::Wire::getSimplifyController()). Example:
180
181
const agx::Frame* parentFrame = ship->getFrame();
182
wire->simplify( parentFrame ); // Will remove the wire from the simulation but keep updating geometry and node positions.
183
bool simplified = wire->isSimplified(); // True!
184
wire->unsimplify(); // Will add the wire again. Wire will start to interact again.
185
186
When the wire is simplified it will unsimplify itself if:
187
* A new node is inserted (e.g., valid contact).
188
* An unsimplified wire is merged with it.
189
*/
190
class
AGXPHYSICS_EXPORT
WireSimplifyController :
public
agxWire::WireSimplifyInterface
191
{
192
public
:
197
static
void
garbageCollect(
const
agxSDK::Simulation
* originalSimulation );
198
204
static
void
validateRemoveState(
agxWire::Wire
* wire );
205
206
public
:
207
enum
State
208
{
209
SIMPLIFYING = ( 1 << 0 ),
210
SIMPLIFIED = ( 1 << 1 ),
211
UNSIMPLIFYING = ( 1 << 2 ),
212
NONE = ( 1 << 3 ),
213
COLLIDING = ( 1 << 4 ),
214
HAS_MERGED_BODY = ( 1 << 5 ),
215
MERGED_ACTIVE = ( 1 << 6 )
216
};
217
218
public
:
223
WireSimplifyController(
agxWire::Wire
* wire );
224
228
bool
is(
agx::Int
state )
const
;
229
233
void
initializeGeometryController();
234
242
agx::MergedBody
* getMergedBody(
agx::Bool
onlyIfActive )
const
;
243
251
agx::RigidBody
* getMergedParentBody(
agx::Bool
onlyIfActive )
const
;
252
253
public
:
259
virtual
WireSimplifyController* clone(
agxWire::Wire
* wireForClone )
const
;
260
265
virtual
bool
simplify(
const
agx::Frame
* parentFrame )
override
;
266
271
virtual
bool
unsimplify()
override
;
272
277
virtual
bool
merge(
agx::RigidBody
* parentBody,
agx::MergedBody
* mergedBody );
278
282
virtual
bool
split();
283
287
virtual
void
reset()
override
;
288
292
virtual
void
preCollide(
const
agxSDK::Simulation
* simulation )
override
;
293
298
virtual
void
collide(
const
agxWire::Node
* node );
299
303
virtual
void
pre(
const
agxSDK::Simulation
* simulation )
override
;
304
308
virtual
void
post(
const
agxSDK::Simulation
* simulation )
override
;
309
313
virtual
void
store(
agxStream::OutputArchive
&
out
)
const
;
314
318
virtual
void
restore(
agxStream::InputArchive
&
in
);
319
320
protected
:
324
virtual
~WireSimplifyController();
325
326
protected
:
330
void
setState(
agx::Int
state );
331
335
void
addState(
State
state );
336
340
agx::Int
getState()
const
;
341
345
agxWire::Wire
* getWire()
const
;
346
351
void
updateMergedState();
352
353
protected
:
354
typedef
agx::observer_ptr< agx::Referenced >
WireType;
355
356
protected
:
357
WireType m_wire;
358
agx::Int
m_state;
359
};
360
361
typedef
agx::ref_ptr< WireSimplifyController >
WireSimplifyControllerRef;
362
}
363
364
DOXYGEN_END_INTERNAL_BLOCK
()
Referenced.h
agx::Vector
Templated vector class.
Definition:
Vector.h:52
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition:
OutputArchive.h:412
Simulation.h
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:54
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition:
macros.h:97
agx::AffineMatrix4x4T< Real >
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition:
macros.h:96
agx::Int
int32_t Int
Definition:
Integer.h:35
agxWire::Wire
Interface and placeholder of controllers/helpers for wires.
Definition:
Wire.h:61
agx::observer_ptr< Simulation >
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition:
AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition:
InputArchive.h:400
Node.h
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition:
ref_ptr.h:29
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition:
Simulation.h:126
agxWire
Implements a Wire model with adaptive resolution.
Definition:
MergedBody.h:39
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition:
OutputArchive.h:56
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition:
InputArchive.h:51
agx::GraphNode::State
State
Definition:
GraphNode.h:39
agx::Referenced
Base class providing referencing counted objects.
Definition:
Referenced.h:113
agx::Bool
bool Bool
Definition:
Integer.h:48
agxWire::Node
Class defining a node that is part of a wire.
Definition:
agxWire/Node.h:511
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition:
Frame.h:67
agx::MergedBody
Structure holding several "normal" rigid bodies.
Definition:
MergedBody.h:55
include
agxWire
WireSimplifyController.h
Generated on Fri Feb 10 2023 14:06:22 for AGXDynamics by
1.8.17