forked from libtcod/python-tcod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath.cpp
More file actions
47 lines (37 loc) · 1.45 KB
/
path.cpp
File metadata and controls
47 lines (37 loc) · 1.45 KB
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 "path.h"
#include <SDL_stdinc.h>
static char* PickArrayValue(const struct PathCostArray *map, int i, int j) {
return map->array + map->strides[0] * i + map->strides[1] * j;
}
template <typename T>
static float GetPathCost(const struct PathCostArray *map, int i, int j) {
return (float)(((T*)PickArrayValue(map, i, j))[0]);
}
float PathCostArrayFloat32(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<float>(map, x2, y2);
}
float PathCostArrayInt8(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<int8_t>(map, x2, y2);
}
float PathCostArrayInt16(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<int16_t>(map, x2, y2);
}
float PathCostArrayInt32(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<int32_t>(map, x2, y2);
}
float PathCostArrayUInt8(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<uint8_t>(map, x2, y2);
}
float PathCostArrayUInt16(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<uint16_t>(map, x2, y2);
}
float PathCostArrayUInt32(int x1, int y1, int x2, int y2,
const struct PathCostArray *map){
return GetPathCost<uint32_t>(map, x2, y2);
}