mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
experimental optimizations
This commit is contained in:
parent
f0fbceb0af
commit
4ea36f8996
3 changed files with 24 additions and 20 deletions
|
|
@ -93,7 +93,7 @@ void Lighting::buildSkyLight(int cx, int cz){
|
|||
solverS->solve();
|
||||
}
|
||||
|
||||
void Lighting::onChunkLoaded(int cx, int cz){
|
||||
void Lighting::onChunkLoaded(int cx, int cz, bool expand){
|
||||
const Block* const* blockDefs = content->getIndices()->getBlockDefs();
|
||||
const Chunk* chunk = chunks->getChunk(cx, cz);
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ void Lighting::onChunkLoaded(int cx, int cz){
|
|||
const Block* block = blockDefs[vox.id];
|
||||
int gx = x + cx * CHUNK_W;
|
||||
int gz = z + cz * CHUNK_D;
|
||||
if (block->emission[0] || block->emission[1] || block->emission[2]){
|
||||
if (block->rt.emissive){
|
||||
solverR->add(gx,y,gz,block->emission[0]);
|
||||
solverG->add(gx,y,gz,block->emission[1]);
|
||||
solverB->add(gx,y,gz,block->emission[2]);
|
||||
|
|
@ -113,18 +113,20 @@ void Lighting::onChunkLoaded(int cx, int cz){
|
|||
}
|
||||
}
|
||||
|
||||
for (int y = -1; y <= CHUNK_H; y++){
|
||||
for (int z = -1; z <= CHUNK_D; z++){
|
||||
for (int x = -1; x <= CHUNK_W; x++){
|
||||
if (!(x == -1 || x == CHUNK_W || z == -1 || z == CHUNK_D))
|
||||
continue;
|
||||
int gx = x + cx * CHUNK_W;
|
||||
int gz = z + cz * CHUNK_D;
|
||||
if (chunks->getLight(x,y,z)){
|
||||
solverR->add(gx,y,gz);
|
||||
solverG->add(gx,y,gz);
|
||||
solverB->add(gx,y,gz);
|
||||
solverS->add(gx,y,gz);
|
||||
if (expand) {
|
||||
for (int y = -1; y <= CHUNK_H; y++){
|
||||
for (int z = -1; z <= CHUNK_D; z++){
|
||||
for (int x = -1; x <= CHUNK_W; x++){
|
||||
if (!(x == -1 || x == CHUNK_W || z == -1 || z == CHUNK_D))
|
||||
continue;
|
||||
int gx = x + cx * CHUNK_W;
|
||||
int gz = z + cz * CHUNK_D;
|
||||
if (chunks->getLight(x,y,z)){
|
||||
solverR->add(gx,y,gz);
|
||||
solverG->add(gx,y,gz);
|
||||
solverB->add(gx,y,gz);
|
||||
solverS->add(gx,y,gz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue