diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-22 22:49:33 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-22 22:49:33 +0100 |
commit | f41b33ba80f2dda6658a5d7322332aafbc9216d6 (patch) | |
tree | f61a3cb9b7516629334d5ee17c3ffa91b2b1b98d /source | |
parent | Fixed block update queueing and water meta change not propagated to clients. (diff) | |
download | cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.tar cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.tar.gz cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.tar.bz2 cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.tar.lz cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.tar.xz cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.tar.zst cuberite-f41b33ba80f2dda6658a5d7322332aafbc9216d6.zip |
Diffstat (limited to 'source')
-rw-r--r-- | source/Generating/Caves.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp index 39c207199..2bfef8054 100644 --- a/source/Generating/Caves.cpp +++ b/source/Generating/Caves.cpp @@ -42,6 +42,13 @@ reduced in complexity in order for this generator to be useful, so the caves' sh +const int MIN_RADIUS = 3;
+const int MAX_RADIUS = 8;
+
+
+
+
+
struct cCaveDefPoint
{
int m_BlockX;
@@ -207,7 +214,7 @@ void cCaveTunnel::Randomize(cNoise & a_Noise) len += (PrevY - itr->m_BlockY) * (PrevY - itr->m_BlockY);
len += (PrevZ - itr->m_BlockZ) * (PrevZ - itr->m_BlockZ);
len = 3 * (int)sqrt((double)len) / 4;
- int Rad = (PrevR + itr->m_Radius) / 2 + (Random % 3) - 1;
+ int Rad = std::min(MAX_RADIUS, std::max(MIN_RADIUS, (PrevR + itr->m_Radius) / 2 + (Random % 3) - 1));
Random /= 4;
int x = (itr->m_BlockX + PrevX) / 2 + (Random % (len + 1) - len / 2);
Random /= 256;
@@ -479,19 +486,19 @@ void cCaveTunnel::ProcessChunk( continue;
}
- // Carve out a sphere around the xyz point, m_Radius in diameter; skip 20 % off the top and bottom:
+ // Carve out a sphere around the xyz point, m_Radius in diameter; skip 3/7 off the top and bottom:
int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc
int DifY = itr->m_BlockY;
int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc
- int Bottom = std::max(itr->m_BlockY - 4 * itr->m_Radius / 5, 1);
- int Top = std::min(itr->m_BlockY + 4 * itr->m_Radius / 5, (int)(cChunkDef::Height));
+ int Bottom = std::max(itr->m_BlockY - 3 * itr->m_Radius / 7, 1);
+ int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, (int)(cChunkDef::Height));
int SqRad = itr->m_Radius * itr->m_Radius;
for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++)
{
for (int y = Bottom; y <= Top; y++)
{
int SqDist = (DifX - x) * (DifX - x) + (DifY - y) * (DifY - y) + (DifZ - z) * (DifZ - z);
- if (SqDist <= SqRad)
+ if (4 * SqDist <= SqRad)
{
switch (cChunkDef::GetBlock(a_BlockTypes, x, y, z))
{
@@ -721,8 +728,8 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig int res = 3 + abs((sum / 24) - 16);
*/
- // The algorithm of choice: Divide a constant by the random number returned, thus producing a hyperbole-shaped noise distribution
- int res = 2 + (32 / ((rnd & 0xff) + 2));
+ // Algorithm of choice: random value in the range of zero to random value - heavily towards zero
+ int res = MIN_RADIUS + (rnd >> 8) % ((rnd % (MAX_RADIUS - MIN_RADIUS)) + 1);
return res;
}
|