gwnavruntime/navmesh/navfloor.h Source File

navfloor.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 
13 
14 namespace Kaim
15 {
16 
17 class NavCell;
18 class DynamicNavFloor;
19 class NavHalfEdgeRawPtr;
20 class NavFloorToNavGraphLinks;
21 class Database;
22 class SpatializedPoint;
23 class NavFloor;
24 class NavFloor1To1StitchData;
25 
32 class NavFloor
33 {
34  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
37 
38 public:
39  // ------------------------------ Functions -----------------------------
40 
41  const NavFloorBlob* GetNavFloorBlob() const;
42  const CellPos& GetCellPos() const;
43  bool IsStillLoaded() const;
44 
47  bool IsActive() const;
48 
49 public: // internal
50 
51  NavFloor* GetAssociatedStaticNavFloor() const; // returns the associated static NavFloor if "this" is a dynamic NavFloor. Else it just returns "this".
52  bool IsStaticVersion() const;
53 
54  const ConnectedComponentId& GetConnexConnectedComponentId(KyUInt32 navConnexIdx) const; // used in generation
55  void SetConnexConnectedComponentId(KyUInt32 navConnexIdx, ConnectedComponentId connectedComponentId); // used in generation
56  NavHalfEdgeRawPtr* GetLinksBuffer() const;
57 
58  bool HasAnUnconnectedLink() const;
59 
61  void OnRemove();
62  void OnDeActivate();
63 
64  NavFloorToNavGraphLinks* GetNavFloorToNavGraphLinks() const;
65 
66  class CreateConfig
67  {
68  public:
69  CreateConfig() : m_navFloorBlob(nullptr), m_database(nullptr), m_navCell(nullptr), m_floor1To1StitchData(nullptr) {}
70 
71  NavFloorBlob* m_navFloorBlob;
72  Database* m_database;
73  NavCell* m_navCell;
74  NavFloor1To1StitchData* m_floor1To1StitchData;
75  CellPos m_cellPos;
76  };
77 
78  static Ptr<NavFloor> Create(const CreateConfig& navFloorCongig, MemoryHeap* pheap = nullptr);
79  static KyUInt32 ComputeSizeForNavFloor(const NavFloorBlob& navFloorBlob);
80 
81  KyUInt32 GetIndexInCollection() const;
82  void SetIndexInCollection(KyUInt32 indexInCollection);
83 
84  // SpatializedPoint management
85  const Collection<SpatializedPoint*>& GetSpatializedPoints() const;
86  void AddSpatializedPoint(SpatializedPoint* spatializedPoint);
87  void RemoveSpatializedPoint(SpatializedPoint* spatializedPoint);
88  void RemoveAllSpatializedPoints();
89 
90  void UnstitchStaticLinks();
91 private:
92  static Ptr<NavFloor> PlaceNavFloorInBuffer(const CreateConfig& navFloorCongig, char* currentMemoryPlace);
93 
94 public: // internal
95  Database* m_database;
96  NavCell* m_navCell;
97 
98  NavFloor1To1StitchData* m_floor1To1StitchData;
99  const NavFloorBlob* m_navFloorBlob;
100  NavTag* m_navTags; // the navTag presents in the NavFloorBlob are copied in the NavFloor. 1 per NavConnex
101  ConnectedComponentId* m_connexConnectedComponents; // used in generation. 1 per NavConnex
102 
103  CellPos m_cellPos; // The position of this NavFloor within the grid of NavData cells. Do not modify.
104  FloorAltitudeRange m_floorAltitudeRange;
105 
106  Collection<SpatializedPoint*> m_spatializedPoints;
107 
108  KyUInt16 m_floorLinksOffset; // bytes offsets to NavHalfEdgeRawPtr buffer
109  KyUInt16 m_graphLinksOffset; // bytes offsets to NavFloorToNavGraphLinks buffer
110  KyUInt16 m_numberOfLink;
111  KyUInt16 m_numberOfUnconnectedLink;
112  KyUInt16 m_idxInActiveNavFloorCollection;
113  KyUInt16 m_idxInTheNavCellBuffer;
114 };
115 
116 KY_INLINE const NavFloorBlob* NavFloor::GetNavFloorBlob() const
117 {
118  KY_DEBUG_ASSERTN(m_navFloorBlob != nullptr,("the SizedPtr is not valid"));
119  return m_navFloorBlob;
120 }
121 
122 KY_INLINE KyUInt32 NavFloor::GetIndexInCollection() const { return m_idxInActiveNavFloorCollection; }
123 KY_INLINE void NavFloor::SetIndexInCollection(KyUInt32 indexInCollection) { m_idxInActiveNavFloorCollection = (KyUInt16)indexInCollection; }
124 
125 KY_INLINE bool NavFloor::IsStillLoaded() const { return m_navFloorBlob != nullptr; }
126 KY_INLINE bool NavFloor::IsActive() const { return m_idxInActiveNavFloorCollection != KyUInt16MAXVAL; }
127 
128 KY_INLINE const CellPos& NavFloor::GetCellPos() const { return m_cellPos; }
129 KY_INLINE const ConnectedComponentId& NavFloor::GetConnexConnectedComponentId(KyUInt32 navConnexIdx) const { return m_connexConnectedComponents[navConnexIdx]; }
130 
131 KY_INLINE NavHalfEdgeRawPtr* NavFloor::GetLinksBuffer() const { return (NavHalfEdgeRawPtr*)((char*)this + m_floorLinksOffset); }
132 KY_INLINE NavFloorToNavGraphLinks* NavFloor::GetNavFloorToNavGraphLinks() const { return (NavFloorToNavGraphLinks*)((char*)this + m_graphLinksOffset); }
133 
134 KY_INLINE bool NavFloor::HasAnUnconnectedLink() const { return m_numberOfUnconnectedLink != 0; }
135 
136 KY_INLINE void NavFloor::SetConnexConnectedComponentId(KyUInt32 navConnexIdx, ConnectedComponentId connectedComponentId) { m_connexConnectedComponents[navConnexIdx] = connectedComponentId; }
137 
138 KY_INLINE const Collection<SpatializedPoint*>& NavFloor::GetSpatializedPoints() const { return m_spatializedPoints; }
139 KY_INLINE void NavFloor::AddSpatializedPoint(SpatializedPoint* spatializedPoint) { m_spatializedPoints.PushBack(spatializedPoint); }
140 KY_INLINE void NavFloor::RemoveSpatializedPoint(SpatializedPoint* spatializedPoint) { m_spatializedPoints.RemoveFirstOccurrence(spatializedPoint); }
141 
142 KY_INLINE bool NavFloor::IsStaticVersion() const { return GetAssociatedStaticNavFloor() == this; }
143 
144 }
145 
146 
Represents the range of altitudes covered by a single NavFloorBlob.
Definition: flooraltituderange.h:15
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
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
const NavFloorBlob * GetNavFloorBlob() const
Retrieves the NavFloorBlob that contains the static data for this NavFloor.
Definition: navfloor.h:116
Collection is a class which is a "Collection" of elements (not sorted, not unique) ...
Definition: collection.h:31
#define KY_REFCOUNT_MALLOC_FREE(ClassName)
Specific to RefCounting, no inheritance involved, used to make RefCount-able classes compatible with ...
Definition: memory.h:141
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
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
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:57
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
void OnRemove()
Clears all information maintained by this object.
Definition: navfloor.cpp:38
#define KyUInt16MAXVAL
KyUInt16 max value
Definition: types.h:67
bool IsActive() const
This function returns true if the NavFloor has been "activated" in term of overlap, dynamic version,...
Definition: navfloor.h:126
bool IsStillLoaded() const
This function returns false if the NavData containing corresponding NavFloorBlob has been removed fro...
Definition: navfloor.h:125
SpatializedPoint is used to the NavTriangle of "object": Bot, CylinderObstacle, BoxObstacle and Point...
Definition: spatializedpoint.h:146
const CellPos & GetCellPos() const
Returns the position of this NavFloor within the grid of NavData cells.
Definition: navfloor.h:128
Each instance of this class uniquely identifies a single NavHalfEdge in a NavFloor.
Definition: navhalfedgerawptr.h:23