![]() |
AGX Dynamics 2.40.0.0
|
This class performs raycasting against the source geometry to get height data for tiles. More...
#include <TerrainDataSource.h>
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. | |
![]() | |
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 |
![]() | |
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. | |
![]() | |
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::Serializable * | create (agxStream::InputArchive &) |
![]() | |
template<typename T > | |
static bool | ValidateCast (const Referenced *object) |
![]() | |
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 () | |
![]() | |
virtual | ~Referenced () |
Destructor. | |
void | allocateObserverVector () const |
void | deleteUsingDeleteHandler () const |
![]() | |
Serializable () | |
Default constructor. | |
Serializable (const Serializable &other) | |
Copy constructor. | |
void | generateUuid () |
Additional Inherited Members | |
![]() | |
typedef agx::RealVector | TerrainHeightType |
Datatype used for returning height values. | |
typedef agx::Vector< std::pair< agxCollide::Geometry *, agx::UInt32 > > | TerrainMaterialsType |
![]() | |
static DeleteHandler * | getDeleteHandler () |
static void | setDeleteHandler (DeleteHandler *handler) |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
![]() | |
agx::ReaderWriterLock | m_rwLock |
![]() | |
Mutex | m_mutex |
ObserverContainer | m_observers |
AtomicValue | m_refCount |
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.
agxTerrain::TerrainRasterizer::TerrainRasterizer | ( | agx::Real | sampleRayLength = 1000.0 | ) |
Constructor.
|
protected |
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.
agxTerrain::TerrainRasterizer::AGXSTREAM_DECLARE_SERIALIZABLE_BASE | ( | agxTerrain::TerrainRasterizer | ) |
|
inlinestatic |
Definition at line 217 of file TerrainDataSource.h.
|
overridevirtual |
Return height data for requested tile according to the TileSpecification.
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 |
Implements agxTerrain::TerrainDataSource.
agx::Real agxTerrain::TerrainRasterizer::getRayLength | ( | ) | const |
Definition at line 285 of file TerrainDataSource.h.
|
overridevirtual |
Overload of TerrainDataSource::raycast for testing against source geometry.
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, |
Reimplemented from agxTerrain::TerrainDataSource.
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.
void agxTerrain::TerrainRasterizer::setRayLength | ( | agx::Real | length | ) |
Set the length of the ray.
Definition at line 290 of file TerrainDataSource.h.