default load-speed set to 4 + minor refactor
This commit is contained in:
@@ -40,18 +40,17 @@ void Lighting::clear(){
|
||||
}
|
||||
}
|
||||
|
||||
void Lighting::prebuildSkyLight(int cx, int cz){
|
||||
const Block* const* blockDefs = content->getIndices()->getBlockDefs();
|
||||
void Lighting::prebuildSkyLight(Chunk* chunk, const ContentIndices* indices){
|
||||
auto* blockDefs = indices->getBlockDefs();
|
||||
|
||||
Chunk* chunk = chunks->getChunk(cx, cz);
|
||||
int highestPoint = 0;
|
||||
for (int z = 0; z < CHUNK_D; z++){
|
||||
for (int x = 0; x < CHUNK_W; x++){
|
||||
for (int y = CHUNK_H-1;;y--){
|
||||
if (y < 0)
|
||||
break;
|
||||
voxel* vox = &(chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x]);
|
||||
const Block* block = blockDefs[vox->id];
|
||||
voxel& vox = chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x];
|
||||
const Block* block = blockDefs[vox.id];
|
||||
if (!block->skyLightPassing) {
|
||||
if (highestPoint < y)
|
||||
highestPoint = y;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define LIGHTING_LIGHTING_H_
|
||||
|
||||
class Content;
|
||||
class ContentIndices;
|
||||
class Chunk;
|
||||
class Chunks;
|
||||
class LightSolver;
|
||||
|
||||
@@ -17,10 +19,11 @@ public:
|
||||
~Lighting();
|
||||
|
||||
void clear();
|
||||
void prebuildSkyLight(int cx, int cz);
|
||||
void buildSkyLight(int cx, int cz);
|
||||
void onChunkLoaded(int cx, int cz, bool expand);
|
||||
void onBlockSet(int x, int y, int z, int id);
|
||||
|
||||
static void prebuildSkyLight(Chunk* chunk, const ContentIndices* indices);
|
||||
};
|
||||
|
||||
#endif /* LIGHTING_LIGHTING_H_ */
|
||||
|
||||
Reference in New Issue
Block a user