gwnavruntime/navmesh/navmeshtypes.h Source File

navmeshtypes.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
13 
14 namespace Kaim
15 {
16 typedef Vec2LL CoordPos64;
17 typedef Box2LL CoordBox64;
18 
19 typedef KyInt32 Coord;
20 typedef Vec2i CoordPos;
21 typedef Box2i CoordBox;
23 
24 typedef KyInt32 PixelCoord;
25 typedef Vec2i PixelPos;
26 typedef Box2i PixelBox;
28 
29 typedef KyInt32 CellCoord;
30 typedef Vec2i CellPos;
31 typedef Box2i CellBox;
33 
34 enum PolygonWinding
35 {
36  POLYGON_IS_CCW,
37  POLYGON_IS_CW,
38  POLYGON_UNKNOWN_WINDING,
39 };
40 
43 {
46 };
47 
50 {
59 };
60 
61 KY_INLINE bool IsHalfEdgeACellBoundary(NavHalfEdgeType type) { return type < EDGETYPE_FLOORBOUNDARY; }
62 KY_INLINE bool IsHalfEdgeAFloorOrCellBoundary(NavHalfEdgeType type) { return type < EDGETYPE_OBSTACLE; }
63 KY_INLINE bool IsHalfEdgeOnNavFloorBorder(NavHalfEdgeType type) { return type < EDGETYPE_CONNEXBOUNDARY; }
64 KY_INLINE bool IsHalfEdgeOnConnexBorder(NavHalfEdgeType type) { return type < EDGETYPE_PAIRED; }
65 
66 
67 // --- vertex Index in the Floor ---
68 
69 typedef KyUInt16 CompactNavVertexIdx;
70 static const CompactNavVertexIdx CompactNavVertexIdx_MAXVAL = 0x0FFF; // vertexIndex encoded en 12 bits in NavHalfEdge
71 
73 static const NavVertexIdx NavVertexIdx_Invalid = (NavVertexIdx)CompactNavVertexIdx_MAXVAL;
74 
76 KY_INLINE bool IsNavVertexIdxValid(const NavVertexIdx idx) { return idx < NavVertexIdx_Invalid; }
77 
78 
79 // --- HalfEdge Index in the Floor ---
80 
81 typedef KyUInt16 CompactNavHalfEdgeIdx;
82 static const CompactNavHalfEdgeIdx CompactNavHalfEdgeIdx_MAXVAL = 0x3FFF; // NavHalfEdgeIdx coded en 14 bits in NavHalfEdge
83 
85 static const NavHalfEdgeIdx NavHalfEdgeIdx_Invalid = (NavHalfEdgeIdx)CompactNavHalfEdgeIdx_MAXVAL;
86 
88 KY_INLINE bool IsNavHalfEdgeIdxValid(const NavHalfEdgeIdx idx) { return idx < NavHalfEdgeIdx_Invalid; }
89 
90 
91 // --- Triangle Index in the Floor ---
92 
93 //WARNING, we call it Idx opposed to NavTrianglePtr, but it is not an Idx in an array
94 typedef KyUInt16 CompactNavTriangleIdx;
95 static const CompactNavTriangleIdx CompactNavTriangleIdx_MAXVAL = 0xFFFF;
96 
98 static const NavTriangleIdx NavTriangleIdx_Invalid = (NavTriangleIdx)CompactNavVertexIdx_MAXVAL;
99 
101 KY_INLINE bool IsNavTriangleIdxValid(const NavTriangleIdx idx) { return idx < NavTriangleIdx_Invalid; }
102 
103 //WARNING, we call it Idx opposed to NavConnexPtr, but it is not an Idx in an array
104 typedef KyUInt16 CompactNavConnexIdx;
105 static const CompactNavConnexIdx CompactNavConnexIdx_MAXVAL = 0xFFFF;
106 
108 static const NavConnexIdx NavConnexIdx_Invalid = (NavConnexIdx)CompactNavVertexIdx_MAXVAL;
109 
110 // --- Floor Index in the Cell ---
111 
113 static const NavFloorIdx NavFloorIdx_Invalid = KyUInt32MAXVAL;
114 
116 KY_INLINE bool IsNavFloorIdxValid(const NavFloorIdx idx) { return idx < NavFloorIdx_Invalid; }
117 
118 // --- NavCellBlob Index in a NavMeshElement ---
119 
121 static const NavCellIdx NavCellIdx_Invalid = KyUInt32MAXVAL;
122 
124 KY_INLINE bool IsNavCellIdxValid(const NavCellIdx idx) { return idx < NavCellIdx_Invalid; }
125 
126 // --- index of a Cell in the buffer of ActiveData ---
127 
128 typedef KyUInt32 CellIdxInActiveData;
129 static const CellIdxInActiveData CellIdxInActiveData_Invalid = 0x0FFFFFFF; // limit NavFloorIdx to 0x0FFFFFFF to be able to store IdxInActiveData and ActiveCellIdx on 32 bits
130 
131 // --- Id of connected component ---
132 
133 typedef KyUInt32 ConnectedComponentId;
134 static const ConnectedComponentId ConnectedComponent_UNDEFINED = KyUInt32MAXVAL;
135 static const ConnectedComponentId ConnectedComponent_TRAVERSALOPEN = KyUInt32MAXVAL - 1;
136 
137 // SetBitInMask<bit_idx>(mask) UnSetBitInMask<bit_idx>(mask) IsBitSetInMask<bit_idx>(mask) mask being KyUInt8, KyUInt16 or KyUInt32
138 // Looks like it's used only in one place (DynamicNavTag), so we may reconsider the usefulness of these functions
139 #define KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(integerType) \
140 template<int BitIdx> KY_INLINE void SetBitInMask(integerType& mask) { mask |= (1 << (integerType)BitIdx); } \
141 template<int BitIdx> KY_INLINE void UnSetBitInMask(integerType& mask) { mask &= ~(1 << (integerType)BitIdx); } \
142 template<int BitIdx> KY_INLINE bool IsBitSetInMask(integerType mask) { return (mask & (1 << (integerType)BitIdx)) != 0; } \
143 
144 KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(KyUInt8)
145 KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(KyUInt16)
146 KY_DEFINE_TEMPLATE_MASK_MANIPULATOR(KyUInt32)
147 
148 // ---
149 struct DatabaseVisualDetails { enum Enum { Normal = 0, High = 1, VeryHigh = 2 }; };
150 
151 }
152 
153 
bool IsNavTriangleIdxValid(const NavTriangleIdx idx)
Indicates whether or not the specified NavTriangleIdx is valid.
Definition: navmeshtypes.h:101
KyUInt32 NavTriangleIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:97
KyUInt32 NavConnexIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:107
static const KyInt32 InvalidPixelCoord
Represents an invalidPixelCoord object.
Definition: navmeshtypes.h:27
static const CardinalDir CardinalDir_NORTH
Y positive axis.
Definition: cardinaldir.h:17
static const NavVertexIdx NavVertexIdx_Invalid
Represents an invalid NavVertexIdx.
Definition: navmeshtypes.h:73
2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min...
Definition: box2i.h:17
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:31
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:30
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Indicates that the obstacle represents a wall.
Definition: navmeshtypes.h:44
static const KyInt32 InvalidCoord
Represents an invalidCoord object.
Definition: navmeshtypes.h:22
Box2LL CoordBox64
A type that represents a bounding box in the integer 2D grid.
Definition: navmeshtypes.h:17
static const NavConnexIdx NavConnexIdx_Invalid
Represents an invalid NavConnexIdx.
Definition: navmeshtypes.h:108
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:84
Box2i CoordBox
A type that represents a bounding box in the integer 2D grid.
Definition: navmeshtypes.h:21
static const NavFloorIdx NavFloorIdx_Invalid
Represents an invalid NavFloorIdx.
Definition: navmeshtypes.h:113
bool IsNavCellIdxValid(const NavCellIdx idx)
Indicates whether or not the specified NavCellIdx is valid.
Definition: navmeshtypes.h:124
Indicates that another NavHalfEdge in the same NavFloor but in different Connex lies adjacent to the ...
Definition: navmeshtypes.h:57
static const KyInt32 InvalidCellCoord
Represents an invalidCellCoord object.
Definition: navmeshtypes.h:32
2d vector using KyInt64
Definition: vec2ll.h:18
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
Vec2i CoordPos
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:20
KyUInt32 NavCellIdx
An index that uniquely identifies a single NavCell within the set of NavCells owned by a NavMesh...
Definition: navmeshtypes.h:120
bool IsNavHalfEdgeIdxValid(const NavHalfEdgeIdx idx)
Indicates whether or not the specified NavHalfEdgeIdx is valid.
Definition: navmeshtypes.h:88
NavHalfEdgeObstacleType
Enumerates the possible types of obstacles that can be represented by a NavHalfEdge whose type is EDG...
Definition: navmeshtypes.h:42
static const CardinalDir CardinalDir_SOUTH
Y negative axis.
Definition: cardinaldir.h:19
static const CardinalDir CardinalDir_EAST
X positive axis.
Definition: cardinaldir.h:16
static const NavCellIdx NavCellIdx_Invalid
Represents an invalid NavCellIdx.
Definition: navmeshtypes.h:121
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:54
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:112
#define KyInt32MAXVAL
KyInt32 max value
Definition: types.h:60
static const CardinalDir CardinalDir_WEST
X negative axis.
Definition: cardinaldir.h:18
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:51
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:16
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that this NavHalfEdge lies on the border of its NavFloor.
Definition: navmeshtypes.h:55
Indicates that this NavHalfEdge lies on an external border of the NavMesh.
Definition: navmeshtypes.h:56
KyUInt32 NavVertexIdx
An index that uniquely identifies a single vertex of a triangle within the set of vertices owned by a...
Definition: navmeshtypes.h:72
Indicates that another NavHalfEdge in the same Connex lies adjacent to the NavHalfEdge.
Definition: navmeshtypes.h:58
std::int32_t KyInt32
int32_t
Definition: types.h:24
NavHalfEdgeType
Enumerates the possible types of boundary that can be represented by a NavHalfEdge.
Definition: navmeshtypes.h:49
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:52
bool IsNavFloorIdxValid(const NavFloorIdx idx)
Indicates whether or not the specified NavFloorIdx is valid.
Definition: navmeshtypes.h:116
static const NavHalfEdgeIdx NavHalfEdgeIdx_Invalid
Represents an invalid NavHalfEdgeIdx.
Definition: navmeshtypes.h:85
static const NavTriangleIdx NavTriangleIdx_Invalid
Represents an invalid NavTriangleIdx.
Definition: navmeshtypes.h:98
KyInt32 CellCoord
A type that represents the placement of a cell on one axis of a 2D grid.
Definition: navmeshtypes.h:29
Indicates that this NavHalfEdge lies on the border of its NavFloor and its NavCell.
Definition: navmeshtypes.h:53
std::uint8_t KyUInt8
uint8_t
Definition: types.h:27
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
2d axis aligned box of 64bits integers. Does not maintain m_countXY = m_max - m_min as a member...
Definition: box2ll.h:16
Indicates that the obstacle represents a hole or a cliff.
Definition: navmeshtypes.h:45