add 'player-min-spawn-height', 'player-max-spawn-height' generator parameters

This commit is contained in:
MihailRis 2026-03-19 19:15:11 +03:00
parent fda8e9753a
commit 4befbb0086
3 changed files with 7 additions and 1 deletions

View file

@ -219,6 +219,8 @@ void ContentLoader::loadGenerator(
map.at("sea-level").get(def.seaLevel);
map.at("wide-structs-chunks-radius").get(def.wideStructsChunksRadius);
map.at("player-spawn-radius").get(def.playerSpawnRadius);
map.at("player-min-spawn-height").get(def.playerMinSpawnHeight);
map.at("player-max-spawn-height").get(def.playerMaxSpawnHeight);
if (map.has("heightmap-inputs")) {
for (const auto& element : map["heightmap-inputs"]) {
int index = element.asInteger();

View file

@ -128,7 +128,9 @@ void Player::attemptToChooseSpawnpoint() {
const auto& generatorDef =
level.content.generators.require(level.getWorld()->getGenerator());
glm::vec3 newpos {0.0f, random.randFloat() * 100 + 100, 0.0f};
int minHeight = generatorDef.playerMinSpawnHeight;
int maxHeight = generatorDef.playerMaxSpawnHeight;
glm::vec3 newpos {0.0f, random.randFloat() * (maxHeight - minHeight + 1) + minHeight, 0.0f};
double angle = random.randDouble() * glm::two_pi<double>();
double radius = glm::sqrt(random.randDouble());
newpos.x += glm::cos(angle) * generatorDef.playerSpawnRadius * radius;

View file

@ -214,6 +214,8 @@ struct GeneratorDef {
uint heightsBPD = 4;
float playerSpawnRadius = DEFAULT_PLAYER_SPAWN_RADIUS;
int playerMinSpawnHeight = CHUNK_H / 4;
int playerMaxSpawnHeight = CHUNK_H;
/// @brief Biome parameter maps interpolation method
InterpolationType biomesInterpolation = InterpolationType::LINEAR;