Biome API: Add noise defined biome blend
authorparamat <mat.gregory@virginmedia.com>
Wed, 3 Jun 2015 07:59:07 +0000 (08:59 +0100)
committerparamat <mat.gregory@virginmedia.com>
Thu, 18 Jun 2015 06:05:22 +0000 (07:05 +0100)
minetest.conf.example
src/mapgen.cpp
src/mapgen.h
src/mapgen_v5.cpp
src/mapgen_v5.h
src/mapgen_v7.cpp
src/mapgen_v7.h

index f73dc3e27f48c163f561d0581bdabc307aab8562..2d533b91e186bb1a8bae84da07ad832fe6d01a45 100644 (file)
 #    Mgv5 uses eased noise for np_ground so this is shown in group format,
 #    other noise parameters are shown in positional format to save space.
 
-#    Noise parameters for biome API temperature and humidity
+#    Noise parameters for biome API temperature, humidity and biome blend
 #mg_biome_np_heat = 50, 50, (750, 750, 750), 5349, 3, 0.5, 2.0
+#mg_biome_np_heat_blend = 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0
 #mg_biome_np_humidity = 50, 50, (750, 750, 750), 842, 3, 0.5, 2.0
+#mg_biome_np_humidity_blend = 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0
 
 #mgv5_np_filler_depth = 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0
 #mgv5_np_factor = 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0
index 7965730e48cc4efbed72d3772bef66e439eb397f..d1171e29d6459edc55c54727500d8ce05bcb4790 100644 (file)
@@ -445,7 +445,9 @@ void MapgenParams::load(const Settings &settings)
        settings.getS16NoEx("chunksize", chunksize);
        settings.getFlagStrNoEx("mg_flags", flags, flagdesc_mapgen);
        settings.getNoiseParams("mg_biome_np_heat", np_biome_heat);
+       settings.getNoiseParams("mg_biome_np_heat_blend", np_biome_heat_blend);
        settings.getNoiseParams("mg_biome_np_humidity", np_biome_humidity);
+       settings.getNoiseParams("mg_biome_np_humidity_blend", np_biome_humidity_blend);
 
        delete sparams;
        sparams = EmergeManager::createMapgenParams(mg_name);
@@ -462,7 +464,9 @@ void MapgenParams::save(Settings &settings) const
        settings.setS16("chunksize", chunksize);
        settings.setFlagStr("mg_flags", flags, flagdesc_mapgen, (u32)-1);
        settings.setNoiseParams("mg_biome_np_heat", np_biome_heat);
+       settings.setNoiseParams("mg_biome_np_heat_blend", np_biome_heat_blend);
        settings.setNoiseParams("mg_biome_np_humidity", np_biome_humidity);
+       settings.setNoiseParams("mg_biome_np_humidity_blend", np_biome_humidity_blend);
 
        if (sparams)
                sparams->writeParams(&settings);
index a875e0f3d74df4c96d21cf3d18ff6ebe8e37881e..a1cc8af534eb2e10461c171ebc5544b648b3a9df 100644 (file)
@@ -115,7 +115,9 @@ struct MapgenParams {
        u32 flags;
 
        NoiseParams np_biome_heat;
+       NoiseParams np_biome_heat_blend;
        NoiseParams np_biome_humidity;
+       NoiseParams np_biome_humidity_blend;
 
        MapgenSpecificParams *sparams;
 
@@ -126,7 +128,9 @@ struct MapgenParams {
                water_level(1),
                flags(MG_TREES | MG_CAVES | MG_LIGHT),
                np_biome_heat(NoiseParams(50, 50, v3f(750.0, 750.0, 750.0), 5349, 3, 0.5, 2.0)),
+               np_biome_heat_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 13, 2, 1.0, 2.0)),
                np_biome_humidity(NoiseParams(50, 50, v3f(750.0, 750.0, 750.0), 842, 3, 0.5, 2.0)),
+               np_biome_humidity_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 90003, 2, 1.0, 2.0)),
                sparams(NULL)
        {}
 
index 92febf43b2f4e2ff8c24278a8e1bdcb5e4d9fd5e..f748e7b8652b1dafe599624389a970ebdb330129 100644 (file)
@@ -68,13 +68,15 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
        noise_height       = new Noise(&sp->np_height,       seed, csize.X, csize.Z);
 
        // 3D terrain noise
-       noise_cave1        = new Noise(&sp->np_cave1,   seed, csize.X, csize.Y + 2, csize.Z);
-       noise_cave2        = new Noise(&sp->np_cave2,   seed, csize.X, csize.Y + 2, csize.Z);
-       noise_ground       = new Noise(&sp->np_ground,  seed, csize.X, csize.Y + 2, csize.Z);
+       noise_cave1  = new Noise(&sp->np_cave1,  seed, csize.X, csize.Y + 2, csize.Z);
+       noise_cave2  = new Noise(&sp->np_cave2,  seed, csize.X, csize.Y + 2, csize.Z);
+       noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);
 
        // Biome noise
-       noise_heat         = new Noise(&params->np_biome_heat,     seed, csize.X, csize.Z);
-       noise_humidity     = new Noise(&params->np_biome_humidity, seed, csize.X, csize.Z);
+       noise_heat           = new Noise(&params->np_biome_heat,           seed, csize.X, csize.Z);
+       noise_humidity       = new Noise(&params->np_biome_humidity,       seed, csize.X, csize.Z);
+       noise_heat_blend     = new Noise(&params->np_biome_heat_blend,     seed, csize.X, csize.Z);
+       noise_humidity_blend = new Noise(&params->np_biome_humidity_blend, seed, csize.X, csize.Z);
 
        //// Resolve nodes to be used
        INodeDefManager *ndef = emerge->ndef;
