From cb07541029bbce8a2bd46a58850af20687588978 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 1 May 2014 23:10:37 +0200 Subject: Fixed a warning in Noise. --- src/Noise.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Noise.h') diff --git a/src/Noise.h b/src/Noise.h index 62004503f..e605051b5 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -280,7 +280,7 @@ NOISE_DATATYPE cNoise::CubicInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE cNoise::CosineInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_Pct) { const NOISE_DATATYPE ft = a_Pct * (NOISE_DATATYPE)3.1415927; - const NOISE_DATATYPE f = (1 - cos(ft)) * (NOISE_DATATYPE)0.5; + const NOISE_DATATYPE f = (NOISE_DATATYPE)((NOISE_DATATYPE)(1 - cos(ft)) * (NOISE_DATATYPE)0.5); return a_A * (1 - f) + a_B * f; } -- cgit v1.2.3 From bead36f5ed9ec9501ff9fa67bbaa8d734a7a168a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 23:38:50 +0200 Subject: Added cRidgedMultiNoise, fixed cPerlinNoise. --- src/Noise.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'src/Noise.h') diff --git a/src/Noise.h b/src/Noise.h index e605051b5..83af0cf08 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -192,6 +192,70 @@ protected: +class cRidgedMultiNoise +{ +public: + cRidgedMultiNoise(void); + cRidgedMultiNoise(int a_Seed); + + + void SetSeed(int a_Seed); + + void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude); + + void Generate1D( + NOISE_DATATYPE * a_Array, ///< Array to generate into + int a_SizeX, ///< Count of the array + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + + + void Generate2D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y] + int a_SizeX, int a_SizeY, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + + + void Generate3D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z] + int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + +protected: + class cOctave + { + public: + cCubicNoise m_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) : + m_Noise(a_Seed), + m_Frequency(a_Frequency), + m_Amplitude(a_Amplitude) + { + } + } ; + + typedef std::vector cOctaves; + + int m_Seed; + cOctaves m_Octaves; +} ; + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Inline function definitions: // These need to be in the header, otherwise linker error occur in MSVC -- cgit v1.2.3 From 993fd14ddfc881cf5be951df77da0338124d68cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 16:33:09 +0200 Subject: Fixed basic whitespace problems. Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines. --- src/Noise.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Noise.h') diff --git a/src/Noise.h b/src/Noise.h index 83af0cf08..014e43239 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -100,7 +100,7 @@ protected: cNoise m_Noise; // Used for integral rnd values #ifdef _DEBUG - // Statistics on the noise-space coords: + // Statistics on the noise-space coords: static int m_NumSingleX; static int m_NumSingleXY; static int m_NumSingleY; -- cgit v1.2.3 From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/Noise.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Noise.h') diff --git a/src/Noise.h b/src/Noise.h index 014e43239..48a1c73f7 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -256,7 +256,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Inline function definitions: // These need to be in the header, otherwise linker error occur in MSVC @@ -361,7 +361,7 @@ NOISE_DATATYPE cNoise::LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Global functions: extern void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase); -- cgit v1.2.3 From 30893e7ee2f4dbaa3e4348b07cdc77aada168e1f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 19:57:47 +0200 Subject: RoughRavines: Made floor and ceiling settings-adjustable. The world.ini has settings for the minimum and maximum height for each at the ravines' center and edges. --- src/Noise.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Noise.h') diff --git a/src/Noise.h b/src/Noise.h index 48a1c73f7..e69e5cdad 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -33,6 +33,12 @@ public: INLINE NOISE_DATATYPE IntNoise2D(int a_X, int a_Y) const; INLINE NOISE_DATATYPE IntNoise3D(int a_X, int a_Y, int a_Z) const; + // Return a float number in the specified range: + INLINE NOISE_DATATYPE IntNoise2DInRange(int a_X, int a_Y, float a_Min, float a_Max) const + { + return a_Min + std::abs(IntNoise2D(a_X, a_Y)) * (a_Max - a_Min); + } + // Note: These functions have a mod8-irregular chance - each of the mod8 remainders has different chance of occurrence. Divide by 8 to rectify. INLINE int IntNoise1DInt(int a_X) const; INLINE int IntNoise2DInt(int a_X, int a_Y) const; -- cgit v1.2.3 From 579b80fd3a3b633e59034c0924459a860d611b27 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 20:08:33 +0200 Subject: Added a missing include for abs(float). --- src/Noise.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Noise.h') diff --git a/src/Noise.h b/src/Noise.h index e69e5cdad..4cf8d4ad8 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -5,6 +5,12 @@ #pragma once +#include + + + + + // Some settings #define NOISE_DATATYPE float -- cgit v1.2.3