gwnavruntime/navmesh/navcell.h Source File

navcell.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 class ActiveNavFloorCollection;
17 class NavFloorPtr;
18 class NavFloor;
19 class Database;
20 class DynamicNavMeshQuery;
21 class StaticToDynamicHalfEdge;
22 
27 class NavCell
28 {
29  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
31 public:
32  // ------------------------------ Functions -----------------------------
33 
34  const CellPos& GetCellPos() const { return m_navCellBlob->GetCellPos(); }
35 
36  KyUInt32 GetNavFloorCount() const { return m_numberOfFloors; }
37 
38  NavFloor* GetNavFloor(NavFloorIdx floorIdx) const { return m_metaNavFloorBuffer[floorIdx].m_activeNavFloor; }
39 
41  const GuidCompound& GetGuidCompound() const { return m_parentNavMeshElement->GetGuidCompound(); }
42 
44 
45  bool IsNavCellBlobEmpty() const { return GetNavFloorCount() == 0; }
46 
49  bool IsNavCellActive() const { return GetActivenessStatus() == ACTIVE; }
50 
51 public: // internal
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 { return m_idxOfNavCellVersionCollection; }
70 
71  void SetIndexInCollection(KyUInt32 indexInCollection) { m_idxOfNavCellVersionCollection = (KyUInt16)indexInCollection; }
72 
73  NavFloor* GetStaticNavFloorVersion(NavFloorIdx floorIdx) const { return m_metaNavFloorBuffer[floorIdx].m_staticNavFloor; }
74 
75  void RestoreStaticNavFloorAsActive(NavFloorIdx floorIdx);
76  void SetNewDynamicVersionOfNavFloor(NavFloorIdx floorIdx, BlobHandler<NavFloorBlob>* navFloorBlobHandler);
77 
78  ActivenessStatus GetActivenessStatus() const { return (ActivenessStatus)m_currentActivenessStatus; }
79 
80  ActivenessStatus GetNextActivenessStatus() const { return (ActivenessStatus)m_nextActivenessStatus; }
81 
82  void SetActivenessStatus(ActivenessStatus status) { m_currentActivenessStatus = (KyUInt8)status; }
83 
84  void SetNextActivenessStatus(ActivenessStatus status) { m_nextActivenessStatus = (KyUInt8)status; }
85 
86  class MetaNavFloor
87  {
88  public:
89  MetaNavFloor();
90  ~MetaNavFloor();
91  Ptr<NavFloor> m_staticNavFloor;
92  Ptr<NavFloor> m_activeNavFloor;
93  Ptr<BaseBlobHandler> m_blobHandlerOfDynamicNavFloor;
94  NavFloor1To1StitchData m_floor1To1StitchData;
95  };
96 
97  const NavFloorBlob* GetFutureActiveNavFloorBlob(KyUInt32 floorIdx);
98 
99 public: // internal
102 
103  MetaNavFloor* m_metaNavFloorBuffer;
104 
105  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
106 
114  bool m_mustLaunchRuntimStitchQuery;
115 };
116 
117 }
118 
119 
const GuidCompound & GetGuidCompound() const
Returns the GuidCompound that uniquely identifies this NavMeshElement.
Definition: navmeshelement.h:40
This class is a runtime wrapper of a NavMeshElementBlob.
Definition: navmeshelement.h:21
This class is a runtime wrapper of a NavFloorBlob, it gathers all the runtime information associated ...
Definition: navfloor.h:32
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
KyUInt8 m_currentActivenessStatus
Current ActivenessStatus. Do not modify.
Definition: navcell.h:111
The NavCellBlob contains the NavMesh static data of a NavMeshElement at a CellPos.
Definition: navcellblob.h:19
KyUInt8 m_nextActivenessStatus
this is a temporary ActivenessStatus value used by the NavCellGrid when updating the database...
Definition: navcell.h:112
MetaNavFloor * m_metaNavFloorBuffer
m_metaNavFloorBuffer
Definition: navcell.h:103
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
const GuidCompound & GetGuidCompound() const
Returns the GuidCompound that identifies the NavMeshElement that contains this NavCell.
Definition: navcell.h:41
const NavCellBlob * m_navCellBlob
The NavCellBlob that contains the static data for this NavCell. Do not modify.
Definition: navcell.h:101
This class is a runtime wrapper of a NavCellBlob.
Definition: navcell.h:27
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:112
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
NavMeshElement * m_parentNavMeshElement
The NavMeshElement that contains this NavCell. Do not modify.
Definition: navcell.h:100
bool IsNavCellActive() const
Indicates whether or not this NavCell has been considered active by the NavCellGrid in term of overla...
Definition: navcell.h:49
KyUInt16 m_idxOfNavCellVersionCollection
the idx of this NavCell in the SmallPtrTrackedCollection located at this CellPos in the NavCellGrid...
Definition: navcell.h:108
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:113
KyUInt16 m_numberOfFloors
The total number of NavFloors in m_metaNavFloorBuffer. never change. Do not modify.
Definition: navcell.h:109
bool IsNavCellBlobEmpty() const
Returns true if the NavCellBlob contains no NavFloor ie no triangle.
Definition: navcell.h:45
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:107
std::uint8_t KyUInt8
uint8_t
Definition: types.h:27
NavMeshElement * GetParentNavMeshElement() const
Returns a pointer to the NavMeshElement that contains this NavCell.
Definition: navcell.h:43
const CellPos & GetCellPos() const
Retrieves the position of this NavCellBlob within the partitioning scheme of its NavMeshElementBlob.
Definition: navcellblob.h:49
KyUInt16 m_numberOfActiveDynamicFloors
The number of dynamicNavFloors in the m_metaNavFloorBuffer buffer. Do not modify. ...
Definition: navcell.h:110