VoxelFarm::CBlockData Class Reference

A default implementation of IBlockData that also acts as a VoxelLayer. More...

#include <BlockData.h>

Inheritance diagram for VoxelFarm::CBlockData:
VoxelFarm::IVoxelLayer VoxelFarm::IBlockData

Classes

class  IBlockCache
 
class  IBlockIO
 This interface allows the CBlockData object to persist blocks in an external storage. More...
 
struct  ThreadContext
 

Public Member Functions

virtual void setBlock (CellId &cell, int &x, int &y, int &z, int material, double dx, double dy, double dz, TSet< CellId > *changedCells)
 Sets a value for a voxel. More...
 
virtual void getBlock (CellId cell, int x, int y, int z, int &material, double &dx, double &dy, double &dz)
 Gets the value of a voxel. More...
 
virtual void getContourData (CellId cell, ContourVoxelData *data, bool &empty, void *threadContext) override
 Reads the entire Cell contents into a buffer. More...
 
virtual void * createThreadContext () override
 The voxel layer can use this method to return a structure that will be unique for each calling thread. This allows to have lock-free work buffers assigned to each worker thread.
 
virtual void disposeThreadContext (void *threadContext) override
 Destroys the specified thread context.
 
virtual int getStatsContourId () override
 Returns the stats ID to be used for measuring performance of the getContourData() method.
 
virtual bool isCacheable () override
 Returns true if the layer's output can be cached. Return true if the output for a cell will always be the same.
 
virtual void updateLOD (const TSet< CellId > &changedCells)
 Recomputes higher LOD data.
 
virtual void beginChanges ()
 Sets a marker for a change set that can be undone.
 
virtual void trackCellChanges (CellId cell, const BlockVoxelData *blockData)
 Requests changes made to a cell to be remembered so they can be undone.
 
virtual void endChanges ()
 Closes the marker for a change set that can be undone.
 
virtual void undo (TSet< CellId > &changedCells)
 Undoes the last changes.
 
void setBlockIOHandler (IBlockIO *blockIOHandler)
 Sets the IBlockIO interface.
 
BlockVoxelDataloadCell (CellId cell)
 Loads voxel data for the specified cell using the assigned IBlockIO handler.
 
void saveCell (CellId cell, BlockVoxelData *data)
 Saves voxel data for the specified cell using the assigned IBlockIO handler.
 
void setBlockCacheHandler (IBlockCache *blockCacheHandler)
 Sets the IBlockCache interface.
 
virtual BlockVoxelDatafetchData (CellId cell, bool create)
 Returns the voxel data buffer for the specified cell. More...
 
virtual BlockVoxelDatafetchCacheData (CellId cell, bool create)
 Returns a cache voxel data buffer for the specified cell. More...
 
void removeFromCache (CellId cell)
 Removes a cell from the memory cache.
 
bool pendingForUpdate ()
 
void cellProcessed (CellId cell)
 
bool cellChildIsInProcessForUpdate (CellId cell)
 
CellId getNextPendingForUpdate (CellId cell=0)
 
bool cellIsPendingForUpdate (CellId cell)
 
int getVoxelIntersections (VoxelFarm::Algebra::Vector *result, BlockVoxelData *data, CellId cell, int x, int y, int z)
 Returns all triangles that intercept a voxel. More...
 
- Public Member Functions inherited from VoxelFarm::IVoxelLayer
virtual void planJobs (Scene *scene)
 This is called when a new scene is discovered. It can be used to create objects that will be later returned in voxel form.
 
virtual void runJobs ()
 Execute any additional generation task.
 
virtual int getStatsPlanJobsId ()
 Returns the stats ID to be used for measuring performance of the planJobs() method.
 
virtual int getStatsRunJobsId ()
 Returns the stats ID to be used for measuring performance of the runJobs() method.
 

Public Attributes

TMap< CellId, BlockVoxelData * > blockCache
 An index where cell IDs are matched to their corresponding voxel data buffer.
 
ExternalMutex::Mutex lock
 A critical section used to protect the block cache.
 
