-
Notifications
You must be signed in to change notification settings - Fork 34
/
detour.h
97 lines (77 loc) · 2.66 KB
/
detour.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef __NMS_DETOUR_H__
#define __NMS_DETOUR_H__
#include <cstdint>
#include <unordered_map>
#include <mutex>
class dtNavMesh;
class dtNavMeshQuery;
class dtQueryFilter;
class dtTileCache;
namespace NavMeshScene {
class LinearAllocator;
class FastLZCompressor;
class MeshProcess;
class Detour {
public:
Detour(bool bStaticMesh = true, uint16_t maxNode = 2048);
virtual ~Detour();
int Load(const char* path);
bool TryMove(
uint64_t startPolyRef,
float startPos[3],
float endPos[3],
float halfExtents[3],
const dtQueryFilter& filter,
uint64_t& realEndPolyRef,
float realEndPos[3],
bool& bHit);
bool GetPoly(
float pos[3],
float halfExtents[3],
const dtQueryFilter& filter,
uint64_t& nearestRef,
float nearestPt[3]);
bool Raycast(
uint64_t startPolyRef,
float startPos[3],
float endPos[3],
const dtQueryFilter &filter,
bool& bHit,
float hitPos[3]);
bool RandomPosition(
float halfExtents[3],
const dtQueryFilter* filter,
float(*frand)(),
uint64_t& randomRef,
float randomPt[3]);
inline void SetHeightMode(int heightMode) { mHeightMode = heightMode; }
unsigned int AddCapsuleObstacle(const float pos[3], const float radius, const float height);
unsigned int AddBoxObstacle(const float bmin[3], const float bmax[3]);
unsigned int AddBoxObstacle(const float center[3], const float halfExtents[3], const float yRadians);
void RemoveObstacle(unsigned int obstacleId);
float* GetBoundsMin() { return mBoundsMin; }
float* GetBoundsMax() { return mBoundsMax; }
public:
inline dtTileCache* GetTileCache() { return mTileCache; }
inline dtNavMesh* GetMesh() { return mMesh; }
protected:
dtNavMesh* loadStaticMesh(const char*path, int& errCode);
dtNavMesh* loadDynamicMesh(const char*path, int& errCode);
dtNavMesh* createStaticMesh(const char*path, int& errCode);
bool mbStaticMesh;
int mMaxNode;
dtNavMesh* mMesh;
dtTileCache* mTileCache;
dtNavMeshQuery* mQuery;
float mBoundsMin[3];
float mBoundsMax[3];
int mHeightMode;
LinearAllocator* mTalloc;
FastLZCompressor* mTcomp;
MeshProcess* mTmproc;
dtNavMeshQuery* mQueryForHeightMode2;
static std::unordered_map<std::string, dtNavMesh*> mStaticMesh;
static std::mutex mMutex;
};
}
#endif