|
My Project
|
Chunk is a 16*16*16 inside a region. More...
#include <BlockChunk.h>
Public Member Functions | |
| BlockChunk (uint16_t nPackedChunkId, BlockRegion *pRegion) | |
| void | ReserveBlocks (int nCount) |
| int | GetTotalBytes () |
| get total number of memory bytes that this chunk occupies. More... | |
| bool | CanBlockSeeTheSkyWS (uint16 x, uint16 y, uint16 z) |
| blocks higher than the highest solid block in the height map can sky. More... | |
| uint32 | GetBlockCount () |
| bool | IsDirty () const |
| void | SetDirty (bool val) |
| set dirty by block changes in this chunk | |
| void | SetDirtyByNeighbor () |
| set dirty by neighbor block change. More... | |
| void | SetLightDirty () |
| bool | IsDirtyByNeighbor () |
| whether this chunk is made dirty by neighbor other than content change. More... | |
| bool | IsDirtyByLight () |
| whether this chunk is made dirty by light than content change. More... | |
| bool | IsDirtyByBlockChange () |
| whether this chunk is made dirty by actual block changes. More... | |
| void | SetLightingInitialized (bool bInitialized) |
| bool | IsLightingInitialized () |
| void | Reset () |
| Block & | GetBlockByIndex (uint16_t nBlockIndex) |
| the caller should ensure that nBlockIndex is valid. More... | |
| Block * | GetBlock (uint16_t nBlockIndex) |
| get block More... | |
| int | LoadBlocks (const std::vector< uint16_t > &blockIndices, BlockTemplate *pTemplate) |
| load one or more blocks of a given block type. More... | |
| Uint16x3 | GetBlockPosRs (uint16 nBlockIndex) |
| void | UpdateHeightMapAtLoadTime (uint16_t nBlockIndex, bool isTransparent) |
| void | LoadBlock (uint16_t nBlockIndex, BlockTemplate *pTemplate) |
| void | SetBlockTemplate (uint16_t nBlockIndex, BlockTemplate *pTemplate) |
| BlockTemplate * | GetBlockTemplate (uint16_t nBlockIndex) |
| void | SetBlockData (uint16_t nBlockIndex, uint32 nData) |
| void | SetBlock (uint16_t nBlockIndex, BlockTemplate *pTemplate, uint32 nData) |
| set block template and data | |
| CBlockWorld * | GetBlockWorld () |
| get container block world | |
| bool | SetBlockToAir (Uint16x3 &blockId_r) |
| set block to empty More... | |
| bool | RemoveLight (Uint16x3 &blockId_r) |
| remove light More... | |
| void | AddLight (Uint16x3 &blockId_r) |
| add light | |
| void | AddLight (uint16 nPackedBlockID) |
| LightData * | GetLightData (uint16_t nIndex) |
| get the light data. More... | |
| bool | IsInfluenceBySunLight () |
| is any block influenced by sun light. More... | |
| bool | IsVisibleBlock (int32_t index, Block *pBlock=NULL) |
| void | QueryNeighborBlockData (const Uint16x3 &blockId_cs, Block **pBlockData, int nFrom=0, int nTo=26) |
| bool | IsNearbyChunksLoaded () |
| return true if the nearby 4 chunk columns have been generated (and loaded) | |
| std::vector< Uint16x3 > | refreshBlockVisible (uint16_t blockTemplateId) |
| return the blocks need to re notification | |
| void | ClearAllLight () |
Static Public Member Functions | |
| static int | GetTotalChunksInMemory () |
Public Attributes | |
| std::vector< int16_t > | m_blockIndices |
| std::set< uint16_t > | m_lightBlockIndices |
| std::vector< LightData > | m_lightmapArray |
| 16*16*16 of light data (fixed sized at initialization) | |
| Uint16x3 | m_minBlockId_ws |
| Uint16x3 | m_minBlockId_rs |
| Uint16x3 | m_chunkId_rs |
Static Public Attributes | |
| static int | s_total_chunks = 0 |
| total number of chunks | |
Protected Member Functions | |
| bool | IsBoundaryChunk () const |
| void | SetBoundaryChunk (bool val) |
| int16 | FindBlock (BlockTemplate *pTemplate) |
| find block in the m_blocks pool by template. More... | |
| int16 | FindBlock (BlockTemplate *pTemplate, uint32 nData) |
| void | SetBlockEmpty (uint16_t nBlockIndex, Block &block) |
| bool | RecycleBlock (uint16 nIndex, Block &block) |
| Block * | CreateBlock (uint16_t nBlockIndex) |
Protected Attributes | |
| std::vector< Block > | m_blocks |
| uint32 | m_nDirty |
| uint16 | m_isBoundaryChunk |
| uint16 | m_emptyBlockSlotIndex |
| BlockRegion * | m_ownerBlockRegion |
| int16_t | m_packedChunkID |
Chunk is a 16*16*16 inside a region.
| bool ParaEngine::BlockChunk::CanBlockSeeTheSkyWS | ( | uint16 | x, |
| uint16 | y, | ||
| uint16 | z | ||
| ) |
blocks higher than the highest solid block in the height map can sky.
Note, the top most opaque block can not see the sky.
| x,y,z | in world space |
|
protected |
find block in the m_blocks pool by template.
return -1 if not found.
| Block * ParaEngine::BlockChunk::GetBlock | ( | uint16_t | nBlockIndex | ) |
get block
| nBlockIndex | [0,4096) |
| Block & ParaEngine::BlockChunk::GetBlockByIndex | ( | uint16_t | nBlockIndex | ) |
the caller should ensure that nBlockIndex is valid.
| LightData * ParaEngine::BlockChunk::GetLightData | ( | uint16_t | nIndex | ) |
get the light data.
may return NULL.
| nIndex | parameters |
| int ParaEngine::BlockChunk::GetTotalBytes | ( | ) |
get total number of memory bytes that this chunk occupies.
for memory algorithm or stats.
| bool ParaEngine::BlockChunk::IsDirtyByBlockChange | ( | ) |
whether this chunk is made dirty by actual block changes.
| bool ParaEngine::BlockChunk::IsDirtyByLight | ( | ) |
whether this chunk is made dirty by light than content change.
| bool ParaEngine::BlockChunk::IsDirtyByNeighbor | ( | ) |
whether this chunk is made dirty by neighbor other than content change.
| bool ParaEngine::BlockChunk::IsInfluenceBySunLight | ( | ) |
is any block influenced by sun light.
| int ParaEngine::BlockChunk::LoadBlocks | ( | const std::vector< uint16_t > & | blockIndices, |
| BlockTemplate * | pTemplate | ||
| ) |
load one or more blocks of a given block type.
usually called when chunk is loaded from file return the number of blocks created.
| void ParaEngine::BlockChunk::QueryNeighborBlockData | ( | const Uint16x3 & | blockId_cs, |
| Block ** | pBlockData, | ||
| int | nFrom = 0, |
||
| int | nTo = 26 |
||
| ) |
| pBlockData | Block* neighborBlocks[27] depending on nFrom, nTo; |
| nFrom,nTo | default to query all 27 neighbor. Other frequently used ones are 1,6 (for six adjacent ones) |
| bool ParaEngine::BlockChunk::RemoveLight | ( | Uint16x3 & | blockId_r | ) |
remove light
| blockId_r | region space |
| bool ParaEngine::BlockChunk::SetBlockToAir | ( | Uint16x3 & | blockId_r | ) |
set block to empty
| blockId_r | region space |
| void ParaEngine::BlockChunk::SetDirtyByNeighbor | ( | ) |
set dirty by neighbor block change.
1.8.12