gwnavruntime/navmesh/identifiers/navtriangleptr.h Source File

navtriangleptr.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 
11 
12 namespace Kaim
13 {
14 
18 {
19  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
20 public:
21  NavTrianglePtr();
22 
26  NavTrianglePtr(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx);
27 
29  explicit NavTrianglePtr(const NavTriangleRawPtr& navTriangleRawPtr);
30 
34  void Set(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx);
35 
37  bool IsValid() const;
38 
39  void Invalidate();
40 
41  bool operator==(const NavTrianglePtr& rhs) const;
42  bool operator!=(const NavTrianglePtr& rhs) const;
43 
45  NavFloor* GetNavFloor() const;
46  const NavFloorBlob* GetNavFloorBlob() const;
47 
48  // ---------------------------------- Member Functions for valid instance ----------------------------------
51 
55 
58  const NavFloorBlob* GetNavFloorBlob_Unsafe() const;
59 
63 
66  const NavTag& GetNavTag() const;
67 
70  const CellPos& GetCellPos() const;
71 
77  void GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const;
78 
82  void GetVerticesPos3f(Triangle3f& triangle3f) const;
83 
89  void GetVerticesCoordPos64(CoordPos64& v0CoordPos64, CoordPos64& v1CoordPos64, CoordPos64& v2CoordPos64) const;
90 
96  void GetVerticesCoordPos(CoordPos& v0CoordPos, CoordPos& v1CoordPos, CoordPos& v2CoordPos) const;
97 
102  KyFloat32 GetAltitudeOfPointInTriangle(const Vec3f& pos) const;
103 
104 public:
106  CompactNavTriangleIdx m_triangleIdx;
107 };
108 
109 KY_INLINE NavTrianglePtr::NavTrianglePtr() : m_triangleIdx(CompactNavTriangleIdx_MAXVAL) {}
110 
111 KY_INLINE NavTrianglePtr::NavTrianglePtr(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx) :
112  m_navFloorPtr(navFloorPtr), m_triangleIdx((CompactNavTriangleIdx)triangleIdx) {}
113 
114 KY_INLINE NavTrianglePtr::NavTrianglePtr(const NavTriangleRawPtr& navTriangleRawPtr) :
115  m_navFloorPtr(navTriangleRawPtr.GetNavFloor()), m_triangleIdx((CompactNavTriangleIdx)navTriangleRawPtr.GetTriangleIdx()) {}
116 
117 KY_INLINE void NavTrianglePtr::Set(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx)
118 {
119  m_navFloorPtr = navFloorPtr;
120  m_triangleIdx = (CompactNavTriangleIdx)triangleIdx;
121 }
122 
123 KY_INLINE bool NavTrianglePtr::IsValid() const { return m_navFloorPtr.IsValid() && m_triangleIdx != CompactNavTriangleIdx_MAXVAL; }
124 
125 KY_INLINE void NavTrianglePtr::Invalidate() { m_navFloorPtr.Invalidate(); m_triangleIdx = CompactNavTriangleIdx_MAXVAL; }
126 
127 KY_INLINE bool NavTrianglePtr::operator==(const NavTrianglePtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr && m_triangleIdx == rhs.m_triangleIdx; }
128 KY_INLINE bool NavTrianglePtr::operator!=(const NavTrianglePtr& rhs) const { return !(*this == rhs); }
129 
131 
136 
138 
139 KY_INLINE const CellPos& NavTrianglePtr::GetCellPos() const { return GetRawPtr().GetCellPos(); }
140 KY_INLINE const NavTag& NavTrianglePtr::GetNavTag() const { return GetRawPtr().GetNavTag(); }
141 KY_INLINE void NavTrianglePtr::GetVerticesPos3f(Triangle3f& triangle3f) const { return GetRawPtr().GetVerticesPos3f(triangle3f); }
143 
144 KY_INLINE void NavTrianglePtr::GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const
145 {
146  return GetRawPtr().GetVerticesPos3f(v0Pos3f, v1Pos3f, v2Pos3f) ;
147 }
148 KY_INLINE void NavTrianglePtr::GetVerticesCoordPos64(CoordPos64& v0CoordPos64, CoordPos64& v1CoordPos64, CoordPos64& v2CoordPos64) const
149 {
150  return GetRawPtr().GetVerticesCoordPos64(v0CoordPos64, v1CoordPos64, v2CoordPos64);
151 }
152 KY_INLINE void NavTrianglePtr::GetVerticesCoordPos(CoordPos& v0CoordPos, CoordPos& v1CoordPos, CoordPos& v2CoordPos) const
153 {
154  return GetRawPtr().GetVerticesCoordPos(v0CoordPos, v1CoordPos, v2CoordPos);
155 }
156 }
157 
158 
NavTriangleRawPtr GetRawPtr() const
Constructs and returns a NavTriangleRawPtr that refers to the same NavTriangle.
Definition: navtriangleptr.h:137
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor identified by this object. Returns nullptr if this object is not va...
Definition: navfloorptr.h:81
bool IsValid() const
Returns true if this object refers to a valid triangle: i.e. a triangle in a validNavFloor. see NavFloorPtr::IsValid().
Definition: navtriangleptr.h:123
void GetVerticesPos3f(Vec3f &A, Vec3f &B, Vec3f &C) const
Get the triangle Navigation world coordinates.
Definition: navtrianglerawptr.cpp:14
void Invalidate()
Invalidates this object.
Definition: navtriangleptr.h:125
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor that contains this triangle. Returns nullptr if this object is not ...
Definition: navtriangleptr.h:132
KyUInt32 NavTriangleIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:97
Each instance of this class uniquely identifies a single NavFloor.
Definition: navfloorptr.h:16
bool operator!=(const NavTrianglePtr &rhs) const
Returns true if this object identifies a different triangle from rhs.
Definition: navtriangleptr.h:128
This class is a runtime wrapper of a NavFloorBlob, it gathers all the runtime information associated ...
Definition: navfloor.h:32
The NavFloorBlob contains a connected and not overlapping part of triangle mesh static data within a ...
Definition: navfloorblob.h:38
const CellPos & GetCellPos() const
Returns a const reference to the CellPos that indicates the position of the cell that contains this t...
Definition: navtriangleptr.h:139
3d triangle of 32bits floating points
Definition: triangle3f.h:15
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor identified by this object.
Definition: navfloorptr.h:84
NavTriangleIdx GetTriangleIdx() const
Returns the index of this triangle within its NavFloor.
Definition: navtriangleptr.h:130
const CellPos & GetCellPos() const
Returns the triangle NavCell 2d position.
Definition: navtrianglerawptr.h:71
CompactNavTriangleIdx m_triangleIdx
The index of this triangle within its NavFloor.
Definition: navtriangleptr.h:106
bool IsValid() const
Returns true if this object refers to a valid NavFloor, which means a NavFloor:that is not null...
Definition: navfloorptr.h:69
bool operator==(const NavTrianglePtr &rhs) const
Returns true if this object identifies the same triangle as rhs, or if both are invalid.
Definition: navtriangleptr.h:127
2d vector using KyInt64
Definition: vec2ll.h:18
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob identified by this object. Returns nullptr if this object...
Definition: navfloorptr.h:82
KyFloat32 GetAltitudeOfPointInTriangle(const Vec3f &pos) const
Returns the altitude of the point on the plane defined by this triangle that has the same (X...
Definition: navtriangleptr.h:142
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob identified by this object.
Definition: navfloorptr.h:85
NavFloor * GetNavFloor_Unsafe() const
All these function should be called only if IsValid() returns true.
Definition: navtriangleptr.h:134
NavFloorRawPtr GetRawPtr() const
Constructs and returns a NavFloorRawPtr that refers to the same NavFloor.
Definition: navfloorptr.h:87
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
void GetVerticesCoordPos64(CoordPos64 &v0CoordPos64, CoordPos64 &v1CoordPos64, CoordPos64 &v2CoordPos64) const
Updates the parameters to identify the vertices in this triangle.
Definition: navtriangleptr.h:148
void GetVerticesCoordPos(CoordPos &v0CoordPos, CoordPos &v1CoordPos, CoordPos &v2CoordPos) const
Updates the parameters to identify the vertices in this triangle.
Definition: navtriangleptr.h:152
void GetVerticesCoordPos64(CoordPos64 &A, CoordPos64 &B, CoordPos64 &C) const
Get the triangle world integer 2d coordinates.
Definition: navtrianglerawptr.cpp:39
NavTrianglePtr()
Creates an invalid NavTrianglePtr.
Definition: navtriangleptr.h:109
Identifies a single NavTriangle in a NavFloor.
Definition: navtrianglerawptr.h:21
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob that contains this triangle.
Definition: navtriangleptr.h:135
KyFloat32 GetAltitudeOfPointInTriangle(const Vec3f &pos) const
Returns the altitude of the vertical projection of pos on the triangle plane.
Definition: navtrianglerawptr.cpp:75
const NavTag & GetNavTag() const
Retrieves the triangle NavTag.
Definition: navtrianglerawptr.h:74
void GetVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f, Vec3f &v2Pos3f) const
Updates the parameters to identify the vertices in this triangle.
Definition: navtriangleptr.h:144
void Invalidate()
m_navFloorPtr = nullptr;
Definition: navfloorptr.h:68
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
void GetVerticesCoordPos(CoordPos &A, CoordPos &B, CoordPos &C) const
Get the triangle local to cell integer 2d coordinates.
Definition: navtrianglerawptr.cpp:58
NavFloorPtr m_navFloorPtr
The NavFloor that contains this triangle.
Definition: navtriangleptr.h:105
void Set(const NavFloorPtr &navFloorPtr, NavTriangleIdx triangleIdx)
Clears all information maintained by this object.
Definition: navtriangleptr.h:117
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob that contains this triangle. Returns nullptr if this obje...
Definition: navtriangleptr.h:133
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16