gwnavruntime/navmesh/navfloor.h Source File

navfloor.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_NavFloor_H
11 #define Navigation_NavFloor_H
12 
17 
18 namespace Kaim
19 {
20 
21 class NavCell;
22 class DynamicNavFloor;
23 class NavHalfEdgeRawPtr;
24 class NavFloorToNavGraphLinks;
25 class Database;
26 class SpatializedPoint;
27 class NavFloor;
28 class NavFloor1To1StitchData;
29 
30 
31 
38 class NavFloor
39 {
43 
44 public:
45  // ---------------------------------- Public Member Functions ----------------------------------
46 
47  const NavFloorBlob* GetNavFloorBlob() const;
48  const CellPos& GetCellPos() const;
49  bool IsStillLoaded() const;
50 
53  bool IsActive() const;
54 
55 public: //Internal
56 
57  NavFloor* GetAssociatedStaticNavFloor() const; // returns the associated static NavFloor if "this" is a dynamic NavFloor. Else it just returns "this".
58  bool IsStaticVersion() const;
59 
60  const ConnectedComponentId& GetConnexConnectedComponentId(KyUInt32 navConnexIdx) const; // used in generation
61  void SetConnexConnectedComponentId(KyUInt32 navConnexIdx, ConnectedComponentId connectedComponentId); // used in generation
62  NavHalfEdgeRawPtr* GetLinksBuffer() const;
63 
64  bool HasAnUnconnectedLink() const;
65 
67  void OnRemove();
68  void OnDeActivate();
69 
70  NavFloorToNavGraphLinks* GetNavFloorToNavGraphLinks() const;
71 
72  class CreateConfig
73  {
74  public:
75  CreateConfig() : m_navFloorBlob(KY_NULL), m_database(KY_NULL), m_navCell(KY_NULL), m_floor1To1StitchData(KY_NULL) {}
76 
77  NavFloorBlob* m_navFloorBlob;
78  Database* m_database;
79  NavCell* m_navCell;
80  NavFloor1To1StitchData* m_floor1To1StitchData;
81  CellPos m_cellPos;
82  };
83 
84  static Ptr<NavFloor> Create(const CreateConfig& navFloorCongig, MemoryHeap* pheap = KY_NULL);
85  static KyUInt32 ComputeSizeForNavFloor(const NavFloorBlob& navFloorBlob);
86 
87  KyUInt32 GetIndexInCollection() const;
88  void SetIndexInCollection(KyUInt32 indexInCollection);
89 
90  // SpatializedPoint management
91  const Collection<SpatializedPoint*>& GetSpatializedPoints() const;
92  void AddSpatializedPoint(SpatializedPoint* spatializedPoint);
93  void RemoveSpatializedPoint(SpatializedPoint* spatializedPoint);
94  void RemoveAllSpatializedPoints();
95 
96  void UnstitchStaticLinks();
97 private:
98  static Ptr<NavFloor> PlaceNavFloorInBuffer(const CreateConfig& navFloorCongig, char*& currentMemoryPlace);
99 
100 public: // internal
101  Database* m_database;
102  NavCell* m_navCell;
103 
104  NavFloor1To1StitchData* m_floor1To1StitchData;
105  const NavFloorBlob* m_navFloorBlob;
106  NavTag* m_navTags; // the navTag presents in the NavFloorBlob are copied in the NavFloor. 1 per NavConnex
107  ConnectedComponentId* m_connexConnectedComponents; // used in generation. 1 per NavConnex
108 
109  CellPos m_cellPos; // The position of this NavFloor within the grid of NavData cells. Do not modify.
110  FloorAltitudeRange m_floorAltitudeRange;
111 
112  Collection<SpatializedPoint*> m_spatializedPoints;
113 
114  KyUInt16 m_floorLinksOffset; // bytes offsets to NavHalfEdgeRawPtr buffer
115  KyUInt16 m_graphLinksOffset; // bytes offsets to NavFloorToNavGraphLinks buffer
116  KyUInt16 m_numberOfLink;
117  KyUInt16 m_numberOfUnconnectedLink;
118  KyUInt16 m_idxInActiveNavFloorCollection;
119  KyUInt16 m_idxInTheNavCellBuffer;
120 };
121 
122 KY_INLINE const NavFloorBlob* NavFloor::GetNavFloorBlob() const
123 {
124  KY_DEBUG_ASSERTN(m_navFloorBlob != KY_NULL,("the SizedPtr is not valid"));
125  return m_navFloorBlob;
126 }
127 
128 KY_INLINE KyUInt32 NavFloor::GetIndexInCollection() const { return m_idxInActiveNavFloorCollection; }
129 KY_INLINE void NavFloor::SetIndexInCollection(KyUInt32 indexInCollection) { m_idxInActiveNavFloorCollection = (KyUInt16)indexInCollection; }
130 
131 KY_INLINE bool NavFloor::IsStillLoaded() const { return m_navFloorBlob != KY_NULL; }
132 KY_INLINE bool NavFloor::IsActive() const { return m_idxInActiveNavFloorCollection != KyUInt16MAXVAL; }
133 
134 KY_INLINE const CellPos& NavFloor::GetCellPos() const { return m_cellPos; }
135 KY_INLINE const ConnectedComponentId& NavFloor::GetConnexConnectedComponentId(KyUInt32 navConnexIdx) const { return m_connexConnectedComponents[navConnexIdx]; }
136 
137 KY_INLINE NavHalfEdgeRawPtr* NavFloor::GetLinksBuffer() const { return (NavHalfEdgeRawPtr*)((char*)this + m_floorLinksOffset); }
138 KY_INLINE NavFloorToNavGraphLinks* NavFloor::GetNavFloorToNavGraphLinks() const { return (NavFloorToNavGraphLinks*)((char*)this + m_graphLinksOffset); }
139 
140 KY_INLINE bool NavFloor::HasAnUnconnectedLink() const { return m_numberOfUnconnectedLink != 0; }
141 
142 KY_INLINE void NavFloor::SetConnexConnectedComponentId(KyUInt32 navConnexIdx, ConnectedComponentId connectedComponentId) { m_connexConnectedComponents[navConnexIdx] = connectedComponentId; }
144 KY_INLINE const Collection<SpatializedPoint*>& NavFloor::GetSpatializedPoints() const { return m_spatializedPoints; }
145 KY_INLINE void NavFloor::AddSpatializedPoint(SpatializedPoint* spatializedPoint) { m_spatializedPoints.PushBack(spatializedPoint); }
146 KY_INLINE void NavFloor::RemoveSpatializedPoint(SpatializedPoint* spatializedPoint) { m_spatializedPoints.RemoveFirstOccurrence(spatializedPoint); }
147 
148 KY_INLINE bool NavFloor::IsStaticVersion() const { return GetAssociatedStaticNavFloor() == this; }
149 
150 }
151 
152 #endif //Navigation_NavFloor_H
153 
Represents the range of altitudes covered by a single NavFloorBlob.
Definition: flooraltituderange.h:18
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
#define KY_REFCOUNT_MALLOC_FREE(ClassName)
Specific to RefCounting, no inheritance involved, used to make RefCount-able classes compatible with ...
Definition: memory.h:145
const NavFloorBlob * GetNavFloorBlob() const
Retrieves the NavFloorBlob that contains the static data for this NavFloor.
Definition: navfloor.h:134
Collection is a class which is a "Collection" of elements (not sorted, not unique) ...
Definition: collection.h:32
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
This class is a runtime wrapper of a NavCellBlob.
Definition: navcell.h:33
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
void OnRemove()
Clears all information maintained by this object.
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
#define KyUInt16MAXVAL
The maximum value that can be stored in the KyUInt16 variable type.
Definition: types.h:230
bool IsActive() const
This function returns true if the NavFloor has been "activated" in term of overlap, dynamic version,...
Definition: navfloor.h:144
bool IsStillLoaded() const
This function returns false if the NavData containing corresponding NavFloorBlob has been removed fro...
Definition: navfloor.h:143
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Internal class used for point spatialization in NavData.
Definition: spatializedpoint.h:171
const CellPos & GetCellPos() const
Returns the position of this NavFloor within the grid of NavData cells.
Definition: navfloor.h:146
Each instance of this class uniquely identifies a singleNavHalfEdge in a NavFloor.
Definition: navhalfedgerawptr.h:34