voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
blub::procedural::voxel::simple::container::database< voxelType > Class Template Reference
Inheritance diagram for blub::procedural::voxel::simple::container::database< voxelType >:
blub::procedural::voxel::simple::container::inMemory< voxelType > blub::procedural::voxel::simple::container::base< voxelType > blub::procedural::voxel::simple::base< voxelType::t_container::t_tile > blub::noncopyable

Public Types

typedef inMemory< voxelType > t_base
 
typedef std::function
< byteArray(const byteArray &)> 
t_funcCompress
 
- Public Types inherited from blub::procedural::voxel::simple::container::inMemory< voxelType >
typedef base< voxelType > t_base
 
typedef vector3int32map
< typename t_base::t_utilsTile > 
t_tilesMap
 
- Public Types inherited from blub::procedural::voxel::simple::container::base< voxelType >
typedef voxelType t_config
 
typedef t_config::t_data t_voxel
 
typedef
voxelType::t_container::t_tile 
t_tile
 
typedef simple::base< t_tile > t_base
 
typedef sharedPointer< t_tile > t_tilePtr
 
typedef utils::tile< t_tile > t_utilsTile
 
typedef sharedPointer
< edit::base< t_config > const > 
t_editConstPtr
 
typedef sharedPointer
< edit::base< t_config > > 
t_editPtr
 
typedef t_base::t_tileId t_tileId
 
typedef hashMap< t_tileId,
t_utilsTile
t_tilesGotChangedMap
 
- Public Types inherited from blub::procedural::voxel::simple::base< voxelType::t_container::t_tile >
typedef
voxelType::t_container::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

 database (blub::async::dispatcher &worker, blub::database::connection &dbConn)
 
void loadTS ()
 
void loadMaster ()
 
byteArray getTileHolderDatabaseMaster (const blub::vector3int32 &id) const
 
t_base::t_utilsTile getTileHolderFromDatabaseMaster (const blub::vector3int32 &id) const
 
void setWriteToDatabase (const bool &en)
 
void setCompressionCallback (const t_funcCompress &compress, const t_funcCompress &decompress)
 
- Public Member Functions inherited from blub::procedural::voxel::simple::container::inMemory< voxelType >
 inMemory (blub::async::dispatcher &worker)
 inMemory constructor More...
 
 ~inMemory ()
 ~inMemory descructor
 
t_base::t_utilsTile getTileHolder (const blub::vector3int32 &id) const override
 getTileHolder returns a utils::tileHolder setted by setTile() or by editVoxel(). Read-lock class before call. Read-lock the class before. More...
 
const t_tilesMapgetTilesMap () const
 getTilesMap returns all tiles. More...
 
void setTileBounds (const axisAlignedBoxInt32 &bounds)
 setTileBounds sets the size for the map. Call for optimization, if you know the tile-dimensions before editing. More...
 
const axisAlignedBoxInt32getTileBounds () const
 getTileBounds returns the tile bounds. More...
 
- Public Member Functions inherited from blub::procedural::voxel::simple::container::base< voxelType >
 base (blub::async::dispatcher &worker)
 base constructor. More...
 
void editVoxel (t_editConstPtr change, const transform &trans=blub::transform())
 editVoxel edits the container. Its guranteed that the edits are getting in order of calling this method. Returns immediately. Does NOT calculate any voxel, but creates and dispatches the jobs for it. More...
 
void setTile (const t_tileId &id, const t_utilsTile &toSet)
 editVoxel edits the container. Its guranteed that the edits are getting in order of calling this method. Returns immediately. Does NOT calculate any voxel, but creates and dispatches the jobs for it. More...
 
t_utilsTile getTileHolderByVoxelPosition (const blub::vector3int32 &pos) const
 getTileHolderByVoxelPosition returns a utils::tileHolder setted by setTile() or by editVoxel(). Read-lock class before call. More...
 
t_voxel getVoxel (const vector3int32 &voxelPos) const
 getVoxel returns an voxel. Read-lock the class before call. More...
 
const t_tilesGotChangedMapgetTilesThatGotEdited () const
 
- Public Member Functions inherited from blub::procedural::voxel::simple::base< voxelType::t_container::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_tilesGotChangedMapgetTilesThatGotEdited () 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::strandgetMaster ()
 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_sigEditDonesignalEditDone ()
 signalEditDone gets called after unlockForEdit() got called. More...
 

Protected Member Functions

virtual void setTileDatabaseMaster (const vector3int32 &id, const blub::byteArray &toSet, const bool &insert, const bool &update, const bool &remove)
 
void setTileToContainerMaster (const typename t_base::t_tileId id, const typename t_base::t_utilsTile &oldOne, const typename t_base::t_utilsTile &toSet) override
 setTileToContainerMaster replaces a tile. Call method by one thread at a time. Write-lock class before. More...
 
- Protected Member Functions inherited from blub::procedural::voxel::simple::container::inMemory< voxelType >
void setTileMaster (const blub::vector3int32 &id, const typename t_base::t_utilsTile &toSet) override
 setTileMaster sets a tile to an id. Call by one thread at a time. More...
 
