-
Notifications
You must be signed in to change notification settings - Fork 3
/
DynamicHeightMap.h
78 lines (64 loc) · 2.36 KB
/
DynamicHeightMap.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// DynamicHeightMap.h: interface for the CDynamicHeightMap class.
//
#if !defined(AFX_DYNAMICHEIGHTMAP_H__5A5BD0B8_1FC7_4067_A5A4_D40422E8B6D1__INCLUDED_)
#define AFX_DYNAMICHEIGHTMAP_H__5A5BD0B8_1FC7_4067_A5A4_D40422E8B6D1__INCLUDED_
#pragma once
const int dhm_line = 4;
const int dhm_matrix = (dhm_line+1+dhm_line); // 9x9 array
const float dhm_size = 4.f; // 4m per slot
const int dhm_precision = 16; // 32x32 subdivs per slot
const int dhm_total = dhm_matrix*dhm_matrix;
//
class CHM_Static
{
struct Slot
{
float data [dhm_precision][dhm_precision];
BOOL bReady;
int x,z;
IC void set (int _x, int _z) { x=_x; z=_z; }
IC void clear ()
{
for (u32 i=0; i<dhm_precision; ++i)
for (u32 j=0; j<dhm_precision; ++j)
data [i][j] = flt_min;
}
Slot()
{
clear ();
set (0,0);
bReady = TRUE;
}
};
struct Poly
{
Fvector v[3];
};
Slot pool [dhm_matrix*dhm_matrix]; // pool
Slot* data [dhm_matrix][dhm_matrix]; // database
int c_x,c_z; // center of heighmap
svector<Slot*,dhm_total> task;
xr_vector<Poly> polys;
public:
void Update ();
float Query (float x, float z); // 2D query
CHM_Static ();
};
//
class CHM_Dynamic
{
public:
void Update ();
float Query (float x, float z); // 2D query
};
//
class CHeightMap
{
CHM_Static hm_static;
CHM_Dynamic hm_dynamic;
u32 dwFrame;
public:
float Query (float x, float z); // 2D query
Fvector Query (Fvector& pos, Fvector& dir); // 3D ray-query
};
#endif // !defined(AFX_DYNAMICHEIGHTMAP_H__5A5BD0B8_1FC7_4067_A5A4_D40422E8B6D1__INCLUDED_)