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

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)