move WorldGenerator to world/generator
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include "world/LevelEvents.hpp"
|
||||
#include "Block.hpp"
|
||||
#include "Chunk.hpp"
|
||||
#include "WorldGenerator.hpp"
|
||||
#include "voxel.hpp"
|
||||
|
||||
Chunks::Chunks(
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#include "WorldGenerator.hpp"
|
||||
|
||||
#include "content/Content.hpp"
|
||||
#include "Block.hpp"
|
||||
#include "Chunk.hpp"
|
||||
#include "voxel.hpp"
|
||||
#include "world/generator/GeneratorDef.hpp"
|
||||
|
||||
WorldGenerator::WorldGenerator(
|
||||
const GeneratorDef& def,
|
||||
const Content* content
|
||||
) : def(def), content(content) {
|
||||
}
|
||||
|
||||
#include "util/timeutil.hpp"
|
||||
void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ, int seed) {
|
||||
timeutil::ScopeLogTimer log(555);
|
||||
auto heightmap = def.script->generateHeightmap(
|
||||
{chunkX*CHUNK_W, chunkZ*CHUNK_D}, {CHUNK_W, CHUNK_D}
|
||||
);
|
||||
auto& baseStone = content->blocks.require("base:stone");
|
||||
auto& baseWater = content->blocks.require("base:water");
|
||||
for (uint z = 0; z < CHUNK_D; z++) {
|
||||
for (uint x = 0; x < CHUNK_W; x++) {
|
||||
auto height = heightmap->getValues()[z * CHUNK_W + x] * 255 + 10;
|
||||
for (uint y = 0; y < CHUNK_H; y++) {
|
||||
voxels[vox_index(x, y, z)].state = {};
|
||||
if (y > height) {
|
||||
voxels[vox_index(x, y, z)].id = y <= 64 ? baseWater.rt.id : 0;
|
||||
} else {
|
||||
voxels[vox_index(x, y, z)].id = baseStone.rt.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "typedefs.hpp"
|
||||
|
||||
struct voxel;
|
||||
class Content;
|
||||
struct GeneratorDef;
|
||||
|
||||
class WorldGenerator {
|
||||
const GeneratorDef& def;
|
||||
const Content* content;
|
||||
public:
|
||||
WorldGenerator(
|
||||
const GeneratorDef& def,
|
||||
const Content* content
|
||||
);
|
||||
virtual ~WorldGenerator() = default;
|
||||
|
||||
virtual void generate(voxel* voxels, int x, int z, int seed);
|
||||
|
||||
inline static std::string DEFAULT = "core:default";
|
||||
};
|
||||
Reference in New Issue
Block a user