VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vrfNavAreaManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 #include <vrfNavigation/navArea.h>
14 
17 
19 #include <matrix/vlVector.h>
20 #include <matrix/coordTransform.h>
21 
23 #include <geometry/extent.h>
24 #include <geometry/point.h>
25 
28 
30 #include <tbb/spin_mutex.h>
31 #include <tbb/task_arena.h>
32 #include <tbb/task_group.h>
33 
35 #include <atomic>
36 #include <map>
37 #include <queue>
38 #include <vector>
40 
41 
42 class DtTerrainInterface;
43 class DtSimManager;
44 class DtSimObject;
45 class DtLocalVertexList;
46 class DtSimMessage;
47 class Coordinate_System;
48 class DtUUID;
49 class DtAttachedTerrain;
50 class DtLocalObject;
53 class DtTerrainAttachedTo;
54 
55 namespace makArchives
56 {
57  class DtGenericTerrainRecord;
58 }
59 
61 typedef void (*DtNavAreaRemovalCallbackFcn)(DtNavArea* area,
62  void* usr);
63 
66 {
67 public:
68 
70 
72  virtual ~DtVrfNavAreaManager();
73 
74  static void tickCallback(void* args);
75 
77  virtual bool init();
78 
80  virtual void tick();
81 
83 
84  virtual void setTerrainInterface(DtTerrainInterface* terrainInterface);
86  {
87  return myTerrainInterface;
88  }
90 
93 
94  static void genericRecordLoadedCallback(
95  makArchives::DtGenericTerrainRecord* record, void *user);
96  virtual void processGenericRecordLoaded(
99 
102 
103  void loadObjectNavData(const DtSimObject* simObject, const DtReaderWriter::SearchPaths& searchPaths = DtReaderWriter::SearchPaths());
104  void removeObjectNavData(const DtSimObject* simObject);
105  DtNavArea* areaForObject(const DtSimObject* simObject) const;
107 
109  virtual void unloadAllNavData();
110 
112  virtual void revertNavData();
113 
115  virtual void pauseNavDataRegeneration();
116 
118  virtual void resumeNavDataRegeneration();
119 
123  virtual void addNavArea(DtNavArea* a);
124 
128  virtual DtNavArea* loadNavArea(DtNavArea::NavAreaId id, const DtFilename& filename);
129 
133  virtual DtNavArea* loadNavDataForObject(DtNavArea::NavAreaId id, const DtFilename& filename,
134  const DtSimObject* simObject, const DtReaderWriter::SearchPaths& searchPaths = DtReaderWriter::SearchPaths());
135 
138  virtual void loadAllNavData(bool* dataAvailable = 0);
139 
142  virtual DtNavArea::NavAreaId nextNavAreaId();
143 
151 
152  virtual DtNavArea* findNavAreaForLocation(const DtVector& localPosition, const DtString& profile,
153  const DtSimObject* = 0, bool* dataAvailable = 0);
154  virtual std::vector<DtNavArea*> findNavAreasForLocation(const DtVector& localPosition,
155  const DtString& profile, DtTerrainCategoryMask terrainCategoryMask,
156  const DtSimObject* = 0, bool* dataAvailable = 0, const DtAttachedTerrain* terrainAttachedTo = 0,
157  bool loadNavAreas = true);
158  virtual std::vector<DtNavArea*> findNavAreasForArea(const DtLocalVertexList* boundingArea,
159  const DtString& profile, const DtSimObject* = 0, bool* dataAvailable = 0);
160  virtual DtNavArea* findNavAreaForArea(const DtLocalVertexList* area, const DtString& profile,
161  const DtSimObject* = 0, bool* dataAvailable = 0);
162 
164  virtual std::vector<DtNavArea*> findNavAreasForLocation(const DtVector& localPosition) const;
166 
168  virtual void addNavAreaAboutToBeRemovedCallback(
169  DtNavAreaRemovalCallbackFcn fcn, void* usrData) const;
170 
173  virtual void removeNavAreaAboutToBeRemovedCallback(
174  DtNavAreaRemovalCallbackFcn fcn, void* usrData) const;
175 
178  virtual void setBlockingNavDataLoad(bool b);
179 
181 
182  static void requestNavAreaStatusCallback(DtSimMessage*, void* usr);
183  virtual void processRequestNavAreaStatus();
185 
187 
188  static void requestSimObjectDebugPortsCallback(DtSimMessage* msg, void* usr);
189  virtual void processRequestSimObjectDebugPortsCallback(DtUUID uuid);
191 
193  virtual void sendNavDataStatus();
194 
196  virtual void processNavQueues();
197 
199 
200  static void setGamewareWorkingMemorySize(int sizeInMb);
201  static void setRegenerateNavigationDataAtRuntime(bool regen);
202  static void setMaxRegenerationThreads(int threads);
203  static void setNumberOfNavQueueProcessingThreads(int threads);
204  static void setRegenerationDelay(double delay);
205  static void setQueryTimeBudget(double ms);
206  static void setRegenerationFileDirectory(const DtFilename& dir);
208 
213  static double theRegenerationDelay;
214  static double theQueryTimeBudget;
215  static DtFilename theRegenerationFileDirectory;
216 
218  virtual void processSimObjectDeleted(const DtSimObject* simObject);
219 
221  virtual void invokeAreaAboutToBeDeletedCallbacks(DtNavArea*);
222 
224 
225  static void navigationRegenUpdateCallback(void* usr);
226  virtual void processNavigationRegenUpdate();
228 
229  void processUnloadTerrain();
230 
231  virtual void updateSimOperationStatus();
232 
233  void setBlockOnAsynchronousOperations(bool block);
234 
235  bool hasAsynchronousOperationsPending() const;
236 
237 protected:
238 
244 
245  static void terainChangeNotificationCallback(const DtTerrainChangeNotificationInfo& terrainChangeInfo, void* usr);
246  void processTerrainChangeNotification(const DtTerrainChangeNotificationInfo& terrainChangeInfo);
248 
250  virtual void processNavAreasTerrainChangesQueues();
251 
252 protected:
254 
255  //the extents and their data for all the unloaded nav areas in this terrain
257  {
258  DtFilename filename;
259 
261  std::shared_ptr<DtCoordTransform> Matrix;
264  DtCoordTransform InvMatrix;
265  std::set<DtString> Profiles;
266  bool IsLoading;
269  boost::signals2::connection DynamicTerrainConnection;
270  };
271 
272  std::map<DtNavArea::NavAreaId, navAreaExtentData> myNavAreaExtents;
273 
274 
275 
276  //the nav areas whose data has been loaded
277  typedef std::vector<DtNavArea*> DtNavAreas;
279 
280  typedef std::map<DtUUID, DtNavArea*> DtObjectNavAreaMap;
282 
283  typedef std::queue<DtTerrainChangeNotificationInfo> DtNavAreaTerrainChangesQueue;
284  typedef std::map<DtNavArea::NavAreaId, DtNavAreaTerrainChangesQueue*> DtNavAreasTerrainChangesQueues;
285  typedef std::map<DtNavArea::NavAreaId, DtExtent> DtNavAreasLocalExtents;
286 
290 
294 
299 
304 
306 
308 
309 public:
311 protected:
312 
315  tbb::spin_mutex myNavAreaExtentsMutex;
316  mutable tbb::spin_rw_mutex myNavAreaMutex;
317  mutable tbb::spin_rw_mutex myObjectNavAreaMutex;
318 
320  std::atomic<bool> myContinueProcessing;
321  std::atomic<bool> myProcessingStopped;
322 
323  tbb::task_arena myNavAreaArena;
324  tbb::task_group myNavAreaTaskGroup;
325  boost::signals2::connection myUnloadTerrainConnection;
326 
328  bool myNavRegenerating = false;
329  bool myNavOperations = false;
330 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
This class is just used to count the nav generation threads to ensure we do not start too many thread...
Definition: navArea.h:160
static int theGamewareWorkingMemorySize
Definition: vrfNavAreaManager.h:209
static int theMaxRegenerationThreads
Definition: vrfNavAreaManager.h:211
Coordinate_System * myObjectCoordSys
Coord system used for nav datas on embarked objects.
Definition: vrfNavAreaManager.h:303
bool myRegenInTempDirectory
Definition: vrfNavAreaManager.h:327
This class is used to interface with the terrain a particular entity is &quot;attached&quot; to...
Definition: attachedTerrain.h:57
DtTerrainInterface * myTerrainInterface
Definition: vrfNavAreaManager.h:253
std::map< DtNavArea::NavAreaId, DtNavAreaTerrainChangesQueue * > DtNavAreasTerrainChangesQueues
Definition: vrfNavAreaManager.h:284
static int theNumberOfNavQueueProcessingThreads
Definition: vrfNavAreaManager.h:212
std::map< DtNavArea::NavAreaId, navAreaExtentData > myNavAreaExtents
Definition: vrfNavAreaManager.h:272
DtDcm LocalCorrectionMatrix
Definition: vrfNavAreaManager.h:262
DtGenericTerrainRecords allow the VR-Forces terrainInterface library to instantiate and configure the...
Definition: DtGenericTerrainRecord.h:34
std::shared_ptr< DtCoordTransform > Matrix
Definition: vrfNavAreaManager.h:261
std::atomic< bool > myProcessingStopped
Definition: vrfNavAreaManager.h:321
bool myNavigationInitialized
Definition: vrfNavAreaManager.h:300
Definition: vrfNavAreaManager.h:256
DtPoint ReferencePoint
Definition: vrfNavAreaManager.h:260
std::atomic< bool > myContinueProcessing
Definition: vrfNavAreaManager.h:320
DtSimulationServices * mySimulationServices
Definition: vrfNavAreaManager.h:301
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:29
DtNavArea::NavAreaId myNextNavAreaId
Definition: vrfNavAreaManager.h:307
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
tbb::spin_rw_mutex myObjectNavAreaMutex
Definition: vrfNavAreaManager.h:317
bool myRegisteredForTerrainChanges
Indicates if the DtVrfNavAreaManager has a terrain notifications callback registered with the DtVanta...
Definition: vrfNavAreaManager.h:298
tbb::spin_rw_mutex myNavAreaMutex
Definition: vrfNavAreaManager.h:316
tbb::spin_mutex myNavAreaExtentsMutex
Definition: vrfNavAreaManager.h:315
DtCallbackList< DtNavArea * > NavAreaAboutToBeRemovedList
Definition: vrfNavAreaManager.h:313
std::vector< DtNavArea * > DtNavAreas
Definition: vrfNavAreaManager.h:277
std::set< DtString > Profiles
Definition: vrfNavAreaManager.h:265
DtDcm InvLocalCorrectionMatrix
Definition: vrfNavAreaManager.h:263
DtNavAreasTerrainChangesQueues myNavAreasTerrainChangesQueues
Map of queues with terrain changes - created for each nav area. The terrain changes are added to the ...
Definition: vrfNavAreaManager.h:289
bool myBlockingNavLoad
Definition: vrfNavAreaManager.h:305
tbb::task_group myNavAreaTaskGroup
Definition: vrfNavAreaManager.h:324
bool IsLoading
Definition: vrfNavAreaManager.h:266
Definition: coordSystem.h:54
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
The DtVrfNavAreaManager manages all of the nav areas currently created in the sim.
Definition: vrfNavAreaManager.h:65
This class contains all the data and logic for navigation within a specific area. Nav Data may be loa...
Definition: navArea.h:205
File: simMsg.h.
Definition: simMessage.h:35
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
boost::signals2::connection DynamicTerrainConnection
Definition: vrfNavAreaManager.h:269
DtTerrainInterface allows access to common terrain calls without having to know the terrain implement...
Definition: terrainInterface.h:93
DtFilename filename
Definition: vrfNavAreaManager.h:258
DtVrfCallbackQueue * myNavQueryProcessingParallelQueue
Definition: vrfNavAreaManager.h:319
virtual DtTerrainInterface * terrainInterface()
The terrain interface used by this nav area manager.
Definition: vrfNavAreaManager.h:85
DtNavAreas myNavAreas
Definition: vrfNavAreaManager.h:278
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
static double theQueryTimeBudget
Definition: vrfNavAreaManager.h:214
DtDynamicTerrainQueryHandle DynamicTerrainQuery
Definition: vrfNavAreaManager.h:268
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:80
Contains the declaration of the DtExtent class.
unsigned int DtTerrainCategoryMask
This bitmask is made using DtTerrainCategory values.
Definition: rwTerrainCategoryMask.h:27
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtNavAreasLocalExtents myNavAreasLocalExtents
Map of the the nav areas extents - converted to local coordinates. It is used within the terain chage...
Definition: vrfNavAreaManager.h:293
DtCoordTransform InvMatrix
Definition: vrfNavAreaManager.h:264
The simulation engine is controlled by a single,top-level class called the Simulation Manager...
Definition: simManager.h:137
Resource handle for a query which has been added to the system. Returned from DtTerrainImplementation...
Definition: terrainImplementation.h:180
DtExtent * Extent
Definition: vrfNavAreaManager.h:267
DtNavGenerationThreadCounter * myNavGenThreadCounter
Definition: vrfNavAreaManager.h:310
NavAreaAboutToBeRemovedList myNavAreaAboutToRemRemovedList
Definition: vrfNavAreaManager.h:314
static bool theRegenerateNavDataAtRuntime
Definition: vrfNavAreaManager.h:210
std::map< DtUUID, DtNavArea * > DtObjectNavAreaMap
Definition: vrfNavAreaManager.h:280
static double theRegenerationDelay
Definition: vrfNavAreaManager.h:213
static DtFilename theRegenerationFileDirectory
Definition: vrfNavAreaManager.h:215
class DtLocalVertexList:
Definition: localVertexList.h:20
std::queue< DtTerrainChangeNotificationInfo > DtNavAreaTerrainChangesQueue
Definition: vrfNavAreaManager.h:283
std::map< DtNavArea::NavAreaId, DtExtent > DtNavAreasLocalExtents
Definition: vrfNavAreaManager.h:285
Provides information about the terrain changes: mySpatExtent defines the terrain change type - e...
Definition: terrainImplementation.h:50
boost::signals2::connection myUnloadTerrainConnection
Definition: vrfNavAreaManager.h:325
Definition: point.h:34
DtObjectNavAreaMap myObjectNavAreas
Definition: vrfNavAreaManager.h:281
A locally simulated VRF object.
Definition: localObject.h:98
tbb::task_arena myNavAreaArena
Definition: vrfNavAreaManager.h:323
void(* DtNavAreaRemovalCallbackFcn)(DtNavArea *area, void *usr)
Callback function definition for nav area removals.
Definition: vrfNavAreaManager.h:61

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)