AGX Dynamics 2.42.3.0
Loading...
Searching...
No Matches
ActiveZone.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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
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 ShovelDebugRenderSettings;
43
45
48
50 {
51 public:
52
53 enum class Type
54 {
55 PRIMARY_ACTIVE_ZONE,
56 DEFORMER_ACTIVE_ZONE
57 };
58
59 ActiveZone(agx::Frame* parentFrame);
60
61 virtual void onPreCollide(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector) = 0;
62
63 virtual void onPre(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector) = 0;
64
65 virtual void onPost(Terrain* terrain, const agx::Line& cuttingEdge, const agx::Line& topEdge, const agx::Vec3& forwardVector) = 0;
66
67 virtual ActiveZone::Type getType() const = 0;
68
70
72
74
75 agx::Bool overlapsVoxel(const agx::Vec3i& index) const;
76
78
80
82
84
86
87 bool isSoilWedgeEnabled(agx::UInt index) const;
88
90
95
97
99
101
103
105
107
113 void onEnableChange( bool enable );
114
116
118
120
121 protected:
122
123 virtual ~ActiveZone();
124
125 void createSoilWedges( const Terrain* terrain,
126 const agx::Line& cuttingEdge,
127 const agx::Line& topEdge,
128 const agx::Vec3& forwardVector,
129 const agx::Vec3& flatForwardVector,
130 const ShovelDebugRenderSettings* dbgSettings );
131
132 agx::Vec3 projectVectorToTerrainPlane(const agx::Vec3& vec, const agx::Vec3& upVector) const;
133
134 protected:
135 // Parent frame following shovel body model frame.
138
139 // Soil wedge meshes
141
143
145
147
148 private:
149 void initializeGeometry();
150
151 SoilWedge createSoilWedge( const Terrain* terrain,
152 const agx::UInt wedgeCount,
153 const agx::Line& cuttingEdge,
154 const agx::Line& topEdge,
155 const agx::Vec3& forwardVector,
156 const agx::Vec3& flatForwardVector,
157 const ShovelDebugRenderSettings* dbgSettings );
158
159 bool calculateFailurePlaneIntersection( const Terrain* terrain,
160 SoilWedge& soilWedge,
161 const agx::Line& cuttingEdge,
162 const agx::Line& topEdge,
163 const agx::Vec3& forwardVector,
164 const agx::Vec3& flatForwardVector,
165 const ShovelDebugRenderSettings* dbgSettings );
166
167 void createSoilWedgeConvex(const SoilWedge& soilWedge,
168 const ShovelDebugRenderSettings* dbgSettings );
169
170 void createSoilWedgePlanes(SoilWedge& soilWedge);
171
172 bool isSoilWedgeSubmerged( const Terrain* terrain, const SoilWedge& soilWedge );
173
174 bool doTerrainToolIntersectionTest(const Terrain* terrain,
175 const agx::AffineMatrix4x4& worldToHeightField,
176 const SoilWedge& soilWedge,
177 const agx::Vec3& upVector,
178 const agx::Vec3& flatForwardVector,
179 const agx::Vec3& forwardVector,
180 agx::Real forwardAngle,
181 agx::Real maxWedgeLength,
182 agx::Vec3& intersectionPoint) const;
183
184 bool handleMissedIntersection( const Terrain* terrain,
185 const agx::Vec3& upVector,
186 const agx::Vec3& flatForwardVector,
187 const agx::Line& flatForwardLine,
188 agx::Vec3iVector::iterator& voxelIterator,
189 const agx::Vec3iVector& voxels,
190 agx::Vec3& intersectionPoint ) const;
191
192 bool isIntersectionAboveTerrainMesh( const Terrain* terrain,
193 const SoilWedge& soilWedge,
194 const agx::AffineMatrix4x4& worldToHeightField,
195 const agx::Vec3& upVector ) const;
196
197 void updateSoilWedgeInclinations(const Terrain* terrain,
198 SoilWedge& soilWedge,
199 const agx::Vec2i terrainIndex,
200 const agx::Vec3i voxelIndex,
201 const agx::Real cuttingEdgeHeight,
202 const agx::Vec3& upVector,
203 const agx::Vec3& forwardVector,
204 const agx::Vec3& flatForwardVector,
205 const agx::Line& cuttingEdge) const;
206
207 private:
208 // Active zone geometry and inner-shape
209 agxCollide::GeometryRef m_geometry;
210
211 bool m_convexCreationFailed;
212 };
213}
#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
agx::UInt m_soilWedgesSize
Definition: ActiveZone.h:140
WedgePlaneVector getSoilWedgePlanes() const
agx::Vector< SoilWedge > m_soilWedges
Definition: ActiveZone.h:142
virtual void onPreCollide(Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector)=0
void createSoilWedges(const Terrain *terrain, const agx::Line &cuttingEdge, const agx::Line &topEdge, const agx::Vec3 &forwardVector, const agx::Vec3 &flatForwardVector, const ShovelDebugRenderSettings *dbgSettings)
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:137
agx::Bool overlapsVoxel(const agx::Vec3i &index) const
agx::Frame * m_parentFrame
Definition: ActiveZone.h:136
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:146
virtual ActiveZone::Type getType() const =0
agx::Real getFailureAngle() const
agx::Vector< agxCollide::ConvexRef > m_soilWedgeMeshses
Definition: ActiveZone.h:144
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:92
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
bool Bool
Definition: Integer.h:40
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41