voxels renderer rebuilt, WorldFiles fix

This commit is contained in:
MihailRis
2023-11-02 13:23:52 +03:00
committed by GitHub
parent 0576316282
commit 754c5b80d0
44 changed files with 1141 additions and 524 deletions
+10 -4
View File
@@ -1,13 +1,18 @@
#include "World.h"
#include <memory>
#include "Level.h"
#include "../files/WorldFiles.h"
#include "../voxels/Chunk.h"
#include "../voxels/Chunks.h"
#include "Level.h"
#include "../voxels/ChunksStorage.h"
#include "../objects/Player.h"
#include "../physics/PhysicsSolver.h"
#include "../window/Camera.h"
using std::shared_ptr;
World::World(std::string name, std::string directory, int seed) : name(name), seed(seed) {
wfile = new WorldFiles(directory, REGION_VOL * (CHUNK_VOL * 2 + 8));
}
@@ -20,10 +25,10 @@ void World::write(Level* level) {
Chunks* chunks = level->chunks;
for (unsigned int i = 0; i < chunks->volume; i++) {
Chunk* chunk = chunks->chunks[i];
shared_ptr<Chunk> chunk = chunks->chunks[i];
if (chunk == nullptr || !chunk->isUnsaved())
continue;
wfile->put((const char*)chunk->voxels, chunk->x, chunk->z);
wfile->put((const ubyte*)chunk->voxels, chunk->x, chunk->z);
}
wfile->write();
@@ -31,7 +36,8 @@ void World::write(Level* level) {
}
Level* World::loadLevel(Player* player) {
Level* level = new Level(this, player, new Chunks(56, 56, 0, 0), new PhysicsSolver(vec3(0, -19.6f, 0)));
ChunksStorage* storage = new ChunksStorage();
Level* level = new Level(this, player, new Chunks(16, 16, 0, 0), storage, new PhysicsSolver(vec3(0, -19.6f, 0)));
wfile->readPlayer(player);
Camera* camera = player->camera;