added base of procedural generation

This commit is contained in:
Namonay
2025-05-23 23:48:17 +02:00
parent 9928c98215
commit 910f21b9b9
2 changed files with 96 additions and 4 deletions

View File

@@ -4,17 +4,27 @@
#include <ScopMaths.h>
#include <Chunk.h>
#include <array>
#include <random>
#define NOISE_SIZE 512
class Noise
{
public:
Noise() = default;
Noise(const std::uint32_t seed = 42);
[[nodiscard]] std::array<std::uint32_t, CHUNK_SIZE.y> GetHeight(Scop::Vec2i pos);
float perlin2D(float x, float y);
int perlin2D(int x, int y);
~Noise() = default;
private:
std::mt19937 seed;
std::array<int, NOISE_SIZE> perms;
void InitPermutation(void);
float fade(float t);
float lerp(float a, float b, float t);
float grad(int hash, float x, float y);
};
#endif