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

The renderer class handles the correct rendering of a lod. Including renderdistance and enabling the submeshes for losing the cracks (transvoxel results). Takes the results and updates from the simple::surface and saves them into an octree. Casts signals on when to update an LOD. More...

#include <renderer.hpp>

Inheritance diagram for blub::procedural::voxel::simple::renderer< configType >:
blub::procedural::voxel::simple::base< configType::t_renderer::t_tile > blub::noncopyable

Public Types

typedef configType t_config
 
typedef
t_config::t_renderer::t_tile 
t_tile
 
typedef sharedPointer< t_tile > t_tilePtr
 
typedef base< t_tile > t_base
 
typedef t_base::t_tileId t_tileId
 
typedef sharedPointer
< sync::identifier
t_cameraPtr
 
typedef sync::sender< t_tileId,
t_cameraPtr
t_sync
 
typedef hashMap< vector3int32,
t_tilePtr
t_tileMap
 
typedef t_config::t_surface::t_tile t_tileSurface
 
typedef sharedPointer
< t_tileSurface > 
t_tileDataPtr
 
typedef std::function< bool(vector3,
axisAlignedBox)> 
t_octreeSearchCallback
 
typedef
t_config::t_surface::t_simple 
t_rendererSurface
 
- Public Types inherited from blub::procedural::voxel::simple::base< configType::t_renderer::t_tile >
typedef
configType::t_renderer::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

 renderer (blub::async::dispatcher &worker, t_rendererSurface *tiles, const int32 &lod, const real &lodCutDistNear, const real &lodCutDistFar)
 renderer constructor. More...
 
 ~renderer ()
 ~renderer destructor.
 
void addCamera (t_cameraPtr toAdd, const blub::vector3 &position)
 addCamera adds an camera. More...
 
void updateCamera (t_cameraPtr toUpdate, const blub::vector3 &position)
 updateCamera updates the position of a camera you have to add before by using addCamera() More...
 
void removeCamera (t_cameraPtr toRemove)
 removeCamera removes a camera. More...
 
const t_tileMapgetTileMap () const
 getTileMap Returns all surface-tiles holded by this class. Read-lock class before. More...
 
- Public Member Functions inherited from blub::procedural::voxel::simple::base< configType::t_renderer::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 simple::surface changed. Read-locks surface.
 
void editDoneMaster ()
 editDoneMaster gets called when simple::surface changed. More...
 
void tileGotSetMaster (const t_tileId &id, const t_tileDataPtr toSet)
 tileGotSetMaster sets the surface tiles to the octree. More...
 
void tileGotRemovedMaster (const t_tileId &id)
 tileGotRemovedMaster removes tile from octree. More...
 
bool isInSyncRangeReceiver (const typename t_sync::t_receiver receiver, const vector3 &posOfReceiverLeafCenter, const typename t_sync::t_syncTree::t_nodePtr &octreeNode)
 
bool isInSyncRangeSync (const typename t_sync::t_sync sync, const vector3 &posOfSyncLeafCenter, const typename t_sync::t_receiverTree::t_nodePtr &octreeNode)
 
void addSyncReceiver (const typename t_sync::t_receiver receiver, const typename t_sync::t_sync sync)
 addSyncReceiver gets called by octree if a tile should be visible. More...
 
void removeSyncReceiver (const typename t_sync::t_receiver receiver, const typename t_sync::t_sync sync)
 removeSyncReceiver gets called by octree if a tile shouldn't be visible. More...
 
void updateLod (const t_tileId &id, t_tilePtr toUpdate)
 updateLod checks if a neighbour of the tile has a different lod. If so it enables the by the transvoxel calculated submeshes, used to close the cracks. More...
 
int32 isInRange (const vector3 &posLeafCenter, const axisAlignedBox &octreeNode)
 isInRange checks the distance of a tile to the camera. More...
 
void updateCameraMaster (t_cameraPtr toUpdate, const blub::vector3 &position)
 
- Protected Member Functions inherited from blub::procedural::voxel::simple::base< configType::t_renderer::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_renderer::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::renderer< configType >

The renderer class handles the correct rendering of a lod. Including renderdistance and enabling the submeshes for losing the cracks (transvoxel results). Takes the results and updates from the simple::surface and saves them into an octree. Casts signals on when to update an LOD.

