Files
Cubed/include/Cubed/tools/perlin_noise.hpp
zhenyan121 a54e87dbc6 refactor: terrain generation (#9)
* feat: add BlockType

* refactor: use fBM for heightmap generation

* feat: improve mountain realism

* refactor: adjust mountain spawn probability

* feat: add biome boundary blending

* refactor: remove resolve_biome_adjacency_conflict function

* feat: add snowy plain

* perf: speed up world generation

* refactor: lower overall terrain height
2026-05-23 10:33:52 +08:00

36 lines
880 B
C++

#pragma once
#include <atomic>
#include <vector>
namespace Cubed {
class PerlinNoise3D {
public:
static void init(unsigned seed);
static float noise(float x, float y, float z);
static void reload(unsigned seed);
private:
static inline std::atomic<bool> is_init = false;
static inline std::vector<int> p;
static float fade(float t);
static float lerp(float t, float a, float b);
static float grad(int hash, float x, float y, float z);
};
class PerlinNoise2D {
public:
static void init(unsigned seed);
static float noise(float x, float y);
static void reload(unsigned seed);
private:
static inline std::atomic<bool> is_init = false;
static inline std::vector<int> p;
static float fade(float t);
static float lerp(float t, float a, float b);
static float grad(int hash, float x, float y);
};
} // namespace Cubed