diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-13 22:47:03 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-13 22:47:03 +0100 |
commit | 4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch) | |
tree | febea3ecd89c0d4aa83924e430bf11366d754733 /source/cWorldGenerator.cpp | |
parent | New makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff) | |
download | cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2 cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cWorldGenerator.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/source/cWorldGenerator.cpp b/source/cWorldGenerator.cpp index c54be8899..5d087014b 100644 --- a/source/cWorldGenerator.cpp +++ b/source/cWorldGenerator.cpp @@ -6,7 +6,6 @@ #include "cWorld.h"
#include "cChunk.h"
#include "cGenSettings.h"
-#include "MersenneTwister.h"
#include "BlockID.h"
#include "Vector3i.h"
@@ -19,17 +18,33 @@ cWorldGenerator::cWorldGenerator() {
}
+
+
+
+
cWorldGenerator::~cWorldGenerator()
{
}
-void cWorldGenerator::GenerateChunk( cChunk* a_Chunk )
+
+
+
+void cWorldGenerator::GenerateChunk( cChunkPtr a_Chunk )
{
+ assert(!a_Chunk->IsValid());
+
+ memset(a_Chunk->pGetBlockData(), 0, cChunk::c_BlockDataSize);
GenerateTerrain( a_Chunk );
GenerateFoliage( a_Chunk );
+ a_Chunk->CalculateHeightmap();
+ a_Chunk->CalculateLighting();
}
+
+
+
+
static float GetNoise( float x, float y, cNoise & a_Noise )
{
float oct1 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq1, y*cGenSettings::HeightFreq1 )*cGenSettings::HeightAmp1;
@@ -44,6 +59,10 @@ static float GetNoise( float x, float y, cNoise & a_Noise ) return (oct1 + oct2 + oct3) * flatness + height;
}
+
+
+
+
#define PI_2 (1.57079633f)
static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise )
{
@@ -56,6 +75,10 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) return oct1;
}
+
+
+
+
static float GetOreNoise( float x, float y, float z, cNoise & a_Noise )
{
float oct1 = a_Noise.CubicNoise3D( x*0.1f, y*0.1f, z*0.1f );
@@ -69,7 +92,11 @@ static float GetOreNoise( float x, float y, float z, cNoise & a_Noise ) return oct1;
}
-void cWorldGenerator::GenerateTerrain( cChunk* a_Chunk )
+
+
+
+
+void cWorldGenerator::GenerateTerrain( cChunkPtr a_Chunk )
{
Vector3i ChunkPos( a_Chunk->GetPosX(), a_Chunk->GetPosY(), a_Chunk->GetPosZ() );
char* BlockType = a_Chunk->pGetType();
@@ -154,7 +181,9 @@ void cWorldGenerator::GenerateTerrain( cChunk* a_Chunk ) -void cWorldGenerator::GenerateFoliage( cChunk* a_Chunk )
+
+
+void cWorldGenerator::GenerateFoliage( cChunkPtr a_Chunk )
{
const ENUM_BLOCK_ID GrassID = E_BLOCK_GRASS;
const ENUM_BLOCK_ID DirtID = E_BLOCK_DIRT;
@@ -213,7 +242,6 @@ void cWorldGenerator::GenerateFoliage( cChunk* a_Chunk ) BlockType[ index ] = (char)GrassID;
}
- MTRand r1;
// Plant sum trees
{
int xx = x + PosX*16;
@@ -253,3 +281,7 @@ void cWorldGenerator::GenerateFoliage( cChunk* a_Chunk ) }
}
}
+
+
+
+
|