Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
cImprovedNoise Class Reference

Improved noise, as described by Ken Perlin: https://mrl.nyu.edu/~perlin/paper445.pdf Implementation adapted from Perlin's Java implementation: https://mrl.nyu.edu/~perlin/noise/. More...

#include <Noise.h>

Public Member Functions

 cImprovedNoise (int a_Seed)
 Constructs a new instance of the noise obbject. More...
 
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) const
 Fills a 2D array with the values of the noise. More...
 
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) const
 Fills a 3D array with the values of the noise. More...
 
NOISE_DATATYPE GetValueAt (int a_X, int a_Y, int a_Z)
 Returns the value at the specified integral coords. More...
 

Static Protected Member Functions

static NOISE_DATATYPE Fade (NOISE_DATATYPE a_T)
 Calculates the fade curve, 6 * t^5 - 15 * t^4 + 10 * t^3. More...
 
static NOISE_DATATYPE Grad (int a_Hash, NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z)
 Returns the gradient value based on the hash. More...
 

Protected Attributes

int m_Perm [512]
 The permutation table used by the noise function. More...
 

Detailed Description

Improved noise, as described by Ken Perlin: https://mrl.nyu.edu/~perlin/paper445.pdf Implementation adapted from Perlin's Java implementation: https://mrl.nyu.edu/~perlin/noise/.

Definition at line 121 of file Noise.h.

Constructor & Destructor Documentation

◆ cImprovedNoise()

cImprovedNoise::cImprovedNoise ( int  a_Seed)

Constructs a new instance of the noise obbject.

Note that this operation is quite expensive (the permutation array being constructed).

Definition at line 873 of file Noise.cpp.

Member Function Documentation

◆ Fade()

static NOISE_DATATYPE cImprovedNoise::Fade ( NOISE_DATATYPE  a_T)
inlinestaticprotected

Calculates the fade curve, 6 * t^5 - 15 * t^4 + 10 * t^3.

Definition at line 157 of file Noise.h.

◆ Generate2D()

void cImprovedNoise::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 
) const

Fills a 2D array with the values of the noise.

Parameters
a_ArrayArray to generate into [x + a_SizeX * y]
a_SizeYCount of the array, in each direction
a_EndXNoise-space coords of the array in the X direction
a_EndYNoise-space coords of the array in the Y direction

Definition at line 900 of file Noise.cpp.

◆ Generate3D()

void cImprovedNoise::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 
) const

Fills a 3D array with the values of the noise.

Parameters
a_ArrayArray to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z]
a_SizeZCount of the array, in each direction
a_EndXNoise-space coords of the array in the X direction
a_EndYNoise-space coords of the array in the Y direction
a_EndZNoise-space coords of the array in the Z direction

Definition at line 947 of file Noise.cpp.

◆ GetValueAt()

NOISE_DATATYPE cImprovedNoise::GetValueAt ( int  a_X,
int  a_Y,
int  a_Z 
)

Returns the value at the specified integral coords.

Used for raw speed measurement.

Definition at line 1013 of file Noise.cpp.

◆ Grad()

static NOISE_DATATYPE cImprovedNoise::Grad ( int  a_Hash,
NOISE_DATATYPE  a_X,
NOISE_DATATYPE  a_Y,
NOISE_DATATYPE  a_Z 
)
inlinestaticprotected

Returns the gradient value based on the hash.

Definition at line 163 of file Noise.h.

Member Data Documentation

◆ m_Perm

int cImprovedNoise::m_Perm[512]
protected

The permutation table used by the noise function.

Initialized using seed.

Definition at line 153 of file Noise.h.


The documentation for this class was generated from the following files: