The accessor class accesses and caches voxels for the surface-calculation. It caches voxel optimized for the marching cubes algorithm. If lod is larger 0 it addionally caches voxel for the transvoxel aalgorithm. More...
#include <accessor.hpp>
Public Types | |
| typedef configType | t_config |
|
typedef t_config::t_accessor::t_tile | t_tile |
| typedef sharedPointer< t_tile > | t_tilePtr |
| typedef base< t_tile > | t_base |
| typedef t_config::t_data | t_voxel |
| typedef t_base::t_tileId | t_tileId |
|
typedef hashMap< vector3int32, t_tilePtr > | t_tiles |
|
typedef t_config::t_container::t_tile | t_tileContainer |
|
typedef sharedPointer < t_tileContainer > | t_tileContainerPtr |
| typedef hashList< vector3int32 > | t_tileIdList |
| typedef container::utils::tileState | t_tileState |
|
typedef container::utils::tile < t_tileContainer > | t_tileHolder |
|
typedef hashMap< t_tileId, t_tileHolder > | t_tileHolderMap |
|
typedef t_config::t_container::t_simple | t_simpleContainerVoxel |
Public Types inherited from blub::procedural::voxel::simple::base< configType::t_accessor::t_tile > | |
|
typedef configType::t_accessor::t_tile | t_tile |
| typedef sharedPointer< t_tile > | t_tilePtr |
| typedef base< t_tile > | t_thisClass |
| typedef vector3int32 | t_tileId |
|
typedef hashMap< t_tileId, t_tilePtr > | t_tilesGotChangedMap |
| typedef std::function< t_tilePtr()> | t_createTileCallback |
| typedef blub::signal< void()> | t_sigEditDone |
Public Member Functions | |
| accessor (async::dispatcher &worker, t_simpleContainerVoxel &voxels, const int32 &lod) | |
| accessor constructor More... | |
| ~accessor () | |
| ~accessor destructor | |
| t_simpleContainerVoxel & | getVoxelContainer () const |
| getVoxelContainer returns the voxel container, set in the constructor. More... | |
| t_tilePtr | getTile (const t_tileId &id) const |
| getTile returns an accessor tile. Read-lock class before. More... | |
Public Member Functions inherited from blub::procedural::voxel::simple::base< configType::t_accessor::t_tile > | |
| base (blub::async::dispatcher &worker) | |
| base constructor More... | |
| ~base () | |
| ~base destructor | |
| void | lockForEdit () |
| lockForEdit locks the class for editing/writing it. Call unlockForEdit() after work done. Method executes locks by the dispatcher master. More... | |
| void | unlockForEdit () |
| unlockForEdit unlocks edit/write-lock and calls signalEditDone() . Method executes unlock by the dispatcher master. More... | |
| void | lockForRead () |
| lockForRead locks the class for reading. | |
| void | unlockRead () |
| unlockRead unlocks the class after reading. | |
| const t_tilesGotChangedMap & | getTilesThatGotEdited () const |
| getTilesThatGotEdited returns a list of tiles which changed since the last call lockForEdit() / lockForEditMaster() More... | |
| void | setCreateTileCallback (const t_createTileCallback &callback) |
| setCreateTileCallback sets a callback for creating tiles. Use this method if you want to create custom tiles. More... | |
| blub::async::strand & | getMaster () |
| getMaster returns the master dispatcher. The master synchronises jobs for the worker-thread and writes to class member. The master calls all methods which end with *Master. More... | |
| t_sigEditDone * | signalEditDone () |
| signalEditDone gets called after unlockForEdit() got called. More... | |
Protected Member Functions | |
| void | tilesGotChanged () |
| tilesGotChanged gets called after in the voxel container m_voxels, set in the constructor, the voxels changed. Which leads to a recalculation of the cache. | |
| void | tilesGotChangedMaster () |
| tilesGotChangedMaster must not get called paralell. More... | |
| void | calculateAccessorTS (const t_tileId &id, t_tilePtr workTile) |
| calculateAccessorTS accesses the container and pulls out all voxel needed for surface calculation (marching-cubes/transvoxel). More... | |
| void | afterCalculateAccessorMaster (const t_tileId &id, t_tilePtr workTile, const bool &didValuesChanged) |
| afterCalculateAccessorMaster gets called after a worker-thread finished calculation of a part. More... | |
| void | calculateAffectedAccessorTilesByContainerTile (const t_tileId &conterainerId, const t_tileHolder &holder, t_tileIdList &resultingSurfaceTiles) |
| When a tile in container gets changed it affects (because of normal-correction and lod) 3^3 accessor-tiles. More... | |
| t_tilePtr | createTile () const override |
| createTile creates an empty tile. More... | |
| t_voxel | getVoxelData (const vector3int32 &voxelPosAbs, t_tileHolderMap &lastUsedTiles) |
| getVoxelData returns a voxel from a cahned container-tile or looks up the tile and returns it. More... | |
Protected Member Functions inherited from blub::procedural::voxel::simple::base< configType::t_accessor::t_tile > | |
| void | addToChangeList (const t_tileId &id, t_tilePtr toAdd) |
| addToChangeList adds a tile to the change-list. More... | |
| virtual bool | tryLockForEditMaster () |
| tryLockForEditMaster tries to lock for write. Call by master dispatcher. More... | |
| virtual void | lockForEditMaster () |
| lockForEditMaster locks for write, or waits until possible. Call by master dispatcher. | |
| virtual void | unlockForEditMaster () |
| unlockForEditMaster unlocks write. Call by master dispatcher. | |
Protected Attributes | |
| t_simpleContainerVoxel & | m_voxels |
| const int32 | m_lod |
| const int32 | m_voxelSkip |
| int32 | m_numTilesInWork |
| t_tiles | m_tiles |
| boost::signals2::scoped_connection | m_connTilesGotChanged |
Protected Attributes inherited from blub::procedural::voxel::simple::base< configType::t_accessor::t_tile > | |
| blub::async::strand | m_master |
| m_master The master synchronises jobs for the worker-thread and writes to class member. The master calls all methods which end with *Master. | |
| blub::async::dispatcher & | m_worker |
| m_worker use it to dispatch heavy work. Don't write to class member with it. Do not use any locks. Use m_master for such tasks. | |
| t_tilesGotChangedMap | m_tilesThatGotEdited |
| t_createTileCallback | m_createTileCallback |
| async::mutexReadWrite | m_classLocker |
| t_sigEditDone | m_sigEditDone |
The accessor class accesses and caches voxels for the surface-calculation. It caches voxel optimized for the marching cubes algorithm. If lod is larger 0 it addionally caches voxel for the transvoxel aalgorithm.
|
inline |
accessor constructor
| worker | May gets run by multiple threads. |
| voxels | The container to read the voxels from. The Accessor will connect the signal container::base::signalEditDone() to this class, so it keeps up to date. |
| lod | Indicates the level of detail. Use 0 zero for the most detailed one, use 1 for half detail and so on. |
|
inlineprotected |
afterCalculateAccessorMaster gets called after a worker-thread finished calculation of a part.
| id | TileId |
| workTile | The resulting accessor-tile. |
| didValuesChanged | Tells if anything changed. |
|
inlineprotected |
calculateAccessorTS accesses the container and pulls out all voxel needed for surface calculation (marching-cubes/transvoxel).
| id | Accessor-TileId |
| workTile | The accessor-tile to fill with. |
|
inlineprotected |
When a tile in container gets changed it affects (because of normal-correction and lod) 3^3 accessor-tiles.
| conterainerId | Container-Tile-Id |
| holder | Container-Data |
| resultingSurfaceTiles | Resulting, up to 27, to recalculate tiles. Depending on how the change-axisAligendBox in the container-tile looks like. |
|
inlineoverrideprotectedvirtual |
createTile creates an empty tile.
Reimplemented from blub::procedural::voxel::simple::base< configType::t_accessor::t_tile >.
|
inline |
getTile returns an accessor tile. Read-lock class before.
| id | TileId |
|
inline |
getVoxelContainer returns the voxel container, set in the constructor.
|
inlineprotected |
getVoxelData returns a voxel from a cahned container-tile or looks up the tile and returns it.
| voxelPosAbs | Absolut voxel position. |
| lastUsedTiles | Last used container-tile. |
|
inlineprotected |
tilesGotChangedMaster must not get called paralell.
1.8.8