gwnavruntime/navmesh/identifiers/navtriangleptr.h Source File

navtriangleptr.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 
9 // ---------- Primary contact: JUBA - secondary contact: NOBODY
10 #ifndef Navigation_NavTrianglePtr_H
11 #define Navigation_NavTrianglePtr_H
12 
15 
16 namespace Kaim
17 {
18 
21 class NavTrianglePtr
22 {
23  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
24 public:
25  NavTrianglePtr();
26 
30  NavTrianglePtr(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx);
31 
33  explicit NavTrianglePtr(const NavTriangleRawPtr& navTriangleRawPtr);
34 
35 
39  void Set(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx);
40 
42  bool IsValid() const;
43 
44  void Invalidate();
45 
46  bool operator==(const NavTrianglePtr& rhs) const;
47  bool operator!=(const NavTrianglePtr& rhs) const;
48 
50  NavFloor* GetNavFloor() const;
51  const NavFloorBlob* GetNavFloorBlob() const;
52 
53  // ---------------------------------- Member Functions for valid instance ----------------------------------
56 
60 
63  const NavFloorBlob* GetNavFloorBlob_Unsafe() const;
64 
68 
71  const NavTag& GetNavTag() const;
72 
75  const CellPos& GetCellPos() const;
76 
82  void GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const;
83 
87  void GetVerticesPos3f(Triangle3f& triangle3f) const;
88 
94  void GetVerticesCoordPos64(CoordPos64& v0CoordPos64, CoordPos64& v1CoordPos64, CoordPos64& v2CoordPos64) const;
95 
101  void GetVerticesCoordPos(CoordPos& v0CoordPos, CoordPos& v1CoordPos, CoordPos& v2CoordPos) const;
102 
107  KyFloat32 GetAltitudeOfPointInTriangle(const Vec3f& pos) const;
108 public:
110  CompactNavTriangleIdx m_triangleIdx;
111 };
112 
113 KY_INLINE NavTrianglePtr::NavTrianglePtr() : m_triangleIdx(CompactNavTriangleIdx_MAXVAL) {}
114 KY_INLINE NavTrianglePtr::NavTrianglePtr(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx) :
115  m_navFloorPtr(navFloorPtr), m_triangleIdx((CompactNavTriangleIdx)triangleIdx) {}
116 KY_INLINE NavTrianglePtr::NavTrianglePtr(const NavTriangleRawPtr& navTriangleRawPtr) :
117  m_navFloorPtr(navTriangleRawPtr.GetNavFloor()), m_triangleIdx((CompactNavTriangleIdx)navTriangleRawPtr.GetTriangleIdx()) {}
118 
119 KY_INLINE void NavTrianglePtr::Set(const NavFloorPtr& navFloorPtr, NavTriangleIdx triangleIdx)
120 {
121  m_navFloorPtr = navFloorPtr;
122  m_triangleIdx = (CompactNavTriangleIdx)triangleIdx;
123 }
124 
125 KY_INLINE bool NavTrianglePtr::IsValid() const { return m_navFloorPtr.IsValid() && m_triangleIdx != CompactNavTriangleIdx_MAXVAL; }
127 KY_INLINE void NavTrianglePtr::Invalidate() { m_navFloorPtr.Invalidate(); m_triangleIdx = CompactNavTriangleIdx_MAXVAL; }
128 
129 KY_INLINE bool NavTrianglePtr::operator==(const NavTrianglePtr& rhs) const { return m_navFloorPtr == rhs.m_navFloorPtr && m_triangleIdx == rhs.m_triangleIdx; }
130 KY_INLINE bool NavTrianglePtr::operator!=(const NavTrianglePtr& rhs) const { return !(*this == rhs); }
131 
133 
135 KY_INLINE const NavFloorBlob* NavTrianglePtr::GetNavFloorBlob() const { return m_navFloorPtr.GetNavFloorBlob(); }
138 
140 
141 KY_INLINE const CellPos& NavTrianglePtr::GetCellPos() const { return GetRawPtr().GetCellPos(); }
142 KY_INLINE const NavTag& NavTrianglePtr::GetNavTag() const { return GetRawPtr().GetNavTag(); }
143 KY_INLINE void NavTrianglePtr::GetVerticesPos3f(Triangle3f& triangle3f) const { return GetRawPtr().GetVerticesPos3f(triangle3f); }
145 KY_INLINE void NavTrianglePtr::GetVerticesPos3f(Vec3f& v0Pos3f, Vec3f& v1Pos3f, Vec3f& v2Pos3f) const
146 {
147  return GetRawPtr().GetVerticesPos3f(v0Pos3f, v1Pos3f, v2Pos3f) ;
148 }
149 KY_INLINE void NavTrianglePtr::GetVerticesCoordPos64(CoordPos64& v0CoordPos64, CoordPos64& v1CoordPos64, CoordPos64& v2CoordPos64) const
150 {
151  return GetRawPtr().GetVerticesCoordPos64(v0CoordPos64, v1CoordPos64, v2CoordPos64);
152 }
153 KY_INLINE void NavTrianglePtr::GetVerticesCoordPos(CoordPos& v0CoordPos, CoordPos& v1CoordPos, CoordPos& v2CoordPos) const
154 {
155  return GetRawPtr().GetVerticesCoordPos(v0CoordPos, v1CoordPos, v2CoordPos);
156 }
157 }
158 
159 #endif //Navigation_NavTrianglePtr_H
NavTriangleRawPtr GetRawPtr() const
Constructs and returns a NavTriangleRawPtr that refers to the same NavTriangle.
Definition: navtriangleptr.h:146
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor identified by this object. Returns KY_NULL if this object is not va...
Definition: navfloorptr.h:97
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:132
void Invalidate()
Invalidates this object.
Definition: navtriangleptr.h:134
NavFloor * GetNavFloor() const
Returns a pointer to the NavFloor that contains this triangle. Returns KY_NULL if this object is not ...
Definition: navtriangleptr.h:141
KyUInt32 NavTriangleIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:100
Each instance of this class uniquely identifies a single NavFloor.
Definition: navfloorptr.h:21
bool operator!=(const NavTrianglePtr &rhs) const
Returns true if this object identifies a different triangle from rhs.
Definition: navtriangleptr.h:137
This class is a runtime wrapper of a NavFloorBlob, it gathers all the runtime information associated ...
Definition: navfloor.h:40
The NavFloorBlob contains a connected and not overlapping part of triangle mesh static data within a ...
Definition: navfloorblob.h:42
const NavTag & GetNavTag() const
Retrieves the NavTag associated to the NavFloor that contains this triangle.
Definition: navtrianglerawptr.inl:45
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:148
This class represents a triangle in three-dimensional space, whose dimensions are stored using float ...
Definition: triangle3f.h:22
const NavTag & GetNavTag() const
Definition: navtriangleptr.h:149
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor identified by this object.
Definition: navfloorptr.h:100
NavTriangleIdx GetTriangleIdx() const
Returns the index of this triangle within its NavFloor.
Definition: navtriangleptr.h:139
CompactNavTriangleIdx m_triangleIdx
The index of this triangle within its NavFloor.
Definition: navtriangleptr.h:117
bool IsValid() const
Returns true if this object refers to a valid NavFloor, which means a NavFloor:that exists...
Definition: navfloorptr.h:83
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:136
This class defines a two-dimensional vector whose coordinates are stored using 64-bit integers...
Definition: vec2ll.h:27
void GetVerticesCoordPos(CoordPos &v0CoordPos, CoordPos &v1CoordPos, CoordPos &v2CoordPos) const
Updates the parameters to identify the vertices in this triangle.
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob identified by this object. Returns KY_NULL if this object...
Definition: navfloorptr.h:98
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:151
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob identified by this object.
Definition: navfloorptr.h:101
NavFloor * GetNavFloor_Unsafe() const
Returns a pointer to the NavFloor that contains this triangle.
Definition: navtriangleptr.h:143
NavFloorRawPtr GetRawPtr() const
Constructs and returns a NavFloorRawPtr that refers to the same NavFloor.
Definition: navfloorptr.h:103
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
void GetVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f, Vec3f &v2Pos3f) const
Updates the parameters to identify the vertices in this triangle.
void GetVerticesCoordPos64(CoordPos64 &v0CoordPos64, CoordPos64 &v1CoordPos64, CoordPos64 &v2CoordPos64) const
Updates the parameters to identify the vertices in this triangle.
Definition: navtriangleptr.h:156
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
void GetVerticesCoordPos(CoordPos &v0CoordPos, CoordPos &v1CoordPos, CoordPos &v2CoordPos) const
Updates the parameters to identify the vertices in this triangle.
Definition: navtriangleptr.h:160
NavTrianglePtr()
Creates an invalid NavTrianglePtr.
Definition: navtriangleptr.h:120
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtrianglerawptr.h:30
const NavFloorBlob * GetNavFloorBlob_Unsafe() const
Returns a const pointer to the NavFloorBlob that contains this triangle.
Definition: navtriangleptr.h:144
const CellPos & GetCellPos() const
Returns a const reference to the CellPos that indicates the position of the cell that contains this t...
Definition: navtrianglerawptr.inl:44
KyFloat32 GetAltitudeOfPointInTriangle(const Vec3f &pos) const
Returns the altitude of the point on the plane defined by this triangle that has the same (X...
void GetVerticesPos3f(Vec3f &v0Pos3f, Vec3f &v1Pos3f, Vec3f &v2Pos3f) const
Updates the parameters to identify the vertices in this triangle.
Definition: navtriangleptr.h:152
void Invalidate()
Invalidates this object.
Definition: navfloorptr.h:82
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
NavFloorPtr m_navFloorPtr
The NavFloor that contains this triangle.
Definition: navtriangleptr.h:116
void Set(const NavFloorPtr &navFloorPtr, NavTriangleIdx triangleIdx)
Clears all information maintained by this object.
Definition: navtriangleptr.h:126
void GetVerticesCoordPos64(CoordPos64 &v0CoordPos64, CoordPos64 &v1CoordPos64, CoordPos64 &v2CoordPos64) const
Updates the parameters to identify the vertices in this triangle.
const NavFloorBlob * GetNavFloorBlob() const
Returns a const pointer to the NavFloorBlob that contains this triangle. Returns KY_NULL if this obje...
Definition: navtriangleptr.h:142
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23