gwnavruntime/navmesh/navmeshtypes.h Source File

navmeshtypes.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 // ---------- Primary contact: JUBA - secondary contact: NOBODY
9 #ifndef Navigation_NavMeshTypes_H
10 #define Navigation_NavMeshTypes_H
11 
16 
17 namespace Kaim
18 {
19 typedef Vec2LL CoordPos64;
20 typedef Box2LL CoordBox64;
21 
22 typedef KyInt32 Coord;
23 typedef Vec2i CoordPos;
24 typedef Box2i CoordBox;
26 
27 typedef KyInt32 PixelCoord;
28 typedef Vec2i PixelPos;
29 typedef Box2i PixelBox;
31 
32 typedef KyInt32 CellCoord;
33 typedef Vec2i CellPos;
34 typedef Box2i CellBox;
36 
37 enum PolygonWinding
38 {
39  POLYGON_IS_CCW,
40  POLYGON_IS_CW,
41  POLYGON_UNKNOWN_WINDING,
42 };
43 
46 {
49 };
50 
53 {
62 };
63 
64 KY_INLINE bool IsHalfEdgeACellBoundary(NavHalfEdgeType type) { return type < EDGETYPE_FLOORBOUNDARY; }
65 KY_INLINE bool IsHalfEdgeAFloorOrCellBoundary(NavHalfEdgeType type) { return type < EDGETYPE_OBSTACLE; }
66 KY_INLINE bool IsHalfEdgeOnNavFloorBorder(NavHalfEdgeType type) { return type < EDGETYPE_CONNEXBOUNDARY; }
67 KY_INLINE bool IsHalfEdgeOnConnexBorder(NavHalfEdgeType type) { return type < EDGETYPE_PAIRED; }
68 
69 
70 // --- vertex Index in the Floor ---
71 
72 typedef KyUInt16 CompactNavVertexIdx;
73 static const CompactNavVertexIdx CompactNavVertexIdx_MAXVAL = 0x0FFF; // vertexIndex encoded en 12 bits in NavHalfEdge
74 
76 static const NavVertexIdx NavVertexIdx_Invalid = (NavVertexIdx)CompactNavVertexIdx_MAXVAL;
77 
79 KY_INLINE bool IsNavVertexIdxValid(const NavVertexIdx idx) { return idx < NavVertexIdx_Invalid; }
80 
81 
82 // --- HalfEdge Index in the Floor ---
83 
84 typedef KyUInt16 CompactNavHalfEdgeIdx;
85 static const CompactNavHalfEdgeIdx CompactNavHalfEdgeIdx_MAXVAL = 0x3FFF; // NavHalfEdgeIdx coded en 14 bits in NavHalfEdge
86 
88 static const NavHalfEdgeIdx NavHalfEdgeIdx_Invalid = (NavHalfEdgeIdx)CompactNavHalfEdgeIdx_MAXVAL;
89 
91 KY_INLINE bool IsNavHalfEdgeIdxValid(const NavHalfEdgeIdx idx) { return idx < NavHalfEdgeIdx_Invalid; }
92 
93 
94 // --- Triangle Index in the Floor ---
95 
96 //WARNING, we call it Idx opposed to NavTrianglePtr, but it is not an Idx in an array
97 typedef KyUInt16 CompactNavTriangleIdx;
98 static const CompactNavTriangleIdx CompactNavTriangleIdx_MAXVAL = 0xFFFF;
99 
101 static const NavTriangleIdx NavTriangleIdx_Invalid = (NavTriangleIdx)CompactNavVertexIdx_MAXVAL;
102 
104 KY_INLINE bool IsNavTriangleIdxValid(const NavTriangleIdx idx) { return idx < NavTriangleIdx_Invalid; }
105 
106 //WARNING, we call it Idx opposed to NavConnexPtr, but it is not an Idx in an array
107 typedef KyUInt16 CompactNavConnexIdx;
108 static const CompactNavConnexIdx CompactNavConnexIdx_MAXVAL = 0xFFFF;
109 
111 static const NavConnexIdx NavConnexIdx_Invalid = (NavConnexIdx)CompactNavVertexIdx_MAXVAL;
112 
113 // --- Floor Index in the Cell ---
114 
116 static const NavFloorIdx NavFloorIdx_Invalid = KyUInt32MAXVAL;
117 
119 KY_INLINE bool IsNavFloorIdxValid(const NavFloorIdx idx) { return idx < NavFloorIdx_Invalid; }
120 
121 // --- NavCellBlob Index in a NavMeshElement ---
122 
124 static const NavCellIdx NavCellIdx_Invalid = KyUInt32MAXVAL;
125 
127 KY_INLINE bool IsNavCellIdxValid(const NavCellIdx idx) { return idx < NavCellIdx_Invalid; }
128 
129 // --- index of a Cell in the buffer of ActiveData ---
130 
131 typedef KyUInt32 CellIdxInActiveData;
132 static const CellIdxInActiveData CellIdxInActiveData_Invalid = 0x0FFFFFFF; // limit NavFloorIdx to 0x0FFFFFFF to be able to store IdxInActiveData and ActiveCellIdx on 32 bits
133 
134 // --- Id of connected component ---
135 
136 typedef KyUInt32 ConnectedComponentId;
137 static const ConnectedComponentId ConnectedComponent_UNDEFINED = KyUInt32MAXVAL;
138 static const ConnectedComponentId ConnectedComponent_TRAVERSALOPEN = KyUInt32MAXVAL - 1;
139 
140 #define KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(integerType) \
141 template<int BitIdx> KY_INLINE void SetBitInMask(integerType& mask) { mask |= (1 << (integerType)BitIdx); } \
142 template<int BitIdx> KY_INLINE void UnSetBitInMask(integerType& mask) { mask &= ~(1 << (integerType)BitIdx); } \
143 template<int BitIdx> KY_INLINE bool IsBitSetInMask(integerType mask) { return (mask & (1 << (integerType)BitIdx)) != 0; } \
144 
145 KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(KyUInt8)
146 KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(KyUInt16)
147 KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(KyUInt32)
148 
149 }
150 
151 #endif
152 
bool IsNavTriangleIdxValid(const NavTriangleIdx idx)
Indicates whether or not the specified NavTriangleIdx is valid.
Definition: navmeshtypes.h:104
KyUInt32 NavTriangleIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:100
KyUInt32 NavConnexIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:110
static const KyInt32 InvalidPixelCoord
Represents an invalidPixelCoord object.
Definition: navmeshtypes.h:30
static const CardinalDir CardinalDir_NORTH
Identifies North, defined as the positive direction of the Y axis.
Definition: cardinaldir.h:26
static const NavVertexIdx NavVertexIdx_Invalid
Represents an invalid NavVertexIdx.
Definition: navmeshtypes.h:76
This class represents a two-dimensional axis-aligned bounding box whose dimensions are stored using 3...
Definition: box2i.h:119
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
Indicates that the obstacle represents a wall.
Definition: navmeshtypes.h:47
static const KyInt32 InvalidCoord
Represents an invalidCoord object.
Definition: navmeshtypes.h:25
Box2LL CoordBox64
A type that represents a bounding box in the integer 2D grid.
Definition: navmeshtypes.h:20
static const NavConnexIdx NavConnexIdx_Invalid
Represents an invalid NavConnexIdx.
Definition: navmeshtypes.h:111
KyUInt32 NavHalfEdgeIdx
An index that uniquely identifies a single edge of a triangle within the set of edges owned by a NavF...
Definition: navmeshtypes.h:87
Box2i CoordBox
A type that represents a bounding box in the integer 2D grid.
Definition: navmeshtypes.h:24
static const NavFloorIdx NavFloorIdx_Invalid
Represents an invalid NavFloorIdx.
Definition: navmeshtypes.h:116
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
bool IsNavCellIdxValid(const NavCellIdx idx)
Indicates whether or not the specified NavCellIdx is valid.
Definition: navmeshtypes.h:127
Indicates that another NavHalfEdge in the same NavFloor but in different Connex lies adjacent to the ...
Definition: navmeshtypes.h:60
static const KyInt32 InvalidCellCoord
Represents an invalidCellCoord object.
Definition: navmeshtypes.h:35
This class defines a two-dimensional vector whose coordinates are stored using 64-bit integers...
Definition: vec2ll.h:27
Vec2i CoordPos
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:23
KyUInt32 NavCellIdx
An index that uniquely identifies a single NavCell within the set of NavCells owned by a NavMesh...
Definition: navmeshtypes.h:123
bool IsNavHalfEdgeIdxValid(const NavHalfEdgeIdx idx)
Indicates whether or not the specified NavHalfEdgeIdx is valid.
Definition: navmeshtypes.h:91
NavHalfEdgeObstacleType
Enumerates the possible types of obstacles that can be represented by a NavHalfEdge whose type is EDG...
Definition: navmeshtypes.h:45
static const CardinalDir CardinalDir_SOUTH
Identifies South, defined as the negative direction of the Y axis.
Definition: cardinaldir.h:28
static const CardinalDir CardinalDir_EAST
Identifies East, defined as the positive direction of the X axis.
Definition: cardinaldir.h:25
static const NavCellIdx NavCellIdx_Invalid
Represents an invalid NavCellIdx.
Definition: navmeshtypes.h:124
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:57
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:115
#define KyInt32MAXVAL
The maximum value that can be stored in the KyInt32 variable type.
Definition: types.h:224
static const CardinalDir CardinalDir_WEST
Identifies West, defined as the negative direction of the X axis.
Definition: cardinaldir.h:27
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:54
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:19
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
Indicates that this NavHalfEdge lies on the border of its NavFloor.
Definition: navmeshtypes.h:58
Indicates that this NavHalfEdge lies on an external border of the NavMesh.
Definition: navmeshtypes.h:59
KyUInt32 NavVertexIdx
An index that uniquely identifies a single vertex of a triangle within the set of vertices owned by a...
Definition: navmeshtypes.h:75
Indicates that another NavHalfEdge in the same Connex lies adjacent to the NavHalfEdge.
Definition: navmeshtypes.h:61
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
NavHalfEdgeType
Enumerates the possible types of boundary that can be represented by a NavHalfEdge.
Definition: navmeshtypes.h:52
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:55
bool IsNavFloorIdxValid(const NavFloorIdx idx)
Indicates whether or not the specified NavFloorIdx is valid.
Definition: navmeshtypes.h:119
static const NavHalfEdgeIdx NavHalfEdgeIdx_Invalid
Represents an invalid NavHalfEdgeIdx.
Definition: navmeshtypes.h:88
static const NavTriangleIdx NavTriangleIdx_Invalid
Represents an invalid NavTriangleIdx.
Definition: navmeshtypes.h:101
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
KyInt32 CellCoord
A type that represents the placement of a cell on one axis of a 2D grid.
Definition: navmeshtypes.h:32
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:56
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
Each instance of this class also maintains a count of the number of elements (or grid cells) containe...
Definition: box2ll.h:24
Indicates that the obstacle represents a hole or a cliff.
Definition: navmeshtypes.h:48