AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
agxTerrain::TerrainRasterizer Class Reference

This class performs raycasting against the source geometry to get height data for tiles. More...

#include <TerrainDataSource.h>

+ Inheritance diagram for agxTerrain::TerrainRasterizer:

Public Member Functions

 TerrainRasterizer (agx::Real sampleRayLength=1000.0)
 Constructor.
 
bool addSourceGeometry (agxCollide::Geometry *geom)
 The rasterizer can have one or more source geometries which are used when creating the terrain tiles.
 
 AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agxTerrain::TerrainRasterizer)
 
virtual TerrainHeightType fetchTerrainTile (const TileSpecification &ts, agxTerrain::TileId id) override
 Return height data for requested tile according to the TileSpecification.
 
agx::Real getRayLength () const
 
virtual bool raycast (agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult) override
 Overload of TerrainDataSource::raycast for testing against source geometry.
 
bool removeSourceGeometry (agxCollide::Geometry *geom)
 Removes a geometry from the TerrainRasterizer.
 
void setRayLength (agx::Real length)
 Set the length of the ray.
 
- Public Member Functions inherited from agxTerrain::TerrainDataSource
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.
 
virtual TerrainHeightType fetchTerrainTile (const TileSpecification &ts, agxTerrain::TileId id)=0
 Return height data for requested tile according to the TileSpecification.
 
virtual void onReset ()
 Let the external dataSource know we're doing a reset of the terrain so it can reset as well.
 
virtual bool raycast (agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult)
 Perform raycasting against the terrain.
 
bool removeMaterialSourceGeometry (agxCollide::Geometry *geom)
 Removes a geometry from the TerrainRasterizer.
 
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.
 
 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.
 
Referencedoperator= (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 Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
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.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Static Public Member Functions

static agxStream::Serializablecreate (agxStream::InputArchive &)
 
- 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.
 

Protected Member Functions

 ~TerrainRasterizer ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Additional Inherited Members

- Public Types inherited from agxTerrain::TerrainDataSource
typedef agx::RealVector TerrainHeightType
 Datatype used for returning height values.
 
typedef agx::Vector< std::pair< agxCollide::Geometry *, agx::UInt32 > > TerrainMaterialsType
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
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 agxTerrain::TerrainDataSource
agx::ReaderWriterLock m_rwLock
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

This class performs raycasting against the source geometry to get height data for tiles.

The reference position for the grid tiles defined by the TileSpecification is used to determine where to sample the source geometry. This defines the local X- and Y-coordinates. The local height values are not known and depends on the source geometry.

Therefor a sampleRayLength should be defined so that a ray from 0.5 * sampleRayLength to -0.5 * sampleRayLength hits the source geometry.

Changing the ray length will only affect future tiles that will be sampled, not any previous requested tiles that are cached.

The TerrainRasterizer will only return height data for a terrain tile when it was able to sample the entire tile. If parts of the tile or the entire tile is lacking source geometry, no data will be returned and the TerrainPager will not be able to page in a terrain instace for that region.

Definition at line 156 of file TerrainDataSource.h.

Constructor & Destructor Documentation

◆ TerrainRasterizer()

agxTerrain::TerrainRasterizer::TerrainRasterizer ( agx::Real  sampleRayLength = 1000.0)

Constructor.

◆ ~TerrainRasterizer()

agxTerrain::TerrainRasterizer::~TerrainRasterizer ( )
protected

Member Function Documentation

◆ addSourceGeometry()

bool agxTerrain::TerrainRasterizer::addSourceGeometry ( agxCollide::Geometry geom)

The rasterizer can have one or more source geometries which are used when creating the terrain tiles.

These geometries are not required to be part of a agxSDK::Simulation or agxCollide::Space. They will be used directly by the rasterizer.

It is required that they are positioned correctly in the world and it should not be repositioned after it has been given to the rasterizer.

◆ AGXSTREAM_DECLARE_SERIALIZABLE_BASE()

agxTerrain::TerrainRasterizer::AGXSTREAM_DECLARE_SERIALIZABLE_BASE ( agxTerrain::TerrainRasterizer  )

◆ create()

static agxStream::Serializable * agxTerrain::TerrainRasterizer::create ( agxStream::InputArchive )
inlinestatic

Definition at line 217 of file TerrainDataSource.h.

◆ fetchTerrainTile()

virtual TerrainHeightType agxTerrain::TerrainRasterizer::fetchTerrainTile ( const TileSpecification ts,
agxTerrain::TileId  id 
)
overridevirtual

Return height data for requested tile according to the TileSpecification.

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

Implements agxTerrain::TerrainDataSource.

◆ getRayLength()

agx::Real agxTerrain::TerrainRasterizer::getRayLength ( ) const
Returns
Length of ray used for ray casting to get height data

Definition at line 285 of file TerrainDataSource.h.

◆ raycast()

virtual bool agxTerrain::TerrainRasterizer::raycast ( agx::Vec3  start,
agx::Vec3  end,
agx::Vec3 raycastResult 
)
overridevirtual

Overload of TerrainDataSource::raycast for testing against source geometry.

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 from agxTerrain::TerrainDataSource.

◆ removeSourceGeometry()

bool agxTerrain::TerrainRasterizer::removeSourceGeometry ( 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.

◆ setRayLength()

void agxTerrain::TerrainRasterizer::setRayLength ( agx::Real  length)

Set the length of the ray.

Definition at line 290 of file TerrainDataSource.h.


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