voxels renderer rebuilt, WorldFiles fix
This commit is contained in:
+5
-2
@@ -3,18 +3,20 @@
|
||||
#include "../lighting/Lighting.h"
|
||||
#include "../voxels/Chunks.h"
|
||||
#include "../voxels/ChunksController.h"
|
||||
#include "../voxels/ChunksStorage.h"
|
||||
#include "../player_control.h"
|
||||
#include "../physics/Hitbox.h"
|
||||
#include "../physics/PhysicsSolver.h"
|
||||
#include "../objects/Player.h"
|
||||
|
||||
Level::Level(World* world, Player* player, Chunks* chunks, PhysicsSolver* physics) :
|
||||
Level::Level(World* world, Player* player, Chunks* chunks, ChunksStorage* chunksStorage, PhysicsSolver* physics) :
|
||||
world(world),
|
||||
player(player),
|
||||
chunks(chunks),
|
||||
chunksStorage(chunksStorage),
|
||||
physics(physics) {
|
||||
lighting = new Lighting(chunks);
|
||||
chunksController = new ChunksController(world, chunks, lighting);
|
||||
chunksController = new ChunksController(this, chunks, lighting);
|
||||
playerController = new PlayerController(this);
|
||||
}
|
||||
|
||||
@@ -24,6 +26,7 @@ Level::~Level(){
|
||||
delete player;
|
||||
delete lighting;
|
||||
delete chunksController;
|
||||
delete chunksStorage;
|
||||
delete playerController;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ class Chunks;
|
||||
class Lighting;
|
||||
class PhysicsSolver;
|
||||
class ChunksController;
|
||||
class ChunksStorage;
|
||||
class PlayerController;
|
||||
|
||||
class Level {
|
||||
@@ -14,11 +15,12 @@ public:
|
||||
World* world;
|
||||
Player* player;
|
||||
Chunks* chunks;
|
||||
ChunksStorage* chunksStorage;
|
||||
PhysicsSolver* physics;
|
||||
Lighting* lighting;
|
||||
ChunksController* chunksController;
|
||||
PlayerController* playerController;
|
||||
Level(World* world, Player* player, Chunks* chunks, PhysicsSolver* physics);
|
||||
Level(World* world, Player* player, Chunks* chunks, ChunksStorage* chunksStorage, PhysicsSolver* physics);
|
||||
~Level();
|
||||
|
||||
void update(float delta, bool interactions);
|
||||
|
||||
+10
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user