VR-Forces 4.6.1 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 "vrfutil/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 
30 {
36 };
37 
39 {
44 };
45 
46 typedef std::set<DtNavSectorName> DtNavSectorNames;
47 
48 //Base class for asynchronous Nav Area queries.
49 //In this context asynchronous means non-blocking, but performed
50 //in a single-thread. These queries are time-sliced by
51 //gameware's infrastructure.
52 //Will be ticked by the navArea's update function.
53 
55 {
56 public:
57  typedef boost::shared_ptr<DtNavAreaQuery> Ptr;
58 
60  virtual ~DtNavAreaQuery() { };
61 
62  virtual bool complete() = 0;
63  virtual bool tick() = 0;
64  virtual bool success() = 0;
65 
67  virtual bool navDataChanged() = 0;
68  virtual bool outOfWorkingMemory() = 0;
69  virtual bool hadComputationError() = 0;
70 
71  virtual std::vector<DtVector> results() = 0;
72  virtual std::vector<DtVector> debugPoints() { return std::vector<DtVector>(); };
73  virtual void* internalQuery() = 0;
74 };
75 
76 //Query that can be used when there is no valid navData.
78 {
79 public:
81  virtual ~DtNavAreaNullQuery() { };
82 
83  virtual bool complete() { return true; };
84  virtual bool tick() { return true; };
85  virtual bool success() { return true; };
86  virtual void cancel() {};
87  virtual bool navDataChanged() { return false; };
88  virtual bool outOfWorkingMemory() { return false; };
89  virtual bool hadComputationError() { return false; };
90  virtual std::vector<DtVector> results() { return std::vector<DtVector>(); };
91  virtual void *internalQuery(void) { return 0; };
92 };
93 
96 {
97  DtNavAreaConfig() : workingMemorySize(16),
98  regenerateAtRuntime(true), maxRegenerationThreads(2), regenerationDelay(2.5) {};
99 
102  int workingMemorySize;
103 
106 
109 
113 
114 };
115 
119 {
120 public:
122 
123 protected:
126 };
127 
128 
130 typedef boost::weak_ptr<DtNavRegenRequestIdData> DtNavRegenRequestId;
131 
137 {
138 public:
140  {
142  int port;
143  std::vector<DtRwString> profiles;
145  };
146 
147  typedef DtNavArea* (*DtNavAreaCreatorFcn)();
148  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestEvaluatorFcn)(const DtVector& localPoint, void* userData);
149  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestNavTagEvaluatorFcn)(const DtVector& localPoint, const DtNavTag& tag, void* userData);
150  typedef void (*DtSearchAreaPointCostModifierEvaluatorFcn)(const DtVector& localPoint, float* currentCost, void* userData);
151  typedef DtOnPathToGraphVertexComputedResult(*DtPathCalculatedEvaluatorFcn)(const DtVector& localPoint, double pathCost, void* userData);
152  typedef void(*DtSectorRegenerationCb)(void* userData);
153 
154  static DtNavArea* create();
155  static void setNavAreaCreatorFcn(DtNavAreaCreatorFcn fcn);
156 
157  static bool navAreaDebuggingEnabled();
158  static void setNavAreaDebuggingEnabled(bool enable);
159 
160  virtual ~DtNavArea() {};
161  virtual bool initialize(Coordinate_System* coordSys, DtTerrainInterface* terrainIf, DtNavAreaConfig config,
162  std::vector<DtString> profiles = std::vector<DtString>()) = 0;
163  virtual void update(float deltaTimeInSeconds) = 0;
165  virtual bool loadNavData(const DtString& path, const DtVariableBindingsList& variableBindings =
166  DtReaderWriter::nullVariableReference(), bool objectNavData = false) = 0;
167  virtual bool inNavArea(const DtVector& localPos) = 0;
168  virtual bool validPosition(const DtString& profile, const DtVector& localPos, DtNavTag* navTag = 0) = 0;
169 
170  //Returns true if this area is valid for the given navigation profile.
171  virtual bool validForProfile(const DtString& profile) const = 0;
172 
173  virtual DtNavDataDebugInfo* debugInfo() = 0;
174 
175  virtual void setExtent(DtExtent* e) = 0;
176  virtual DtExtent localExtent() = 0;
177 
179  virtual void cancelQuery(DtNavAreaQuery::Ptr) = 0;
180 
183  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterest(const DtString& profile, const DtVector& startLocalPos,
184  int tag = DtNavDataTagAny, double propagationRadius = 200.,
185  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
186 
190  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterestUsingNavTag(const DtString& profile, const DtVector& startLocalPos,
191  int tag = DtNavDataTagAny, double propagationRadius = 200.,
192  DtPointOfInterestNavTagEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
193 
196  virtual DtNavAreaQuery::Ptr findBestExitPoint(const DtString& profile, DtNavBot* searcher,
197  const DtVector& startLocalPos, const DtVector& destination,
198  int tag = DtNavDataTagAny, double propagationRadius = 200.,
199  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
200 
202  virtual bool findInsidePositionFromOutsidePosition(const DtString& profile,
203  double searchRadius, double searchHeight, const DtVector& fromFromHere,
204  DtVector& result, int& halfEdgeType) = 0;
205 
207  virtual DtNavAreaQuery::Ptr findBestPathTo(const DtString& profile, const DtVector& start,
208  const std::vector<DtVector>& localDestinationPositions, DtNavBot* searcher, int tag = -1,
209  DtSearchAreaPointCostModifierEvaluatorFcn = 0, DtPointOfInterestEvaluatorFcn = 0, DtPathCalculatedEvaluatorFcn = 0,
210  void* usrData = 0, bool startMovingWhenFound = false) = 0;
211 
213  virtual DtNavAreaQuery::Ptr findPathToLocation(const DtString& profile, const DtVector& start,
214  const DtVector& destination, bool useAbstractGraphs = true,
215  const DtVector& locationToAvoid = DtVector(), double avoidanceRadius = 0) = 0;
216 
219  virtual bool findFarthestPositionAlongHeading(const DtString& profile, const DtVector& start,
220  double heading, double maxDistance, DtVector& result, bool& reachedMaxDist) = 0;
221 
222  //User callback to check randomly generated points. The callback function
223  //should return true if the point is acceptable.
224  typedef bool (*DtLocalPointUserEvalCallback)(const DtVector& localVector, DtNavAreaQuery* query, void* userData);
225  static bool emptyCallback(const DtVector&, DtNavAreaQuery*, void*);
226 
227  //Generate some number of random points.
228  //If localAccessibilityPoint is set, all points must be navigable
229  //from the access point.
230  //If boundingArea is set, all points must be inside the area,
231  //ignoring elevation. Note that this will not cause points to be
232  //generated outside the navArea.
233  //If boundingArea is not set, and radius is set, points will be generated
234  //using radius as a maximum distance from accessibilityPoint.
235  //If minDistanceBetweenPoints is set, generated points will be tested
236  //against the rest of the set of random points to make sure none are within
237  //the given distance of each other.
238  //If placementRestriction is set to one of the MovementMode strings (e.g.
239  //DtMovementModePreferRoads), points will be chosen that match that criteria.
240  //If isStrict is true, only points matching the placementRestriction will be
241  //generated, even if we can't create enough to match the desired number.
242  //If tightlyPack is true, points closer to access point or bounding area center
243  //will be favored.
244  //If needLos is true, will try to choose points that should have LOS to the
245  //specified access point.
246  //If groundClamp is true, points will be ground clamped to the terrain at a point
247  //below the original point plus the height of the entity specified in nav generation.
248  //If leftOfLine, the points specified will be considered a line, and only points
249  //to the left of that line will be generated.
250  //If callbackFcn is set, this user function is called on each generated
251  //point, to test if each point is acceptable.
252  virtual DtNavAreaQuery::Ptr generateRandomPoints(const DtString& profile,
253  const DtVector& localAccessibilityPoint = DtVector::zero(),
254  double minRadius = -1,
255  double maxRadius = -1,
256  const DtLocalVertexList& boundingArea = DtLocalVertexList(),
257  unsigned numberOfPoints = 1,
258  double minDistanceBetweenPoints = 0.0,
259  const DtString& placementRestriction = DtString::nullString(),
260  bool isStrict = true,
261  bool tightlyPack = false,
262  bool needLos = false,
263  bool groundClamp = false,
264  const DtLocalVertexList& leftOfLine = DtLocalVertexList(),
265  DtLocalPointUserEvalCallback callbackFcn = emptyCallback,
266  void* userData = 0) = 0;
267 
269  virtual bool tagVolumesToBeIntegrated() const = 0;
270 
271  DtVrfObject* attachedObject() { return myAttachedObject; }
272  void setAttachedObject(DtVrfObject* object) { myAttachedObject = object; }
273 
278  virtual std::vector<DtVector> searchInArea(const DtString& profile,
279  const DtVector& startLocalPos, double radius, double postSpacing, DtNavBot* searcher,
280  DtPointOfInterestEvaluatorFcn evalFcn = 0, void* evalFcnUserData = 0, int tag = -1) = 0;
281 
283  virtual unsigned newNavTagVolumeId() = 0;
284 
286  virtual void associateNavTagVolumeIdWithObject(unsigned tagVolumeId, const DtUUID& objectUUID) = 0;
287 
290  virtual DtUUID uuidFromNavTagVolumeId(unsigned navTagId) = 0;
291 
294  virtual unsigned navTagVolumeIdFromUuid(const DtUUID& objectUUID) = 0;
295 
297  virtual const DtNavSectorNames& sectorsQueuedForRegeneration() const = 0;
298 
300  virtual const DtNavSectorNames& sectorsBeingRegenerated() const = 0;
301 
304  virtual void addSectorRegenerationCallback(DtSectorRegenerationCb cb, void* usr) = 0;
305  virtual void removeSectorRegenerationCallback(DtSectorRegenerationCb cb, void* usr) = 0;
306 
310  virtual DtNavRegenRequestId requestNavDataGeneration(const DtVector& location, double radius,
311  const std::set<DtString>& profiles = std::set<DtString>()) = 0;
312 
314  virtual void requestNavDataReversion(DtNavRegenRequestId id) = 0;
315 
316 protected:
317  static DtNavAreaCreatorFcn theNavAreaCreatorFcn;
318 
320 
324 };

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)