summaryrefslogtreecommitdiffstats
path: root/src/Noise
diff options
context:
space:
mode:
Diffstat (limited to 'src/Noise')
-rw-r--r--src/Noise/InterpolNoise.h26
-rw-r--r--src/Noise/Noise.cpp54
-rw-r--r--src/Noise/OctavedNoise.h2
3 files changed, 41 insertions, 41 deletions
diff --git a/src/Noise/InterpolNoise.h b/src/Noise/InterpolNoise.h
index afc7cff49..447796739 100644
--- a/src/Noise/InterpolNoise.h
+++ b/src/Noise/InterpolNoise.h
@@ -42,7 +42,7 @@ public:
m_FracY(a_FracY)
{
}
-
+
/** Generates part of the output noise array using the current m_WorkRnds[] values */
void Generate(
@@ -63,7 +63,7 @@ public:
} // for x
} // for y
}
-
+
/** Initializes m_WorkRnds[] with the specified values of the noise at the specified integral coords. */
void InitWorkRnds(int a_FloorX, int a_FloorY)
@@ -75,7 +75,7 @@ public:
(*m_WorkRnds)[1][0] = m_Noise.IntNoise2D(m_CurFloorX + 1, m_CurFloorY);
(*m_WorkRnds)[1][1] = m_Noise.IntNoise2D(m_CurFloorX + 1, m_CurFloorY + 1);
}
-
+
/** Updates m_WorkRnds[] for the new integral coords */
void Move(int a_NewFloorX, int a_NewFloorY)
@@ -85,7 +85,7 @@ public:
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:
// TODO: Try out if simply calculating all 4 elements each time is faster than this monster loop
int DiffX = OldFloorX - a_NewFloorX;
@@ -114,10 +114,10 @@ public:
protected:
typedef NOISE_DATATYPE Workspace[2][2];
-
+
/** The noise used for generating the values at integral coords. */
const cNoise & m_Noise;
-
+
/** The current random values; points to either m_Workspace1 or m_Workspace2 (doublebuffering) */
Workspace * m_WorkRnds;
@@ -129,7 +129,7 @@ protected:
/** Coords of the currently calculated m_WorkRnds[]. */
int m_CurFloorX, m_CurFloorY;
-
+
/** The output array to generate into. */
NOISE_DATATYPE * m_Array;
@@ -346,7 +346,7 @@ public:
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];
@@ -357,11 +357,11 @@ public:
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);
-
+
cInterpolCell2D<T> 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++)
@@ -422,9 +422,9 @@ public:
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++)
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;
diff --git a/src/Noise/OctavedNoise.h b/src/Noise/OctavedNoise.h
index efb9a0167..6dd79365f 100644
--- a/src/Noise/OctavedNoise.h
+++ b/src/Noise/OctavedNoise.h
@@ -167,7 +167,7 @@ protected:
{
public:
N m_Noise;
-
+
/** Coord multiplier. */
NOISE_DATATYPE m_Frequency;