Revert "Remove hacks for triggering adjacent light refill"

This reverts commit 1dca9074d5f087d15f8d30d2941150fe51617489.
This change introduced performance issues with transparent blocks.
This commit is contained in:
Dylan K. Taylor 2019-03-10 19:46:23 +00:00
parent c266f86b1b
commit ae9f57ac28
2 changed files with 12 additions and 10 deletions

View File

@ -1492,8 +1492,8 @@ class Level implements ChunkManager, Metadatable{
for($i = $y; $i >= $newHeightMap; --$i){ for($i = $y; $i >= $newHeightMap; --$i){
$this->skyLightUpdate->setAndUpdateLight($x, $i, $z, 15); $this->skyLightUpdate->setAndUpdateLight($x, $i, $z, 15);
} }
}else{ //No heightmap change, block changed "underground" - trigger recalculation from surroundings }else{ //No heightmap change, block changed "underground"
$this->skyLightUpdate->setAndUpdateLight($x, $y, $z, 0); $this->skyLightUpdate->setAndUpdateLight($x, $y, $z, max(0, $this->getHighestAdjacentBlockSkyLight($x, $y, $z) - BlockFactory::$lightFilter[($source->getId() << 4) | $source->getMeta()]));
} }
$this->timings->doBlockSkyLightUpdates->stopTiming(); $this->timings->doBlockSkyLightUpdates->stopTiming();
@ -1523,10 +1523,12 @@ class Level implements ChunkManager, Metadatable{
$this->timings->doBlockLightUpdates->startTiming(); $this->timings->doBlockLightUpdates->startTiming();
$block = $this->getBlockAt($x, $y, $z); $block = $this->getBlockAt($x, $y, $z);
$newLevel = max($block->getLightLevel(), $this->getHighestAdjacentBlockLight($x, $y, $z) - BlockFactory::$lightFilter[($block->getId() << 4) | $block->getMeta()]);
if($this->blockLightUpdate === null){ if($this->blockLightUpdate === null){
$this->blockLightUpdate = new BlockLightUpdate($this); $this->blockLightUpdate = new BlockLightUpdate($this);
} }
$this->blockLightUpdate->setAndUpdateLight($x, $y, $z, $block->getLightLevel()); $this->blockLightUpdate->setAndUpdateLight($x, $y, $z, $newLevel);
$this->timings->doBlockLightUpdates->stopTiming(); $this->timings->doBlockLightUpdates->stopTiming();
} }

View File

@ -72,13 +72,13 @@ abstract class LightUpdate{
if($oldLevel !== $newLevel){ if($oldLevel !== $newLevel){
$this->setLight($x, $y, $z, $newLevel); $this->setLight($x, $y, $z, $newLevel);
} if($oldLevel < $newLevel){ //light increased
if($newLevel > $oldLevel){ //light increased $this->spreadVisited[$blockHash] = true;
$this->spreadVisited[$blockHash] = true; $this->spreadQueue->enqueue([$x, $y, $z]);
$this->spreadQueue->enqueue([$x, $y, $z]); }else{ //light removed
}elseif($newLevel < 15){ //light removed or stayed the same, force recheck nearby environment $this->removalVisited[$blockHash] = true;
$this->removalVisited[$blockHash] = true; $this->removalQueue->enqueue([$x, $y, $z, $oldLevel]);
$this->removalQueue->enqueue([$x, $y, $z, $oldLevel]); }
} }
} }
} }