AGX Dynamics  2.37.3.2
PrimaryActiveZone.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 
35  ActiveZone::Type getType() const;
36 
37  const agxCollide::Convex* getInnerShape() const;
38 
39  const agx::Vector<agx::Plane>& getInnerPlanes() const;
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 
47  agx::Real getSecondarySeparationAngle() const;
48 
49  agx::Vec3 getSecondaryCuttingDirection() const;
50 
51  void updateInnerShape( const agxCollide::GeometryRefVector& voxelCollisionGeometries );
52 
53  protected:
54  virtual ~PrimaryActiveZone();
55 
56  private:
57 
58  void createInnerShape( const Shovel* shovel, const agxCollide::GeometryRefVector& voxelCollisionGeometries );
59 
60  bool finalizeInnerShapeFromVertices( const agx::Vec3Vector& vertices );
61 
62  void calculateSecondarySeparationProperties( Shovel* shovel );
63 
64  void calculateProjectedVectors( Terrain* terrain,
65  const agx::Line& cuttingEdge,
66  const agx::Line& topEdge,
67  const agx::Vec3& forwardVector,
68  agx::Line& cuttingEdgeWorld,
69  agx::Line& topEdgeWorld );
70 
71  bool findPlaneMeshCenterPoint(
72  agx::Vec3 planePoint,
73  agx::Vec3 planeNormal,
74  agx::Real rayLength,
75  const MeshTransformPairVector& meshes,
76  agx::Vec3& result );
77 
78  bool isTriangleFirstInRay(
79  const agx::Vec3& bottom,
80  const agx::Vec3& top,
81  const agxCollide::Mesh::Triangle& triangle,
82  const MeshTransformPairVector& meshes );
83 
84  agx::Vec3Vector performSecondIntersectionTest(
85  agx::Vec3Vector& vertices,
86  const MeshTransformPairVector& meshes,
87  const agx::Vec3& center);
88 
89  private:
90  // Active zone geometry and inner-shape
91  agxCollide::ConvexRef m_innerShape;
92 
93  // Planes used to sort particles
94  agx::Vector<agx::Plane> m_innerPlanes;
95 
96  // Pointer to shovel
97  Shovel* m_shovel;
98 
99  // Secondary separation
100  agx::Real m_secondarySeparationAngle;
101  agx::Vec3 m_secondaryForwardVector;
102 
103  // Projected vectors
104  agx::Vec3 m_projectedForwardVector;
105  agx::Vec3 m_projectedSecondaryForwardVector;
106  agx::Vec3 m_flatForwardVector;
107  };
108 }
AGXCORE_EXPORT Type * getType(const agx::String &name)
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes...
Definition: Geometry.h:59
A convex class for geometric intersection tests.
Definition: Convex.h:36
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Class for more intuitive access to the Mesh&#39;s mesh data.
Definition: Mesh.h:78
#define AGXTERRAIN_EXPORT
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
double Real
Definition: Real.h:42