62 void QueueChunk(
int a_ChunkX,
int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallbackAfter);
135 virtual void Execute(
void)
override;
155 size_t a_NumSeedsIn,
unsigned char * a_IsSeedIn,
unsigned int * a_SeedIdxIn,
156 size_t & a_NumSeedsOut,
unsigned char * a_IsSeedOut,
unsigned int * a_SeedIdxOut
164 unsigned int a_SrcIdx,
unsigned int a_DstIdx,
165 size_t & a_NumSeedsOut,
unsigned char * a_IsSeedOut,
unsigned int * a_SeedIdxOut
178 if (!a_IsSeedOut[a_DstIdx])
180 a_IsSeedOut[a_DstIdx] =
true;
181 a_SeedIdxOut[a_NumSeedsOut++] = a_DstIdx;
std::unique_ptr< cChunkCoordCallback > m_CallbackAfter
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in...
void QueueChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_CallbackAfter)
Queues the entire chunk for lighting.
virtual void OnDisabled(void) override
Called by the ChunkMap when the ChunkStay is disabled.
unsigned char BLOCKTYPE
The datatype used by blockdata.
void ReadChunks(int a_ChunkX, int a_ChunkZ)
Prepares m_BlockTypes and m_HeightMap data; zeroes out the light arrays.
void PrepareBlockLight(void)
Uses m_BlockTypes to initialize the m_BlockLight[] data; fills in seeds for the blocklight.
cChunkStays m_PendingQueue
The ChunkStays that are waiting for load.
virtual void Execute(void) override
This is the main thread entrypoint.
HEIGHTTYPE m_MaxHeight
The highest block in the current 3x3 chunk data.
unsigned char m_IsSeed2[BlocksPerYLayer *cChunkDef::Height]
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
static const int BlocksPerYLayer
unsigned char HEIGHTTYPE
The type used by the heightmap.
void LightChunk(cLightingChunkStay &a_Item)
Lights the entire chunk.
void CalcLight(NIBBLETYPE *a_Light)
Calculates light in the light array specified, using stored seeds.
static NIBBLETYPE GetSpreadLightFalloff(BLOCKTYPE a_Type)
void CompressLight(NIBBLETYPE *a_LightArray, NIBBLETYPE *a_ChunkLight)
Compresses from 1-block-per-byte (faster calc) into 2-blocks-per-byte (MC storage): ...
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
Called when a specific chunk become available.
void PrepareSkyLight(void)
Uses m_HeightMap to initialize the m_SkyLight[] data; fills in seeds for the skylight.
size_t GetQueueLength(void)
cLightingChunkStay(cLightingThread &a_LightingThread, int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_CallbackAfter)
virtual bool OnAllChunksAvailable(void) override
Caled once all of the contained chunks are available.
virtual ~cLightingThread() override
NIBBLETYPE m_SkyLight[BlocksPerYLayer *cChunkDef::Height]
cLightingThread & m_LightingThread
void WaitForQueueEmpty(void)
Blocks until the queue is empty or the thread is terminated.
cLightingThread(cWorld &a_World)
unsigned int m_SeedIdx2[BlocksPerYLayer *cChunkDef::Height]
cCriticalSection m_CS
The mutex to protect m_Queue and m_PendingQueue.
NIBBLETYPE m_BlockLight[BlocksPerYLayer *cChunkDef::Height]
cChunkStays m_Queue
The ChunkStays that are loaded and are waiting to be lit.
unsigned char m_IsSeed1[BlocksPerYLayer *cChunkDef::Height]
BLOCKTYPE m_BlockTypes[BlocksPerYLayer *cChunkDef::Height]
unsigned int m_SeedIdx1[BlocksPerYLayer *cChunkDef::Height]
void CalcLightStep(NIBBLETYPE *a_Light, size_t a_NumSeedsIn, unsigned char *a_IsSeedIn, unsigned int *a_SeedIdxIn, size_t &a_NumSeedsOut, unsigned char *a_IsSeedOut, unsigned int *a_SeedIdxOut)
Does one step in the light calculation - one seed propagation and seed recalculation.
std::list< cChunkStay * > cChunkStays
void PropagateLight(NIBBLETYPE *a_Light, unsigned int a_SrcIdx, unsigned int a_DstIdx, size_t &a_NumSeedsOut, unsigned char *a_IsSeedOut, unsigned int *a_SeedIdxOut)
void QueueChunkStay(cLightingChunkStay &a_ChunkStay)
Queues a chunkstay that has all of its chunks loaded.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
HEIGHTTYPE m_HeightMap[BlocksPerYLayer]