Mapgen: Use getBlockSeed2() for blockseeds (much better uniformity)

This commit is contained in:
kwolekr 2014-12-29 21:44:52 -05:00
parent ca89e63b27
commit 0974337804
10 changed files with 24 additions and 16 deletions

@ -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());
}

@ -118,7 +118,6 @@ public:
Biome *getBiomeAtPoint(v3s16 p);
int getGroundLevelAtPoint(v2s16 p);
bool isBlockUnderground(v3s16 blockpos);
u32 getBlockSeed(v3s16 p);
};
#endif

@ -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)
{

@ -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);

@ -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++)

@ -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();

@ -56,7 +56,6 @@ public:
int zstride;
u32 spflags;
u32 blockseed;
v3s16 node_min;
v3s16 node_max;
v3s16 full_node_min;

@ -70,7 +70,6 @@ public:
int ystride;
u32 spflags;
u32 blockseed;
v3s16 node_min;
v3s16 node_max;
v3s16 full_node_min;

@ -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();

@ -59,7 +59,6 @@ public:
int zstride;
u32 spflags;
u32 blockseed;
v3s16 node_min;
v3s16 node_max;
v3s16 full_node_min;