update world generation pipeline
This commit is contained in:
@@ -116,7 +116,8 @@ public:
|
||||
const glm::ivec2& offset, const glm::ivec2& size, uint64_t seed) = 0;
|
||||
|
||||
virtual std::vector<StructurePlacement> placeStructures(
|
||||
const glm::ivec2& offset, const glm::ivec2& size, uint64_t seed) = 0;
|
||||
const glm::ivec2& offset, const glm::ivec2& size, uint64_t seed,
|
||||
const std::shared_ptr<Heightmap>& heightmap) = 0;
|
||||
|
||||
/// @brief Get generator biomes
|
||||
virtual const std::vector<Biome>& getBiomes() const = 0;
|
||||
|
||||
@@ -41,18 +41,14 @@ WorldGenerator::WorldGenerator(
|
||||
prototypes[{x, z}] = generatePrototype(x, z);
|
||||
});
|
||||
surroundMap.setLevelCallback(2, [this](int const x, int const z) {
|
||||
const auto& found = prototypes.find({x, z});
|
||||
if (found == prototypes.end()) {
|
||||
throw std::runtime_error("prototype not found");
|
||||
}
|
||||
generateStructures(requirePrototype(x, z), x, z);
|
||||
});
|
||||
surroundMap.setLevelCallback(3, [this](int const x, int const z) {
|
||||
generateBiomes(requirePrototype(x, z), x, z);
|
||||
});
|
||||
surroundMap.setLevelCallback(4, [this](int const x, int const z) {
|
||||
surroundMap.setLevelCallback(3, [this](int const x, int const z) {
|
||||
generateHeightmap(requirePrototype(x, z), x, z);
|
||||
});
|
||||
surroundMap.setLevelCallback(4, [this](int const x, int const z) {
|
||||
generateStructures(requirePrototype(x, z), x, z);
|
||||
});
|
||||
|
||||
structures = def.script->loadStructures();
|
||||
for (auto& structure : structures) {
|
||||
@@ -145,7 +141,8 @@ void WorldGenerator::generateStructures(
|
||||
return;
|
||||
}
|
||||
util::concat(prototype.structures, def.script->placeStructures(
|
||||
{chunkX * CHUNK_W, chunkZ * CHUNK_D}, {CHUNK_W, CHUNK_D}, seed
|
||||
{chunkX * CHUNK_W, chunkZ * CHUNK_D}, {CHUNK_W, CHUNK_D}, seed,
|
||||
prototype.heightmap
|
||||
));
|
||||
for (const auto& placement : prototype.structures) {
|
||||
const auto& offset = placement.position;
|
||||
|
||||
@@ -18,7 +18,7 @@ struct Biome;
|
||||
class VoxelStructure;
|
||||
|
||||
enum class ChunkPrototypeLevel {
|
||||
VOID=0, STRUCTURES, BIOMES, HEIGHTMAP
|
||||
VOID=0, BIOMES, HEIGHTMAP, STRUCTURES
|
||||
};
|
||||
|
||||
struct ChunkPrototype {
|
||||
|
||||
Reference in New Issue
Block a user