Minetest  5.4.0
noise.cpp File Reference
#include <cmath>
#include "noise.h"
#include <iostream>
#include <cstring>
#include "debug.h"
#include "util/numeric.h"
#include "util/string.h"
#include "exceptions.h"
+ Include dependency graph for noise.cpp:

Macros

#define NOISE_MAGIC_X   1619
 
#define NOISE_MAGIC_Y   31337
 
#define NOISE_MAGIC_Z   52591
 
#define NOISE_MAGIC_SEED   1013
 
#define idx(x, y)   ((y) * nlx + (x))
 
#define idx(x, y, z)   ((z) * nly * nlx + (y) * nlx + (x))
 

Typedefs

typedef float(* Interp2dFxn) (float v00, float v10, float v01, float v11, float x, float y)
 
typedef float(* Interp3dFxn) (float v000, float v100, float v010, float v110, float v001, float v101, float v011, float v111, float x, float y, float z)
 

Functions

float noise2d (int x, int y, s32 seed)
 
float noise3d (int x, int y, int z, s32 seed)
 
float dotProduct (float vx, float vy, float wx, float wy)
 
float linearInterpolation (float v0, float v1, float t)
 
float biLinearInterpolation (float v00, float v10, float v01, float v11, float x, float y)
 
float biLinearInterpolationNoEase (float v00, float v10, float v01, float v11, float x, float y)
 
float triLinearInterpolation (float v000, float v100, float v010, float v110, float v001, float v101, float v011, float v111, float x, float y, float z)
 
float triLinearInterpolationNoEase (float v000, float v100, float v010, float v110, float v001, float v101, float v011, float v111, float x, float y, float z)
 
float noise2d_gradient (float x, float y, s32 seed, bool eased)
 
float noise3d_gradient (float x, float y, float z, s32 seed, bool eased)
 
float noise2d_perlin (float x, float y, s32 seed, int octaves, float persistence, bool eased)
 
float noise2d_perlin_abs (float x, float y, s32 seed, int octaves, float persistence, bool eased)
 
float noise3d_perlin (float x, float y, float z, s32 seed, int octaves, float persistence, bool eased)
 
float noise3d_perlin_abs (float x, float y, float z, s32 seed, int octaves, float persistence, bool eased)
 
float contour (float v)
 
float NoisePerlin2D (NoiseParams *np, float x, float y, s32 seed)
 
float NoisePerlin3D (NoiseParams *np, float x, float y, float z, s32 seed)
 

Variables

FlagDesc flagdesc_noiseparams []
 

Macro Definition Documentation

◆ idx [1/2]

#define idx (   x,
 
)    ((y) * nlx + (x))

◆ idx [2/2]

#define idx (   x,
  y,
 
)    ((z) * nly * nlx + (y) * nlx + (x))

◆ NOISE_MAGIC_SEED

#define NOISE_MAGIC_SEED   1013

◆ NOISE_MAGIC_X

#define NOISE_MAGIC_X   1619

◆ NOISE_MAGIC_Y

#define NOISE_MAGIC_Y   31337

◆ NOISE_MAGIC_Z

#define NOISE_MAGIC_Z   52591

Typedef Documentation

◆ Interp2dFxn

typedef float(* Interp2dFxn) (float v00, float v10, float v01, float v11, float x, float y)

◆ Interp3dFxn

typedef float(* Interp3dFxn) (float v000, float v100, float v010, float v110, float v001, float v101, float v011, float v111, float x, float y, float z)

Function Documentation

◆ biLinearInterpolation()

float biLinearInterpolation ( float  v00,
float  v10,
float  v01,
float  v11,
float  x,
float  y 
)
inline

References easeCurve(), and linearInterpolation().

Referenced by Noise::gradientMap2D(), and noise2d_gradient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ biLinearInterpolationNoEase()

float biLinearInterpolationNoEase ( float  v00,
float  v10,
float  v01,
float  v11,
float  x,
float  y 
)
inline

References linearInterpolation().

Referenced by Noise::gradientMap2D(), noise2d_gradient(), triLinearInterpolation(), and triLinearInterpolationNoEase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contour()

float contour ( float  v)

Referenced by OreVein::generate(), and CavesNoiseIntersection::generateCaves().

+ Here is the caller graph for this function:

◆ dotProduct()

float dotProduct ( float  vx,
float  vy,
float  wx,
float  wy 
)
inline

◆ linearInterpolation()

float linearInterpolation ( float  v0,
float  v1,
float  t 
)
inline

