19#include <agx/config/AGX_USE_AGXTERRAIN.h>
127 void setShouldStoreCompaction(
bool shouldStoreCompaction);
132 bool getShouldStoreCompaction()
const;
134 void setMaximumCompactionDepth(
size_t maximumCompactionDepth);
143 void setEmbedCacheFilesInArchive(
bool embed );
149 bool getEmbedCacheFilesInArhive()
const;
231 void store(
agxStream::OutputArchive& out );
237 void pauseBackgroundThread();
239 void resumeBackgroundThread();
246 agx::HashTable <
TileId,
std::pair<
size_t,
size_t>> m_restoreDataTileIdTable;
254 size_t numberOfModifiedVoxels;
257 size_t numberOfInhomogeneousVoxels;
270 void backgroundOperations();
279 bool writeCacheFile(
agx::String filename,
const CachedTile& tile );
281 bool readCacheFile(
agx::String filename, CachedTile& output );
321 std::thread m_backgroundThread;
324 std::mutex m_createTerrainMutex;
326 std::condition_variable m_producerCondition;
328 std::condition_variable m_consumerCondition;
330 std::condition_variable m_clearCondition;
332 bool m_backgroundThreadPaused;
336 bool m_shutdownThread;
340 bool m_shouldStoreCompaction;
341 bool m_shouldEmbedCachedFiles;
343 size_t m_maximumCompactionDepth;
350 std::deque< std::pair<agxTerrain::TileSpecification, agxTerrain::TileId> > m_loadRequests;
352 std::deque< agxTerrain::TerrainTile > m_unloadRequests;
354 std::queue< agxTerrain::TerrainTile > m_readyTiles;
361 m_shouldStoreCompaction = shouldStoreCompaction;
366 return m_shouldStoreCompaction;
371 m_maximumCompactionDepth = maximumCompactionDepth;
376 return &m_compressedIndices;
381 return m_terrainDataSource;
386 return m_templateTerrain;
391 m_templateTerrain = templateTerrain;
397 return m_fileCacheDir;
403 m_shouldEmbedCachedFiles = embed;
408 return m_shouldEmbedCachedFiles;
#define AGXTERRAIN_EXPORT
Class for writing serialized data in binary format to a stream.
The TerrainCache is used internally by the TerrainPager to provide requested terrain tiles.
void setShouldStoreCompaction(bool shouldStoreCompaction)
Sets if the terrain pager should store compaction data for tiles that are paged out.
void unloadTerrainTile(TerrainTile tile)
Schedule a tile for unloading.
agx::String getFileCacheDirectory() const
bool getShouldStoreCompaction() const
Returns whether the terrain pager should store compaction data for tiles that are paged out.
void prepareTerrainInstances(const TileSpecification &ts, size_t poolSize)
Create agxTerrain::Terrain instances so that there are poolSize number of Terrains in the pool for fu...
@ TS_RETURNED
Tile has been fetched by the TerrainPager.
@ 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_IN_RAM
Tile has been returned to the Cache by the TerrainPager.
void setMaximumCompactionDepth(size_t maximumCompactionDepth)
void setTerrainDataSource(TerrainDataSource *tds)
Sets the data source for height data.
void setRestoreData(const TileModificationVector &state)
Specifies the restore data that is used to apply changes the first time they are needed after restore...
virtual ~TerrainCache()
Destructor.
agxTerrain::TerrainTile getReadyTile()
Without blocking, this method tries to return a ready processed terrain tile.
TerrainCache()
Constructor.
void waitForTile()
Waits until one tile is ready.
void setEmbedCacheFilesInArchive(bool embed)
Sets if cached files written out to disk should be embeded in AGX Archives when store is called.
void clearCache()
Removes all internal state.
agxTerrain::TerrainRef getTemplateTerrain()
Returns the template terrain used for properties of new terrain tiles.
TerrainDataSource * getTerrainDataSource() const
Returns the data source used for height data.
void applyChangesToTemplateTerrain(agxTerrain::Terrain *t)
bool setFileCacheDirectory(agx::String dir)
Specifies where paged out height data for terrain should be stored.
TileStatus getTileStatus(TileId id) const
bool getEmbedCacheFilesInArhive() const
Returns if cached files should be embedded in AGX Archives used for serialization.
void handleStagedTerrain()
Checks if there is staged terrain which can be moved to the pool for future usage.
bool haveReadyTile()
Checks if one or more tiles are ready.
agx::HashTable< agxTerrain::TileId, agx::Vec2iVector > * getCompressedIndices()
void setTemplateTerrain(agxTerrain::TerrainRef templateTerrain)
Sets the template terrain used for properties of new terrain tiles.
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.
Abstract interface for requesting height data for a Terrain tile.
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
A TileSpecification determines where in the world a 2D TileId is located and contains utility methods...
Inheritance with partial specialization due to bug with ref_ptr containers.
Vector containing 'raw' data.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
agx::VectorPOD< agx::RealVector > modifiedCompactionVector
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::pair< Real, Real > RealPair
Struct with data to describe a terrain tile.
agxTerrain::TerrainRef terrain