summaryrefslogtreecommitdiffstats
path: root/src/Generating/ProtIntGen.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-11-02 16:36:59 +0100
committerMattes D <github@xoft.cz>2014-11-02 16:36:59 +0100
commitd5b6353493868ac14b277155f398bd87f08c484c (patch)
treea7b41b3a5338582cc17c13895c8a6dff230590ce /src/Generating/ProtIntGen.h
parentGrownProt: Added the rest of rare and M biomes. (diff)
downloadcuberite-d5b6353493868ac14b277155f398bd87f08c484c.tar
cuberite-d5b6353493868ac14b277155f398bd87f08c484c.tar.gz
cuberite-d5b6353493868ac14b277155f398bd87f08c484c.tar.bz2
cuberite-d5b6353493868ac14b277155f398bd87f08c484c.tar.lz
cuberite-d5b6353493868ac14b277155f398bd87f08c484c.tar.xz
cuberite-d5b6353493868ac14b277155f398bd87f08c484c.tar.zst
cuberite-d5b6353493868ac14b277155f398bd87f08c484c.zip
Diffstat (limited to 'src/Generating/ProtIntGen.h')
-rw-r--r--src/Generating/ProtIntGen.h83
1 files changed, 50 insertions, 33 deletions
diff --git a/src/Generating/ProtIntGen.h b/src/Generating/ProtIntGen.h
index 9c3eb36cc..73ed27096 100644
--- a/src/Generating/ProtIntGen.h
+++ b/src/Generating/ProtIntGen.h
@@ -70,14 +70,14 @@ protected:
cNoise m_Noise;
/** Chooses one of a_Val1 or a_Val2, based on m_Noise and the coordinates for querying the noise. */
- int ChooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2)
+ int chooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2)
{
int rnd = m_Noise.IntNoise2DInt(a_RndX, a_RndZ) / 7;
return ((rnd & 1) == 0) ? a_Val1 : a_Val2;
}
/** Chooses one of a_ValN, based on m_Noise and the coordinates for querying the noise. */
- int ChooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2, int a_Val3, int a_Val4)
+ int chooseRandomOne(int a_RndX, int a_RndZ, int a_Val1, int a_Val2, int a_Val3, int a_Val4)
{
int rnd = m_Noise.IntNoise2DInt(a_RndX, a_RndZ) / 7;
switch (rnd % 4)
@@ -173,6 +173,9 @@ protected:
+/** Zooms the underlying value array to twice the size. Uses random-neighbor for the pixels in-between.
+This means that the zoome out image is randomly distorted. Applying zoom several times provides all
+the distortion that the generators need. */
class cProtIntGenZoom :
public cProtIntGenWithNoise
{
@@ -201,7 +204,7 @@ public:
int lowerData[m_BufferSize];
m_UnderlyingGen->GetInts(lowerMinX, lowerMinZ, lowerSizeX, lowerSizeZ, lowerData);
const int lowStepX = (lowerSizeX - 1) * 2;
- int Cache[m_BufferSize];
+ int cache[m_BufferSize];
// Discreet-interpolate the values into twice the size:
for (int z = 0; z < lowerSizeZ - 1; ++z)
@@ -216,12 +219,11 @@ public:
int ValX1Z1 = lowerData[x + 1 + (z + 1) * lowerSizeX];
int RndX = (x + lowerMinX) * 2;
int RndZ = (z + lowerMinZ) * 2;
- Cache[idx] = PrevZ0;
- Cache[idx + lowStepX] = super::ChooseRandomOne(RndX, RndZ, PrevZ0, PrevZ1);
- idx++;
- Cache[idx] = super::ChooseRandomOne(RndX, RndZ, PrevZ0, ValX1Z0);
- Cache[idx + lowStepX] = super::ChooseRandomOne(RndX, RndZ, PrevZ0, ValX1Z0, PrevZ1, ValX1Z1);
- idx++;
+ cache[idx] = PrevZ0;
+ cache[idx + lowStepX] = super::chooseRandomOne(RndX, RndZ + 1, PrevZ0, PrevZ1);
+ cache[idx + 1] = super::chooseRandomOne(RndX, RndZ - 1, PrevZ0, ValX1Z0);
+ cache[idx + 1 + lowStepX] = super::chooseRandomOne(RndX, RndZ, PrevZ0, ValX1Z0, PrevZ1, ValX1Z1);
+ idx += 2;
PrevZ0 = ValX1Z0;
PrevZ1 = ValX1Z1;
}
@@ -230,7 +232,7 @@ public:
// Copy from Cache into a_Values; take into account the even/odd offsets in a_Min:
for (int z = 0; z < a_SizeZ; ++z)
{
- memcpy(a_Values + z * a_SizeX, Cache + (z + (a_MinZ & 1)) * lowStepX + (a_MinX & 1), a_SizeX * sizeof(int));
+ memcpy(a_Values + z * a_SizeX, cache + (z + (a_MinZ & 1)) * lowStepX + (a_MinX & 1), a_SizeX * sizeof(int));
}
}
@@ -242,6 +244,8 @@ protected:
+/** Smoothes out some artifacts generated by the zooming - mostly single-pixel values.
+Compares each pixel to its neighbors and if the neighbors are equal, changes the pixel to their value. */
class cProtIntGenSmooth :
public cProtIntGenWithNoise
{
@@ -272,32 +276,32 @@ public:
for (int x = 0; x < a_SizeX; x++)
{
int val = lowerData[x + 1 + (z + 1) * lowerSizeX];
- int Above = lowerData[x + 1 + z * lowerSizeX];
- int Below = lowerData[x + 1 + (z + 2) * lowerSizeX];
- int Left = lowerData[x + (z + 1) * lowerSizeX];
- int Right = lowerData[x + 2 + (z + 1) * lowerSizeX];
+ int above = lowerData[x + 1 + z * lowerSizeX];
+ int below = lowerData[x + 1 + (z + 2) * lowerSizeX];
+ int left = lowerData[x + (z + 1) * lowerSizeX];
+ int right = lowerData[x + 2 + (z + 1) * lowerSizeX];
- if ((Left == Right) && (Above == Below))
+ if ((left == right) && (above == below))
{
if (((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 2) == 0)
{
- val = Left;
+ val = left;
}
else
{
- val = Above;
+ val = above;
}
}
else
{
- if (Left == Right)
+ if (left == right)
{
- val = Left;
+ val = left;
}
- if (Above == Below)
+ if (above == below)
{
- val = Above;
+ val = above;
}
}
@@ -314,6 +318,7 @@ protected:
+/** Converts land biomes at the edge of an ocean into the respective beach biome. */
class cProtIntGenBeaches :
public cProtIntGen
{
@@ -386,14 +391,15 @@ public:
for (int x = 0; x < a_SizeX; x++)
{
int val = lowerValues[x + 1 + (z + 1) * lowerSizeX];
- int Above = lowerValues[x + 1 + z * lowerSizeX];
- int Below = lowerValues[x + 1 + (z + 2) * lowerSizeX];
- int Left = lowerValues[x + (z + 1) * lowerSizeX];
- int Right = lowerValues[x + 2 + (z + 1) * lowerSizeX];
+ int above = lowerValues[x + 1 + z * lowerSizeX];
+ int below = lowerValues[x + 1 + (z + 2) * lowerSizeX];
+ int left = lowerValues[x + (z + 1) * lowerSizeX];
+ int right = lowerValues[x + 2 + (z + 1) * lowerSizeX];
if (!IsBiomeOcean(val))
{
- if (IsBiomeOcean(Above) || IsBiomeOcean(Below) || IsBiomeOcean(Left) || IsBiomeOcean(Right))
+ if (IsBiomeOcean(above) || IsBiomeOcean(below) || IsBiomeOcean(left) || IsBiomeOcean(right))
{
+ // First convert the value to a regular biome (drop the M flag), then modulo by our biome count:
val = ToBeach[(val % 128) % ARRAYCOUNT(ToBeach)];
}
}
@@ -411,7 +417,7 @@ protected:
/** Generates the underlying numbers and then randomly changes some ocean group pixels into random land
-group pixels, based on the predefined chance. */
+biome group pixels, based on the predefined chance. */
class cProtIntGenAddIslands :
public cProtIntGenWithNoise
{
@@ -441,7 +447,7 @@ public:
int rnd = super::m_Noise.IntNoise2DInt(a_MinX + x, a_MinZ + z) / 7;
if (rnd % 1000 < m_Chance)
{
- a_Values[x + z * a_SizeX] = (rnd / 101) % bgLandOceanMax;
+ a_Values[x + z * a_SizeX] = (rnd / 1003) % bgLandOceanMax;
}
}
}
@@ -575,7 +581,7 @@ public:
// Define the per-biome-group biomes:
static const int oceanBiomes[] =
{
- biOcean, // biDeepOcean,
+ biOcean, // biDeepOcean,
};
// Same as oceanBiomes, there are no rare oceanic biomes (mushroom islands are handled separately)
@@ -680,6 +686,7 @@ protected:
+/** Randomly replaces pixels of one value to another value, using the given chance. */
class cProtIntGenReplaceRandomly :
public cProtIntGenWithNoise
{
@@ -725,9 +732,15 @@ public:
protected:
+ /** The original value to be replaced. */
int m_From;
+
+ /** The destination value to which to replace. */
int m_To;
+
+ /** Chance, in permille, of replacing the value. */
int m_Chance;
+
Underlying m_Underlying;
};
@@ -736,7 +749,9 @@ protected:
/** Mixer that joins together finalized biomes and rivers.
-It first checks for oceans; if there's no ocean, it checks for a river. */
+It first checks for oceans, if there is an ocean in the Biomes, it keeps the ocean.
+If there's no ocean, it checks Rivers for a river, if there is a river, it uses the Biomes to select either
+regular river or frozen river, based on the biome. */
class cProtIntGenMixRivers:
public cProtIntGen
{
@@ -1043,8 +1058,8 @@ protected:
-/** Changes biomes in the parent data into their alternate verions ("M" variants), in such places that
-have their alterations set. */
+/** Changes biomes in the parent data into an alternate versions (usually "hill" variants), in such places
+that have their alterations set. */
class cProtIntGenAlternateBiomes:
public cProtIntGenWithNoise
{
@@ -1080,7 +1095,7 @@ public:
int val = a_Values[idx];
switch (val)
{
- case biBirchForest: val = biBirchForest; break;
+ case biBirchForest: val = biBirchForestHills; break;
case biDesert: val = biDesertHills; break;
case biExtremeHills: val = biExtremeHillsPlus; break;
case biForest: val = biForestHills; break;
@@ -1267,6 +1282,8 @@ protected:
+/** Changes biomes in the parent data into their alternate versions ("M" variants), in such places that
+have their alterations set. */
class cProtIntGenMBiomes:
public cProtIntGenWithNoise
{