mirror of
https://github.com/minetest/minetest.git
synced 2024-11-24 00:23:46 +01:00
Mapgen: Use getBlockSeed2() for blockseeds (much better uniformity)
This commit is contained in:
parent
ca89e63b27
commit
0974337804
@ -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)
|
void EmergeManager::getMapgenNames(std::list<const char *> &mgnames)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i != ARRLEN(reg_mapgens); i++)
|
for (u32 i = 0; i != ARRLEN(reg_mapgens); i++)
|
||||||
@ -547,7 +538,7 @@ void *EmergeThread::Thread()
|
|||||||
VoxelArea(minp, maxp));
|
VoxelArea(minp, maxp));
|
||||||
try { // takes about 90ms with -O1 on an e3-1230v2
|
try { // takes about 90ms with -O1 on an e3-1230v2
|
||||||
m_server->getScriptIface()->environment_OnGenerated(
|
m_server->getScriptIface()->environment_OnGenerated(
|
||||||
minp, maxp, emerge->getBlockSeed(minp));
|
minp, maxp, mapgen->blockseed);
|
||||||
} catch(LuaError &e) {
|
} catch(LuaError &e) {
|
||||||
m_server->setAsyncFatalError(e.what());
|
m_server->setAsyncFatalError(e.what());
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,6 @@ public:
|
|||||||
Biome *getBiomeAtPoint(v3s16 p);
|
Biome *getBiomeAtPoint(v3s16 p);
|
||||||
int getGroundLevelAtPoint(v2s16 p);
|
int getGroundLevelAtPoint(v2s16 p);
|
||||||
bool isBlockUnderground(v3s16 blockpos);
|
bool isBlockUnderground(v3s16 blockpos);
|
||||||
u32 getBlockSeed(v3s16 p);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#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
|
// Returns Y one under area minimum if not found
|
||||||
s16 Mapgen::findGroundLevelFull(v2s16 p2d)
|
s16 Mapgen::findGroundLevelFull(v2s16 p2d)
|
||||||
{
|
{
|
||||||
|
@ -133,9 +133,11 @@ public:
|
|||||||
u32 flags;
|
u32 flags;
|
||||||
bool generating;
|
bool generating;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
ManualMapVoxelManipulator *vm;
|
ManualMapVoxelManipulator *vm;
|
||||||
INodeDefManager *ndef;
|
INodeDefManager *ndef;
|
||||||
|
|
||||||
|
u32 blockseed;
|
||||||
s16 *heightmap;
|
s16 *heightmap;
|
||||||
u8 *biomemap;
|
u8 *biomemap;
|
||||||
v3s16 csize;
|
v3s16 csize;
|
||||||
@ -146,6 +148,8 @@ public:
|
|||||||
Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
|
Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
|
||||||
virtual ~Mapgen();
|
virtual ~Mapgen();
|
||||||
|
|
||||||
|
static u32 getBlockSeed(v3s16 p, int seed);
|
||||||
|
static u32 getBlockSeed2(v3s16 p, int seed);
|
||||||
s16 findGroundLevelFull(v2s16 p2d);
|
s16 findGroundLevelFull(v2s16 p2d);
|
||||||
s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
|
s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
|
||||||
void updateHeightmap(v3s16 nmin, v3s16 nmax);
|
void updateHeightmap(v3s16 nmin, v3s16 nmax);
|
||||||
|
@ -78,6 +78,8 @@ void MapgenSinglenode::makeChunk(BlockMakeData *data) {
|
|||||||
v3s16 node_min = blockpos_min*MAP_BLOCKSIZE;
|
v3s16 node_min = blockpos_min*MAP_BLOCKSIZE;
|
||||||
v3s16 node_max = (blockpos_max+v3s16(1,1,1))*MAP_BLOCKSIZE-v3s16(1,1,1);
|
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);
|
MapNode n_node(c_node);
|
||||||
|
|
||||||
for (s16 z = node_min.Z; z <= node_max.Z; z++)
|
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);
|
full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
|
||||||
|
|
||||||
// Create a block-specific seed
|
// Create a block-specific seed
|
||||||
blockseed = m_emerge->getBlockSeed(full_node_min); //////use getBlockSeed2()!
|
blockseed = getBlockSeed2(full_node_min, seed);
|
||||||
|
|
||||||
// Make some noise
|
// Make some noise
|
||||||
calculateNoise();
|
calculateNoise();
|
||||||
|
@ -56,7 +56,6 @@ public:
|
|||||||
int zstride;
|
int zstride;
|
||||||
u32 spflags;
|
u32 spflags;
|
||||||
|
|
||||||
u32 blockseed;
|
|
||||||
v3s16 node_min;
|
v3s16 node_min;
|
||||||
v3s16 node_max;
|
v3s16 node_max;
|
||||||
v3s16 full_node_min;
|
v3s16 full_node_min;
|
||||||
|
@ -70,7 +70,6 @@ public:
|
|||||||
int ystride;
|
int ystride;
|
||||||
u32 spflags;
|
u32 spflags;
|
||||||
|
|
||||||
u32 blockseed;
|
|
||||||
v3s16 node_min;
|
v3s16 node_min;
|
||||||
v3s16 node_max;
|
v3s16 node_max;
|
||||||
v3s16 full_node_min;
|
v3s16 full_node_min;
|
||||||
|
@ -215,7 +215,7 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
|||||||
full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;
|
full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;
|
||||||
full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
|
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
|
// Make some noise
|
||||||
calculateNoise();
|
calculateNoise();
|
||||||
|
@ -59,7 +59,6 @@ public:
|
|||||||
int zstride;
|
int zstride;
|
||||||
u32 spflags;
|
u32 spflags;
|
||||||
|
|
||||||
u32 blockseed;
|
|
||||||
v3s16 node_min;
|
v3s16 node_min;
|
||||||
v3s16 node_max;
|
v3s16 node_max;
|
||||||
v3s16 full_node_min;
|
v3s16 full_node_min;
|
||||||
|
Loading…
Reference in New Issue
Block a user