1
0

Generators: Unified SeaLevel into a single variable.

It is shared between shape generators and composition generators and there's no sense in having two different values for those.
This commit is contained in:
Mattes D 2014-11-20 15:31:03 +01:00
parent 5325885ef4
commit 76058e8183
3 changed files with 3 additions and 70 deletions

View File

@ -197,7 +197,7 @@ void cCompoGenClassic::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc
void cCompoGenClassic::InitializeCompoGen(cIniFile & a_IniFile) void cCompoGenClassic::InitializeCompoGen(cIniFile & a_IniFile)
{ {
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "ClassicSeaLevel", m_SeaLevel); m_SeaLevel = a_IniFile.GetValueSetI("Generator", "SeaLevel", m_SeaLevel);
m_BeachHeight = a_IniFile.GetValueSetI("Generator", "ClassicBeachHeight", m_BeachHeight); m_BeachHeight = a_IniFile.GetValueSetI("Generator", "ClassicBeachHeight", m_BeachHeight);
m_BeachDepth = a_IniFile.GetValueSetI("Generator", "ClassicBeachDepth", m_BeachDepth); m_BeachDepth = a_IniFile.GetValueSetI("Generator", "ClassicBeachDepth", m_BeachDepth);
m_BlockTop = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockTop", "grass").m_ItemType); m_BlockTop = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockTop", "grass").m_ItemType);

View File

@ -166,69 +166,6 @@ cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
m_Cubic.AddOctave(4, 0.25); m_Cubic.AddOctave(4, 0.25);
m_Cubic.AddOctave(8, 0.125); m_Cubic.AddOctave(8, 0.125);
m_Cubic.AddOctave(16, 0.0625); m_Cubic.AddOctave(16, 0.0625);
#if 0
// DEBUG: Test the noise generation:
// NOTE: In order to be able to run MCS with this code, you need to increase the default thread stack size
// In MSVC, it is done in Project Settings -> Configuration Properties -> Linker -> System, set Stack reserve size to at least 64M
m_SeaLevel = 62;
m_HeightAmplification = 0;
m_MidPoint = 75;
m_FrequencyX = 4;
m_FrequencyY = 4;
m_FrequencyZ = 4;
m_AirThreshold = 0.5;
const int NumChunks = 4;
NOISE_DATATYPE Noise[NumChunks][cChunkDef::Width * cChunkDef::Width * cChunkDef::Height];
for (int x = 0; x < NumChunks; x++)
{
GenerateNoiseArray(x, 5, Noise[x]);
}
// Save in XY cuts:
cFile f1;
if (f1.Open("Test_XY.grab", cFile::fmWrite))
{
for (int z = 0; z < cChunkDef::Width; z++)
{
for (int y = 0; y < cChunkDef::Height; y++)
{
for (int i = 0; i < NumChunks; i++)
{
int idx = y * cChunkDef::Width + z * cChunkDef::Width * cChunkDef::Height;
unsigned char buf[cChunkDef::Width];
for (int x = 0; x < cChunkDef::Width; x++)
{
buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 32 * Noise[i][idx++]))));
}
f1.Write(buf, cChunkDef::Width);
}
} // for y
} // for z
} // if (XY file open)
cFile f2;
if (f2.Open("Test_XZ.grab", cFile::fmWrite))
{
for (int y = 0; y < cChunkDef::Height; y++)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
for (int i = 0; i < NumChunks; i++)
{
int idx = y * cChunkDef::Width + z * cChunkDef::Width * cChunkDef::Height;
unsigned char buf[cChunkDef::Width];
for (int x = 0; x < cChunkDef::Width; x++)
{
buf[x] = (unsigned char)(std::min(256, std::max(0, (int)(128 + 32 * Noise[i][idx++]))));
}
f2.Write(buf, cChunkDef::Width);
}
} // for z
} // for y
} // if (XZ file open)
#endif // 0
} }
@ -247,7 +184,7 @@ cNoise3DGenerator::~cNoise3DGenerator()
void cNoise3DGenerator::Initialize(cIniFile & a_IniFile) void cNoise3DGenerator::Initialize(cIniFile & a_IniFile)
{ {
// Params: // Params:
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62); m_SeaLevel = a_IniFile.GetValueSetI("Generator", "SeaLevel", 62);
m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0.1); m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0.1);
m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 68); m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 68);
m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 8); m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 8);
@ -455,7 +392,6 @@ void cNoise3DComposable::Initialize(cIniFile & a_IniFile)
{ {
// Params: // Params:
// The defaults generate extreme hills terrain // The defaults generate extreme hills terrain
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62);
m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0.045); m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0.045);
m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 75); m_MidPoint = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DMidPoint", 75);
m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 40); m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DFrequencyX", 40);
@ -608,7 +544,7 @@ void cBiomalNoise3DComposable::Initialize(cIniFile & a_IniFile)
{ {
// Params: // Params:
// The defaults generate extreme hills terrain // The defaults generate extreme hills terrain
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "BiomalNoise3DSeaLevel", 62); m_SeaLevel = a_IniFile.GetValueSetI("Generator", "SeaLevel", 62);
m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "BiomalNoise3DFrequencyX", 40); m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "BiomalNoise3DFrequencyX", 40);
m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "BiomalNoise3DFrequencyY", 40); m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "BiomalNoise3DFrequencyY", 40);
m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "BiomalNoise3DFrequencyZ", 40); m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "BiomalNoise3DFrequencyZ", 40);

View File

@ -93,9 +93,6 @@ protected:
/** Heightmap-like noise used to provide variance for low-amplitude biomes. */ /** Heightmap-like noise used to provide variance for low-amplitude biomes. */
cOctavedNoise<cInterpolNoise<Interp5Deg>> m_BaseNoise; cOctavedNoise<cInterpolNoise<Interp5Deg>> m_BaseNoise;
/** Block height of the sealevel, used for composing the terrain. */
int m_SeaLevel;
/** The main parameter of the generator, specifies the slope of the vertical linear gradient. /** The main parameter of the generator, specifies the slope of the vertical linear gradient.
A higher value means a steeper slope and a smaller total amplitude of the generated terrain. */ A higher value means a steeper slope and a smaller total amplitude of the generated terrain. */
NOISE_DATATYPE m_HeightAmplification; NOISE_DATATYPE m_HeightAmplification;