gwnavruntime/navmesh/blobs/navvertex.h Source File

navvertex.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 
12 
13 namespace Kaim
14 {
15 
16 // Represents a single vertex that forms the corner of at least one NavMesh triangle.
17 // NavVertex coordinates are stored on 8 bits and are local to its NavCell.
18 class NavVertex
19 {
20 public:
21  NavVertex() : x(0xFF), y(0xFF) {}
22 
23  KyInt64 GetX64() const { return (KyInt64)GetX32(); }
24  KyInt64 GetY64() const { return (KyInt64)GetY32(); }
25  KyInt32 GetX32() const { return IntCoordSystem::PixelCoordToInt((KyInt32)x); }
26  KyInt32 GetY32() const { return IntCoordSystem::PixelCoordToInt((KyInt32)y); }
27  CoordPos GetCoordPos() const { return CoordPos(GetX32(), GetY32()); }
28  CoordPos64 GetCoordPos64() const { return CoordPos64(GetX64(), GetY64()); }
29  KyUInt8 operator[](KyInt32 idx) const { return (&x)[idx]; }
30 
31  bool operator==(const NavVertex& v) const { return x == v.x && y == v.y; }
32  bool operator!=(const NavVertex& v) const { return x != v.x || y != v.y; }
33  bool operator<(const NavVertex& v) const { return (x != v.x) ? (x < v.x) : (y < v.y); }
34  bool operator>(const NavVertex& v) const { return (x != v.x) ? (x > v.x) : (y > v.y); }
35 
36 public:
37  KyUInt8 x;
38  KyUInt8 y;
39 };
40 
41 KY_INLINE void SwapEndianness(Endianness::Target e, NavVertex& self)
42 {
43  SwapEndianness(e, self.x);
44  SwapEndianness(e, self.y);
45 }
46 }
Vec2i CoordPos
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:20
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
std::int64_t KyInt64
int64_t
Definition: types.h:25
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:16
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
std::uint8_t KyUInt8
uint8_t
Definition: types.h:27