AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
ExternalDeformer.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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#include <agx/BitState.h>
24#include <agx/Plane.h>
25
26#pragma once
27
28namespace agxCollide
29{
30 class Geometry;
31 class Shape;
32}
33
34namespace agxTerrain
35{
36 //--- Forward declarations ---//
37 class Terrain;
38 class TerrainMaterial;
39
41
44
57 {
58 public:
59 class ExcavationSettings;
60 class Settings;
61
72 const agx::Line& cuttingEdge,
73 const agx::Line& topEdge,
74 const agx::Vec3& cuttingDirection );
75
80
84 void addDeformer( const agx::Line& cuttingEdge,
85 const agx::Line& topEdge,
86 const agx::Vec3& cuttingDirection );
87
92
97
102
103 /*
104 \return the active terrain that the external deformer is acting on. If the external deformer is currently
105 not interacting with the terrain, return nullptr.
106 */
108
113
114 /*
115 \return if the deformer is currently active. The deformer is active while interacting with a terrain.
116 */
117 bool isActive() const;
118
119 /*
120 \return if the deformer is valid after construction. If it is not valid, it will not be possible to add the deformer to
121 a simulation.
122 */
123 virtual bool isValid() const override;
124
125 /*
126 Set whether the external deformer should be enabled or not.
127 \param enable - true if the external deformer is enabled, false otherwise.
128 */
129 void setEnable( bool enable );
130
131 /*
132 return whether the external deformer should is enabled or not.
133 */
134 bool getEnable() const;
135
141 void setEnableDebugRendering( bool enable );
142
147
149
150 virtual void onAssemblyAdd(agxSDK::Assembly* assembly) override;
151
153
155
156 protected:
161
166
167 /*
168 Creates a frame which uses the parents body's frame as parent. Other internals
169 attaches to this frame to make sure they follow along the parent rigid body.
170 Requires that the parent body isn't nullptr.
171 */
172 agx::Frame* createParentFrame();
173
177 virtual void addNotification() override;
178
182 virtual void removeNotification() override;
183
188 void setAggregateMaterial(agx::Material* material);
189
190 /*
191 Checks if all internal contact materials are correct.
192 If there is an active terrain (ie, we are interacting with a terrain)
193 the contact material will be customized for that terrain.
194 */
195 void checkContactMaterials();
196
200 void initalizeContactMaterialsForExistingTerrains(agxSDK::Simulation* simulation);
201
208 virtual void preCollide() override;
209
219 virtual void pre() override;
220
225 virtual void post() override;
226
231 virtual void last() override;
232
233 agxSDK::TerrainManager* getTerrainManager();
234
235 TerrainPtrVec getTerrainsInSimulation();
236
240 void clearActiveZoneWedges() const;
241
242 private:
243 enum StateFlags : agx::UInt32
244 {
245 ENABLED = 1 << 0
246 };
247 using Flags = agx::BitState<StateFlags, agx::UInt32>;
248
249
250 void addDeformers(const std::array<DeformerCollectionRef, 3>& deformers);
251
252 bool shouldDeformMass(Terrain* terrain);
253
254 protected:
255
256 // Configuration:
258 agx::FrameRef m_parentFrame; /* Parent frame for parent body geometries synchronized with model center of parent body. */
259 Flags m_flags;
261
262 // Geometries used to find deformer-voxel collisions
268
269
271
273 };
274}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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:207
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:38
An agxTerrain::TerrainToolInstance in a simulation, receiving step and contact callbacks in a control...
ExternaDeformer is a TerrainToolInstance class that models deformer surfaces that are not attached to...
const agxCollide::GeometryRefVector & getVoxelCollisionGeometries() const
DeformControllerRef m_deformController
ExternalDeformer(agx::RigidBody *parentBody)
Empty constructor, for creating a external deformer body to which can be added multiple deformers lat...
agxCollide::BoundingAABB m_collisionBound
ExternalDeformer(agx::RigidBody *parentBody, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &cuttingDirection)
Basic constructor.
agxCollide::GeometryRefVector m_voxelCollisionGeometries
void addDeformer(const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &cuttingDirection)
Add new deformer.
virtual bool isValid() const override
Terrain * getActiveTerrain() const
agx::Vector< DeformerCollectionRef > m_deformers
void setEnableDebugRendering(bool enable)
Set whenever debug rendering of deformer forbidden bounds should be enabled or not.
agx::RigidBody * getRigidBody() const
agx::MaterialRef m_aggregateMaterial
bool getEnableDebugRendering() const
bool collisionGeometriesAreInsideTerrain(Terrain *terrain) const
Check if any of the collision geometries are inside terrain bounds.
void setEnable(bool enable)
DeformController * getDeformController() const
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:92
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
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
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
The agx namespace contains the dynamics/math part of the AGX Dynamics API.