|
AGX Dynamics
2.35.0.1
|
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 () |
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.
| 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.
| 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.
| agxTerrain::TerrainCache::TerrainCache | ( | ) |
Constructor.
|
virtual |
Destructor.
| void agxTerrain::TerrainCache::applyChangesToTemplateTerrain | ( | agxTerrain::Terrain * | t | ) |
| void agxTerrain::TerrainCache::clearCache | ( | ) |
Removes all internal state.
All height values will have to be queried again from the data source.
| agx::HashTable< agxTerrain::TileId, agx::Vec2iVector > * agxTerrain::TerrainCache::getCompressedIndices | ( | ) |
Definition at line 368 of file TerrainCache.h.
| bool agxTerrain::TerrainCache::getEmbedCacheFilesInArhive | ( | ) | const |
Returns if cached files should be embedded in AGX Archives used for serialization.
Definition at line 400 of file TerrainCache.h.
Referenced by agxTerrain::TerrainPager::getEmbedCacheFilesInArhive().
| agx::String agxTerrain::TerrainCache::getFileCacheDirectory | ( | ) | const |
Definition at line 389 of file TerrainCache.h.
| 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.
| bool agxTerrain::TerrainCache::getShouldStoreCompaction | ( | ) | const |
Returns whether the terrain pager should store compaction data for tiles that are paged out.
Definition at line 358 of file TerrainCache.h.
| agxTerrain::TerrainRef agxTerrain::TerrainCache::getTemplateTerrain | ( | ) |
Returns the template terrain used for properties of new terrain tiles.
Definition at line 378 of file TerrainCache.h.
Referenced by agxTerrain::TerrainPager::getDeformable().
| TerrainDataSource * agxTerrain::TerrainCache::getTerrainDataSource | ( | ) | const |
Returns the data source used for height data.
Definition at line 373 of file TerrainCache.h.
| TileStatus agxTerrain::TerrainCache::getTileStatus | ( | TileId | id | ) | const |
| void agxTerrain::TerrainCache::handleStagedTerrain | ( | ) |
Checks if there is staged terrain which can be moved to the pool for future usage.
| bool agxTerrain::TerrainCache::haveReadyTile | ( | ) |
Checks if one or more tiles are ready.
| 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.
|
protected |
| 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.
|
protected |
| 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 395 of file TerrainCache.h.
Referenced by agxTerrain::TerrainPager::setEmbedCacheFilesInArchive().
| bool agxTerrain::TerrainCache::setFileCacheDirectory | ( | agx::String | dir | ) |
Specifies where paged out height data for terrain should be stored.
| void agxTerrain::TerrainCache::setMaximumCompactionDepth | ( | size_t | maximumCompactionDepth | ) |
Definition at line 363 of file TerrainCache.h.
| 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.
| void agxTerrain::TerrainCache::setShouldStoreCompaction | ( | bool | shouldStoreCompaction | ) |
Sets if the terrain pager should store compaction data for tiles that are paged out.
Definition at line 353 of file TerrainCache.h.
| void agxTerrain::TerrainCache::setTemplateTerrain | ( | agxTerrain::TerrainRef | templateTerrain | ) |
Sets the template terrain used for properties of new terrain tiles.
Definition at line 383 of file TerrainCache.h.
| void agxTerrain::TerrainCache::setTerrainDataSource | ( | TerrainDataSource * | tds | ) |
Sets the data source for height data.
This operation will block until ongoing load requests have completed.
| 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.
| void agxTerrain::TerrainCache::waitForTile | ( | ) |
Waits until one tile is ready.