diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-02-05 22:45:45 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-02-05 22:50:18 +0100 |
commit | ca6ef58b1ee8521e4b940ee4883dee714960e413 (patch) | |
tree | 8532add455224b07c07a759e3d906f50c0695888 /src/Noise/Noise.cpp | |
parent | Merge pull request #2972 from marvinkopf/PlayerAutoComplete (diff) | |
download | cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.gz cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.bz2 cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.lz cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.xz cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.zst cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Noise/Noise.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/src/Noise/Noise.cpp b/src/Noise/Noise.cpp index aa9f0412f..cc63a34a9 100644 --- a/src/Noise/Noise.cpp +++ b/src/Noise/Noise.cpp @@ -116,7 +116,7 @@ void Debug3DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY { const int BUF_SIZE = 512; ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed - + // Save in XY cuts: cFile f1; if (f1.Open(Printf("%s_XY (" SIZE_T_FMT ").grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite)) @@ -169,7 +169,7 @@ void Debug2DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY { const int BUF_SIZE = 512; ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed - + cFile f1; if (f1.Open(Printf("%s (" SIZE_T_FMT ").grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite)) { @@ -203,30 +203,30 @@ public: const NOISE_DATATYPE * a_FracX, ///< Pointer to the array that stores the X fractional values const NOISE_DATATYPE * a_FracY ///< Pointer to the attay that stores the Y fractional values ); - + /** Uses current m_WorkRnds[] to generate part of the array */ void Generate( int a_FromX, int a_ToX, int a_FromY, int a_ToY ); - + /** Initializes m_WorkRnds[] with the specified Floor values */ void InitWorkRnds(int a_FloorX, int a_FloorY); - + /** Updates m_WorkRnds[] for the new Floor values. */ void Move(int a_NewFloorX, int a_NewFloorY); protected: typedef NOISE_DATATYPE Workspace[4][4]; - + const cNoise & m_Noise; - + Workspace * m_WorkRnds; ///< The current random values; points to either m_Workspace1 or m_Workspace2 (doublebuffering) Workspace m_Workspace1; ///< Buffer 1 for workspace doublebuffering, used in Move() Workspace m_Workspace2; ///< Buffer 2 for workspace doublebuffering, used in Move() int m_CurFloorX; int m_CurFloorY; - + NOISE_DATATYPE * m_Array; int m_SizeX, m_SizeY; const NOISE_DATATYPE * m_FracX; @@ -311,7 +311,7 @@ void cCubicCell2D::Move(int a_NewFloorX, int a_NewFloorY) int OldFloorY = m_CurFloorY; Workspace * OldWorkRnds = m_WorkRnds; m_WorkRnds = (m_WorkRnds == &m_Workspace1) ? &m_Workspace2 : &m_Workspace1; - + // Reuse as much of the old workspace as possible: int DiffX = OldFloorX - a_NewFloorX; int DiffY = OldFloorY - a_NewFloorY; @@ -355,32 +355,32 @@ public: const NOISE_DATATYPE * a_FracY, ///< Pointer to the attay that stores the Y fractional values const NOISE_DATATYPE * a_FracZ ///< Pointer to the array that stores the Z fractional values ); - + /** Uses current m_WorkRnds[] to generate part of the array */ void Generate( int a_FromX, int a_ToX, int a_FromY, int a_ToY, int a_FromZ, int a_ToZ ); - + /** Initializes m_WorkRnds[] with the specified Floor values */ void InitWorkRnds(int a_FloorX, int a_FloorY, int a_FloorZ); - + /** Updates m_WorkRnds[] for the new Floor values. */ void Move(int a_NewFloorX, int a_NewFloorY, int a_NewFloorZ); protected: typedef NOISE_DATATYPE Workspace[4][4][4]; - + const cNoise & m_Noise; - + Workspace * m_WorkRnds; ///< The current random values; points to either m_Workspace1 or m_Workspace2 (doublebuffering) Workspace m_Workspace1; ///< Buffer 1 for workspace doublebuffering, used in Move() Workspace m_Workspace2; ///< Buffer 2 for workspace doublebuffering, used in Move() int m_CurFloorX; int m_CurFloorY; int m_CurFloorZ; - + NOISE_DATATYPE * m_Array; int m_SizeX, m_SizeY, m_SizeZ; const NOISE_DATATYPE * m_FracX; @@ -490,7 +490,7 @@ void cCubicCell3D::Move(int a_NewFloorX, int a_NewFloorY, int a_NewFloorZ) int OldFloorZ = m_CurFloorZ; Workspace * OldWorkRnds = m_WorkRnds; m_WorkRnds = (m_WorkRnds == &m_Workspace1) ? &m_Workspace2 : &m_Workspace1; - + // Reuse as much of the old workspace as possible: int DiffX = OldFloorX - a_NewFloorX; int DiffY = OldFloorY - a_NewFloorY; @@ -594,7 +594,7 @@ NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) cons { const int BaseX = FAST_FLOOR(a_X); const int BaseY = FAST_FLOOR(a_Y); - + const NOISE_DATATYPE points[4][4] = { { IntNoise2D(BaseX - 1, BaseY - 1), IntNoise2D(BaseX, BaseY - 1), IntNoise2D(BaseX + 1, BaseY - 1), IntNoise2D(BaseX + 2, BaseY - 1), }, @@ -623,7 +623,7 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const int BaseX = FAST_FLOOR(a_X); const int BaseY = FAST_FLOOR(a_Y); const int BaseZ = FAST_FLOOR(a_Z); - + const NOISE_DATATYPE points1[4][4] = { { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), }, @@ -716,7 +716,7 @@ void cCubicNoise::Generate2D( ASSERT(a_SizeY < MAX_SIZE); ASSERT(a_StartX < a_EndX); ASSERT(a_StartY < a_EndY); - + // Calculate the integral and fractional parts of each coord: int FloorX[MAX_SIZE]; int FloorY[MAX_SIZE]; @@ -727,11 +727,11 @@ void cCubicNoise::Generate2D( int NumSameX, NumSameY; CalcFloorFrac(a_SizeX, a_StartX, a_EndX, FloorX, FracX, SameX, NumSameX); CalcFloorFrac(a_SizeY, a_StartY, a_EndY, FloorY, FracY, SameY, NumSameY); - + cCubicCell2D Cell(m_Noise, a_Array, a_SizeX, a_SizeY, FracX, FracY); - + Cell.InitWorkRnds(FloorX[0], FloorY[0]); - + // Calculate query values using Cell: int FromY = 0; for (int y = 0; y < NumSameY; y++) @@ -769,7 +769,7 @@ void cCubicNoise::Generate3D( ASSERT(a_StartX < a_EndX); ASSERT(a_StartY < a_EndY); ASSERT(a_StartZ < a_EndZ); - + // Calculate the integral and fractional parts of each coord: int FloorX[MAX_SIZE]; int FloorY[MAX_SIZE]; @@ -784,15 +784,15 @@ void cCubicNoise::Generate3D( CalcFloorFrac(a_SizeX, a_StartX, a_EndX, FloorX, FracX, SameX, NumSameX); CalcFloorFrac(a_SizeY, a_StartY, a_EndY, FloorY, FracY, SameY, NumSameY); CalcFloorFrac(a_SizeZ, a_StartZ, a_EndZ, FloorZ, FracZ, SameZ, NumSameZ); - + cCubicCell3D Cell( m_Noise, a_Array, a_SizeX, a_SizeY, a_SizeZ, FracX, FracY, FracZ ); - + Cell.InitWorkRnds(FloorX[0], FloorY[0], FloorZ[0]); - + // Calculate query values using Cell: int FromZ = 0; for (int z = 0; z < NumSameZ; z++) @@ -841,7 +841,7 @@ void cCubicNoise::CalcFloorFrac( a_Frac[i] = val - a_Floor[i]; val += dif; } - + // Mark up the same floor values into a_Same / a_NumSame: int CurFloor = a_Floor[0]; int LastSame = 0; |