diff options
author | paramat <mat.gregory@virginmedia.com> | 2017-04-21 02:19:24 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-04-22 01:24:03 +0100 |
commit | 57eaf62c697cec91890d9cb28d10385d293d2d3f (patch) | |
tree | 142e482f197b71d207b4657454a39745f688b7f0 /src/mapgen_flat.cpp | |
parent | 58c083f305d77bd3c7d366c1f0e4a54d80a51719 (diff) | |
download | hax-minetest-server-57eaf62c697cec91890d9cb28d10385d293d2d3f.tar.gz hax-minetest-server-57eaf62c697cec91890d9cb28d10385d293d2d3f.zip |
Mgflat, Mgv7: Only create noise objects if needed
Diffstat (limited to 'src/mapgen_flat.cpp')
-rw-r--r-- | src/mapgen_flat.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mapgen_flat.cpp b/src/mapgen_flat.cpp index 3c6a112e2..c51b5e12e 100644 --- a/src/mapgen_flat.cpp +++ b/src/mapgen_flat.cpp @@ -60,10 +60,12 @@ MapgenFlat::MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *em this->hill_threshold = params->hill_threshold; this->hill_steepness = params->hill_steepness; - //// 2D noise - noise_terrain = new Noise(¶ms->np_terrain, seed, csize.X, csize.Z); + // 2D noise noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); + if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS)) + noise_terrain = new Noise(¶ms->np_terrain, seed, csize.X, csize.Z); + // 3D noise MapgenBasic::np_cave1 = params->np_cave1; MapgenBasic::np_cave2 = params->np_cave2; } @@ -136,7 +138,9 @@ void MapgenFlatParams::writeParams(Settings *settings) const int MapgenFlat::getSpawnLevelAtPoint(v2s16 p) { s16 level_at_point = ground_level; - float n_terrain = NoisePerlin2D(&noise_terrain->np, p.X, p.Y, seed); + float n_terrain = 0.0f; + if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS)) + n_terrain = NoisePerlin2D(&noise_terrain->np, p.X, p.Y, seed); if ((spflags & MGFLAT_LAKES) && n_terrain < lake_threshold) { level_at_point = ground_level - |