From bd910e78e274ade7721e9674a1dd73825c2d2d7e Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 16 May 2013 13:14:25 +0000 Subject: DistortedHeightmap: Rewritten to use the optimized cPerlinNoise and linear upscaling git-svn-id: http://mc-server.googlecode.com/svn/trunk@1486 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Generating/DistortedHeightmap.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'source/Generating/DistortedHeightmap.h') diff --git a/source/Generating/DistortedHeightmap.h b/source/Generating/DistortedHeightmap.h index 2b962940a..9027b609a 100644 --- a/source/Generating/DistortedHeightmap.h +++ b/source/Generating/DistortedHeightmap.h @@ -35,11 +35,18 @@ public: protected: typedef cChunkDef::BiomeMap BiomeNeighbors[3][3]; - cNoise m_Noise1; - cNoise m_Noise2; - cNoise m_Noise3; - cNoise m_Noise4; - cNoise m_Noise5; + // Linear upscaling step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively: + static const int INTERPOL_X = 8; + static const int INTERPOL_Y = 4; + static const int INTERPOL_Z = 8; + + // Linear upscaling buffer dimensions, calculated from the step sizes: + static const int DIM_X = 1 + (17 / INTERPOL_X); + static const int DIM_Y = 1 + (257 / INTERPOL_Y); + static const int DIM_Z = 1 + (17 / INTERPOL_Z); + + cPerlinNoise m_NoiseDistortX; + cPerlinNoise m_NoiseDistortZ; int m_SeaLevel; NOISE_DATATYPE m_FrequencyX; @@ -48,7 +55,7 @@ protected: int m_CurChunkX; int m_CurChunkZ; - NOISE_DATATYPE m_DistortedHeightmap[17 * 17 * 257]; + NOISE_DATATYPE m_DistortedHeightmap[17 * 257 * 17]; cBiomeGen & m_BiomeGen; cHeiGenBiomal m_UnderlyingHeiGen; // This generator provides us with base heightmap (before distortion) @@ -65,8 +72,9 @@ protected: } ; static const sGenParam m_GenParam[biNumBiomes]; - NOISE_DATATYPE m_DistortAmpX[17 * 17]; - NOISE_DATATYPE m_DistortAmpZ[17 * 17]; + // Distortion amplitudes for each direction, before linear upscaling + NOISE_DATATYPE m_DistortAmpX[DIM_X * DIM_Z]; + NOISE_DATATYPE m_DistortAmpZ[DIM_X * DIM_Z]; /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise arrays, heightmap) -- cgit v1.2.3