AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxTerrain::TerrainWheelDeformer Class Reference

Class responsible for terrain deformation by the TerrainWheel. More...

#include <TerrainWheelDeformer.h>

+ Inheritance diagram for agxTerrain::TerrainWheelDeformer:

Classes

struct  NodeData
 

Public Member Functions

 TerrainWheelDeformer (TerrainWheel *wheel)
 
bool getContactPatch (agx::Vec3iVector &voxels, agx::RealVector &occupancyOverlap)
 Get the current contact patch.
 
WheelDeformationProperties * getWheelDeformationProperties ()
 
void setWheelDeformationProperties (WheelDeformationProperties *properties)
 Set the WheelDeformationProperties of the TerrainWheelDeformer object.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Public Attributes

 AGXTERRAIN_TERRAINWHEEL_STORE_RESTORE_INTERFACE
 

Protected Types

using NodeVector = agx::Vector< NodeData >
 

Protected Member Functions

 TerrainWheelDeformer ()
 
void calculateOccupancyOverlap (Terrain *terrain, NodeVector &nodes)
 Calculates the occupancy overlap between wheel and terrain in each terrain node.
 
bool canDeform ()
 
bool deformTerrain (Terrain *terrain)
 
void displaceMass (Terrain *terrain, NodeVector &nodes, agx::HashSet< agx::Vec2u > &depositedIndices, bool renderVoxels=false)
 Displace mass from the given nodes.
 
agx::Real getSlipRatio () const
 
void removeMass (Terrain *terrain, NodeVector &nodes, agx::HashSet< agx::Vec2u > &indicesRemovedFrom)
 
void updateContactPatch (const agx::Vec3iVector &voxels)
 Update contact patch from the given surface voxels.
 
void updateHeightField (agx::HashSet< agx::Vec2u > &changedHfIndices)
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Class responsible for terrain deformation by the TerrainWheel.

The algorithm calculates mass removal based on the geometric wheel-terrain overlap. This is stored in an internal NodeVector struct, containing the surface vertex indices and the amount of removed occupancy.

The displacement algorithm is divided into bulldozing (forward and lateral directions) and slip-based displacement (to the rear). A bulldozing factor is used to divide the removed mass into the different displacement modes. Another weight is used to determine how much goes to the forward vs lateral bulldozing directions.

The spatial reach for the displacement is determined by different scale modifiers, which are applied as follows:

  • Forward bulldozing voxels are included in the forward direction within a distance of radius * forward modifier
  • lateral bulldozing voxels are included in the lateral direction within a distance of width * lateral modifier
  • Rear slip-based displacement voxels are included in the forward direction within a distance of radius * rear modifier

Weight, factors, and scale modifers are inside the WheelDeformationProperties in addition to booleans to enable/disable various parts of the deformation logic.

Definition at line 42 of file TerrainWheelDeformer.h.

Member Typedef Documentation

◆ NodeVector

Constructor & Destructor Documentation

◆ TerrainWheelDeformer() [1/2]

agxTerrain::TerrainWheelDeformer::TerrainWheelDeformer ( TerrainWheel *  wheel)

◆ TerrainWheelDeformer() [2/2]

agxTerrain::TerrainWheelDeformer::TerrainWheelDeformer ( )
protected

Member Function Documentation

◆ calculateOccupancyOverlap()

void agxTerrain::TerrainWheelDeformer::calculateOccupancyOverlap ( Terrain *  terrain,
NodeVector &  nodes 
)
protected

Calculates the occupancy overlap between wheel and terrain in each terrain node.

This makes sure we are not removing to much of the soil beneath the wheel.

◆ canDeform()

bool agxTerrain::TerrainWheelDeformer::canDeform ( )
protected

◆ deformTerrain()

bool agxTerrain::TerrainWheelDeformer::deformTerrain ( Terrain *  terrain)
protected

◆ displaceMass()

void agxTerrain::TerrainWheelDeformer::displaceMass ( Terrain *  terrain,
NodeVector &  nodes,
agx::HashSet< agx::Vec2u > &  depositedIndices,
bool  renderVoxels = false 
)
protected

Displace mass from the given nodes.

Mass will only be removed if there was any mass removed in the previous step. The displacement algorithm here is rather faulty but should suffice for driving scenarios; this is mostly due to how the voxels we displace to are chosen. This will be improved with a velocity field implementation later.

Parameters
terrain- active terrain
nodes- contact nodes, cotaining how much mass should be removed.
depositedIndices- hf changes are stored here and later used to update the hf.
renderVoxels- render voxels affected during displacement: Contact voxels (Blue) Contact voxels that mass was removed from (Red) Forward bulldozing displacement (Purple) Lateral bulldozing displacement (Pink) Backwards slip displacement (Green)

◆ getContactPatch()

bool agxTerrain::TerrainWheelDeformer::getContactPatch ( agx::Vec3iVector &  voxels,
agx::RealVector &  occupancyOverlap 
)

Get the current contact patch.

Each surface voxel voxels[i] correspond to the occupancyOverlap[i]. If a voxel (i,j,k) has an occupancyOverlap > 1.0, this means that the voxel directly below it, (i, j, k-1), is implicitly included in the contact patch.

Parameters
voxels- the surface voxels in the contact patch.
occupancyOverlap- the occupancy overlap in each surface voxel column.

◆ getSlipRatio()

agx::Real agxTerrain::TerrainWheelDeformer::getSlipRatio ( ) const
protected

◆ getWheelDeformationProperties()

WheelDeformationProperties * agxTerrain::TerrainWheelDeformer::getWheelDeformationProperties ( )
Returns
the properties object for the terrain.

◆ removeMass()

void agxTerrain::TerrainWheelDeformer::removeMass ( Terrain *  terrain,
NodeVector &  nodes,
agx::HashSet< agx::Vec2u > &  indicesRemovedFrom 
)
protected

◆ setWheelDeformationProperties()

void agxTerrain::TerrainWheelDeformer::setWheelDeformationProperties ( WheelDeformationProperties *  properties)

◆ updateContactPatch()

void agxTerrain::TerrainWheelDeformer::updateContactPatch ( const agx::Vec3iVector &  voxels)
protected

Update contact patch from the given surface voxels.

Parameters
voxels- surface voxels of the contact patch.
Note
No checks are performed on this.

◆ updateHeightField()

void agxTerrain::TerrainWheelDeformer::updateHeightField ( agx::HashSet< agx::Vec2u > &  changedHfIndices)
protected

Member Data Documentation

◆ AGXTERRAIN_TERRAINWHEEL_STORE_RESTORE_INTERFACE

agxTerrain::TerrainWheelDeformer::AGXTERRAIN_TERRAINWHEEL_STORE_RESTORE_INTERFACE

Definition at line 70 of file TerrainWheelDeformer.h.


The documentation for this class was generated from the following file: