载入中...
搜索中...
未找到
Heightmap.h
浏览该文件的文档.
1#pragma once
2
3#include "procgen/Grid2D.h"
5
6#include <cstdint>
7#include <vector>
8
9namespace eve::procgen {
10
19class Heightmap {
20public:
21 Heightmap() = default;
22 Heightmap(int width, int height);
23
24 void resize(int width, int height);
25 int getWidth() const;
26 int getHeight() const;
27 bool inBounds(int x, int y) const;
28
29 void setHeight(int x, int y, float h);
30 float height(int x, int y) const;
31
33 float sampleBilinear(float x, float y) const;
35 float sampleBilinearSeamless(float x, float y) const;
36
37 const std::vector<float> &data() const { return data_; }
38
40 static Heightmap generate(const TerrainSampler &sampler, int width, int height);
41
43 bool toGrid(Grid2D &out, const TerrainBands &bands) const;
44
45private:
46 int width_ = 0;
47 int height_ = 0;
48 std::vector<float> data_;
49};
50
51} // namespace eve::procgen
int y
Definition Grass.cpp:135
float height
Definition Grass.cpp:235
int x
Definition Grass.cpp:135
int h
int width
Intermediate 2D generation result. cells store semantic ids (see Semantic.h), not tile GIDs — convert...
Definition Grid2D.h:16
In-memory terrain heightmap: a dense float grid (row-major, index = y * width + x) materialized from ...
Definition Heightmap.h:19
float sampleBilinear(float x, float y) const
Bilinear height at continuous coordinate within [0, w) x [0, h).
Definition Heightmap.cpp:37
const std::vector< float > & data() const
Definition Heightmap.h:37
bool toGrid(Grid2D &out, const TerrainBands &bands) const
Classify heights into a semantic Grid2D (source for tilemap generation).
Definition Heightmap.cpp:84
void resize(int width, int height)
Definition Heightmap.cpp:10
float sampleBilinearSeamless(float x, float y) const
Bilinear height with wrap-around (seamless tiling).
Definition Heightmap.cpp:52
void setHeight(int x, int y, float h)
Definition Heightmap.cpp:23
static Heightmap generate(const TerrainSampler &sampler, int width, int height)
Materialize a Heightmap by sampling sampler at every pixel center.
Definition Heightmap.cpp:69
bool inBounds(int x, int y) const
Definition Heightmap.cpp:19
Deterministic terrain height sampling (Red Blob Games / Perlin fBm recipe).