refactor Content

This commit is contained in:
MihailRis
2024-06-25 22:37:53 +03:00
parent f3c5afa1ab
commit ee9f1639e9
25 changed files with 180 additions and 209 deletions
+3 -2
View File
@@ -40,7 +40,7 @@ void ChunksStorage::remove(int x, int z) {
static void verifyLoadedChunk(ContentIndices* indices, Chunk* chunk) {
for (size_t i = 0; i < CHUNK_VOL; i++) {
blockid_t id = chunk->voxels[i].id;
if (indices->getBlockDef(id) == nullptr) {
if (indices->blocks.get(id) == nullptr) {
auto logline = logger.error();
logline << "corruped block detected at " << i << " of chunk ";
logline << chunk->x << "x" << chunk->z;
@@ -79,6 +79,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
}
// reduce nesting on next modification
// 25.06.2024: not now
void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
const Content* content = level->content;
auto indices = content->getIndices();
@@ -137,7 +138,7 @@ void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
voxels[vidx] = cvoxels[cidx];
light_t light = clights[cidx];
if (backlight) {
const Block* block = indices->getBlockDef(voxels[vidx].id);
auto block = indices->blocks.get(voxels[vidx].id);
if (block->lightPassing) {
light = Lightmap::combine(
min(15, Lightmap::extract(light, 0)+1),