9 #ifndef Navigation_WorldIntegerPos_H
10 #define Navigation_WorldIntegerPos_H
42 void Add1OnCoordPosX(
KyInt32 cellSizeInCoord);
43 void Remove1OnCoordPosX(
KyInt32 cellSizeInCoord);
44 void Add1OnCoordPosY(
KyInt32 cellSizeInCoord);
45 void Remove1OnCoordPosY(
KyInt32 cellSizeInCoord);
56 SwapEndianness(e,
self.m_cellPos);
57 SwapEndianness(e,
self.m_coordPosInCell);
62 KY_INLINE WorldIntegerPos::WorldIntegerPos(
const CellPos& cellPos,
const CoordPos& posInCell) : m_cellPos(cellPos), m_coordPosInCell(posInCell) {}
73 m_cellPos.
Set(cellCoordX, cellCoordY);
74 m_coordPosInCell.
Set(coordPosX, coordPosY);
77 KY_INLINE
bool WorldIntegerPos::operator==(
const WorldIntegerPos& rhs)
const {
return m_cellPos == rhs.m_cellPos && m_coordPosInCell == rhs.m_coordPosInCell; }
78 KY_INLINE
bool WorldIntegerPos::operator!=(
const WorldIntegerPos& rhs)
const {
return !operator==(rhs); }
79 KY_INLINE
bool WorldIntegerPos::operator<(
const WorldIntegerPos& rhs)
const {
return m_cellPos != rhs.m_cellPos ? m_cellPos < rhs.m_cellPos : m_coordPosInCell < rhs.m_coordPosInCell; }
80 KY_INLINE
bool WorldIntegerPos::operator>(
const WorldIntegerPos& rhs)
const {
return !operator<(rhs) && operator!=(rhs); }
82 KY_INLINE
void WorldIntegerPos::Add1OnCoordPosX(
KyInt32 cellSizeInCoord)
84 KY_DEBUG_ASSERTN(m_coordPosInCell.
x > 0 || m_coordPosInCell.
x <= cellSizeInCoord, (
"Invalid Object"));
85 KY_DEBUG_ASSERTN(m_coordPosInCell.
y >= 0 || m_coordPosInCell.
y < cellSizeInCoord, (
"Invalid Object"));
86 if (m_coordPosInCell.
x == cellSizeInCoord)
88 m_coordPosInCell.
x = 1;
95 KY_INLINE
void WorldIntegerPos::Remove1OnCoordPosX(
KyInt32 cellSizeInCoord)
97 KY_DEBUG_ASSERTN(m_coordPosInCell.
x > 0 || m_coordPosInCell.
x <= cellSizeInCoord, (
"Invalid Object"));
98 KY_DEBUG_ASSERTN(m_coordPosInCell.
y >= 0 || m_coordPosInCell.
y < cellSizeInCoord, (
"Invalid Object"));
99 if (m_coordPosInCell.
x == 1)
101 m_coordPosInCell.
x = cellSizeInCoord;
105 --m_coordPosInCell.
x;
108 KY_INLINE
void WorldIntegerPos::Add1OnCoordPosY(
KyInt32 cellSizeInCoord)
110 KY_DEBUG_ASSERTN(m_coordPosInCell.
x > 0 || m_coordPosInCell.
x <= cellSizeInCoord, (
"Invalid Object"));
111 KY_DEBUG_ASSERTN(m_coordPosInCell.
y >= 0 || m_coordPosInCell.
y < cellSizeInCoord, (
"Invalid Object"));
112 if (m_coordPosInCell.
y + 1 == cellSizeInCoord)
114 m_coordPosInCell.
y = 0;
118 ++m_coordPosInCell.
y;
121 KY_INLINE
void WorldIntegerPos::Remove1OnCoordPosY(
KyInt32 cellSizeInCoord)
123 KY_DEBUG_ASSERTN(m_coordPosInCell.
x > 0 || m_coordPosInCell.
x <= cellSizeInCoord, (
"Invalid Object"));
124 KY_DEBUG_ASSERTN(m_coordPosInCell.
y >= 0 || m_coordPosInCell.
y < cellSizeInCoord, (
"Invalid Object"));
125 if (m_coordPosInCell.
y == 0)
127 m_coordPosInCell.
y = cellSizeInCoord - 1;
131 --m_coordPosInCell.
y;
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
static const KyInt32 InvalidCoord
Represents an invalidCoord object.
Definition: navmeshtypes.h:25
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
void Set(KyInt32 _x, KyInt32 _y)
Sets the coordinates of the vector to match the specified values.
Definition: vec2i.h:54
KyInt32 x
The size of the vector along the X axis.
Definition: vec2i.h:283
void Clear()
Clears all information maintained by this object.
Definition: worldintegerpos.h:74
static const KyInt32 InvalidCellCoord
Represents an invalidCellCoord object.
Definition: navmeshtypes.h:35
KyInt32 y
The size of the vector along the Y axis.
Definition: vec2i.h:284
Vec2i CoordPos
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:23
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
Utilities for dealing with NavData coordinates, which are expressed in a world space based on integer...
Definition: worldintegerpos.h:21
void Set(const CellPos &cellPos, const CoordPos &posInCell)
Sets the coordinates of the vector to match the specified values.
Definition: worldintegerpos.h:80
KyInt32 CellCoord
A type that represents the placement of a cell on one axis of a 2D grid.
Definition: navmeshtypes.h:32