summaryrefslogtreecommitdiffstats
path: root/src/Noise.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-07-29 17:46:57 +0200
committerMattes D <github@xoft.cz>2014-07-29 17:46:57 +0200
commit8287f2d93354a584bb44216b4b59d28d9a5f0fb2 (patch)
tree767b4c95a3ce907cb1f6162450c10dca39518e7a /src/Noise.h
parentDistortedHeightmap: Now generates gravel in deep ocean. (diff)
parentAdded a missing include for abs(float). (diff)
downloadcuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.tar
cuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.tar.gz
cuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.tar.bz2
cuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.tar.lz
cuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.tar.xz
cuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.tar.zst
cuberite-8287f2d93354a584bb44216b4b59d28d9a5f0fb2.zip
Diffstat (limited to '')
-rw-r--r--src/Noise.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Noise.h b/src/Noise.h
index 48a1c73f7..4cf8d4ad8 100644
--- a/src/Noise.h
+++ b/src/Noise.h
@@ -5,6 +5,12 @@
#pragma once
+#include <cmath>
+
+
+
+
+
// Some settings
#define NOISE_DATATYPE float
@@ -33,6 +39,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;