gwnavruntime/navmesh/navcell.h Source File

navcell.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_NavCell_H
11 #define Navigation_NavCell_H
12 
16 
17 namespace Kaim
18 {
19 
20 class ActiveNavFloorCollection;
21 class NavFloorPtr;
22 class NavFloor;
23 class Database;
24 class DynamicNavMeshQuery;
25 class StaticToDynamicHalfEdge;
26 
31 class NavCell
32 {
35 public:
36  // ---------------------------------- Public Member Functions ----------------------------------
37 
38  const CellPos& GetCellPos() const;
39  KyUInt32 GetNavFloorCount() const;
40  NavFloor* GetNavFloor(NavFloorIdx floorIdx) const;
41  const GuidCompound& GetGuidCompound() const;
43 
44  bool IsNavCellBlobEmpty() const;
45 
48  bool IsNavCellActive() const;
49 
50 public: // Internal
51 
52  enum ActivenessStatus
53  {
54  NOT_PROCESSED ,
55  ACTIVE ,
56  INACTIVE ,
57  REMOVED
58  };
59 
60  NavCell(const NavCellBlob& navCellBlob);
61  ~NavCell();
62 
63  void OnRemove();
64  void OnDeActivate();
65 
66  static KyUInt32 ComputeSizeForNavCell(const NavCellBlob& navCellBlob);
67  static NavCell* PlaceNavCellInBuffer(const BlobRef<NavCellBlob>& navCellRef, Database* database, NavMeshElement* navMeshElement, char*& currentMemoryPlace);
68 
69  KyUInt32 GetIndexInCollection() const;
70  void SetIndexInCollection(KyUInt32 indexInCollection);
71 
72  NavFloor* GetStaticNavFloorVersion(NavFloorIdx floorIdx) const;
73  void RestoreStaticNavFloorAsActive(NavFloorIdx floorIdx);
74  void SetNewDynamicVersionOfNavFloor(NavFloorIdx floorIdx, BlobHandler<NavFloorBlob>* navFloorBlobHandler);
75 
76 
77  ActivenessStatus GetActivenessStatus() const;
78  ActivenessStatus GetNextActivenessStatus() const;
79  void SetActivenessStatus(ActivenessStatus status);
80  void SetNextActivenessStatus(ActivenessStatus status);
81 
82  class MetaNavFloor
83  {
84  public:
85  MetaNavFloor();
86  ~MetaNavFloor();
87  Ptr<NavFloor> m_staticNavFloor;
88  Ptr<NavFloor> m_activeNavFloor;
89  Ptr<BaseBlobHandler> m_blobHandlerOfDynamicNavFloor;
90  NavFloor1To1StitchData m_floor1To1StitchData;
91  };
92 
93  const NavFloorBlob* GetFutureActiveNavFloorBlob(KyUInt32 floorIdx);
94 public: // Internal
95  NavMeshElement* m_parentNavMeshElement;
96  const NavCellBlob* m_navCellBlob;
97 
98  MetaNavFloor* m_metaNavFloorBuffer;
99 
100  Ptr<DynamicNavMeshQuery> m_dynamicNavMeshQuery; // The dynamicNavMesh query that is running or that has finished on this Cell. Keep it to retrieve its result when computing run-time stitch
101 
109  bool m_mustLaunchRuntimStitchQuery;
110 };
113 KY_INLINE const GuidCompound& NavCell::GetGuidCompound() const { return m_parentNavMeshElement->GetGuidCompound(); }
115 KY_INLINE const CellPos& NavCell::GetCellPos() const { return m_navCellBlob->GetCellPos(); }
117 KY_INLINE NavFloor* NavCell::GetNavFloor(NavFloorIdx floorIdx) const { return m_metaNavFloorBuffer[floorIdx].m_activeNavFloor; }
118 KY_INLINE NavFloor* NavCell::GetStaticNavFloorVersion(NavFloorIdx floorIdx) const { return m_metaNavFloorBuffer[floorIdx].m_staticNavFloor; }
119 
120 KY_INLINE bool NavCell::IsNavCellBlobEmpty() const { return GetNavFloorCount() == 0; }
121 KY_INLINE bool NavCell::IsNavCellActive() const { return GetActivenessStatus() == ACTIVE; }
123 KY_INLINE KyUInt32 NavCell::GetIndexInCollection() const { return m_idxOfNavCellVersionCollection; }
124 KY_INLINE void NavCell::SetIndexInCollection(KyUInt32 indexInCollection) { m_idxOfNavCellVersionCollection = (KyUInt16)indexInCollection; }
126 KY_INLINE NavCell::ActivenessStatus NavCell::GetActivenessStatus() const { return (ActivenessStatus)m_currentActivenessStatus; }
127 KY_INLINE NavCell::ActivenessStatus NavCell::GetNextActivenessStatus() const { return (ActivenessStatus)m_nextActivenessStatus; }
128 KY_INLINE void NavCell::SetActivenessStatus(ActivenessStatus status) { m_currentActivenessStatus = (KyUInt8)status; }
129 KY_INLINE void NavCell::SetNextActivenessStatus(ActivenessStatus status) { m_nextActivenessStatus = (KyUInt8)status; }
131 }
132 
133 #endif //Navigation_NavCell_H
134 
const GuidCompound & GetGuidCompound() const
Retrieves the GuidCompound that identifies the NavMeshElement that contains this NavCell.
Definition: navcell.h:122
NavFloor * GetNavFloor(NavFloorIdx floorIdx) const
Retrieves the NavFloor with the specified index.
Definition: navcell.h:126
This class is a runtime wrapper of a NavMeshElementBlob.
Definition: navmeshelement.h:24
This class is a runtime wrapper of a NavFloorBlob, it gathers all the runtime information associated ...
Definition: navfloor.h:40
KyUInt8 m_currentActivenessStatus
Current ActivenessStatus. Do not modify.
Definition: navcell.h:115
The NavCellBlob contains the NavMesh static data of a NavMeshElement at a CellPos.
Definition: navcellblob.h:22
KyUInt8 m_nextActivenessStatus
this is a temporary ActivenessStatus value used by the NavCellGrid when updating the database...
Definition: navcell.h:116
NavMeshElement * GetParentNavMeshElement() const
Retrieves a pointer to the NavMeshElement that contains this NavCell.
Definition: navcell.h:123
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:45
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
const NavCellBlob * m_navCellBlob
The NavCellBlob that contains the static data for this NavCell. Do not modify.
Definition: navcell.h:105
This class is a runtime wrapper of a NavCellBlob.
Definition: navcell.h:33
A BlobRef is a type of reference that is compatible with the blob serialization framework.
Definition: blobref.h:58
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:115
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
const CellPos & GetCellPos() const
Retrieves the position of this NavCell within the grid of NavData cells.
Definition: navcell.h:124
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
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
NavMeshElement * m_parentNavMeshElement
The NavMeshElement that contains this NavCell. Do not modify.
Definition: navcell.h:104
bool IsNavCellActive() const
Indicates whether or not this NavCell has been considered active by the NavCellGrid in term of overla...
Definition: navcell.h:130
KyUInt16 m_idxOfNavCellVersionCollection
the idx of this NavCell in the SmallPtrTrackedCollection located at this CellPos in the NavCellGrid...
Definition: navcell.h:112
const GuidCompound & GetGuidCompound() const
Retrieves the GuidCompound that uniquely identifies this NavMeshElement.
Definition: navmeshelement.h:77
bool m_navFloorsAreStitched
Indicates whether or not the NavFloors in this NavCell have been stitched into a Database. For Internal Use. Do not modify.
Definition: navcell.h:117
KyUInt16 m_numberOfFloors
The total number of NavFloors in #m_activeNavFloors. never change. Do not modify. ...
Definition: navcell.h:113
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
bool IsNavCellBlobEmpty() const
Returns true if the NavCellBlob contains no NavFloors and triangles.
Definition: navcell.h:129
KyUInt32 m_navCellIdxInNavMesh
The index of the NavCell within the buffer of NavCell in its NavMeshElement. Equal to the index of Na...
Definition: navcell.h:111
const CellPos & GetCellPos() const
Retrieves the position of this NavCellBlob within the partitioning scheme of its NavMeshElementBlob.
Definition: navcellblob.h:58
KyUInt32 GetNavFloorCount() const
Retrieves the number of NavFloors in this NavCell.
Definition: navcell.h:125
KyUInt16 m_numberOfActiveDynamicFloors
The number of dynamicNavFloors in the #m_activeNavFloors buffer. Do not modify.
Definition: navcell.h:114