AGX Dynamics  2.35.0.1
PrimaryActiveZone.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 <agx/config/AGX_USE_AGXTERRAIN.h>
20 
21 #include <agxTerrain/ActiveZone.h>
22 
23 namespace agxTerrain
24 {
25  class Shovel;
26  class Terrain;
27 
29 
31  {
32  public:
33  PrimaryActiveZone(agx::Frame* parentFrame, Shovel* shovel, const agxCollide::GeometryRefVector& voxelCollisionGeometries);
34 
36 
38 
40 
41  void onPreCollide(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector);
42 
43  void onPre(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector);
44 
45  void onPost(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector);
46 
48 
50 
51  protected:
52  virtual ~PrimaryActiveZone();
53 
54  private:
55 
56  void createInnerShape(const Shovel* shovel, const agxCollide::GeometryRefVector& voxelCollisionGeometries);
57 
58  bool finalizeInnerShapeFromVertices(const agx::Vec3Vector& vertices);
59 
60  void calculateSecondarySeparationProperties(Shovel* shovel);
61 
62  void calculateProjectedVectors(Terrain* terrain,
63  const agx::Line& cuttingEdge,
64  const agx::Line& topEdge,
65  const agx::Vec3& forwardVector,
66  agx::Line& cuttingEdgeWorld,
67  agx::Line& topEdgeWorld);
68 
69  bool findPlaneMeshCenterPoint(agx::Vec3 planePoint, agx::Vec3 planeNormal, agx::Real rayLength, const MeshTransformPairVector& meshes, agx::Vec3& result);
70 
71  bool isTriangleFirstInRay(const agx::Vec3& bottom,
72  const agx::Vec3& top,
73  const agxCollide::Mesh::Triangle& triangle,
74  const MeshTransformPairVector& meshes);
75 
76  void updateInnerShape(const agxCollide::GeometryRefVector& voxelCollisionGeometries);
77 
78  void projectPointsToTrianglePlanes(agx::Vec3Vector& vertices, const agx::Vector<agx::Plane>& trianglePlanes);
79 
80  private:
81  // Active zone geometry and inner-shape
82  agxCollide::ConvexRef m_innerShape;
83 
84  // Planes used to sort particles
85  agx::Vector<agx::Plane> m_innerPlanes;
86 
87  // Pointer to shovel
88  Shovel* m_shovel;
89 
90  // Secondary separation
91  agx::Real m_secondarySeparationAngle;
92  agx::Vec3 m_secondaryForwardVector;
93 
94  // Projected vectors
95  agx::Vec3 m_projectedForwardVector;
96  agx::Vec3 m_projectedSecondaryForwardVector;
97  agx::Vec3 m_flatForwardVector;
98  };
99 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXTERRAIN_EXPORT
A convex class for geometric intersection tests.
Definition: Convex.h:38
Class for more intuitive access to the Mesh's mesh data.
Definition: Mesh.h:79
const agxCollide::Convex * getInnerShape() const
void onPreCollide(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)
PrimaryActiveZone(agx::Frame *parentFrame, Shovel *shovel, const agxCollide::GeometryRefVector &voxelCollisionGeometries)
void onPost(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)
ActiveZone::Type getType() const
agx::Vec3 getSecondaryCuttingDirection() const
const agx::Vector< agx::Plane > & getInnerPlanes() const
agx::Real getSecondarySeparationAngle() const
void onPre(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)
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
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
double Real
Definition: Real.h:42