* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef NOISE_HEADER
-#define NOISE_HEADER
+#pragma once
#include "irr_v3d.h"
#include "exceptions.h"
#include "util/string.h"
+#if defined(RANDOM_MIN)
+#undef RANDOM_MIN
+#endif
+#if defined(RANDOM_MAX)
+#undef RANDOM_MAX
+#endif
+
extern FlagDesc flagdesc_noiseparams[];
// Note: this class is not polymorphic so that its high level of
throw PrngException("Invalid range (max < min)");
/*
Here, we ensure the range is not too large relative to RANDOM_MAX,
- as otherwise the effects of bias would become noticable. Unlike
+ as otherwise the effects of bias would become noticeable. Unlike
PcgRandom, we cannot modify this RNG's range as it would change the
output of this RNG for reverse compatibility.
*/
NoiseParams() = default;
- NoiseParams(float offset_, float scale_, v3f spread_, s32 seed_,
+ NoiseParams(float offset_, float scale_, const v3f &spread_, s32 seed_,
u16 octaves_, float persist_, float lacunarity_,
u32 flags_=NOISE_FLAG_DEFAULTS)
{
float *persist_buf = nullptr;
float *result = nullptr;
- Noise(NoiseParams *np, s32 seed, u32 sx, u32 sy, u32 sz=1);
+ Noise(const NoiseParams *np, s32 seed, u32 sx, u32 sy, u32 sz=1);
~Noise();
void setSize(u32 sx, u32 sy, u32 sz=1);
private:
void allocBuffers();
void resizeNoiseBuf(bool is3d);
- void updateResults(float g, float *gmap, float *persistence_map, size_t bufsize);
+ void updateResults(float g, float *gmap, const float *persistence_map,
+ size_t bufsize);
};
-float NoisePerlin2D(NoiseParams *np, float x, float y, s32 seed);
-float NoisePerlin3D(NoiseParams *np, float x, float y, float z, s32 seed);
+float NoisePerlin2D(const NoiseParams *np, float x, float y, s32 seed);
+float NoisePerlin3D(const NoiseParams *np, float x, float y, float z, s32 seed);
inline float NoisePerlin2D_PO(NoiseParams *np, float x, float xoff,
float y, float yoff, s32 seed)
float noise2d_perlin(float x, float y, s32 seed,
int octaves, float persistence, bool eased=true);
-float noise2d_perlin_abs(float x, float y, s32 seed,
- int octaves, float persistence, bool eased=true);
-
-float noise3d_perlin(float x, float y, float z, s32 seed,
- int octaves, float persistence, bool eased=false);
-
-float noise3d_perlin_abs(float x, float y, float z, s32 seed,
- int octaves, float persistence, bool eased=false);
-
inline float easeCurve(float t)
{
return t * t * t * (t * (6.f * t - 15.f) + 10.f);
}
float contour(float v);
-
-#endif
-