mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 18:09:46 +00:00
Merge pull request #852 from MihailRis/refactor-world-renderer
update world renderer (part 1)
This commit is contained in:
commit
33053f07ed
45 changed files with 737 additions and 593 deletions
|
|
@ -29,16 +29,16 @@ public:
|
|||
voxel voxels[CHUNK_VOL] {};
|
||||
std::shared_ptr<Lightmap> lightmap;
|
||||
struct {
|
||||
bool modified : 1;
|
||||
bool ready : 1;
|
||||
bool loaded : 1;
|
||||
bool lighted : 1;
|
||||
bool unsaved : 1;
|
||||
bool loadedLights : 1;
|
||||
bool entities : 1;
|
||||
bool blocksData : 1;
|
||||
bool dirtyHeights : 1;
|
||||
bool inventoriesRemoved : 1;
|
||||
bool modified : 1; // is chunk mesh should be updated
|
||||
bool ready : 1; // is chunk ready for modifications (loaded / generated)
|
||||
bool loaded : 1; // was chunk loaded from region
|
||||
bool lighted : 1; // is lights built (chunk ready to be visualized)
|
||||
bool unsaved : 1; // does chunk contain unsaved changes
|
||||
bool loadedLights : 1; // was lights loaded from cache
|
||||
bool entities : 1; // does chunk contain entities list changes
|
||||
bool blocksData : 1; // does chunk contain block fields changes
|
||||
bool dirtyHeights : 1; // is chunk bottom, top should be recalculated
|
||||
bool inventoriesRemoved : 1; // was block inventories removed since the last save
|
||||
} flags {};
|
||||
|
||||
uint64_t lastRandomTickId = -1;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ std::shared_ptr<Chunk> GlobalChunks::create(int x, int z, bool lighting) {
|
|||
chunks_pool.create(x, z, lighting ? lightmaps_pool.create() : nullptr);
|
||||
chunksMap[keyfrom(x, z)] = chunk;
|
||||
|
||||
World& world = *level.getWorld();
|
||||
World& world = level.getWorld();
|
||||
auto& regions = world.wfile.get()->getRegions();
|
||||
|
||||
if (regions.getVoxels(chunk->x, chunk->z, voxelDataBuffer.get())) {
|
||||
|
|
@ -197,7 +197,7 @@ void GlobalChunks::save(Chunk* chunk) {
|
|||
if (!entities.empty()) {
|
||||
chunk->flags.entities = true;
|
||||
}
|
||||
level.getWorld()->wfile->getRegions().put(
|
||||
level.getWorld().wfile->getRegions().put(
|
||||
chunk,
|
||||
chunk->flags.entities ? json::to_binary(root, true)
|
||||
: std::vector<ubyte>()
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public:
|
|||
return lights.get();
|
||||
}
|
||||
|
||||
inline blockid_t pickBlockId(int bx, int by, int bz) const {
|
||||
blockid_t pickBlockId(int bx, int by, int bz) const {
|
||||
if (bx < x || by < y || bz < z || bx >= x + w || by >= y + h ||
|
||||
bz >= z + d) {
|
||||
return BLOCK_VOID;
|
||||
|
|
@ -75,7 +75,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
inline voxel pickBlock(int bx, int by, int bz) const {
|
||||
voxel pickBlock(int bx, int by, int bz) const {
|
||||
if (bx < x || by < y || bz < z || bx >= x + w || by >= y + h ||
|
||||
bz >= z + d) {
|
||||
return {BLOCK_VOID, {}};
|
||||
|
|
@ -83,7 +83,7 @@ public:
|
|||
return voxels[vox_index(bx - x, by - y, bz - z, w, d)];
|
||||
}
|
||||
|
||||
inline light_t pickLight(int bx, int by, int bz) const {
|
||||
light_t pickLight(int bx, int by, int bz) const {
|
||||
if (bx < x || by < y || bz < z || bx >= x + w || by >= y + h ||
|
||||
bz >= z + d) {
|
||||
return 0;
|
||||
|
|
@ -103,10 +103,10 @@ private:
|
|||
template <int w, int h, int d>
|
||||
class StaticVoxelsVolume {
|
||||
public:
|
||||
static inline constexpr size_t size = w * h * d;
|
||||
static inline constexpr int width = w;
|
||||
static inline constexpr int height = h;
|
||||
static inline constexpr int depth = d;
|
||||
static constexpr size_t size = w * h * d;
|
||||
static constexpr int width = w;
|
||||
static constexpr int height = h;
|
||||
static constexpr int depth = d;
|
||||
|
||||
StaticVoxelsVolume()
|
||||
: StaticVoxelsVolume(0, 0, 0) {}
|
||||
|
|
@ -142,7 +142,7 @@ public:
|
|||
return lights;
|
||||
}
|
||||
|
||||
inline blockid_t pickBlockId(uint bx, uint by, uint bz) const {
|
||||
blockid_t pickBlockId(uint bx, uint by, uint bz) const {
|
||||
bx -= x;
|
||||
by -= y;
|
||||
bz -= z;
|
||||
|
|
@ -153,7 +153,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
inline const voxel& pickBlock(uint bx, uint by, uint bz) const {
|
||||
const voxel& pickBlock(uint bx, uint by, uint bz) const {
|
||||
bx -= x;
|
||||
by -= y;
|
||||
bz -= z;
|
||||
|
|
@ -164,7 +164,7 @@ public:
|
|||
return voxels[vox_index(bx, by, bz, w, d)];
|
||||
}
|
||||
|
||||
inline light_t pickLight(uint bx, uint by, uint bz) const {
|
||||
light_t pickLight(uint bx, uint by, uint bz) const {
|
||||
bx -= x;
|
||||
by -= y;
|
||||
bz -= z;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue