mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 13:14:54 +00:00
Small optimization to light propagation
This commit is contained in:
parent
8cca8e1256
commit
6d7b76f356
@ -76,7 +76,7 @@ abstract class LightUpdate{
|
|||||||
$this->setLight($x, $y, $z, $newLevel);
|
$this->setLight($x, $y, $z, $newLevel);
|
||||||
if($oldLevel < $newLevel){ //light increased
|
if($oldLevel < $newLevel){ //light increased
|
||||||
$this->spreadVisited[$index] = true;
|
$this->spreadVisited[$index] = true;
|
||||||
$this->spreadQueue->enqueue([$x, $y, $z]);
|
$this->spreadQueue->enqueue([$x, $y, $z, $newLevel]);
|
||||||
}else{ //light removed
|
}else{ //light removed
|
||||||
$this->removalVisited[$index] = true;
|
$this->removalVisited[$index] = true;
|
||||||
$this->removalQueue->enqueue([$x, $y, $z, $oldLevel]);
|
$this->removalQueue->enqueue([$x, $y, $z, $oldLevel]);
|
||||||
@ -106,12 +106,7 @@ abstract class LightUpdate{
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(!$this->spreadQueue->isEmpty()){
|
while(!$this->spreadQueue->isEmpty()){
|
||||||
list($x, $y, $z) = $this->spreadQueue->dequeue();
|
list($x, $y, $z, $newAdjacentLight) = $this->spreadQueue->dequeue();
|
||||||
|
|
||||||
$newAdjacentLight = $this->getLight($x, $y, $z);
|
|
||||||
if($newAdjacentLight <= 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$points = [
|
$points = [
|
||||||
[$x + 1, $y, $z],
|
[$x + 1, $y, $z],
|
||||||
@ -146,7 +141,7 @@ abstract class LightUpdate{
|
|||||||
}elseif($current >= $oldAdjacentLevel){
|
}elseif($current >= $oldAdjacentLevel){
|
||||||
if(!isset($this->spreadVisited[$index = Level::blockHash($x, $y, $z)])){
|
if(!isset($this->spreadVisited[$index = Level::blockHash($x, $y, $z)])){
|
||||||
$this->spreadVisited[$index] = true;
|
$this->spreadVisited[$index] = true;
|
||||||
$this->spreadQueue->enqueue([$x, $y, $z]);
|
$this->spreadQueue->enqueue([$x, $y, $z, $current]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +156,7 @@ abstract class LightUpdate{
|
|||||||
if(!isset($this->spreadVisited[$index = Level::blockHash($x, $y, $z)])){
|
if(!isset($this->spreadVisited[$index = Level::blockHash($x, $y, $z)])){
|
||||||
$this->spreadVisited[$index] = true;
|
$this->spreadVisited[$index] = true;
|
||||||
if($potentialLight > 1){
|
if($potentialLight > 1){
|
||||||
$this->spreadQueue->enqueue([$x, $y, $z]);
|
$this->spreadQueue->enqueue([$x, $y, $z, $potentialLight]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user