gwnavruntime/database/navtag.h Source File

navtag.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 
9 // primary contact: GUAL - secondary contact: LASI
10 #ifndef Navigation_NavTag_H
11 #define Navigation_NavTag_H
12 
19 
20 namespace Kaim
21 {
22 
23 typedef KyUInt32 NavTagIdx;
24 static const NavTagIdx NavTagIdx_Invalid = KyUInt32MAXVAL;
25 
26 class NavTag;
27 
28 enum NavTagBitFlag
29 {
30  NAVTAG_IS_EXCLUSIVE_BIT = 0,
31  NAVTAG_IS_ON_NAVGRAPH_BIT = 1,
32  NAVTAG_IS_FROM_GENERATION = 2,
33  NAVTAG_IS_GENERATION_DEFAULT = 3, // only relevant if from generation
34 };
35 
36 class DynamicNavTag
37 {
38  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
39 public:
40  static VisualColor GetDefaultColor() { return VisualColor::DarkOrange; }
41  static VisualColor GetExclusiveColor() { return VisualColor::Red; }
42 
43  DynamicNavTag();
44 
45  void Clear();
46 
47  void Init(const KyUInt32* blindDataBuffer, KyUInt32 blindDataCount);
48  void InitFromBlob(const NavTag& navTag);
49 
50  bool operator <(const DynamicNavTag& other) const;
51  bool operator!=(const DynamicNavTag& other) const;
52  bool operator==(const DynamicNavTag& other) const;// NavTags are compared using the values in the blind array
53 
54  bool operator <(const NavTag& other) const;
55  bool operator!=(const NavTag& other) const;
56  bool operator==(const NavTag& other) const;
57 
58  bool IsEqualToNavTag(const NavTag& other) const;
59 
60  KyUInt32 GetWordCount() const;
61  const KyUInt32* GetWords() const;
62  KyUInt32 GetWord(KyUInt32 wordIdx) const;
63 
64  bool IsEmpty() const;
65  bool IsExclusive() const;
66  bool IsWalkable() const;
67  bool IsOnNavGraph() const;
68  bool IsOnNavMesh() const;
69  bool IsFromGeneration() const;
70  bool IsFromRuntime() const;
71  bool IsGenerationDefault() const;
72 
73  VisualColor GetColor() const;
74 
75  void SetAsExclusive();
76  void SetAsWalkable();
77  void SetColor(VisualColor color);
78  void SetColor(KyUInt8 r, KyUInt8 g, KyUInt8 b);
79 
80 public: // Deprecated
81  KY_DEPRECATED(VisualColor GetVisualColor() const) { return GetColor(); }
82  KY_DEPRECATED(static VisualColor GetDefaultVisualColor()) { return GetDefaultColor(); }
83  KY_DEPRECATED(static VisualColor GetExclusiveVisualColor()) { return GetExclusiveColor(); }
84 
85 public: //Internal
86  void SetOnNavGraph();
87  void SetOnNavMesh();
88  void SetFromGeneration();
89  void SetAsGenerationDefault();
90 
91 public:
92  KyArrayPOD<KyUInt32> m_blindDataArray;
93  KyUInt8 m_flags; // tells if the navTag is exclusive, if it is on the navMesh, or on the navGrah ...
94  KyUInt8 m_colorR;
95  KyUInt8 m_colorG;
96  KyUInt8 m_colorB;
97 };
98 
99 class NavTag
100 {
101  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
102  KY_ROOT_BLOB_CLASS(NavData, NavTag, 1)
103  KY_CLASS_WITHOUT_COPY(NavTag)
104 public:
105  static VisualColor GetDefaultColor() { return DynamicNavTag::GetDefaultColor(); }
106  static VisualColor GetExclusiveColor() { return DynamicNavTag::GetExclusiveColor(); }
107 
108  NavTag() {}
109 
110  bool operator!=(const NavTag& other) const;
111  bool operator==(const NavTag& other) const;
112  bool operator<(const NavTag& other) const;
113 
114  bool operator <(const DynamicNavTag& other) const;
115  bool operator!=(const DynamicNavTag& other) const;
116  bool operator==(const DynamicNavTag& other) const;
117 
118  KyUInt32 GetWordCount() const;
119  const KyUInt32* GetWords() const;
120  KyUInt32 GetWord(KyUInt32 wordIdx) const;
121  KyUInt32 GetByteSize() const;
122 
123  bool IsWalkable() const;
124  bool IsOnNavMesh() const;
125  bool IsExclusive() const;
126  bool IsOnNavGraph() const;
127  bool IsFromGeneration() const;
128  bool IsFromRuntime() const;
129  bool IsGenerationDefault() const;
130 
131  VisualColor GetColor() const;
132 
133 public: // Deprecated
134  KY_DEPRECATED(VisualColor GetVisualColor() const) { return GetColor(); }
135  KY_DEPRECATED(static VisualColor GetDefaultVisualColor()) { return GetDefaultColor(); }
136  KY_DEPRECATED(static VisualColor GetExclusivetVisualColor()) { return GetExclusiveColor(); }
137 
138 
139 public:
140  BlobArray<KyUInt32> m_blindData;
141  KyUInt8 m_flags; // tells if the navTag is exclusive, if it is on the navMesh, or on the navGrah
142  KyUInt8 m_colorR;
143  KyUInt8 m_colorG;
144  KyUInt8 m_colorB;
145 };
146 
147 
148 inline void SwapEndianness(Endianness::Target e, NavTag& self)
149 {
150  SwapEndianness(e, self.m_blindData);
151  SwapEndianness(e, self.m_flags);
152  SwapEndianness(e, self.m_colorR);
153  SwapEndianness(e, self.m_colorG);
154  SwapEndianness(e, self.m_colorB);
155 }
156 
157 class NavTagBlobBuilder : public BaseBlobBuilder<NavTag>
158 {
159 public:
160  NavTagBlobBuilder(const DynamicNavTag& navTag) : m_navTag(&navTag) {}
161 private:
162  void DoBuild();
163 
164  const DynamicNavTag* m_navTag;
165 };
166 
167 class NavTagCopier : public BaseBlobBuilder<NavTag>
168 {
169 public:
170  NavTagCopier(const NavTag& navTag) : m_navTag(&navTag) {}
171 private:
172  void DoBuild();
173  const NavTag* m_navTag;
174 };
175 
176 }
177 
179 
180 #endif
181 
static const VisualColor Red
Represents the color with RGBA values (255, 0, 0, 255).  
Definition: visualcolor.h:209
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
static const VisualColor DarkOrange
Represents the color with RGBA values (255, 140, 0, 255).  
Definition: visualcolor.h:125
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
#define KY_DEPRECATED(f)
Macro to mark a function, class or method as deprecated.
Definition: types.h:289
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226