First look at 3D biome support

This commit is contained in:
Dylan K. Taylor
2023-01-17 21:41:30 +00:00
parent 3a13f5cf5f
commit 7abfc46567
19 changed files with 319 additions and 243 deletions

View File

@ -40,6 +40,7 @@ class SubChunk{
public function __construct(
private int $emptyBlockId,
private array $blockLayers,
private PalettedBlockArray $biomes,
private ?LightArray $skyLight = null,
private ?LightArray $blockLight = null
){}
@ -102,6 +103,8 @@ class SubChunk{
return null; //highest block not in this subchunk
}
public function getBiomeArray() : PalettedBlockArray{ return $this->biomes; }
public function getBlockSkyLightArray() : LightArray{
return $this->skyLight ??= LightArray::fill(0);
}
@ -137,6 +140,7 @@ class SubChunk{
unset($this->blockLayers[$k]);
}
$this->blockLayers = array_values($this->blockLayers);
$this->biomes->collectGarbage();
if($this->skyLight !== null && $this->skyLight->isUniform(0)){
$this->skyLight = null;
@ -150,6 +154,7 @@ class SubChunk{
$this->blockLayers = array_map(function(PalettedBlockArray $array) : PalettedBlockArray{
return clone $array;
}, $this->blockLayers);
$this->biomes = clone $this->biomes;
if($this->skyLight !== null){
$this->skyLight = clone $this->skyLight;