Constructor & Destructor Documentation

template<class configType >
blub::procedural::voxel::simple::renderer< configType >::renderer ( blub::async::dispatcher worker,
t_rendererSurface *  tiles,
const int32 &  lod,
const real &  lodCutDistNear,
const real &  lodCutDistFar 
)
inline

renderer constructor.

Parameters
workerMay get called by several threads.
tilesMust not be nullptr.
lodLevel of detail index. Zero is the detail with highest resolution, one has half resolution and so on.
lodCutDistNearDefines distance when a tile when it is too near. Will get disabled if tile is nearer lodCutDistNear.
lodCutDistFarDefines distance when a tile when it is too far. Will get disabled if tile is farer away than lodCutDistFar.

Member Function Documentation

template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::addCamera ( t_cameraPtr  toAdd,
const blub::vector3 position 
)
inline

addCamera adds an camera.

Parameters
toAddMust not be nullptr
positionThe initial position of the camera.
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::addSyncReceiver ( const typename t_sync::t_receiver  receiver,
const typename t_sync::t_sync  sync 
)
inlineprotected

addSyncReceiver gets called by octree if a tile should be visible.

Parameters
receiverCamera
syncTile
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::editDoneMaster ( )
inlineprotected

editDoneMaster gets called when simple::surface changed.

See also
editDone()
template<class configType >
const t_tileMap& blub::procedural::voxel::simple::renderer< configType >::getTileMap ( ) const
inline

getTileMap Returns all surface-tiles holded by this class. Read-lock class before.

Returns
template<class configType >
int32 blub::procedural::voxel::simple::renderer< configType >::isInRange ( const vector3 posLeafCenter,
const axisAlignedBox octreeNode 
)
inlineprotected

isInRange checks the distance of a tile to the camera.

Parameters
posLeafCentercamera position.
octreeNodeaxisAlignedBox of the surface-tile.
Returns
Returns 0 for too near, 2 for too far and 1 for in range.
template<class configType >
bool blub::procedural::voxel::simple::renderer< configType >::isInSyncRangeReceiver ( const typename t_sync::t_receiver  receiver,
const vector3 posOfReceiverLeafCenter,
const typename t_sync::t_syncTree::t_nodePtr &  octreeNode 
)
inlineprotected
See also
isInRange()
template<class configType >
bool blub::procedural::voxel::simple::renderer< configType >::isInSyncRangeSync ( const typename t_sync::t_sync  sync,
const vector3 posOfSyncLeafCenter,
const typename t_sync::t_receiverTree::t_nodePtr &  octreeNode 
)
inlineprotected
See also
isInRange()
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::removeCamera ( t_cameraPtr  toRemove)
inline

removeCamera removes a camera.

Parameters
toRemoveMust not be nullptr.
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::removeSyncReceiver ( const typename t_sync::t_receiver  receiver,
const typename t_sync::t_sync  sync 
)
inlineprotected

removeSyncReceiver gets called by octree if a tile shouldn't be visible.

Parameters
receiverCamera
syncTile
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::tileGotRemovedMaster ( const t_tileId id)
inlineprotected

tileGotRemovedMaster removes tile from octree.

Parameters
idTileId
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::tileGotSetMaster ( const t_tileId id,
const t_tileDataPtr  toSet 
)
inlineprotected

tileGotSetMaster sets the surface tiles to the octree.

Parameters
idTileId
toSetThe Surface-tile to work on.
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::updateCamera ( t_cameraPtr  toUpdate,
const blub::vector3 position 
)
inline

updateCamera updates the position of a camera you have to add before by using addCamera()

Parameters
toUpdateThe camera, must not be nullptr.
positionThe new position.
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::updateCameraMaster ( t_cameraPtr  toUpdate,
const blub::vector3 position 
)
inlineprotected
See also
updateCamera
template<class configType >
void blub::procedural::voxel::simple::renderer< configType >::updateLod ( const t_tileId id,
t_tilePtr  toUpdate 
)
inlineprotected

updateLod checks if a neighbour of the tile has a different lod. If so it enables the by the transvoxel calculated submeshes, used to close the cracks.

Parameters
idTileId
toUpdateSurface-tile to work on.

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