voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
blub::procedural::voxel::simple::surface< configType > Class Template Reference

The surface class convertes accessor-tiles to surface-tiles. In between polygons get calculated by the surface-tile. More...

#include <surface.hpp>

Inheritance diagram for blub::procedural::voxel::simple::surface< configType >:
blub::procedural::voxel::simple::base< configType::t_surface::t_tile > blub::noncopyable

Public Types

typedef configType t_config
 
typedef t_config::t_surface::t_tile t_tile
 
typedef sharedPointer< t_tile > t_tilePtr
 
typedef base< t_tile > t_base
 
typedef t_base::t_tileId t_tileId
 
typedef hashMap< t_tileId,
t_tilePtr
t_tilesMap
 
typedef hashList< vector3int32t_tileIdList
 
typedef
t_config::t_accessor::t_tile 
t_tileAccessor
 
typedef sharedPointer
< t_tileAccessor > 
t_tileAccessorPtr
 
typedef base< t_tileAccessor > t_voxelAccessor
 
- Public Types inherited from blub::procedural::voxel::simple::base< configType::t_surface::t_tile >
typedef
configType::t_surface::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

 surface (blub::async::dispatcher &worker, t_voxelAccessor &voxels, const int32 &lod)
 surface constructor. More...
 
 ~surface ()
 ~surface destructor.
 
int32 getTileCount () const
 getTileCount returns the tile count calculated by this class. Read-lock class before calling. More...
 
real getVoxelSize () const
 getVoxelSize returns the voxel-size. More...
 
t_tilePtr getTile (const blub::vector3int32 &id) const
 getTile returns a surface-tile. Lock-read class before. More...
 
t_tilePtr getOrCreateTile (const blub::vector3int32 &id) const
 getOrCreateTile returns same like getTile() except that when not found instances a new tile. More...
 
- Public Member Functions inherited from blub::procedural::voxel::simple::base< configType::t_surface::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

void editDone ()
 editDone gets called when data in accessor changed.
 
void editDoneMaster ()
 editDoneMaster same like editDone() but on master-thread. Write locks class, dispatches surface generation to worker threads. More...
 
void calculateSurfaceTS (const t_tileId id, t_tileAccessorPtr work, t_tilePtr workTile)
 calculateSurfaceTS gets called by editDoneMaster(), by any worker-thread. Calls afterCalculateSurfaceMaster() after work is done. More...
 
void afterCalculateSurfaceMaster (const t_tileId &id, t_tilePtr workTile)
 afterCalculateSurfaceMaster gets called by calculateSurfaceTS() on master-thread. More...
 
- Protected Member Functions inherited from blub::procedural::voxel::simple::base< configType::t_surface::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.
 
virtual t_tilePtr createTile () const
 createTile creates a new Tile. Uses callback set by setCreateTileCallback() More...
 

Additional Inherited Members

- Protected Attributes inherited from blub::procedural::voxel::simple::base< configType::t_surface::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
 

Detailed Description

template<class configType>
class blub::procedural::voxel::simple::surface< configType >

The surface class convertes accessor-tiles to surface-tiles. In between polygons get calculated by the surface-tile.

Constructor & Destructor Documentation

template<class configType >
blub::procedural::voxel::simple::surface< configType >::surface ( blub::async::dispatcher worker,
t_voxelAccessor voxels,
const int32 &  lod 
)
inline

surface constructor.

Parameters
workerMay getting called by several threads.
voxelsThe accessor to which this class listens for updates to.
lodIndicates the lod. 0 for highest detail, 1 for half detail and so on.

Member Function Documentation

template<class configType >
void blub::procedural::voxel::simple::surface< configType >::afterCalculateSurfaceMaster ( const t_tileId id,
t_tilePtr  workTile 
)
inlineprotected

afterCalculateSurfaceMaster gets called by calculateSurfaceTS() on master-thread.

Parameters
idTileId
workTileThe reulting surface-tile. If no polygons got created it is nullptr.
See also
calculateSurfaceTS()
template<class configType >
void blub::procedural::voxel::simple::surface< configType >::calculateSurfaceTS ( const t_tileId  id,
t_tileAccessorPtr  work,
t_tilePtr  workTile 
)
inlineprotected

calculateSurfaceTS gets called by editDoneMaster(), by any worker-thread. Calls afterCalculateSurfaceMaster() after work is done.

Parameters
idTileId
workThe accessorTile to turn into a surface-tile.
workTilethe resulting surface tile.
See also
editDoneMaster()
template<class configType >
void blub::procedural::voxel::simple::surface< configType >::editDoneMaster ( )
inlineprotected

editDoneMaster same like editDone() but on master-thread. Write locks class, dispatches surface generation to worker threads.

See also
editDone()
template<class configType >
t_tilePtr blub::procedural::voxel::simple::surface< configType >::getOrCreateTile ( const blub::vector3int32 id) const
inline

getOrCreateTile returns same like getTile() except that when not found instances a new tile.

Parameters
idTileId.
Returns
Never nullptr.
See also
getTile()
template<class configType >
t_tilePtr blub::procedural::voxel::simple::surface< configType >::getTile ( const blub::vector3int32 id) const
inline

getTile returns a surface-tile. Lock-read class before.

Parameters
idTileId
Returns
If not found returns nullptr.
template<class configType >
int32 blub::procedural::voxel::simple::surface< configType >::getTileCount ( ) const
inline

getTileCount returns the tile count calculated by this class. Read-lock class before calling.

Returns
Always a positive value.
template<class configType >
real blub::procedural::voxel::simple::surface< configType >::getVoxelSize ( ) const
inline

getVoxelSize returns the voxel-size.

Returns
pow(2, lod)

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