From 0974337804bde705544b9d237df57f92d5ea5253 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Mon, 29 Dec 2014 21:44:52 -0500 Subject: [PATCH] Mapgen: Use getBlockSeed2() for blockseeds (much better uniformity) --- src/emerge.cpp | 11 +---------- src/emerge.h | 1 - src/mapgen.cpp | 15 +++++++++++++++ src/mapgen.h | 4 ++++ src/mapgen_singlenode.cpp | 2 ++ src/mapgen_v5.cpp | 2 +- src/mapgen_v5.h | 1 - src/mapgen_v6.h | 1 - src/mapgen_v7.cpp | 2 +- src/mapgen_v7.h | 1 - 10 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/emerge.cpp b/src/emerge.cpp index aa2c3c531..8da1a2bfd 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -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 &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()); } diff --git a/src/emerge.h b/src/emerge.h index e5d1b68b2..4ad670bde 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -118,7 +118,6 @@ public: Biome *getBiomeAtPoint(v3s16 p); int getGroundLevelAtPoint(v2s16 p); bool isBlockUnderground(v3s16 blockpos); - u32 getBlockSeed(v3s16 p); }; #endif diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 24f9fc556..c1b8889a8 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -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) { diff --git a/src/mapgen.h b/src/mapgen.h index 07202f9a2..aaa89d3bc 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -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); diff --git a/src/mapgen_singlenode.cpp b/src/mapgen_singlenode.cpp index 8558b3b14..91cd9f2f6 100644 --- a/src/mapgen_singlenode.cpp +++ b/src/mapgen_singlenode.cpp @@ -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++) diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index a7d9698d5..c19f55b93 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -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(); diff --git a/src/mapgen_v5.h b/src/mapgen_v5.h index ef573c7ff..dba888e6a 100644 --- a/src/mapgen_v5.h +++ b/src/mapgen_v5.h @@ -56,7 +56,6 @@ public: int zstride; u32 spflags; - u32 blockseed; v3s16 node_min; v3s16 node_max; v3s16 full_node_min; diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 445888242..a76d24831 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -70,7 +70,6 @@ public: int ystride; u32 spflags; - u32 blockseed; v3s16 node_min; v3s16 node_max; v3s16 full_node_min; diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 06a47971e..17d8f7f2b 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -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(); diff --git a/src/mapgen_v7.h b/src/mapgen_v7.h index 5c037cf44..3ba42d7ff 100644 --- a/src/mapgen_v7.h +++ b/src/mapgen_v7.h @@ -59,7 +59,6 @@ public: int zstride; u32 spflags; - u32 blockseed; v3s16 node_min; v3s16 node_max; v3s16 full_node_min; -- 2.25.1