forked from tylermorganwall/terrainmeshr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheightmap.h
47 lines (37 loc) · 761 Bytes
/
heightmap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <Rcpp.h>
using namespace Rcpp;
#include <string>
#include <utility>
#include <vector>
struct ivec2 {
int x;
int y;
};
class Heightmap {
public:
Heightmap(const std::vector<float> &data);
Heightmap(
const int width,
const int height,
const std::vector<float> &data);
int Width() const {
return m_Width;
}
int Height() const {
return m_Height;
}
float At(const int x, const int y) const {
return m_Data[y * m_Width + x];
}
float At(const ivec2 p) const {
return m_Data[p.y * m_Width + p.x];
}
std::pair<ivec2, float> FindCandidate(
const ivec2 p0,
const ivec2 p1,
const ivec2 p2) const;
private:
int m_Width;
int m_Height;
std::vector<float> m_Data;
};