AGX Dynamics  2.35.0.1
TerrainToolCollection.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 <agxTerrain/Shovel.h>
23 
24 #include <agxStream/Serializable.h>
25 
26 namespace agxTerrain
27 {
30 
36  {
37  public:
43  TerrainToolCollection( Terrain* terrain, Shovel* shovel );
44 
48  Terrain* getTerrain() const;
49 
53  Shovel* getShovel() const;
54 
59 
64  void setActiveZone( PrimaryActiveZone* activeZone );
65 
70 
75  void setSoilParticleAggregate( SoilParticleAggregate* soilParticleAggregate );
76 
81 
86  void setAggregateContactGenerator(AggregateContactGenerator* aggregateContactGenerator);
87 
92 
97  void setDeformController(DeformController* deformController);
98 
103 
109 
114 
120 
126 
127 
132 
137 
142 
148 
154  void setZeroAggregateVelocity( bool enable );
155 
160 
161  public:
169  virtual agx::Bool initialize( agxSDK::Simulation* simulation );
170 
178  virtual void uninitialize( agxSDK::Simulation* simulation );
179 
183  virtual void onPreCollide();
184 
188  virtual void onPre();
189 
193  virtual void onPost();
194 
199 
204 
208  void enable(bool enabled);
209 
213  bool getEnable();
214 
219 
223  void clearActiveZoneWedges() const;
224 
229 
234 
237 
238  virtual void onPostRestore( Terrain* terrain );
240 
241  protected:
246 
251 
253  {
254  ENABLED = 1 << 0,
255  SHOVEL_ENABLED = 1 << 1,
256  SET_ZERO_AGGREGATE_VELOCITY = 1 << 2
257  };
258  using Flags = agx::BitState<StateFlags, agx::UInt32>;
259 
260  bool getShovelEnabled() const;
261 
262  void setShovelEnabled( bool enabled );
263 
264  void setEnable( bool enabled );
265 
266  private:
267  Terrain* m_terrain;
268  ShovelRef m_shovel;
269  PrimaryActiveZoneRef m_activeZone;
270  SoilParticleAggregateRef m_soilParticleAggregate;
271  AggregateContactGeneratorRef m_aggregateContactGenerator;
272  DeformControllerRef m_deformController;
273  ShovelAggregateContactMaterialContainerRef m_shovelAggregateCMContainer;
274  SoilPenetrationResistanceRef m_penetrationResistance;
275  Flags m_flags;
276 
277  agx::FrameRef m_parentFrame;
278  agxCollide::GeometryRefVector m_voxelCollisionGeometries;
279  };
280 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#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
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Simple container class for storing and handling explicit contact material for shovel-aggregate contac...
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition: Shovel.h:87
Collection of terrain tool (currently Shovel) related objects which are terrain instance specific.
const agx::RigidBody * getWedgeAggregate(Shovel::ExcavationMode excavationMode) const
agx::Frame * getParentFrame() const
void setSoilParticleAggregate(SoilParticleAggregate *soilParticleAggregate)
Assign soil particle aggregate for the shovel in this terrain.
void enable(bool enabled)
Set enable/disable of the ToolCollection.
void setAggregateContactGenerator(AggregateContactGenerator *aggregateContactGenerator)
Assign aggregate contact generator for the soil particle aggregate in this terrain.
agx::Real getAggregateTerrainContactDepth(Shovel::ExcavationMode excavationMode) const
SoilParticleAggregate * getSoilParticleAggregate() const
TerrainToolCollection(Terrain *terrain, Shovel *shovel)
Construct given terrain and shovel.
virtual void onPre()
Callback from terrain pre-solve.
virtual agx::Bool initialize(agxSDK::Simulation *simulation)
bool collisionGeometriesAreInsideTerrain() const
Check if any of the collision geometries are inside terrain bounds.
virtual void onPost()
Callback from terrain post-solve.
ShovelAggregateContactMaterialContainer * getShovelTerrainContactMaterialContainer()
agx::Bool getSetZeroAggregateVelocity() const
virtual void onPreCollide()
Callback from terrain preCollide.
void setZeroAggregateVelocity(bool enable)
Set whenever the innerbody aggregate should have zero velocity before solve step as opposed to using ...
AggregateContactGenerator * getAggregateContactGenerator() const
virtual void uninitialize(agxSDK::Simulation *simulation)
void handleEnableChange()
Update ToolCollection if shovel enable has changed.
void setPenetrationResistance(SoilPenetrationResistance *penetrationResistance)
Assign penetration resistance instance for the shovel in this terrain.
agx::BitState< StateFlags, agx::UInt32 > Flags
void setEnableShovelTerrainGeometryContacts(bool enable)
Set if regular geometry contacts should be created between the shovel geometries and the associated t...
void setDeformController(DeformController *deformController)
Assign aggregate contact generator for the soil particle aggregate in this terrain.
DeformController * getDeformController() const
void setVoxelCollisionGeometries(const agxCollide::GeometryRefVector &geometries)
Assign collision geometries used to test voxel overlaps.
void clearActiveZoneWedges() const
Clear the active zone wedges of the primary active zones and deformers.
void setShovelEnabled(bool enabled)
PrimaryActiveZone * getActiveZone() const
SoilPenetrationResistance * getPenetrationResistance() const
void setActiveZone(PrimaryActiveZone *activeZone)
Assign active zone for the shovel in this terrain.
const agxCollide::GeometryRefVector & getVoxelCollisionGeometries() const
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
The object defining a frame of reference and providing transformations operations.
Definition: agx/Frame.h:68
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
bool Bool
Definition: Integer.h:48
double Real
Definition: Real.h:42