Mapgen: Use getBlockSeed2() for blockseeds (much better uniformity)
authorkwolekr <kwolekr@minetest.net>
Tue, 30 Dec 2014 02:44:52 +0000 (21:44 -0500)
committerkwolekr <kwolekr@minetest.net>
Tue, 30 Dec 2014 02:44:52 +0000 (21:44 -0500)
src/emerge.cpp
src/emerge.h
src/mapgen.cpp
src/mapgen.h
src/mapgen_singlenode.cpp
src/mapgen_v5.cpp
src/mapgen_v5.h
src/mapgen_v6.h
src/mapgen_v7.cpp
src/mapgen_v7.h

index aa2c3c5319ee7e903696af66ba08c4703dcddd28..8da1a2bfd24ea147a7043079f26a62ca22282626 100644 (file)
@@ -325,15 +325,6 @@ bool EmergeManager::isBlockUnderground(v3s16 blockpos)
 }
 
 
-u32 EmergeManager::getBlockSeed(v3s16 p)
-{
-       return (u32)(params.seed & 0xFFFFFFFF) +
-               p.Z * 38134234 +
-               p.Y * 42123 +
-               p.X * 23;
-}
-
-
 void EmergeManager::getMapgenNames(std::list<const char *> &mgnames)
 {
        for (u32 i = 0; i != ARRLEN(reg_mapgens); i++)
@@ -547,7 +538,7 @@ void *EmergeThread::Thread()
                                                VoxelArea(minp, maxp));
                                        try {  // takes about 90ms with -O1 on an e3-1230v2
                                                m_server->getScriptIface()->environment_OnGenerated(
-                                                               minp, maxp, emerge->getBlockSeed(minp));
+                                                               minp, maxp, mapgen->blockseed);
                                        } catch(LuaError &e) {
                                                m_server->setAsyncFatalError(e.what());
                                        }
index e5d1b68b22e2660ad5103696122bbb295270aaba..4ad670bde22d47dfb87065c33adc9426d57ded15 100644 (file)
@@ -118,7 +118,6 @@ public:
        Biome *getBiomeAtPoint(v3s16 p);
        int getGroundLevelAtPoint(v2s16 p);
        bool isBlockUnderground(v3s16 blockpos);
-       u32 getBlockSeed(v3s16 p);
 };
 
 #endif
index 24f9fc556be8f7a845bf39946d40e027d5634d2a..c1b8889a8fc56ee38fac4d881628799c82a8c721 100644 (file)
@@ -101,6 +101,21 @@ Mapgen::~Mapgen()
 }
 
 
+u32 Mapgen::getBlockSeed(v3s16 p, int seed)
+{
+       return (u32)seed   +
+               p.Z * 38134234 +
+               p.Y * 42123    +
+               p.X * 23;
+}
+
+
+u32 Mapgen::getBlockSeed2(v3s16 p, int seed)
+{
+       return noise3d(p.X, p.Y, p.Z, seed);
+}
+
+
 // Returns Y one under area minimum if not found
 s16 Mapgen::findGroundLevelFull(v2s16 p2d)
 {
index 07202f9a227cca2f7d2dd42d66e484383fe6656c..aaa89d3bc15d224ac217760cff962a6b79a51072 100644 (file)
@@ -133,9 +133,11 @@ public:
        u32 flags;
        bool generating;
        int id;
+
        ManualMapVoxelManipulator *vm;
        INodeDefManager *ndef;
 
+       u32 blockseed;
        s16 *heightmap;
        u8 *biomemap;
        v3s16 csize;
@@ -146,6 +148,8 @@ public:
        Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
        virtual ~Mapgen();
 
+       static u32 getBlockSeed(v3s16 p, int seed);
+       static u32 getBlockSeed2(v3s16 p, int seed);
        s16 findGroundLevelFull(v2s16 p2d);
        s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
        void updateHeightmap(v3s16 nmin, v3s16 nmax);
index 8558b3b1427e9e06795ae11f185f45c40e2a5760..91cd9f2f6e34e4a7e997369c6b1df9eca3a1702e 100644 (file)
@@ -78,6 +78,8 @@ void MapgenSinglenode::makeChunk(BlockMakeData *data) {
        v3s16 node_min = blockpos_min*MAP_BLOCKSIZE;
        v3s16 node_max = (blockpos_max+v3s16(1,1,1))*MAP_BLOCKSIZE-v3s16(1,1,1);
 
+       blockseed = getBlockSeed2(node_min, data->seed);
+
        MapNode n_node(c_node);
 
        for (s16 z = node_min.Z; z <= node_max.Z; z++)
index a7d9698d5d945906e1a58e7713f9b93a02b0c650..c19f55b939bf2b1310e7737634a2bb86602387d0 100644 (file)
@@ -240,7 +240,7 @@ void MapgenV5::makeChunk(BlockMakeData *data) {
        full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
 
        // Create a block-specific seed
-       blockseed = m_emerge->getBlockSeed(full_node_min);  //////use getBlockSeed2()!
+       blockseed = getBlockSeed2(full_node_min, seed);
 
        // Make some noise
        calculateNoise();
index ef573c7ff7d329356e6e463ca1d6a0aae718d774..dba888e6ae938efe00e28fd7726701c3b6e4105f 100644 (file)
@@ -56,7 +56,6 @@ public:
        int zstride;
        u32 spflags;
 
-       u32 blockseed;
        v3s16 node_min;
        v3s16 node_max;
        v3s16 full_node_min;
index 445888242b7efccc39efbfa8259171b1396621f5..a76d24831e26418b7f619a5013b75b3d497ca3e1 100644 (file)
@@ -70,7 +70,6 @@ public:
        int ystride;
        u32 spflags;
 
-       u32 blockseed;
        v3s16 node_min;
        v3s16 node_max;
        v3s16 full_node_min;
index 06a47971ef7cf50fa9f776893dbfc521a92b35e5..17d8f7f2b370bc5507be6a6a5a9f9fe27f612fe6 100644 (file)
@@ -215,7 +215,7 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
        full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;
        full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
 
-       blockseed = m_emerge->getBlockSeed(full_node_min);  //////use getBlockSeed2()!
+       blockseed = getBlockSeed2(full_node_min, seed);
 
        // Make some noise
        calculateNoise();
index 5c037cf440e2052c10bc60005942b6fd0f7a8c69..3ba42d7ff23fc19ca4005675ec0a6cd40f66141f 100644 (file)
@@ -59,7 +59,6 @@ public:
        int zstride;
        u32 spflags;
 
-       u32 blockseed;
        v3s16 node_min;
        v3s16 node_max;
        v3s16 full_node_min;