AGX Dynamics  2.37.2.0
agxTerrain::TerrainCache Class Reference

The TerrainCache is used internally by the TerrainPager to provide requested terrain tiles. More...

#include <TerrainCache.h>

Public Types

enum  TilePriority { TP_HIGH, TP_LOW }
 
enum  TileStatus {
  TS_MISSING, TS_LOADED, TS_ACTIVE, TS_RETURNED,
  TS_IN_RAM, TS_ON_DISK
}
 

Public Member Functions

 TerrainCache ()
 Constructor. More...
 
virtual ~TerrainCache ()
 Destructor. More...
 
void applyChangesToTemplateTerrain (agxTerrain::Terrain *t)
 
void clearCache ()
 Removes all internal state. More...
 
agx::HashTable< agxTerrain::TileId, agx::Vec2iVector > * getCompressedIndices ()
 
bool getEmbedCacheFilesInArhive () const
 Returns if cached files should be embedded in AGX Archives used for serialization. More...
 
agx::String getFileCacheDirectory () const
 
agxTerrain::TerrainTile getReadyTile ()
 Without blocking, this method tries to return a ready processed terrain tile. More...
 
bool getShouldStoreCompaction () const
 Returns whether the terrain pager should store compaction data for tiles that are paged out. More...
 
agxTerrain::TerrainRef getTemplateTerrain ()
 Returns the template terrain used for properties of new terrain tiles. More...
 
TerrainDataSource * getTerrainDataSource () const
 Returns the data source used for height data. More...
 
TileStatus getTileStatus (TileId id) const
 
void handleStagedTerrain ()
 Checks if there is staged terrain which can be moved to the pool for future usage. More...
 
bool haveReadyTile ()
 Checks if one or more tiles are ready. More...
 
void loadTerrainTile (const TileSpecification &ts, TileId id, TilePriority prio)
 Load a terrain tile, either from cache (memory or disk) or request the tile from a data source. More...
 
void prepareTerrainInstances (const TileSpecification &ts, size_t poolSize)
 Create agxTerrain::Terrain instances so that there are poolSize number of Terrains in the pool for future use. More...
 
void setEmbedCacheFilesInArchive (bool embed)
 Sets if cached files written out to disk should be embeded in AGX Archives when store is called. More...
 
bool setFileCacheDirectory (agx::String dir)
 Specifies where paged out height data for terrain should be stored. More...
 
void setMaximumCompactionDepth (size_t maximumCompactionDepth)
 
void setRestoreData (const TileModificationVector &state)
 Specifies the restore data that is used to apply changes the first time they are needed after restore. More...
 
void setShouldStoreCompaction (bool shouldStoreCompaction)
 Sets if the terrain pager should store compaction data for tiles that are paged out. More...
 
void setTemplateTerrain (agxTerrain::TerrainRef templateTerrain)
 Sets the template terrain used for properties of new terrain tiles. More...
 
void setTerrainDataSource (TerrainDataSource *tds)
 Sets the data source for height data. More...
 
void unloadTerrainTile (TerrainTile tile)
 Schedule a tile for unloading. More...
 
void waitForTile ()
 Waits until one tile is ready. More...
 

Protected Member Functions

void pauseBackgroundThread ()
 
void resumeBackgroundThread ()
 

Detailed Description

The TerrainCache is used internally by the TerrainPager to provide requested terrain tiles.

The first time a tile is requested, the tile is fetched from a TerrainDataSource. On later reuse, the tile is handled via the paging system where it might reside in memory or on disk.

Definition at line 53 of file TerrainCache.h.

Member Enumeration Documentation

◆ TilePriority

Enumerator
TP_HIGH 
TP_LOW 

Will be placed first in queue for processing.

Will be places last in queue for processing

Definition at line 56 of file TerrainCache.h.

◆ TileStatus

Enumerator
TS_MISSING 
TS_LOADED 

Tile not seen before, must be loaded from data source.

TS_ACTIVE 

Tile is loaded and ready to be used by the TerrainPager.

TS_RETURNED 

Tile has been fetched by the TerrainPager.

TS_IN_RAM 

Tile has been returned to the Cache by the TerrainPager.

TS_ON_DISK 

Tile is paged out, heights held in memory.

Tile is paged out, heights stored in a file on disk

Definition at line 70 of file TerrainCache.h.

Constructor & Destructor Documentation

◆ TerrainCache()

agxTerrain::TerrainCache::TerrainCache ( )

Constructor.

◆ ~TerrainCache()

virtual agxTerrain::TerrainCache::~TerrainCache ( )
virtual

Destructor.

Member Function Documentation

◆ applyChangesToTemplateTerrain()

void agxTerrain::TerrainCache::applyChangesToTemplateTerrain ( agxTerrain::Terrain *  t)

◆ clearCache()

void agxTerrain::TerrainCache::clearCache ( )

Removes all internal state.

All height values will have to be queried again from the data source.

◆ getCompressedIndices()

agx::HashTable< agxTerrain::TileId, agx::Vec2iVector > * agxTerrain::TerrainCache::getCompressedIndices ( )

