mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
make chunk lightmap optional
This commit is contained in:
parent
64f7c19766
commit
5250c748be
12 changed files with 103 additions and 73 deletions
|
|
@ -115,9 +115,10 @@ ubyte Chunks::getLight(int32_t x, int32_t y, int32_t z, int channel) const {
|
|||
if (chunk == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
assert(chunk->lightmap != nullptr);
|
||||
int lx = x - cx * CHUNK_W;
|
||||
int lz = z - cz * CHUNK_D;
|
||||
return chunk->lightmap.get(lx, y, lz, channel);
|
||||
return chunk->lightmap->get(lx, y, lz, channel);
|
||||
}
|
||||
|
||||
light_t Chunks::getLight(int32_t x, int32_t y, int32_t z) const {
|
||||
|
|
@ -135,9 +136,10 @@ light_t Chunks::getLight(int32_t x, int32_t y, int32_t z) const {
|
|||
if (chunk == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
assert(chunk->lightmap != nullptr);
|
||||
int lx = x - cx * CHUNK_W;
|
||||
int lz = z - cz * CHUNK_D;
|
||||
return chunk->lightmap.get(lx, y, lz);
|
||||
return chunk->lightmap->get(lx, y, lz);
|
||||
}
|
||||
|
||||
Chunk* Chunks::getChunkByVoxel(int32_t x, int32_t y, int32_t z) const {
|
||||
|
|
@ -373,7 +375,8 @@ void Chunks::getVoxels(VoxelsVolume& volume, bool backlight) const {
|
|||
}
|
||||
} else {
|
||||
const voxel* cvoxels = chunk->voxels;
|
||||
const light_t* clights = chunk->lightmap.getLights();
|
||||
const light_t* clights =
|
||||
chunk->lightmap ? chunk->lightmap->getLights() : nullptr;
|
||||
for (int ly = y; ly < y + h; ly++) {
|
||||
for (int lz = std::max(z, cz * CHUNK_D);
|
||||
lz < std::min(z + d, (cz + 1) * CHUNK_D);
|
||||
|
|
@ -390,7 +393,8 @@ void Chunks::getVoxels(VoxelsVolume& volume, bool backlight) const {
|
|||
CHUNK_D
|
||||
);
|
||||
voxels[vidx] = cvoxels[cidx];
|
||||
light_t light = clights[cidx];
|
||||
light_t light = clights ? clights[cidx]
|
||||
: Lightmap::SUN_LIGHT_ONLY;
|
||||
if (backlight) {
|
||||
const auto block =
|
||||
indices.blocks.get(voxels[vidx].id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue