38 lines
744 B
C
38 lines
744 B
C
|
/*
|
||
|
* SimplexNoise.h
|
||
|
*
|
||
|
* Created on: 14.06.2013
|
||
|
* Author: Felix
|
||
|
*/
|
||
|
|
||
|
#ifndef DG_SIMPLEXNOISE_H_
|
||
|
#define DG_SIMPLEXNOISE_H_
|
||
|
|
||
|
#include <array>
|
||
|
#include <map>
|
||
|
|
||
|
/**
|
||
|
* Caching simplex noise generator.
|
||
|
*
|
||
|
* The actual simplex noise generator is simplexnoise1234.h/cpp
|
||
|
* from http://staffwww.itn.liu.se/~stegu/aqsis/aqsis-newnoise/ . See
|
||
|
* that implementation for more details.
|
||
|
*/
|
||
|
class SimplexNoise {
|
||
|
public:
|
||
|
SimplexNoise();
|
||
|
float getNoise(int x, int y);
|
||
|
|
||
|
|
||
|
private:
|
||
|
float noise(float x, float y) const;
|
||
|
float grad(int hash, float x, float y) const;
|
||
|
int fastFloor(float f) const;
|
||
|
|
||
|
private:
|
||
|
std::array<unsigned char, 512> mPerm;
|
||
|
std::map<int, std::map<int, float> > mCache;
|
||
|
};
|
||
|
|
||
|
#endif /* DG_SIMPLEXNOISE_H_ */
|