Added Comments

Added ability to hold shift and skip the terrain generation when loading
Added ability for the perlin terrain to save a raw image of the terrain to use as a cache
This commit is contained in:
iDunnoDev
2022-06-13 16:41:25 +01:00
committed by iDunnoDev
parent 51afdeecbd
commit 616f68bf8b
40 changed files with 468 additions and 51 deletions

View File

@ -3,9 +3,11 @@
#include <vector>
#include <numeric>
#include <random>
#include <fstream>
#include "SharedMethods.h"
#include "TerrainNode.h"
// Class for generating a terrain using a perlin noise algorithm, this now caches the result too so it only has to run on the initial time its loaded.
class PerlinTerrainNode : public TerrainNode
{
public:
@ -41,11 +43,20 @@ private:
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
};
// Vector to hold the actual randomised perlin noise permutation array
vector<unsigned char> _p;
// The chunk size lets us control how large a noise spot should be, lower numbers will make things flatter, larger numbers will make things spikey
float _chunkSize;
// Methods for Caching the output to a raw image format, and reading it back in the next time its loaded
bool ReadCache();
void CacheOutput();
// Methods for fading a number, used for the noise calculation
float Fade(float t);
// Method for generating a perlin gradient.
float Grad(int hash, float x, float y);
void GeneratePerlinValues();