-
Notifications
You must be signed in to change notification settings - Fork 6
/
slope_height_func.cpp
101 lines (101 loc) · 2.62 KB
/
slope_height_func.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <cassert>
float slope_height_offset(unsigned char slope_type, float dx, float dz) {
assert((dx >= 0.0f) && (dx <= 1.0f));
assert((dz >= 0.0f) && (dz <= 1.0f));
switch(slope_type) {
case 0:
return 1.0f;
case 1:
return 0.500000f - dz * 0.500000f;
case 2:
return 1.000000f - dz * 0.500000f;
case 3:
return 0.000000f + dz * 0.500000f;
case 4:
return 0.500000f + dz * 0.500000f;
case 5:
return 0.500000f - dx * 0.500000f;
case 6:
return 1.000000f - dx * 0.500000f;
case 7:
return 0.000000f + dx * 0.500000f;
case 8:
return 0.500000f + dx * 0.500000f;
case 9:
return 0.130000f - dz * 0.130000f;
case 10:
return 0.250000f - dz * 0.120000f;
case 11:
return 0.380000f - dz * 0.130000f;
case 12:
return 0.500000f - dz * 0.120000f;
case 13:
return 0.630000f - dz * 0.130000f;
case 14:
return 0.750000f - dz * 0.120000f;
case 15:
return 0.880000f - dz * 0.130000f;
case 16:
return 1.000000f - dz * 0.120000f;
case 17:
return 0.000000f + dz * 0.130000f;
case 18:
return 0.130000f + dz * 0.120000f;
case 19:
return 0.250000f + dz * 0.130000f;
case 20:
return 0.380000f + dz * 0.120000f;
case 21:
return 0.500000f + dz * 0.130000f;
case 22:
return 0.630000f + dz * 0.120000f;
case 23:
return 0.750000f + dz * 0.130000f;
case 24:
return 0.880000f + dz * 0.120000f;
case 25:
return 0.130000f - dx * 0.130000f;
case 26:
return 0.250000f - dx * 0.120000f;
case 27:
return 0.380000f - dx * 0.130000f;
case 28:
return 0.500000f - dx * 0.120000f;
case 29:
return 0.630000f - dx * 0.130000f;
case 30:
return 0.750000f - dx * 0.120000f;
case 31:
return 0.880000f - dx * 0.130000f;
case 32:
return 1.000000f - dx * 0.120000f;
case 33:
return 0.000000f + dx * 0.130000f;
case 34:
return 0.130000f + dx * 0.120000f;
case 35:
return 0.250000f + dx * 0.130000f;
case 36:
return 0.380000f + dx * 0.120000f;
case 37:
return 0.500000f + dx * 0.130000f;
case 38:
return 0.630000f + dx * 0.120000f;
case 39:
return 0.750000f + dx * 0.130000f;
case 40:
return 0.880000f + dx * 0.120000f;
case 41:
return 1.000000f - dz * 1.000000f;
case 42:
return 0.000000f + dz * 1.000000f;
case 43:
return 1.000000f - dx * 1.000000f;
case 44:
return 0.000000f + dx * 1.000000f;
default:
break;
}
assert(0);
return 0.0f; // should never be reached
}