AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ActiveZone.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agx/config/AGX_USE_AGXTERRAIN.h>
20
21#include <agx/agx.h>
22#include <agx/Line.h>
23#include <agx/RigidBody.h>
25
26#include <agxCollide/Geometry.h>
28#include <agxCollide/Convex.h>
29
31
32#include <agxSDK/Simulation.h>
34
35#include <agxTerrain/export.h>
36#include <agxTerrain/Grid.h>
38
39namespace agxTerrain
40{
41 class Terrain;
42 class TerrainToolCollection;
43
44 typedef std::pair<agxCollide::MeshRef, agx::AffineMatrix4x4> MeshTransformPair;
46
48
51
53 {
54 public:
55
56 enum class Type
57 {
58 PRIMARY_ACTIVE_ZONE,
59 DEFORMER_ACTIVE_ZONE
60 };
61
62 ActiveZone(agx::Frame* parentFrame);
63
64 virtual void onPreCollide(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector) = 0;
65
66 virtual void onPre(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector) = 0;
67
68 virtual void onPost(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector) = 0;
69
70 virtual ActiveZone::Type getType() const = 0;
71
73
75
77
78 agx::Bool overlapsVoxel(const agx::Vec3i& index) const;
79
81
83
85
87
89
90 bool isSoilWedgeEnabled(agx::UInt index) const;
91
93
98
100
102
104
106
108
110
116 void onEnableChange( bool enable );
117
119
121
123
124 protected:
125
126 virtual ~ActiveZone();
127
128 void createSoilWedges(const Terrain* terrain,
129 const agx::Line& cuttingEdge,
130 const agx::Line& topEdge,
131 const agx::Vec3& forwardVector,
132 const agx::Vec3& flatForwardVector);
133
134 agx::Vec3 projectVectorToTerrainPlane(const agx::Vec3& vec, const agx::Vec3& upVector) const;
135
136 protected:
137 // Parent frame following shovel body model frame.
140
141 // Soil wedge meshes
143
145
147
149
150 private:
151 void initializeGeometry();
152
153 SoilWedge createSoilWedge(const Terrain* terrain,
154 const agx::UInt wedgeCount,
155 const agx::Line& cuttingEdge,
156 const agx::Line& topEdge,
157 const agx::Vec3& forwardVector,
158 const agx::Vec3& flatForwardVector);
159
160 bool calculateFailurePlaneIntersection(const Terrain* terrain,
161 SoilWedge& soilWedge,
162 const agx::Line& cuttingEdge,
163 const agx::Line& topEdge,
164 const agx::Vec3& forwardVector,
165 const agx::Vec3& flatForwardVector);
166
167 void createSoilWedgeConvex(const SoilWedge& soilWedge);
168
169 void createSoilWedgePlanes(SoilWedge& soilWedge);
170
171 bool isSoilWedgeSubmerged( const Terrain* terrain, const SoilWedge& soilWedge );
172
173 bool doTerrainToolIntersectionTest(const Terrain* terrain,
174 const agx::AffineMatrix4x4& worldToHeightField,
175 const SoilWedge& soilWedge,
176 const agx::Vec3& upVector,
177 const agx::Vec3& flatForwardVector,
178 const agx::Vec3& forwardVector,
179 agx::Real forwardAngle,
180 agx::Real maxWedgeLength,
181 agx::Vec3& intersectionPoint) const;
182
183 bool handleMissedIntersection( const Terrain* terrain,
184 const agx::Vec3& upVector,
185 const agx::Vec3& flatForwardVector,
186 const agx::Line& flatForwardLine,
187 agx::Vec3iVector::iterator& voxelIterator,
188 const agx::Vec3iVector& voxels,
189 agx::Vec3& intersectionPoint ) const;
190
191 bool isIntersectionAboveTerrainMesh( const Terrain* terrain,
192 const SoilWedge& soilWedge,
193 const agx::AffineMatrix4x4& worldToHeightField,
194 const agx::Vec3& upVector ) const;
195
196 void updateSoilWedgeInclinations(const Terrain* terrain,
197 SoilWedge& soilWedge,
198 const agx::Vec2i terrainIndex,
199 const agx::Vec3i voxelIndex,
200 const agx::Real cuttingEdgeHeight,
201 const agx::Vec3& upVector,
202 const agx::Vec3& forwardVector,
203 const agx::Vec3& flatForwardVector,
204 const agx::Line& cuttingEdge) const;
205
206 private:
207 // Active zone geometry and inner-shape
208 agxCollide::GeometryRef m_geometry;
209
210 bool m_convexCreationFailed;
211 };
212}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition agx/Vector.h:34
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
bool soilWedgeCreationFailed() const
agx::Line getWedgeCuttingEdge() const
agx::Real getToolInclination() const
agx::Real getTotalSoilWedgeVolume(const agx::Vec3 &upVector) const
const agx::Vector< agxCollide::ConvexRef > & getWedgeShapes() const
agxCollide::Geometry * getGeometry()
agx::Bound3i getVoxelOverlapBound() const
agx::Real getTerrainInclination() const
agx::Plane getSplittingPlane() const
virtual void onPost(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)=0
agx::Real getFailureAngleToTerrainPlane(const agx::Vec3 &upVector) const
void onEnableChange(bool enable)
bool isAnySoilWedgeEnabled() const
WedgePlaneVector getSoilWedgePlanes() const
agx::Vector< SoilWedge > m_soilWedges
Definition ActiveZone.h:144
virtual void onPreCollide(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)=0
agx::Line getWedgeFailureEdge() const
agx::String getActiveZoneTypeName() const
const agxCollide::Geometry * getGeometry() const
agx::Vec3 projectVectorToTerrainPlane(const agx::Vec3 &vec, const agx::Vec3 &upVector) const
agx::Bound3i m_voxelOverlapBound
Definition ActiveZone.h:139
agx::Bool overlapsVoxel(const agx::Vec3i &index) const
agx::Frame * m_parentFrame
Definition ActiveZone.h:138
virtual void onPre(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)=0
agx::Plane m_splittingPlane
Definition ActiveZone.h:148
void createSoilWedges(const Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector, const agx::Vec3 &flatForwardVector)
virtual ActiveZone::Type getType() const =0
agx::Real getFailureAngle() const
agx::Vector< agxCollide::ConvexRef > m_soilWedgeMeshses
Definition ActiveZone.h:146
agx::Vec3iVector getFailurePlaneVoxels(const Terrain *terrain) const
ActiveZone(agx::Frame *parentFrame)
bool isSoilWedgeEnabled(agx::UInt index) const
agx::Line getWedgeTopEdge() const
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition Terrain.h:86
A BoundT represents a range defined by a minimum and a maximum value.
Definition Bound.h:37
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:120
Vector containing 'raw' data.
Definition agx/Vector.h:246
Templated vector class.
Definition agx/Vector.h:53
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition Geometry.h:59
std::pair< agxCollide::MeshRef, agx::AffineMatrix4x4 > MeshTransformPair
Definition ActiveZone.h:44
agx::Vector< MeshTransformPair > MeshTransformPairVector
Definition ActiveZone.h:45
bool Bool
Definition Integer.h:40
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42