@@ -116,6 +118,8 @@ MapgenV5::~MapgenV5()
 
        delete noise_heat;
        delete noise_humidity;
+       delete noise_heat_blend;
+       delete noise_humidity_blend;
 
        delete[] heightmap;
        delete[] biomemap;
@@ -330,7 +334,13 @@ void MapgenV5::calculateNoise()
        noise_filler_depth->perlinMap2D(x, z);
        noise_heat->perlinMap2D(x, z);
        noise_humidity->perlinMap2D(x, z);
+       noise_heat_blend->perlinMap2D(x, z);
+       noise_humidity_blend->perlinMap2D(x, z);
 
+       for (s32 i = 0; i < csize.X * csize.Z; i++) {
+               noise_heat->result[i] += noise_heat_blend->result[i];
+               noise_humidity->result[i] += noise_humidity_blend->result[i];
+       }
        //printf("calculateNoise: %dus\n", t.stop());
 }
 
index 5575dfe61a45f484ed0ff6ac9858acab53eef476..911975e7fdc9894e680edbae3e2c460f2a374c20 100644 (file)
@@ -69,8 +69,11 @@ public:
        Noise *noise_cave1;
        Noise *noise_cave2;
        Noise *noise_ground;
+
        Noise *noise_heat;
        Noise *noise_humidity;
+       Noise *noise_heat_blend;
+       Noise *noise_humidity_blend;
 
        content_t c_stone;
        content_t c_water_source;
index 247d9debc6d0995473ee3ef7222dade729a12097..6e97c2c1635da3c0143b8f0645d98e334e19a718 100644 (file)
@@ -82,8 +82,10 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
        noise_cave2    = new Noise(&sp->np_cave2,    seed, csize.X, csize.Y + 2, csize.Z);
 
        //// Biome noise
-       noise_heat     = new Noise(&params->np_biome_heat,     seed, csize.X, csize.Z);
-       noise_humidity = new Noise(&params->np_biome_humidity, seed, csize.X, csize.Z);
+       noise_heat           = new Noise(&params->np_biome_heat,           seed, csize.X, csize.Z);
+       noise_humidity       = new Noise(&params->np_biome_humidity,       seed, csize.X, csize.Z);
+       noise_heat_blend     = new Noise(&params->np_biome_heat_blend,     seed, csize.X, csize.Z);
+       noise_humidity_blend = new Noise(&params->np_biome_humidity_blend, seed, csize.X, csize.Z);
 
        //// Resolve nodes to be used
        INodeDefManager *ndef = emerge->ndef;
@@ -130,6 +132,8 @@ MapgenV7::~MapgenV7()
 
        delete noise_heat;
        delete noise_humidity;
+       delete noise_heat_blend;
+       delete noise_humidity_blend;
 
        delete[] ridge_heightmap;
        delete[] heightmap;
@@ -227,11 +231,11 @@ void MapgenV7::makeChunk(BlockMakeData *data)
        assert(data->vmanip);
        assert(data->nodedef);
        assert(data->blockpos_requested.X >= data->blockpos_min.X &&
-                  data->blockpos_requested.Y >= data->blockpos_min.Y &&
-                  data->blockpos_requested.Z >= data->blockpos_min.Z);
+               data->blockpos_requested.Y >= data->blockpos_min.Y &&
+               data->blockpos_requested.Z >= data->blockpos_min.Z);
        assert(data->blockpos_requested.X <= data->blockpos_max.X &&
-                  data->blockpos_requested.Y <= data->blockpos_max.Y &&
-                  data->blockpos_requested.Z <= data->blockpos_max.Z);
+               data->blockpos_requested.Y <= data->blockpos_max.Y &&
+               data->blockpos_requested.Z <= data->blockpos_max.Z);
 
        this->generating = true;
        this->vm   = data->vmanip;
@@ -365,14 +369,23 @@ void MapgenV7::calculateNoise()
        noise_filler_depth->perlinMap2D(x, z);
        noise_heat->perlinMap2D(x, z);
        noise_humidity->perlinMap2D(x, z);
+       noise_heat_blend->perlinMap2D(x, z);
+       noise_humidity_blend->perlinMap2D(x, z);
+
+       for (s32 i = 0; i < csize.X * csize.Z; i++) {
+               noise_heat->result[i] += noise_heat_blend->result[i];
+               noise_humidity->result[i] += noise_humidity_blend->result[i];
+       }
        //printf("calculateNoise: %dus\n", t.stop());
 }
 
 
 Biome *MapgenV7::getBiomeAtPoint(v3s16 p)
 {
-       float heat      = NoisePerlin2D(&noise_heat->np, p.X, p.Z, seed);
-       float humidity  = NoisePerlin2D(&noise_humidity->np, p.X, p.Z, seed);
+       float heat = NoisePerlin2D(&noise_heat->np, p.X, p.Z, seed) +
+               NoisePerlin2D(&noise_heat_blend->np, p.X, p.Z, seed);
+       float humidity = NoisePerlin2D(&noise_humidity->np, p.X, p.Z, seed) +
+               NoisePerlin2D(&noise_humidity_blend->np, p.X, p.Z, seed);
        s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Z);
 
        return bmgr->getBiome(heat, humidity, groundlevel);
index eb46c371b2683d6cf0cc9284681612f8b2430ead..0a8a8c876b2a191899977a7013a15d259af53b49 100644 (file)
@@ -82,6 +82,8 @@ public:
 
        Noise *noise_heat;
        Noise *noise_humidity;
+       Noise *noise_heat_blend;
+       Noise *noise_humidity_blend;
 
        content_t c_stone;
        content_t c_water_source;