blob: 17c6e456e2e8660651c6813e24d8d2b9be2fc2f7 (
plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#ifndef RUNTIME_NAVMESHOBSTACLE
#define RUNTIME_NAVMESHOBSTACLE
#include "Runtime/GameCode/Behaviour.h"
#include "Runtime/Graphics/Transform.h"
#include "Runtime/Math/Vector3.h"
#include "NavMeshManager.h"
#include "DetourFeatures.h"
#include "DetourReference.h"
struct NavMeshCarveData;
class dtCrowd;
class dtNavMeshQuery;
class Matrix4x4f;
class NavMeshObstacle : public Behaviour
{
public:
REGISTER_DERIVED_CLASS (NavMeshObstacle, Behaviour)
DECLARE_OBJECT_SERIALIZE (NavMeshObstacle)
NavMeshObstacle (MemLabelId& label, ObjectCreationMode mode);
// ~NavMeshObstacle (); declared by a macro
virtual void AwakeFromLoad (AwakeFromLoadMode mode);
static void InitializeClass ();
static void CleanupClass () { }
inline bool InCrowdSystem () const;
inline void SetManagerHandle (int handle);
void OnNavMeshChanged ();
void OnNavMeshCleanup ();
#if ENABLE_NAVMESH_CARVING
inline void SetCarveHandle (int handle);
void WillRebuildNavmesh (NavMeshCarveData& carveData);
bool NeedsRebuild () const;
inline bool GetCarving () const;
void SetCarving (bool carve);
inline float GetMoveThreshold () const;
void SetMoveThreshold (float moveThreshold);
#endif
Vector3f GetScaledDimensions () const;
inline Vector3f GetPosition () const;
inline Vector3f GetVelocity () const;
void SetVelocity (const Vector3f& value);
inline float GetRadius () const;
void SetRadius (float value);
inline float GetHeight () const;
void SetHeight (float value);
protected:
virtual void Reset ();
virtual void SmartReset ();
virtual void AddToManager ();
virtual void RemoveFromManager ();
virtual void CheckConsistency ();
virtual UInt32 CalculateSupportedMessages ();
void OnVelocityChanged (Vector3f* value);
void OnTransformChanged (int mask);
private:
void AddToCrowdSystem ();
void RemoveFromCrowdSystem ();
void CalculateTransformAndSize (Matrix4x4f& trans, Vector3f& size);
static inline float EnsurePositive (float value);
static dtCrowd* GetCrowdSystem ();
int m_ManagerHandle;
dtCrowdHandle m_ObstacleHandle;
float m_Radius;
float m_Height;
Vector3f m_Velocity;
#if ENABLE_NAVMESH_CARVING
void AddOrRemoveObstacle ();
enum
{
kClean = 0,
kHasMoved = 1 << 0,
kForceRebuild = 1 << 1
};
float m_MoveThreshold;
Vector3f m_LastCarvedPosition;
UInt32 m_Status;
int m_CarveHandle;
bool m_Carve;
#endif
};
inline bool NavMeshObstacle::InCrowdSystem () const
{
return m_ObstacleHandle.IsValid ();
}
inline void NavMeshObstacle::SetManagerHandle (int handle)
{
m_ManagerHandle = handle;
}
inline float NavMeshObstacle::EnsurePositive (float value)
{
return std::max (0.00001F, value);
}
inline Vector3f NavMeshObstacle::GetPosition () const
{
return GetComponent (Transform).GetPosition ();
}
inline Vector3f NavMeshObstacle::GetVelocity () const
{
return m_Velocity;
}
inline float NavMeshObstacle::GetRadius () const
{
return m_Radius;
}
inline float NavMeshObstacle::GetHeight () const
{
return m_Height;
}
#if ENABLE_NAVMESH_CARVING
inline void NavMeshObstacle::SetCarveHandle (int handle)
{
m_CarveHandle = handle;
}
inline bool NavMeshObstacle::GetCarving () const
{
return m_Carve;
}
inline float NavMeshObstacle::GetMoveThreshold () const
{
return m_MoveThreshold;
}
#endif // ENABLE_NAVMESH_CARVING
#endif
|