1
0

Generator: Added notes of failed optimization attempts

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1404 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-04-22 19:27:15 +00:00
parent 7624d4ed81
commit d852ea78f9
3 changed files with 37 additions and 25 deletions

View File

@ -192,6 +192,13 @@ void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc)
int ChunkX = a_ChunkDesc.GetChunkX(); int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ(); int ChunkZ = a_ChunkDesc.GetChunkZ();
/*
_X 2013_04_22:
There's no point in generating the whole cubic noise at once, because the noise values are used in
only about 20 % of the cases, so the speed gained by precalculating is lost by precalculating too much data
*/
for (int z = 0; z < cChunkDef::Width; z++) for (int z = 0; z < cChunkDef::Width; z++)
{ {
for (int x = 0; x < cChunkDef::Width; x++) for (int x = 0; x < cChunkDef::Width; x++)
@ -256,7 +263,14 @@ void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc)
default: default:
{ {
// Fill with water, sand/dirt/clay mix and stone // Fill with water, sand/dirt/clay mix and stone
FillColumnWaterMix(ChunkX, ChunkZ, x, z, Height, a_ChunkDesc.GetBlockTypes()); if (m_Noise.CubicNoise2D(0.1f * (cChunkDef::Width * ChunkX + x), 0.1f * (cChunkDef::Width * ChunkZ + z)) < 0)
{
FillColumnWaterSand(x, z, Height, a_ChunkDesc.GetBlockTypes());
}
else
{
FillColumnWaterDirt(x, z, Height, a_ChunkDesc.GetBlockTypes());
}
break; break;
} }
} // switch (biome) } // switch (biome)
@ -347,32 +361,25 @@ void cCompoGenBiomal::FillColumnWaterSand(int a_RelX, int a_RelZ, int a_Height,
void cCompoGenBiomal::FillColumnWaterMix(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes) void cCompoGenBiomal::FillColumnWaterDirt(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes)
{ {
if (m_Noise.CubicNoise2D(0.5f * (cChunkDef::Width * a_ChunkX + a_RelX), 0.5f * (cChunkDef::Width * a_ChunkZ + a_RelZ)) < 0) // Dirt
BLOCKTYPE Pattern[] =
{ {
FillColumnWaterSand(a_RelX, a_RelZ, a_Height, a_BlockTypes); E_BLOCK_DIRT,
} E_BLOCK_DIRT,
else E_BLOCK_DIRT,
{ E_BLOCK_DIRT,
// Dirt } ;
BLOCKTYPE Pattern[] = FillColumnPattern(a_RelX, a_RelZ, a_Height, a_BlockTypes, Pattern, ARRAYCOUNT(Pattern));
{
E_BLOCK_DIRT,
E_BLOCK_DIRT,
E_BLOCK_DIRT,
E_BLOCK_DIRT,
} ;
FillColumnPattern(a_RelX, a_RelZ, a_Height, a_BlockTypes, Pattern, ARRAYCOUNT(Pattern));
for (int y = a_Height - ARRAYCOUNT(Pattern); y > 0; y--) for (int y = a_Height - ARRAYCOUNT(Pattern); y > 0; y--)
{ {
cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STONE); cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STONE);
} }
for (int y = a_Height + 1; y <= m_SeaLevel + 1; y++) for (int y = a_Height + 1; y <= m_SeaLevel + 1; y++)
{ {
cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STATIONARY_WATER); cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STATIONARY_WATER);
}
} }
} }

View File

@ -111,8 +111,7 @@ protected:
void FillColumnSand (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnSand (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes);
void FillColumnMycelium (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnMycelium (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes);
void FillColumnWaterSand(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes); void FillColumnWaterSand(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes);
void FillColumnWaterDirt(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes);
void FillColumnWaterMix (int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes);
void FillColumnPattern (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes, const BLOCKTYPE * a_Pattern, int a_PatternSize); void FillColumnPattern (int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes, const BLOCKTYPE * a_Pattern, int a_PatternSize);
} ; } ;

View File

@ -228,6 +228,12 @@ void cHeiGenBiomal::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMa
} // for x } // for x
} // for z } // for z
/*
_X 2013_04_22:
There's no point in precalculating the entire perlin noise arrays, too many values are calculated uselessly,
resulting in speed DEcrease.
*/
/* /*
// Linearly interpolate 4x4 blocks of heightmap: // Linearly interpolate 4x4 blocks of heightmap:
// This is fast, but really ugly! Do not use! // This is fast, but really ugly! Do not use!