AGX Dynamics  2.37.3.2
agxTerrain::TerrainDataSource Class Referenceabstract

Abstract interface for requesting height data for a Terrain tile. More...

#include <TerrainDataSource.h>

+ Inheritance diagram for agxTerrain::TerrainDataSource:

Public Types

typedef agx::RealVector TerrainHeightType
 Datatype used for returning height values. More...
 
typedef agx::Vector< std::pair< agxCollide::Geometry *, agx::UInt32 > > TerrainMaterialsType
 

Public Member Functions

bool addTerrainMaterialSourceGeometry (agxCollide::Geometry *geom, agx::UInt32 terrainMaterialIndex)
 
 AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE (agxTerrain::TerrainDataSource)
 
virtual TerrainMaterialsType fetchTerrainMaterials (const TileSpecification &ts, agxTerrain::TileId id, agx::Real maxHeight)
 Return assigned terrain material geometries in the requested tile. More...
 
virtual TerrainHeightType fetchTerrainTile (const TileSpecification &ts, agxTerrain::TileId id)=0
 Return height data for requested tile according to the TileSpecification. More...
 
virtual bool raycast (agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult)
 Perform raycasting against the terrain. More...
 
bool removeMaterialSourceGeometry (agxCollide::Geometry *geom)
 Removes a geometry from the TerrainRasterizer. More...
 
virtual void restore (agxStream::InputArchive &in) override
 
virtual void store (agxStream::OutputArchive &out) const override
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor. More...
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings. More...
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 

Protected Attributes

agx::ReaderWriterLock m_rwLock
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor. More...
 
 Serializable (const Serializable &other)
 Copy constructor. More...
 
void generateUuid ()
 
- 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. More...
 

Detailed Description

Abstract interface for requesting height data for a Terrain tile.

Definition at line 39 of file TerrainDataSource.h.

Member Typedef Documentation

◆ TerrainHeightType

Datatype used for returning height values.

Definition at line 50 of file TerrainDataSource.h.

◆ TerrainMaterialsType

Member Function Documentation

◆ addTerrainMaterialSourceGeometry()

bool agxTerrain::TerrainDataSource::addTerrainMaterialSourceGeometry ( agxCollide::Geometry *  geom,
agx::UInt32  terrainMaterialIndex 
)

◆ AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE()

agxTerrain::TerrainDataSource::AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE ( agxTerrain::TerrainDataSource  )

◆ fetchTerrainMaterials()

virtual TerrainMaterialsType agxTerrain::TerrainDataSource::fetchTerrainMaterials ( const TileSpecification &  ts,
agxTerrain::TileId  id,
agx::Real  maxHeight 
)
virtual

Return assigned terrain material geometries in the requested tile.

Parameters
ts- The specification of how new tiles are created by the data source
id- The id or position of the tile relative to other paged terrain tiles
maxHeight- The maximum sampling height of the tile. Geometries containing terrain materials beneath this value will not be added to the simulation.

◆ fetchTerrainTile()

virtual TerrainHeightType agxTerrain::TerrainDataSource::fetchTerrainTile ( const TileSpecification &  ts,
agxTerrain::TileId  id 
)
pure virtual

Return height data for requested tile according to the TileSpecification.

The returned vector should have ts.getTileResolution squared number of height values. If the TerrainDataSource is not able to provide data, an empty vector can be returned.

Upon no data returned, the TerrainCache will reply to the TerrainPager with the requested TileId id but having no terrain instance signaling that the request was processed but could not be fullfilled. In this scenario, there will be an empty tile where it should have been a terrain instance and the same tile will be requested again on the next stepForward.

Parameters
ts- The specification of how new tiles are created by the data source
id- The id or position of the tile relative to other paged terrain tiles
Returns
A vector containing the height data for the new tile

Implemented in agxTerrain::ExternalTerrainDataSource, and agxTerrain::TerrainRasterizer.

◆ raycast()

virtual bool agxTerrain::TerrainDataSource::raycast ( agx::Vec3  start,
agx::Vec3  end,
agx::Vec3 &  raycastResult 
)
virtual

Perform raycasting against the terrain.

This can be called by the TerrainPager when TerrainPager::raycast is used and no active tile is hit.

Default implementation returns false. Classes inheriting from TerrainDataSource can overload this method and add support if possible.

Parameters
start- The start position of the raycast
end- The end position of the raycast
raycastResult- A reference to a Vec3 in which to store the point where the raycast hits the data source,
Returns
true if terrain is hit and raycastResult is then updated with position for the hit.

Reimplemented in agxTerrain::ExternalTerrainDataSource, and agxTerrain::TerrainRasterizer.

◆ removeMaterialSourceGeometry()

bool agxTerrain::TerrainDataSource::removeMaterialSourceGeometry ( agxCollide::Geometry *  geom)

Removes a geometry from the TerrainRasterizer.

Areas that has been sampled which hit the geometry being removed will not be resampled and cached heights will still be used.

◆ restore()

virtual void agxTerrain::TerrainDataSource::restore ( agxStream::InputArchive &  in)
overridevirtual

◆ store()

virtual void agxTerrain::TerrainDataSource::store ( agxStream::OutputArchive &  out) const
overridevirtual

Member Data Documentation

◆ m_rwLock

agx::ReaderWriterLock agxTerrain::TerrainDataSource::m_rwLock
protected

Definition at line 123 of file TerrainDataSource.h.


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