mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
reduce Chunks.getChunkByVoxel calls in LightSolver
This commit is contained in:
parent
117199a3ec
commit
bf7732f68a
4 changed files with 47 additions and 27 deletions
|
|
@ -167,10 +167,10 @@ void Lighting::onChunkLoaded(int cx, int cz, bool expand) {
|
|||
}
|
||||
}
|
||||
}
|
||||
solverR.solve();
|
||||
solverG.solve();
|
||||
solverB.solve();
|
||||
solverS.solve();
|
||||
solverR.solve(chunk);
|
||||
solverG.solve(chunk);
|
||||
solverB.solve(chunk);
|
||||
solverS.solve(chunk);
|
||||
}
|
||||
|
||||
void Lighting::onBlockSet(int x, int y, int z, blockid_t id){
|
||||
|
|
@ -180,9 +180,10 @@ void Lighting::onBlockSet(int x, int y, int z, blockid_t id){
|
|||
solverB->remove(x,y,z);
|
||||
|
||||
if (id == 0){
|
||||
solverR->solve();
|
||||
solverG->solve();
|
||||
solverB->solve();
|
||||
auto chunk = chunks.getChunkByVoxel(glm::ivec3{x, y, z});
|
||||
solverR->solve(chunk);
|
||||
solverG->solve(chunk);
|
||||
solverB->solve(chunk);
|
||||
if (chunks.getLight(x,y+1,z, 3) == 0xF){
|
||||
for (int i = y; i >= 0; i--){
|
||||
voxel* vox = chunks.get(x,i,z);
|
||||
|
|
@ -197,11 +198,12 @@ void Lighting::onBlockSet(int x, int y, int z, blockid_t id){
|
|||
solverR->add(x-1,y,z); solverG->add(x-1,y,z); solverB->add(x-1,y,z); solverS->add(x-1,y,z);
|
||||
solverR->add(x,y,z+1); solverG->add(x,y,z+1); solverB->add(x,y,z+1); solverS->add(x,y,z+1);
|
||||
solverR->add(x,y,z-1); solverG->add(x,y,z-1); solverB->add(x,y,z-1); solverS->add(x,y,z-1);
|
||||
solverR->solve();
|
||||
solverG->solve();
|
||||
solverB->solve();
|
||||
solverS->solve();
|
||||
solverR->solve(chunk);
|
||||
solverG->solve(chunk);
|
||||
solverB->solve(chunk);
|
||||
solverS->solve(chunk);
|
||||
} else {
|
||||
auto chunk = chunks.getChunkByVoxel(glm::ivec3{x, y, z});
|
||||
if (!block.skyLightPassing){
|
||||
solverS->remove(x,y,z);
|
||||
for (int i = y-1; i >= 0; i--){
|
||||
|
|
@ -210,19 +212,19 @@ void Lighting::onBlockSet(int x, int y, int z, blockid_t id){
|
|||
break;
|
||||
}
|
||||
}
|
||||
solverS->solve();
|
||||
solverS->solve(chunk);
|
||||
}
|
||||
solverR->solve();
|
||||
solverG->solve();
|
||||
solverB->solve();
|
||||
solverR->solve(chunk);
|
||||
solverG->solve(chunk);
|
||||
solverB->solve(chunk);
|
||||
|
||||
if (block.emission[0] || block.emission[1] || block.emission[2]){
|
||||
solverR->add(x,y,z,block.emission[0]);
|
||||
solverG->add(x,y,z,block.emission[1]);
|
||||
solverB->add(x,y,z,block.emission[2]);
|
||||
solverR->solve();
|
||||
solverG->solve();
|
||||
solverB->solve();
|
||||
solverR->solve(chunk);
|
||||
solverG->solve(chunk);
|
||||
solverB->solve(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue