mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add block.get_field(...), block.set_field(...)
This commit is contained in:
parent
8d89e06ac5
commit
fc99343fb5
5 changed files with 169 additions and 28 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "data/StructLayout.hpp"
|
||||
#include "coders/byte_utils.hpp"
|
||||
#include "coders/json.hpp"
|
||||
#include "content/Content.hpp"
|
||||
|
|
@ -370,6 +371,7 @@ void Chunks::set(
|
|||
}
|
||||
int lx = x - cx * CHUNK_W;
|
||||
int lz = z - cz * CHUNK_D;
|
||||
size_t index = vox_index(lx, y, lz);
|
||||
|
||||
// block finalization
|
||||
voxel& vox = chunk->voxels[(y * CHUNK_D + lz) * CHUNK_W + lx];
|
||||
|
|
@ -380,6 +382,9 @@ void Chunks::set(
|
|||
if (prevdef.rt.extended && !vox.state.segment) {
|
||||
eraseSegments(prevdef, vox.state, gx, y, gz);
|
||||
}
|
||||
if (prevdef.dataStruct) {
|
||||
chunk->blocksMetadata.free(chunk->blocksMetadata.find(index));
|
||||
}
|
||||
|
||||
// block initialization
|
||||
const auto& newdef = indices->blocks.require(id);
|
||||
|
|
@ -389,6 +394,9 @@ void Chunks::set(
|
|||
if (!state.segment && newdef.rt.extended) {
|
||||
repairSegments(newdef, state, gx, y, gz);
|
||||
}
|
||||
if (newdef.dataStruct) {
|
||||
chunk->blocksMetadata.allocate(index, newdef.dataStruct->size());
|
||||
}
|
||||
|
||||
if (y < chunk->bottom)
|
||||
chunk->bottom = y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue