My Project
|
Classes | |
struct | InstanceGroup |
Public Types | |
enum | ChunkBuildState { ChunkBuild_Ready, ChunkBuild_RequestRebuild, ChunkBuild_Rebuilding, ChunkBuild_RequestBufferUpload, ChunkBuild_empty } |
Public Member Functions | |
void | ReuseChunk (BlockRegion *m_ownerBlockRegion, int16_t chunkIndex) |
void | ClearChunkData () |
void | ReleaseVertexBuffers () |
void | Reset () |
bool | ShouldRebuildRenderBuffer (CBlockWorld *pWorld, bool bNewBuffer=true, bool bUpdatedBuffer=true) |
every frame, we will ensure some new buffer is updated, and some updated buffer is updated as well. More... | |
bool | RebuildRenderBuffer (CBlockWorld *pWorld, bool bAsyncMode) |
every frame, we will ensure some new buffer is updated, and some updated buffer is updated as well. More... | |
void | FillRenderQueue (CBlockWorld *pWorld) |
fill the render queue with buffer data. More... | |
void | OnLeaveWorld () |
void | DeleteDeviceObjects () |
void | ClearRenderTasks () |
void | RendererRecreated () |
bool | IsEmptyChunk () |
uint16_t | GetChunkIndex () |
Int16x3 | GetChunkPosWs () |
chunk position in world space. More... | |
BlockChunk * | GetChunk () |
get the associated raw chunk data | |
void | FillRenderQueue (CBlockWorld *pWorld, Vector3 &renderOfs, float verticalOffset) |
void | SetChunkDirty (bool isDirty) |
only dirty if chunk is first loaded or reused and all render buffer content can not be used to render | |
bool | IsDirty () const |
only dirty if chunk is first loaded or reused and all render buffer content can not be used to render this has NOTHING to do when the actual block or light content of the chunk has changed or not. | |
bool | IsDirtyByNeighbor () |
bool | GetIsDirtyByBlockChange () |
whether this chunk is made dirty by actual block changes. More... | |
bool | IsIntersect (CShapeSphere &sphere) |
whether the chunk intersect with the given sphere. More... | |
bool | IsNearbyChunksLoaded () |
return true if the nearby 4 chunk columns have been generated (and loaded) | |
RenderableChunk::ChunkBuildState | GetChunkBuildState () const |
bool | IsBuildingBuffer () const |
bool | IsReadyOrEmpty () const |
void | SetChunkBuildState (RenderableChunk::ChunkBuildState val) |
void | WaitUntilChunkReady () |
only used when the chunk is destroyed. More... | |
void | RebuildRenderBufferToMemory (Scoped_ReadLock< BlockReadWriteLock > *Lock_, int *pnCpuYieldCount) |
call this function to generate all vertices to memory buffer. More... | |
void | ClearBuilderBuffer () |
void | UploadFromMemoryToDeviceBuffer () |
only call in main thread | |
int32 | GetTotalFaceCount () const |
int32 | GetDelayedRebuildTick () const |
how many render ticks that this chunk has been delayed from buffer rebuilding. More... | |
void | SetDelayedRebuildTick (int32 val) |
int16 | GetChunkViewDistance () const |
distance to current camera in chunk space. More... | |
void | SetChunkViewDistance (int16 val) |
int16 | GetViewIndex () const |
each chunk has a unique view index, the smaller the closer to the current view center. More... | |
void | SetViewIndex (int16 val) |
int | GetRenderFrameCount () const |
when this chunk should be rendered last time. More... | |
void | SetRenderFrameCount (int val) |
int | GetVertexBufferBytes () |
get the current size of all of its vertex buffer. More... | |
int | GetLastBufferBytes () |
this is usually same as GetVertexBufferBytes(), except that when we clear vertex buffer, this size remain unchanged until the chunk is reused. More... | |
std::vector< BlockRenderTask * > | GetRenderTasks () |
const CShapeBox & | GetShapeAABB () const |
int | GetShaderID () const |
this determined how the vertex buffer format is. More... | |
void | SetShaderID (int val) |
bool | IsMainRenderer () const |
for main renderer (default to true), we will set chuck dirty to false, whenever the buffer is rebuilt. More... | |
void | SetIsMainRenderer (bool val) |
bool | IsDirtyByBlockChange () const |
void | IsDirtyByBlockChange (bool val) |
std::vector< InstanceGroup *> & | GetInstanceGroups () |
this function returns thread local data | |
std::map< int32_t, int > & | GetInstanceMap () |
mapping from a hashed value of block_template id and template data if any. More... | |
BlockGeneralTessellator & | GetBlockTessellator () |
get thread local block tessellator | |
Static Public Member Functions | |
static void | StaticInit () |
static void | StaticRelease () |
static ParaVertexBufferPool * | GetVertexBufferPool () |
static int | GetTotalRenderableChunks () |
total number of renderable chunks in memory. More... | |
static void | StaticReleaseInstGroup (std::vector< RenderableChunk::InstanceGroup * > *pInstances) |
Protected Member Functions | |
void | BuildRenderGroup () |
void | ResetInstanceGroups () |
int32 | BuildInstanceGroupsByIdAndData (BlockChunk *pChunk) |
void | SortAndMergeInstanceGroupsByTexture () |
ParaVertexBuffer * | RequestVertexBuffer (int32 nFaceCountInVertexBuffer) |
each rectangle face is 2 triangles or 4 vertices. More... | |
ParaMemoryBuffer | RequestMemoryBuffer (int32 nFaceCountInVertexBuffer, int32 *pBufferIndex) |
Protected Attributes | |
std::vector< BlockRenderTask * > | m_builder_tasks |
std::vector< ParaMemoryBuffer > | m_memoryBuffers |
void ParaEngine::RenderableChunk::FillRenderQueue | ( | CBlockWorld * | pWorld | ) |
fill the render queue with buffer data.
please note, it does not fill if the buffer has not been created before.
Int16x3 ParaEngine::RenderableChunk::GetChunkPosWs | ( | ) |
chunk position in world space.
int16 ParaEngine::RenderableChunk::GetChunkViewDistance | ( | ) | const |
distance to current camera in chunk space.
int32 ParaEngine::RenderableChunk::GetDelayedRebuildTick | ( | ) | const |
how many render ticks that this chunk has been delayed from buffer rebuilding.
If a chunk has been delayed for too long, we will force it to rebuild even it is farther from the camera than other dirty chunks with smaller delayed ticks.
std::map< int32_t, int > & ParaEngine::RenderableChunk::GetInstanceMap | ( | ) |
mapping from a hashed value of block_template id and template data if any.
bool ParaEngine::RenderableChunk::GetIsDirtyByBlockChange | ( | ) |
whether this chunk is made dirty by actual block changes.
int ParaEngine::RenderableChunk::GetLastBufferBytes | ( | ) |
this is usually same as GetVertexBufferBytes(), except that when we clear vertex buffer, this size remain unchanged until the chunk is reused.
It will internally call GetVertexBufferBytes() to refresh size
int ParaEngine::RenderableChunk::GetRenderFrameCount | ( | ) | const |
when this chunk should be rendered last time.
we will likely to remove old chunks when memory is small.
int ParaEngine::RenderableChunk::GetShaderID | ( | ) | const |
this determined how the vertex buffer format is.
this is -1, pWorld->GetBlockRenderMethod() is used. otherwise it is one of the BlockRenderMethod enumeration
|
static |
total number of renderable chunks in memory.
int ParaEngine::RenderableChunk::GetVertexBufferBytes | ( | ) |
get the current size of all of its vertex buffer.
int16 ParaEngine::RenderableChunk::GetViewIndex | ( | ) | const |
each chunk has a unique view index, the smaller the closer to the current view center.
bool ParaEngine::RenderableChunk::IsIntersect | ( | CShapeSphere & | sphere | ) |
whether the chunk intersect with the given sphere.
used in fast view culling.
bool ParaEngine::RenderableChunk::IsMainRenderer | ( | ) | const |
for main renderer (default to true), we will set chuck dirty to false, whenever the buffer is rebuilt.
bool ParaEngine::RenderableChunk::RebuildRenderBuffer | ( | CBlockWorld * | pWorld, |
bool | bAsyncMode | ||
) |
every frame, we will ensure some new buffer is updated, and some updated buffer is updated as well.
bAsyncMode | true to update in a separate thread. |
void ParaEngine::RenderableChunk::RebuildRenderBufferToMemory | ( | Scoped_ReadLock< BlockReadWriteLock > * | Lock_, |
int * | pnCpuYieldCount | ||
) |
call this function to generate all vertices to memory buffer.
this functions take 20-30ms to complete. Better run from another thread.
Lock_ | if this function is called from chunk builder thread, we need to pass the lock, so that we only process nMaxBlockPerStep of blocks per step and yield CPU to main render thread. |
pnCpuYieldCount | how many times we have yield CPU to writer thread. |
|
protected |
each rectangle face is 2 triangles or 4 vertices.
bool ParaEngine::RenderableChunk::ShouldRebuildRenderBuffer | ( | CBlockWorld * | pWorld, |
bool | bNewBuffer = true , |
||
bool | bUpdatedBuffer = true |
||
) |
every frame, we will ensure some new buffer is updated, and some updated buffer is updated as well.
bNewBuffer | if true, we will update buffer that has not been created yet. |
bUpdatedBuffer | if true, we will update buffer within which some light is updated. return true if the buffer is updated. and false, it is not dirty. |
void ParaEngine::RenderableChunk::WaitUntilChunkReady | ( | ) |
only used when the chunk is destroyed.
do not call this function is other cases.