载入中...
搜索中...
未找到
HexNoise.h
浏览该文件的文档.
1#pragma once
2
5#include "hexmap/HexMetrics.h"
6
7#include <cstdint>
8
9namespace eve::hexmap {
10
23class HexNoise {
24public:
26 static constexpr float kCellScale = 43.3f;
27
32 explicit HexNoise(std::uint32_t seed = 0u) noexcept : seed_(seed) {}
33
35 void reset(std::uint32_t seed) noexcept { seed_ = seed; }
37 [[nodiscard]] std::uint32_t seed() const noexcept { return seed_; }
38
46 [[nodiscard]] HexVec4 sample(float worldX, float worldZ) const noexcept;
47
53 [[nodiscard]] HexVec3 perturb(HexVec3 position) const noexcept;
54
60 [[nodiscard]] float elevationPerturb(float worldX, float worldZ) const noexcept;
61
62private:
63 [[nodiscard]] float lattice(int ix, int iz, int channel) const noexcept;
64
65 std::uint32_t seed_ = 0u;
66};
67
68} // namespace eve::hexmap
float u
Definition Grass.cpp:233
Pointy-top hex metrics, directions and vertex helpers.
std::array< float, 3 > position
Deterministic four-channel value noise over the XZ plane.
Definition HexNoise.h:23
HexVec3 perturb(HexVec3 position) const noexcept
Perturbs a position in XZ by ±kCellPerturbStrength.
Definition HexNoise.cpp:56
std::uint32_t seed() const noexcept
The seed this field was created with.
Definition HexNoise.h:37
HexNoise(std::uint32_t seed=0u) noexcept
Creates a noise field for seed.
Definition HexNoise.h:32
float elevationPerturb(float worldX, float worldZ) const noexcept
Vertical perturbation applied to a cell's elevation, ±kElevationPerturbStrength.
Definition HexNoise.cpp:63
static constexpr float kCellScale
Scale of the noise relative to one hex cell (world units per noise unit).
Definition HexNoise.h:26
HexVec4 sample(float worldX, float worldZ) const noexcept
Samples the four noise channels at a world XZ position.
Definition HexNoise.cpp:32
void reset(std::uint32_t seed) noexcept
Reseeds the field.
Definition HexNoise.h:35
Minimal 3-component float vector used by the hex mesh builders.
Definition HexMetrics.h:18
Four-component float vector, matching the reference four-channel noise sample.
Definition HexMetrics.h:43