mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 00:09:39 +00:00
Major performance improvement to basic sky light calculation
this was degraded whenever it was I decided to make chunks always be allocated. This commit uses a fast path for light filling in subchunks which are completely clear of the heightmap, which returns the performance back to its old fast levels.
This commit is contained in:
parent
101dc1e1d7
commit
b81cc671e9
@ -308,11 +308,18 @@ class Chunk{
|
||||
* TODO: fast adjacent light spread
|
||||
*/
|
||||
public function populateSkyLight(\SplFixedArray $lightFilters) : void{
|
||||
$this->setAllBlockSkyLight(0);
|
||||
$highestHeightMap = max($this->heightMap->getValues());
|
||||
$lowestFullyLitSubChunk = ($highestHeightMap >> 4) + (($highestHeightMap & 0xf) !== 0 ? 1 : 0);
|
||||
for($y = 0; $y < $lowestFullyLitSubChunk; $y++){
|
||||
$this->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill(0));
|
||||
}
|
||||
for($y = $lowestFullyLitSubChunk, $yMax = $this->subChunks->count(); $y < $yMax; $y++){
|
||||
$this->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill(15));
|
||||
}
|
||||
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$y = ($this->subChunks->count() * 16) - 1;
|
||||
$y = ($lowestFullyLitSubChunk * 16) - 1;
|
||||
$heightMap = $this->getHeightMap($x, $z);
|
||||
|
||||
for(; $y >= $heightMap; --$y){
|
||||
|
Loading…
x
Reference in New Issue
Block a user