Referenced by biLinearInterpolation(), biLinearInterpolationNoEase(), triLinearInterpolation(), and triLinearInterpolationNoEase().

+ Here is the caller graph for this function:

◆ noise2d()

float noise2d ( int  x,
int  y,
s32  seed 
)

References NOISE_MAGIC_SEED, NOISE_MAGIC_X, NOISE_MAGIC_Y, and seed.

Referenced by MapgenV6::getBiome(), Noise::gradientMap2D(), and noise2d_gradient().

+ Here is the caller graph for this function:

◆ noise2d_gradient()

float noise2d_gradient ( float  x,
float  y,
s32  seed,
bool  eased 
)

References biLinearInterpolation(), biLinearInterpolationNoEase(), myfloor, noise2d(), and seed.

Referenced by noise2d_perlin(), noise2d_perlin_abs(), and NoisePerlin2D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise2d_perlin()

float noise2d_perlin ( float  x,
float  y,
s32  seed,
int  octaves,
float  persistence,
bool  eased 
)

References noise2d_gradient(), and seed.

Referenced by Clouds::gridFilled().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise2d_perlin_abs()

float noise2d_perlin_abs ( float  x,
float  y,
s32  seed,
int  octaves,
float  persistence,
bool  eased 
)

References noise2d_gradient(), and seed.

+ Here is the call graph for this function:

◆ noise3d()

float noise3d ( int  x,
int  y,
int  z,
s32  seed 
)

References NOISE_MAGIC_SEED, NOISE_MAGIC_X, NOISE_MAGIC_Y, NOISE_MAGIC_Z, and seed.

Referenced by MapBlockMesh::MapBlockMesh(), Noise::gradientMap3D(), and noise3d_gradient().

+ Here is the caller graph for this function:

◆ noise3d_gradient()

float noise3d_gradient ( float  x,
float  y,
float  z,
s32  seed,
bool  eased 
)

References myfloor, noise3d(), seed, triLinearInterpolation(), and triLinearInterpolationNoEase().

Referenced by noise3d_perlin(), noise3d_perlin_abs(), and NoisePerlin3D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noise3d_perlin()

float noise3d_perlin ( float  x,
float  y,
float  z,
s32  seed,
int  octaves,
float  persistence,
bool  eased 
)

References noise3d_gradient(), and seed.

+ Here is the call graph for this function:

◆ noise3d_perlin_abs()

float noise3d_perlin_abs ( float  x,
float  y,
float  z,
s32  seed,
int  octaves,
float  persistence,
bool  eased 
)

References noise3d_gradient(), and seed.

+ Here is the call graph for this function:

◆ NoisePerlin2D()

◆ NoisePerlin3D()

float NoisePerlin3D ( NoiseParams np,
float  x,
float  y,
float  z,
s32  seed 
)

◆ triLinearInterpolation()

float triLinearInterpolation ( float  v000,
float  v100,
float  v010,
float  v110,
float  v001,
float  v101,
float  v011,
float  v111,
float  x,
float  y,
float  z 
)

References biLinearInterpolationNoEase(), easeCurve(), and linearInterpolation().

Referenced by Noise::gradientMap3D(), and noise3d_gradient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ triLinearInterpolationNoEase()

float triLinearInterpolationNoEase ( float  v000,
float  v100,
float  v010,
float  v110,
float  v001,
float  v101,
float  v011,
float  v111,
float  x,
float  y,
float  z 
)

References biLinearInterpolationNoEase(), and linearInterpolation().

Referenced by Noise::gradientMap3D(), and noise3d_gradient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ flagdesc_noiseparams

FlagDesc flagdesc_noiseparams[]
Initial value:
= {
{"defaults", NOISE_FLAG_DEFAULTS},
{"eased", NOISE_FLAG_EASED},
{"absvalue", NOISE_FLAG_ABSVALUE},
{"pointbuffer", NOISE_FLAG_POINTBUFFER},
{"simplex", NOISE_FLAG_SIMPLEX},
{NULL, 0}
}
#define NOISE_FLAG_SIMPLEX
Definition: noise.h:108
#define NOISE_FLAG_EASED
Definition: noise.h:103
#define NOISE_FLAG_DEFAULTS
Definition: noise.h:102
#define NOISE_FLAG_POINTBUFFER
Definition: noise.h:107
#define NOISE_FLAG_ABSVALUE
Definition: noise.h:104

Referenced by Settings::getNoiseParamsFromGroup(), push_noiseparams(), read_noiseparams(), and Settings::setNoiseParams().