VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
navArea.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 
10 #pragma once
11 
13 #include <string>
16 #include <matrix/vlVector.h>
18 #include "boost/shared_ptr.hpp"
19 #include "boost/weak_ptr.hpp"
20 #include <readerWriter/rwString.h>
21 #include "vrfutil/rwUUID.h"
22 
23 class Coordinate_System;
24 class DtExtent;
25 class DtVrfObject;
26 class DtTerrainInterface;
27 class DtNavBot;
28 class DtInputNavTag;
29 
31 {
37 };
38 
40 {
45 };
46 
47 typedef std::set<DtNavSectorName> DtNavSectorNames;
48 
49 //Base class for asynchronous Nav Area queries.
50 //In this context asynchronous means non-blocking, but performed
51 //in a single-thread. These queries are time-sliced by
52 //gameware's infrastructure.
53 //Will be ticked by the navArea's update function.
54 
56 {
57 public:
58  typedef boost::shared_ptr<DtNavAreaQuery> Ptr;
59 
61  virtual ~DtNavAreaQuery() { };
62 
63  virtual bool complete() = 0;
64  virtual bool tick() = 0;
65  virtual bool success() = 0;
66 
68  virtual bool navDataChanged() = 0;
69  virtual bool outOfWorkingMemory() = 0;
70  virtual bool hadComputationError() = 0;
71 
72  virtual std::vector<DtVector> results() = 0;
73  virtual std::vector<DtVector> debugPoints() { return std::vector<DtVector>(); };
74  virtual void* internalQuery() = 0;
75 };
76 
77 //Query that can be used when there is no valid navData.
79 {
80 public:
82  virtual ~DtNavAreaNullQuery() { };
83 
84  virtual bool complete() { return true; };
85  virtual bool tick() { return true; };
86  virtual bool success() { return true; };
87  virtual void cancel() {};
88  virtual bool navDataChanged() { return false; };
89  virtual bool outOfWorkingMemory() { return false; };
90  virtual bool hadComputationError() { return false; };
91  virtual std::vector<DtVector> results() { return std::vector<DtVector>(); };
92  virtual void *internalQuery(void) { return 0; };
93 };
94 
97 {
98  DtNavAreaConfig() : workingMemorySize(16), regenerateAtRuntime(true),
99  maxRegenerationThreads(2), regenerationDelay(2.5), queryTimeBudget(1) {};
100 
103  int workingMemorySize;
104 
107 
110 
113 
117 
118 };
119 
123 {
124 public:
126 
127 protected:
130 };
131 
132 
134 typedef boost::weak_ptr<DtNavRegenRequestIdData> DtNavRegenRequestId;
135 
141 {
142 public:
144  {
146  int port;
147  std::vector<DtRwString> profiles;
149  };
150 
151  typedef DtNavArea* (*DtNavAreaCreatorFcn)();
152  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestEvaluatorFcn)(const DtVector& localPoint, void* userData);
153  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestNavTagEvaluatorFcn)(const DtVector& localPoint, const DtNavTag& tag, void* userData);
154  typedef void (*DtSearchAreaPointCostModifierEvaluatorFcn)(const DtVector& localPoint, float* currentCost, void* userData);
155  typedef DtOnPathToGraphVertexComputedResult(*DtPathCalculatedEvaluatorFcn)(const DtVector& localPoint, double pathCost, void* userData);
156  typedef void(*DtSectorRegenerationCb)(void* userData);
157 
158  static DtNavArea* create();
159  static void setNavAreaCreatorFcn(DtNavAreaCreatorFcn fcn);
160 
161  static bool navAreaDebuggingEnabled();
162  static void setNavAreaDebuggingEnabled(bool enable);
163 
164  virtual ~DtNavArea() {};
165  virtual bool initialize(Coordinate_System* coordSys, DtTerrainInterface* terrainIf, DtNavAreaConfig config,
166  std::vector<DtString> profiles = std::vector<DtString>()) = 0;
167  virtual void update(float deltaTimeInSeconds) = 0;
169  virtual bool loadNavData(const DtString& path, const DtVariableBindingsList& variableBindings =
170  DtReaderWriter::nullVariableReference(), bool objectNavData = false) = 0;
171  virtual bool inNavArea(const DtVector& localPos) = 0;
172  virtual bool validPosition(const DtString& profile, const DtVector& localPos, DtNavTag* navTag = 0) = 0;
173 
174  //Returns true if this area is valid for the given navigation profile.
175  virtual bool validForProfile(const DtString& profile) const = 0;
176 
177  virtual DtNavDataDebugInfo* debugInfo() = 0;
178 
179  virtual void setExtent(DtExtent* e) = 0;
180  virtual DtExtent localExtent() = 0;
181 
183  virtual void cancelQuery(DtNavAreaQuery::Ptr) = 0;
184 
187  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterest(const DtString& profile, const DtVector& startLocalPos,
188  int tag = DtNavDataTagAny, double propagationRadius = 200.,
189  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
190 
194  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterestUsingNavTag(const DtString& profile, const DtVector& startLocalPos,
195  int tag = DtNavDataTagAny, double propagationRadius = 200.,
196  DtPointOfInterestNavTagEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
197 
200  virtual DtNavAreaQuery::Ptr findBestExitPoint(const DtString& profile, DtNavBot* searcher,
201  const DtVector& startLocalPos, const DtVector& destination,
202  int tag = DtNavDataTagAny, double propagationRadius = 200.,
203  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
204 
206  virtual bool findInsidePositionFromOutsidePosition(const DtString& profile,
207  double searchRadius, double searchHeight, const DtVector& fromFromHere,
208  DtVector& result, int& halfEdgeType) = 0;
209 
211  virtual DtNavAreaQuery::Ptr findBestPathTo(const DtString& profile, const DtVector& start,
212  const std::vector<DtVector>& localDestinationPositions, DtNavBot* searcher, int tag = -1,
213  DtSearchAreaPointCostModifierEvaluatorFcn = 0, DtPointOfInterestEvaluatorFcn = 0, DtPathCalculatedEvaluatorFcn = 0,
214  void* usrData = 0, bool startMovingWhenFound = false) = 0;
215 
217  virtual DtNavAreaQuery::Ptr findPathToLocation(const DtString& profile, const DtVector& start,
218  const DtVector& destination, bool useAbstractGraphs = true,
219  const DtVector& locationToAvoid = DtVector(), double avoidanceRadius = 0) = 0;
220 
223  virtual bool findFarthestPositionAlongHeading(const DtString& profile, const DtVector& start,
224  double heading, double maxDistance, DtVector& result, bool& reachedMaxDist) = 0;
225 
226  //User callback to check randomly generated points. The callback function
227  //should return true if the point is acceptable.
228  typedef bool (*DtLocalPointUserEvalCallback)(const DtVector& localVector, DtNavAreaQuery* query, void* userData);
229  static bool emptyCallback(const DtVector&, DtNavAreaQuery*, void*);
230 
231  //Generate some number of random points.
232  //If localAccessibilityPoint is set, all points must be navigable
233  //from the access point.
234  //If boundingArea is set, all points must be inside the area,
235  //ignoring elevation. Note that this will not cause points to be
236  //generated outside the navArea.
237  //If boundingArea is not set, and radius is set, points will be generated
238  //using radius as a maximum distance from accessibilityPoint.
239  //If minDistanceBetweenPoints is set, generated points will be tested
240  //against the rest of the set of random points to make sure none are within
241  //the given distance of each other.
242  //If placementRestriction is set to one of the MovementMode strings (e.g.
243  //DtMovementModePreferRoads), points will be chosen that match that criteria.
244  //If isStrict is true, only points matching the placementRestriction will be
245  //generated, even if we can't create enough to match the desired number.
246  //If tightlyPack is true, points closer to access point or bounding area center
247  //will be favored.
248  //If needLos is true, will try to choose points that should have LOS to the
249  //specified access point.
250  //If groundClamp is true, points will be ground clamped to the terrain at a point
251  //below the original point plus the height of the entity specified in nav generation.
252  //If leftOfLine, the points specified will be considered a line, and only points
253  //to the left of that line will be generated.
254  //If callbackFcn is set, this user function is called on each generated
255  //point, to test if each point is acceptable.
256  virtual DtNavAreaQuery::Ptr generateRandomPoints(const DtString& profile,
257  const DtVector& localAccessibilityPoint = DtVector::zero(),
258  double minRadius = -1,
259  double maxRadius = -1,
260  const DtLocalVertexList& boundingArea = DtLocalVertexList(),
261  unsigned numberOfPoints = 1,
262  double minDistanceBetweenPoints = 0.0,
263  const DtString& placementRestriction = DtString::nullString(),
264  bool isStrict = true,
265  bool tightlyPack = false,
266  bool needLos = false,
267  bool groundClamp = false,
268  const DtLocalVertexList& leftOfLine = DtLocalVertexList(),
269  DtLocalPointUserEvalCallback callbackFcn = emptyCallback,
270  void* userData = 0) = 0;
271 
273  virtual bool tagVolumesToBeIntegrated() const = 0;
274 
275  DtVrfObject* attachedObject() { return myAttachedObject; }
276  void setAttachedObject(DtVrfObject* object) { myAttachedObject = object; }
277 
282  virtual std::vector<DtVector> searchInArea(const DtString& profile,
283  const DtVector& startLocalPos, double radius, double postSpacing, DtNavBot* searcher,
284  DtPointOfInterestEvaluatorFcn evalFcn = 0, void* evalFcnUserData = 0, int tag = -1) = 0;
285 
287  virtual unsigned newNavTagId() = 0;
288 
290  virtual void associateNavTagIdWithObject(unsigned tagVolumeId, const DtUUID& objectUUID) = 0;
291 
293  virtual void disassociateNavTagId(unsigned navTagId) = 0;
294 
297  virtual DtUUID uuidFromNavTagId(unsigned navTagId) = 0;
298 
301  virtual unsigned navTagVolumeIdFromUuid(const DtUUID& objectUUID) = 0;
302 
304  virtual const DtNavSectorNames& sectorsQueuedForRegeneration() const = 0;
305 
307  virtual const DtNavSectorNames& sectorsBeingRegenerated() const = 0;
308 
311  virtual void addSectorRegenerationCallback(DtSectorRegenerationCb cb, void* usr) = 0;
312  virtual void removeSectorRegenerationCallback(DtSectorRegenerationCb cb, void* usr) = 0;
313 
317  virtual DtNavRegenRequestId requestNavDataGeneration(const DtVector& location, double radius,
318  const std::set<DtString>& profiles = std::set<DtString>()) = 0;
319 
321  virtual void requestNavDataReversion(DtNavRegenRequestId id) = 0;
322 
326  virtual unsigned addNavEdge(const DtString& profile, std::vector<DtVector>& LocalPoints,
327  const DtInputNavTag& navTag, const DtUUID& associatedObject = DtUUID::nullUUID()) = 0;
328 
330  virtual void removeNavEdge(unsigned edgeId) = 0;
331 
332 protected:
333  static DtNavAreaCreatorFcn theNavAreaCreatorFcn;
334 
336 
340 };

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)