replace argument 'seed' with global constant 'SEED'

This commit is contained in:
MihailRis
2024-10-16 08:46:32 +03:00
parent 0ad59fadd9
commit faca68e6c3
5 changed files with 85 additions and 74 deletions
+9 -11
View File
@@ -123,17 +123,17 @@ class GeneratorScript {
public:
virtual ~GeneratorScript() = default;
virtual void initialize(uint64_t seed) = 0;
/// @brief Generate a heightmap with values in range 0..1
/// @param offset position of the heightmap in the world
/// @param size size of the heightmap
/// @param seed world seed
/// @param bpd blocks per dot
/// @param inputs biome parameter maps passed to generate_heightmap
/// @return generated heightmap (can't be nullptr)
virtual std::shared_ptr<Heightmap> generateHeightmap(
const glm::ivec2& offset,
const glm::ivec2& size,
uint64_t seed,
uint bpd,
const std::vector<std::shared_ptr<Heightmap>>& inputs
) = 0;
@@ -141,13 +141,11 @@ public:
/// @brief Generate a biomes parameters maps
/// @param offset position of maps in the world
/// @param size maps size
/// @param seed world seed
/// @param bpd blocks per dot
/// @return generated maps (can't be nullptr)
virtual std::vector<std::shared_ptr<Heightmap>> generateParameterMaps(
const glm::ivec2& offset,
const glm::ivec2& size,
uint64_t seed,
uint bpd
) = 0;
@@ -156,12 +154,10 @@ public:
/// wide-structs-chunks-radius
/// @param offset position of the area
/// @param size size of the area (blocks)
/// @param seed world seed
/// @param chunkHeight chunk height to use as heights multiplier
virtual std::vector<Placement> placeStructuresWide(
const glm::ivec2& offset,
const glm::ivec2& size,
uint64_t seed,
const glm::ivec2& offset,
const glm::ivec2& size,
uint chunkHeight
) = 0;
@@ -169,13 +165,15 @@ public:
/// placed to nearest chunks also (position of out area).
/// @param offset position of the area
/// @param size size of the area (blocks)
/// @param seed world seed
/// @param heightmap area heightmap
/// @param chunkHeight chunk height to use as heights multiplier
/// @return structure & line placements
virtual std::vector<Placement> placeStructures(
const glm::ivec2& offset, const glm::ivec2& size, uint64_t seed,
const std::shared_ptr<Heightmap>& heightmap, uint chunkHeight) = 0;
const glm::ivec2& offset,
const glm::ivec2& size,
const std::shared_ptr<Heightmap>& heightmap,
uint chunkHeight
) = 0;
};
/// @brief Structure voxel fragments and metadata
+4 -4
View File
@@ -31,6 +31,8 @@ WorldGenerator::WorldGenerator(
seed(seed),
surroundMap(0, BASIC_PROTOTYPE_LAYERS + def.wideStructsChunksRadius * 2)
{
def.script->initialize(seed);
uint levels = BASIC_PROTOTYPE_LAYERS + def.wideStructsChunksRadius * 2;
surroundMap = SurroundMap(0, levels);
@@ -228,7 +230,7 @@ void WorldGenerator::generateStructuresWide(
return;
}
auto placements = def.script->placeStructuresWide(
{chunkX * CHUNK_W, chunkZ * CHUNK_D}, {CHUNK_W, CHUNK_D}, seed, CHUNK_H
{chunkX * CHUNK_W, chunkZ * CHUNK_D}, {CHUNK_W, CHUNK_D}, CHUNK_H
);
placeStructures(placements, prototype, chunkX, chunkZ);
@@ -245,7 +247,7 @@ void WorldGenerator::generateStructures(
const auto& heightmap = prototype.heightmap;
auto placements = def.script->placeStructures(
{chunkX * CHUNK_W, chunkZ * CHUNK_D}, {CHUNK_W, CHUNK_D}, seed,
{chunkX * CHUNK_W, chunkZ * CHUNK_D}, {CHUNK_W, CHUNK_D},
heightmap, CHUNK_H
);
placeStructures(placements, prototype, chunkX, chunkZ);
@@ -297,7 +299,6 @@ void WorldGenerator::generateBiomes(
auto biomeParams = def.script->generateParameterMaps(
{floordiv(chunkX * CHUNK_W, bpd), floordiv(chunkZ * CHUNK_D, bpd)},
{floordiv(CHUNK_W, bpd)+1, floordiv(CHUNK_D, bpd)+1},
seed,
bpd
);
for (auto index : def.heightmapInputs) {
@@ -339,7 +340,6 @@ void WorldGenerator::generateHeightmap(
prototype.heightmap = def.script->generateHeightmap(
{floordiv(chunkX * CHUNK_W, bpd), floordiv(chunkZ * CHUNK_D, bpd)},
{floordiv(CHUNK_W, bpd)+1, floordiv(CHUNK_D, bpd)+1},
seed,
bpd,
prototype.heightmapInputs
);