TMap< CellId, BlockVoxelData * > undoData
 Contains the set of Cells that changed in the past modification. More...
 

Static Public Attributes

static const int IMMEDIATE_UPDATE_LOD = LOD_0 + 1
 

Protected Attributes

IBlockIOblockIO
 
IBlockCacheblockCacheHandler
 

Detailed Description

A default implementation of IBlockData that also acts as a VoxelLayer.

Definition at line 182 of file BlockData.h.

Member Function Documentation

virtual BlockVoxelData* VoxelFarm::CBlockData::fetchCacheData ( CellId  cell,
bool  create 
)
virtual

Returns a cache voxel data buffer for the specified cell.

Parameters
cellCell ID for the cell to be retrieved
createIf set to true will create an empty cell buffer if no buffer is found for the cell

Implements VoxelFarm::IBlockData.

virtual BlockVoxelData* VoxelFarm::CBlockData::fetchData ( CellId  cell,
bool  create 
)
virtual

Returns the voxel data buffer for the specified cell.

Parameters
cellCell ID for the cell to be retrieved
createIf set to TRUE will create an empty cell buffer if no buffer is found for the cell

Implements VoxelFarm::IBlockData.

virtual void VoxelFarm::CBlockData::getBlock ( CellId  cell,
int  x,
int  y,
int  z,
int &  material,
double &  dx,
double &  dy,
double &  dz 
)
virtual

Gets the value of a voxel.

Parameters
cellID for the cell containing the voxel to be read
xX coordinates for a voxel relative to the origin of the Cell
yY coordinates for a voxel relative to the origin of the Cell
zZ coordinates for a voxel relative to the origin of the Cell
materialWill contain the material ID for the voxel when the call returns
dxWill contain X coordinates of the inner-voxel point, relative to the origin of the voxel, when the call returns
dyWill contain Y coordinates of the inner-voxel point, relative to the origin of the voxel, when the call returns
dzWill contain Z coordinates of the inner-voxel point, relative to the origin of the voxel, when the call returns
virtual void VoxelFarm::CBlockData::getContourData ( CellId  cell,
ContourVoxelData data,
bool &  empty,
void *  threadContext 
)
overridevirtual

Reads the entire Cell contents into a buffer.

Parameters
cellID of the cell
dataA buffer where the voxel data will be copied.
emptyA flag notifying the entire cell is empty and could be discarded by the caller
threadContextA thread context. This parameter is ignored since the CBlockData object does not require any threadsafe work buffers

Implements VoxelFarm::IVoxelLayer.

int VoxelFarm::CBlockData::getVoxelIntersections ( VoxelFarm::Algebra::Vector result,
BlockVoxelData data,
CellId  cell,
int  x,
int  y,
int  z 
)

Returns all triangles that intercept a voxel.

Parameters
resultList of neighbor vertices forming a quad with the voxel's vertex. Each 3 entries there is a quad
dataVoxel data source
cellCoordinates of the voxel in the form cell, x, y, z
virtual void VoxelFarm::CBlockData::setBlock ( CellId cell,
int &  x,
int &  y,
int &  z,
int  material,
double  dx,
double  dy,
double  dz,
TSet< CellId > *  changedCells 
)
virtual

Sets a value for a voxel.

Parameters
cellID for the cell containing the voxel to be set
xX coordinates for a voxel relative to the origin of the Cell
yY coordinates for a voxel relative to the origin of the Cell
zZ coordinates for a voxel relative to the origin of the Cell
materialID for material being set.
dxX coordinates of the inner-voxel point, relative to the origin of the voxel
dyY coordinates of the inner-voxel point, relative to the origin of the voxel
dzZ coordinates of the inner-voxel point, relative to the origin of the voxel

Implements VoxelFarm::IBlockData.

Member Data Documentation

TMap<CellId, BlockVoxelData*> VoxelFarm::CBlockData::undoData

Contains the set of Cells that changed in the past modification.

Stores the previous state for Cells, so any changes can be reverted to this state

Definition at line 321 of file BlockData.h.


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