AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
AggregateContactGenerator.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#include <agx/Plane.h>
25
26
27
28namespace agxTerrain
29{
30 class Shovel;
31 class ActiveZone;
32 class Terrain;
33
36
38
40 {
41 public:
43
44 void onPre( Shovel* shovel,
45 Terrain* terrain );
46
47 void onPost( Shovel* shovel );
48
53
57 void initializeContactMaterials( Terrain* terrain, Shovel* shovel );
58
63
68
73
79 bool particleIsInShovelContacts( agx::UInt32 particleId ) const;
80
85
90
97
103
105
106
109 void createContactPartitions( Shovel* shovel );
110
111 void setEnableCustomFrictionModels( bool enable );
112 bool getEnableCustomFrictionModels() const;
113
114 agx::UInt getNumContactPatches() const { return m_partitionData.getNumPatches(); };
115
117
118 protected:
120
121 private:
122
123 void createGeometryContacts( SoilParticleAggregate* soilParticleAggregate,
124 PrimaryActiveZone* activeZone,
125 Shovel* shovel,
126 Terrain* terrain );
127
128 void createTerrainContacts( SoilParticleAggregate* soilParticleAggregate,
129 PrimaryActiveZone* activeZone,
130 Shovel* shovel,
131 Terrain* terrain,
132 agxCollide::LocalGeometryContactVector& localContacts );
133
134 void createShovelContacts( SoilParticleAggregate* soilParticleAggregate,
135 Shovel* shovel,
136 Terrain* terrain,
137 agxCollide::LocalGeometryContactVector& localContacts );
138
139 std::tuple<agx::Real, agx::Int> getContactPointAngle( const agx::Vec3& midPoint,
140 const agx::Vec3& zeroPoint,
141 const agx::Vec3& contactPoint,
142 const agx::Plane& polarPlane,
143 const agx::Plane& cutTopPlane ) const;
144
145 GeometryHashSet getShovelGeometries( Shovel* shovel ) const;
146
147 void getShovelContactsAndContactRange( Shovel* shovel,
148 const agx::Vector<agx::Plane>& shovelPlanes,
149 GeometryHashSet& geometrySet,
150 agxCollide::ParticleGeometryContactVector& contacts,
151 agxCollide::ParticleGeometryContactVector& rightWallContacts,
152 agxCollide::ParticleGeometryContactVector& leftWallContacts,
153 agx::RangeReal& range );
154
155 agxCollide::LocalParticleGeometryContactVector calculateShovelContactPoints( Shovel* shovel,
156 const agxCollide::ParticleGeometryContactVector& shovelContacts,
157 const agx::RangeReal& range,
158 agx::Real& meanParticleArea ) const;
159
160 void calculateShovelSideWallContactPoints( Shovel* shovel,
161 const agx::Vector<agx::Plane>& shovelPlanes,
162 GeometryHashSet& shovelGeometryTable,
163 GeometryLocalContactTable& shovelContactTable,
164 agxCollide::ParticleGeometryContactVector& rightWallContacts,
165 agxCollide::ParticleGeometryContactVector& leftWallContacts );
166
167 void updateContactSpan( agxTerrain::Shovel* shovel,
168 ContactSpanData& contactSpanData,
169 const agx::Physics::ParticleGeometryContactPtr& contact,
170 const agx::Plane& middlePlane,
171 agx::Real contactAngle ) const;
172
173 agxCollide::LocalParticleGeometryContactVector constructShovelContacts( Shovel* shovel,
174 agx::Vector<ContactPatch>& contactPatchData,
175 ContactSpanData& contactSpanData,
176 const agx::Vec3f& separationNormal,
177 const agx::Vec3& cuttingVector ) const;
178
179 agx::Real calculateContactArea( const Shovel* shovel,
180 const Terrain* terrain,
181 const agxCollide::LocalParticleGeometryContactVector& contacts,
182 const agx::Real meanParticleArea ) const;
183
184 void debugRenderContactPatches( agxTerrain::Shovel* shovel ) const;
185
186 void updateContactPartitions( agxTerrain::Shovel* shovel );
187
188 private:
189 using ParticleIdSet = agx::HashSet<agx::UInt32>;
190
191 ParticleIdSet m_particleIds;
192 ParticleIdSet m_particlesInShovelContacts;
193 agxCollide::LocalGeometryContactVector m_localGeometryContacts;
194 agxCollide::LocalGeometryContactVector m_localShovelAggregateContacts;
195 agx::ContactMaterialRef m_aggregateTerrainContactMaterial;
196 agx::ContactMaterialRef m_aggregateShovelContactMaterial;
197 AggregateContactDepthModel m_depthModel;
198 ShovelAggregateFrictionModelRef m_frictionModel;
199 bool m_enableCustomFrictionModels;
200 ContactPartitionData m_partitionData;
201 ContactPatchVector m_patchData;
202
203 };
204}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXTERRAIN_EXPORT
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
Class used to calculate the contact depth in the soil aggregate <-> terrain contacts to mimic an elas...
void resetAggregateContactHistory()
Resets contact model history in the contact generator.
size_t getMaxPotentialNumberOfContactPoints() const
void initializeContactMaterials(Terrain *terrain, Shovel *shovel)
Initialize contact materials used in the aggregate contacts.
void onPre(Shovel *shovel, Terrain *terrain)
bool particleIsInShovelContacts(agx::UInt32 particleId) const
Checks if a particle with a given id is in contact with the shovel.
agx::ContactMaterial * getAggregateShovelContactMaterial() const
Get the internal shovel <-> aggregate contact material.
const AggregateContactDepthModel & getAggregateDepthModel() const
Get the aggregate <-> terrain contact depth model.
void initializeFrictionModels(Shovel *shovel)
Initialize custom friction models used in the aggregate contacts.
agxCollide::GeometryContactPtrVector getGeometryContacts(agxSDK::Simulation *simulation) const
agx::ContactMaterial * getAggregateTerrainContactMaterial() const
Get the internal aggregate <-> terrain contact material.
Shovel object used to interact with a terrain via an active zone that converts solid terrain to dynam...
Definition: Shovel.h:63
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:92
This class store the combine material properties between two agx::Material's.
Definition: Material.h:518
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:670
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
Base class providing referencing counted objects.
Definition: Referenced.h:120
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
agx::HashVector< agxCollide::Geometry *, agxCollide::LocalGeometryContact > GeometryLocalContactTable
agx::HashSet< agxCollide::Geometry * > GeometryHashSet
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:32
STL namespace.