AGX Dynamics  2.35.0.1
DeformController.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 
20 #include <agx/Plane.h>
22 #include <array>
23 
24 namespace agxTerrain
25 {
27 
29  {
30  public:
32  const agx::Line& cuttingEdge,
33  const agx::Line& topEdge,
34  const agx::Vec3& forwardVector,
35  const agxCollide::GeometryRefVector& voxelCollisionGeometries);
36 
37  void addNotification(agxSDK::Simulation* simulation, Terrain* terrain);
38 
39  void removeNotification(agxSDK::Simulation* simulation, Terrain* terrain);
40 
42 
43  void onPre(TerrainToolCollection* collection);
44 
45  void onPost(TerrainToolCollection* collection);
46 
48 
50 
52 
54 
56 
57  void onEnableChanged(bool enable);
58 
60 
62 
64 
66 
67  protected:
68  virtual ~DeformController();
69 
70  private:
71  enum DeformSide
72  {
73  BACK = 0,
74  LEFT = 1,
75  RIGHT = 2
76  };
77 
78  private:
79 
80  void createEdges(const agx::Line& cuttingEdge,
81  const agx::Line& topEdge,
82  const agx::Vec3& forwardVector,
83  const agxCollide::GeometryRefVector& voxelCollisionGeometries);
84 
85  agx::Vec3Vector extractVertices(const agxCollide::GeometryRefVector& voxelCollisionGeometries);
86 
87  agx::Vec3 findEdgePoint( agx::Vec3Vector& vertices,
88  agx::Vec3 point,
89  agx::Plane& frontPlane,
90  agx::Plane& bottomPlane,
91  agx::Plane& sidePlane,
92  agx::Real tol );
93 
94  void deformSolidMass(TerrainToolCollection* collection);
95 
96  bool shouldDeformMass(TerrainToolCollection* collection);
97 
98  void createAggregateContactPoints(TerrainToolCollection* collection);
99 
100  void createShovelContacts(TerrainToolCollection* collection);
101 
102  void createTerrainContacts(TerrainToolCollection* collection);
103 
104  agx::Vec3Vector findShovelTerrainIntersectionPoints( TerrainToolCollection* collection,
105  DeformerCollection* deformer );
106 
107  agx::Vec3Vector findAggregateTerrainIntersectionPoints( const agx::Line& wedgeCuttingEdge,
108  const agx::Line& wedgeFailureEdge );
109 
110  agx::Vec3 calculateAggregateNormal( const agx::Line& wedgeCuttingEdge,
111  const agx::Line& wedgeFailureEdge ) const;
112 
113  void pushSoilToSides(TerrainToolCollection* collection,
114  const agx::Vec3& fromVoxelWorldPos,
115  const agx::Real& elementSize,
116  const agx::Vec3& topVectorNormalized,
117  const agx::Vec3& deformerNormal,
118  const agx::Real& timeStep,
119  const agx::Real& voxelSpeed,
120  const agx::Vec2i& fromTerrainIndex,
121  const float& occupancyInVoxel,
122  const float& dynamicMassCompaction,
123  const agx::Vec3i& voxel,
124  agx::Vec3* voxelSideVelocity);
125 
126  void DEBUG_DRAW();
127 
128  private:
129 
130  agx::Frame* m_parentFrame;
131  std::array<DeformerCollectionRef, 3> m_deformers;
132  std::array<AggregateContactDepthModel, 3> m_depthModels;
134  std::array<agx::ContactMaterialRef, 3> m_aggregateTerrainContactMaterials;
135  std::array<agx::ContactMaterialRef, 3> m_aggregateShovelContactMaterials;
136  };
137 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXTERRAIN_EXPORT
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
Class used to calculate the contact depth in the soil aggregate <-> terrain contacts to mimic an elas...
void initializeContactMaterials(TerrainToolCollection *collection)
agxCollide::GeometryPtrVector getActiveZoneGeometries()
void onPre(TerrainToolCollection *collection)
DeformerCollection * getDeformerCollection(size_t i)
void addNotification(agxSDK::Simulation *simulation, Terrain *terrain)
void onPreCollide(TerrainToolCollection *collection)
void onEnableChanged(bool enable)
void removeNotification(agxSDK::Simulation *simulation, Terrain *terrain)
DeformController(agx::Frame *parentFrame, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector, const agxCollide::GeometryRefVector &voxelCollisionGeometries)
ActiveZonePtrVector getActiveZones()
void onPost(TerrainToolCollection *collection)
SoilParticleAggregatePtrVector getSoilParticleAggregates()
const agxTerrain::AggregateContactDepthModel & getAggregateDepthModel(agx::UInt i) const
void resetAggregateContactHistory(agx::UInt i)
agxCollide::GeometryContactPtrVector getGeometryContacts(agxSDK::Simulation *simulation) const
Collection of terrain tool (currently Shovel) related objects which are terrain instance specific.
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
Class representing the mathematical concept of a plane, also called a half- space.
Definition: agx/Plane.h:32
Base class providing referencing counted objects.
Definition: Referenced.h:114
Vector containing 'raw' data.
Definition: agx/Vector.h:246
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42