AGXDynamics  2.31.1.0
DeformController.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 #pragma once
18 
20 #include <agx/Plane.h>
22 #include <array>
23 
24 namespace agxTerrain
25 {
27 
29  {
30  public:
31  DeformController(agx::Frame* parentFrame,
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 
41  void onPreCollide(TerrainToolCollection* collection);
42 
43  void onPre(TerrainToolCollection* collection);
44 
45  void onPost(TerrainToolCollection* collection);
46 
47  DeformerCollection* getDeformerCollection(size_t i);
48 
49  ActiveZonePtrVector getActiveZones();
50 
51  agxCollide::GeometryPtrVector getActiveZoneGeometries();
52 
53  SoilParticleAggregatePtrVector getSoilParticleAggregates();
54 
55  agxCollide::GeometryContactPtrVector getGeometryContacts(agxSDK::Simulation *simulation) const;
56 
57  void onEnableChanged(bool enable);
58 
59  void initializeContactMaterials(TerrainToolCollection* collection);
60 
61  void resetAggregateContactHistories();
62 
63  void resetAggregateContactHistory(agx::UInt i);
64 
65  const agxTerrain::AggregateContactDepthModel& getAggregateDepthModel(agx::UInt i) const;
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 }
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Copyright 2007 - 2018.
Definition: Geometry.h:56
Collection of terrain tool (currently Shovel) related objects which are terrain instance specific...
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
Class used to calculate the contact depth in the soil aggregate <-> terrain contacts to mimic an elas...
Base class providing referencing counted objects.
Definition: Referenced.h:113
uint32_t UInt
Definition: Integer.h:34
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
#define AGXTERRAIN_EXPORT
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:121
double Real
Definition: Real.h:42