Definition at line 372 of file TerrainCache.h.

◆ getEmbedCacheFilesInArhive()

bool agxTerrain::TerrainCache::getEmbedCacheFilesInArhive ( ) const

Returns if cached files should be embedded in AGX Archives used for serialization.

Definition at line 404 of file TerrainCache.h.

◆ getFileCacheDirectory()

agx::String agxTerrain::TerrainCache::getFileCacheDirectory ( ) const
Returns
The directory where paged out data is stored

Definition at line 393 of file TerrainCache.h.

◆ getReadyTile()

agxTerrain::TerrainTile agxTerrain::TerrainCache::getReadyTile ( )

Without blocking, this method tries to return a ready processed terrain tile.

If no tile is available, the terrain member in the tile will be a null pointer.

◆ getShouldStoreCompaction()

bool agxTerrain::TerrainCache::getShouldStoreCompaction ( ) const

Returns whether the terrain pager should store compaction data for tiles that are paged out.

Definition at line 362 of file TerrainCache.h.

◆ getTemplateTerrain()

agxTerrain::TerrainRef agxTerrain::TerrainCache::getTemplateTerrain ( )

Returns the template terrain used for properties of new terrain tiles.

Definition at line 382 of file TerrainCache.h.

◆ getTerrainDataSource()

TerrainDataSource * agxTerrain::TerrainCache::getTerrainDataSource ( ) const

Returns the data source used for height data.

Definition at line 377 of file TerrainCache.h.

◆ getTileStatus()

TileStatus agxTerrain::TerrainCache::getTileStatus ( TileId  id) const

◆ handleStagedTerrain()

void agxTerrain::TerrainCache::handleStagedTerrain ( )

Checks if there is staged terrain which can be moved to the pool for future usage.

◆ haveReadyTile()

bool agxTerrain::TerrainCache::haveReadyTile ( )

Checks if one or more tiles are ready.

◆ loadTerrainTile()

void agxTerrain::TerrainCache::loadTerrainTile ( const TileSpecification &  ts,
TileId  id,
TilePriority  prio 
)

Load a terrain tile, either from cache (memory or disk) or request the tile from a data source.

The priority prio determines if the tile is loaded immediately or scheduled for being loaded in the background.

◆ pauseBackgroundThread()

void agxTerrain::TerrainCache::pauseBackgroundThread ( )
protected

◆ prepareTerrainInstances()

void agxTerrain::TerrainCache::prepareTerrainInstances ( const TileSpecification &  ts,
size_t  poolSize 
)

Create agxTerrain::Terrain instances so that there are poolSize number of Terrains in the pool for future use.

Creating the Terrains in advance should reduce the risk for interruptions during the simulation.

◆ resumeBackgroundThread()

void agxTerrain::TerrainCache::resumeBackgroundThread ( )
protected

◆ setEmbedCacheFilesInArchive()

void agxTerrain::TerrainCache::setEmbedCacheFilesInArchive ( bool  embed)

Sets if cached files written out to disk should be embeded in AGX Archives when store is called.

Default false.

Definition at line 399 of file TerrainCache.h.

◆ setFileCacheDirectory()

bool agxTerrain::TerrainCache::setFileCacheDirectory ( agx::String  dir)

Specifies where paged out height data for terrain should be stored.

◆ setMaximumCompactionDepth()

void agxTerrain::TerrainCache::setMaximumCompactionDepth ( size_t  maximumCompactionDepth)

Definition at line 367 of file TerrainCache.h.

◆ setRestoreData()

void agxTerrain::TerrainCache::setRestoreData ( const TileModificationVector &  state)

Specifies the restore data that is used to apply changes the first time they are needed after restore.

At first, the tile heights are requested from the TerrainDataSource, then the modifications are applied. Finally the terrain tile is placed in the ready queue and can be fetched with getReadyTile.

◆ setShouldStoreCompaction()

void agxTerrain::TerrainCache::setShouldStoreCompaction ( bool  shouldStoreCompaction)

Sets if the terrain pager should store compaction data for tiles that are paged out.

Definition at line 357 of file TerrainCache.h.

◆ setTemplateTerrain()

void agxTerrain::TerrainCache::setTemplateTerrain ( agxTerrain::TerrainRef  templateTerrain)

Sets the template terrain used for properties of new terrain tiles.

Definition at line 387 of file TerrainCache.h.

◆ setTerrainDataSource()

void agxTerrain::TerrainCache::setTerrainDataSource ( TerrainDataSource *  tds)

Sets the data source for height data.

This operation will block until ongoing load requests have completed.

◆ unloadTerrainTile()

void agxTerrain::TerrainCache::unloadTerrainTile ( TerrainTile  tile)

Schedule a tile for unloading.

Unloads data from a terrain tile and stores it. The agxTerrain::Terrain instance will be cleared and returned to the internal pool so it can be reused later when needed.

◆ waitForTile()

void agxTerrain::TerrainCache::waitForTile ( )

Waits until one tile is ready.


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