void setTileToFullMaster (const vector3int32 &id) override
 setTileToFullMaster sets a tiles voxel to maximum - for memory optimizations. Method gets called by a single thread at a time. More...
 
void setTileToEmtpyMaster (const vector3int32 &id) override
 setTileToFullMaster sets a tiles voxel to minimum - for memory optimizations. Method gets called by a single thread at a time. More...
 
BLUB_SERIALIZATION_ACCESS void save (formatType &readWrite, const uint32 &version) const
 
void load (formatType &readWrite, const uint32 &version)
 
void serialize (formatType &readWrite, const uint32 &version)
 
- Protected Member Functions inherited from blub::procedural::voxel::simple::container::base< voxelType >
void addToChangeList (const t_tileId &id, t_utilsTile toAdd)
 
void unlockForEditMaster () override
 unlockForEditMaster unlocks write. Call by master dispatcher.
 
bool tryLockForEditMaster () override
 tryLockForEditMaster tries to lock for write. Call by master dispatcher. More...
 
void lockForEditMaster () override
 lockForEditMaster locks for write, or waits until possible. Call by master dispatcher.
 
void editMaster (t_editConstPtr change, const blub::transform &trans)
 editMaster saves the edit in a qeue and starts to handle it. More...
 
void doNextEditMaster (const bool &alreadyLocked=false)
 doNextEditMaster finds out which tiles the edit affects and dispaches the change to the worker-threads. More...
 
void editVoxelWorker (t_editConstPtr change, const t_utilsTile &holder, const blub::vector3int32 &id, const blub::transform &trans)
 editVoxelWorker affects with change holder. Method gets called paralell by various threads. Method only affects the delivered holder. More...
 
void editVoxelDoneMaster (t_utilsTile tileHolder_, const blub::vector3int32 &id)
 editVoxelDoneMaster gets called after edit got applied on the tile. Call method only by one thread at a time. More...
 
virtual void setTileMaster (const t_tileId &id, const t_utilsTile &toSet)=0
 gets called by setTile. Call only by one thread at a time. Write-lock class before. More...
 
t_tilePtr getOrCreateTile (const vector3int32 &id)
 getOrCreateTile looks up if tile already exists. If not creates one. More...
 
- Protected Member Functions inherited from blub::procedural::voxel::simple::base< voxelType::t_container::t_tile >
void addToChangeList (const t_tileId &id, t_tilePtr toAdd)
 addToChangeList adds a tile to the change-list. More...
 
virtual t_tilePtr createTile () const
 createTile creates a new Tile. Uses callback set by setCreateTileCallback() More...
 

Protected Attributes

blub::database::connection & m_databaseConnection
 
bool m_loading
 
bool m_writeToDatabase
 
t_funcCompress m_funcCompress
 
t_funcCompress m_funcDecompress
 
- Protected Attributes inherited from blub::procedural::voxel::simple::container::base< voxelType >
int32 m_numInTilesInTask
 
t_editTodoList m_editsTodo
 
t_tilesGotChangedMap m_tilesThatGotEdited
 
- Protected Attributes inherited from blub::procedural::voxel::simple::base< voxelType::t_container::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::dispatcherm_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
 

Additional Inherited Members

- Static Public Member Functions inherited from blub::procedural::voxel::simple::container::base< voxelType >
static t_tileId calculateVoxelPosToTileId (const vector3int32 &voxelPos)
 calculateVoxelPosToTileId converts an absolute voxel-position to an relative container-id position. More...
 
static vector3int32 calculateVoxelPosInTile (const vector3int32 &voxelPos)
 calculateVoxelPosInTile converts an absolute voxel-position to an relative container-confirm position. More...
 
- Protected Types inherited from blub::procedural::voxel::simple::container::base< voxelType >
typedef list< editTodo > t_editTodoList
 
- Static Protected Member Functions inherited from blub::procedural::voxel::simple::container::base< voxelType >
static t_tilePtr createTileFull (const bool &full)
 createTileFull creates a tile in which all voxel are maximum or minimum. More...
 
static void calculateAffectetedTilesByAabb (const axisAlignedBoxInt32 &voxelAabb, t_tileId &startResult, t_tileId &endResult)
 calculateAffectetedTilesByAabb caluclates a list of affected tiles by an axisAlignedBox. Used to determine which tiles to recalculate for an edit. More...
 

Member Function Documentation

template<class voxelType >
void blub::procedural::voxel::simple::container::database< voxelType >::setTileToContainerMaster ( const typename t_base::t_tileId  id,
const typename t_base::t_utilsTile &  oldOne,
const typename t_base::t_utilsTile &  toSet 
)
inlineoverrideprotectedvirtual

setTileToContainerMaster replaces a tile. Call method by one thread at a time. Write-lock class before.

Parameters
idTileId
oldOneNot used - may be interesting in derived classes.
toSet

Reimplemented from blub::procedural::voxel::simple::container::inMemory< voxelType >.


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