47 int a_SizeX,
int a_SizeY,
56 ASSERT(!
"cOctavedNoise: No octaves to generate!");
61 std::unique_ptr<NOISE_DATATYPE[]> workspaceHeap;
62 if (a_Workspace ==
nullptr)
65 a_Workspace = workspaceHeap.get();
69 int ArrayCount = a_SizeX * a_SizeY;
73 a_Workspace, a_SizeX, a_SizeY,
78 for (
int i = 0; i < ArrayCount; i++)
80 a_Array[i] = a_Workspace[i] * Amplitude;
88 itr->m_Noise.Generate2D(
89 a_Workspace, a_SizeX, a_SizeY,
90 a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency,
91 a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency
95 for (
int i = 0; i < ArrayCount; i++)
97 a_Array[i] += a_Workspace[i] * Amplitude;
106 int a_SizeX,
int a_SizeY,
int a_SizeZ,
116 ASSERT(!
"cOctavedNoise: No octaves to generate!");
121 std::unique_ptr<NOISE_DATATYPE[]> workspaceHeap;
122 if (a_Workspace ==
nullptr)
125 a_Workspace = workspaceHeap.get();
129 int ArrayCount = a_SizeX * a_SizeY * a_SizeZ;
132 FirstOctave.
m_Noise.Generate3D(
133 a_Workspace, a_SizeX, a_SizeY, a_SizeZ,
139 for (
int i = 0; i < ArrayCount; i++)
141 a_Array[i] = a_Workspace[i] * Amplitude;
149 itr->m_Noise.Generate3D(
150 a_Workspace, a_SizeX, a_SizeY, a_SizeZ,
151 a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency,
152 a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency,
153 a_StartZ * itr->m_Frequency, a_EndZ * itr->m_Frequency
157 for (
int i = 0; i < ArrayCount; i++)
159 a_Array[i] += a_Workspace[i] * Amplitude;
float NOISE_DATATYPE
The datatype used by all the noise generators.
int m_Seed
The seed used by the underlying generators.
cOctavedNoise(int a_Seed=0)
void Generate3D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, int a_SizeZ, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, NOISE_DATATYPE *a_Workspace=nullptr) const
Fills a 3D array with the values of the noise.
void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude)
Adds a new octave to the list of octaves that compose this noise.
void Generate2D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE *a_Workspace=nullptr) const
Fills a 2D array with the values of the noise.
cOctaves m_Octaves
The octaves that compose this noise.
void SetSeed(int a_Seed)
Sets a new seed for the generators.
std::vector< cOctave > cOctaves
Stores information and state for one octave of the noise.
NOISE_DATATYPE m_Frequency
Coord multiplier.
NOISE_DATATYPE m_Amplitude
Value multiplier.
cOctave(int a_Seed, NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude)