PocketMine-MP/src/world/light/LightPropagationContext.php
Dylan K. Taylor ee26d6d570
LightUpdate: avoid trying to propagate light into nodes with higher light levels
Track which direction the current node's light came from, and don't
check it again when we check the current node's adjacent blocks.

e.g. if this node was the eastern neighbour of a light source, we don't
need to check this node's western neighbour, as we already know it has
a higher light level than our own.

This improves performance of basic light spread in a void by about 6%,
which isn't a huge amount, but it's something.

I've yet to explore whether light removal could also benefit from this
change.
2023-10-09 17:06:02 +01:00

49 lines
1.3 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\light;
final class LightPropagationContext{
/** @phpstan-var \SplQueue<array{int, int, int}> */
public \SplQueue $spreadQueue;
/**
* @var int[]|true[]
* @phpstan-var array<int, int|true>
*/
public array $spreadVisited = [];
/** @phpstan-var \SplQueue<array{int, int, int, int}> */
public \SplQueue $removalQueue;
/**
* @var true[]
* @phpstan-var array<int, true>
*/
public array $removalVisited = [];
public function __construct(){
$this->removalQueue = new \SplQueue();
$this->spreadQueue = new \SplQueue();
}
}