VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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>
15 #include <matrix/vlVector.h>
17 #include "boost/shared_ptr.hpp"
18 #include "vrfutil/rwString.h"
19 #include "vrfutil/rwUUID.h"
20 
21 class Coordinate_System;
22 class DtExtent;
23 class DtVrfObject;
24 class DtTerrainInterface;
25 class DtNavBot;
26 
28 {
34 };
35 
37 {
42 };
43 
44 //Base class for asynchronous Nav Area queries.
45 //In this context asynchronous means non-blocking, but performed
46 //in a single-thread. These queries are time-sliced by
47 //gameware's infrastructure.
48 //Will be ticked by the navArea's update function.
49 
51 {
52 public:
53  typedef boost::shared_ptr<DtNavAreaQuery> Ptr;
54 
56  virtual ~DtNavAreaQuery() { };
57 
58  virtual bool complete() = 0;
59  virtual bool tick() = 0;
60  virtual bool success() = 0;
61 
63  virtual bool navDataChanged() = 0;
64  virtual bool outOfWorkingMemory() = 0;
65  virtual bool hadComputationError() = 0;
66 
67  virtual std::vector<DtVector> results() = 0;
68  virtual std::vector<DtVector> debugPoints() { return std::vector<DtVector>(); };
69  virtual void* internalQuery() = 0;
70 };
71 
72 //Query that can be used when there is no valid navData.
74 {
75 public:
77  virtual ~DtNavAreaNullQuery() { };
78 
79  virtual bool complete() { return true; };
80  virtual bool tick() { return true; };
81  virtual bool success() { return true; };
82  virtual void cancel() {};
83  virtual bool navDataChanged() { return false; };
84  virtual bool outOfWorkingMemory() { return false; };
85  virtual bool hadComputationError() { return false; };
86  virtual std::vector<DtVector> results() { return std::vector<DtVector>(); };
87  virtual void *internalQuery(void) { return 0; };
88 };
89 
92 {
93  DtNavAreaConfig() : workingMemorySize(16) {};
94 
97  int workingMemorySize;
98 
99 };
105 {
106 public:
108  {
110  int port;
111  std::vector<DtRwString> profiles;
113  };
114 
115  typedef DtNavArea* (*DtNavAreaCreatorFcn)();
116  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestEvaluatorFcn)(const DtVector& localPoint, void* userData);
117  typedef void (*DtSearchAreaPointCostModifierEvaluatorFcn)(const DtVector& localPoint, float* currentCost, void* userData);
118  typedef DtOnPathToGraphVertexComputedResult (*DtPathCalculatedEvaluatorFcn)(const DtVector& localPoint, double pathCost, void* userData);
119 
120  static DtNavArea* create();
121  static void setNavAreaCreatorFcn(DtNavAreaCreatorFcn fcn);
122 
123  static bool navAreaDebuggingEnabled();
124  static void setNavAreaDebuggingEnabled(bool enable);
125 
126  virtual ~DtNavArea() {};
127  virtual bool initialize(Coordinate_System* coordSys, DtTerrainInterface* terrainIf, DtNavAreaConfig config,
128  std::vector<DtString> profiles = std::vector<DtString>()) = 0;
129  virtual void update(float deltaTimeInSeconds) = 0;
131  virtual bool loadNavData(const DtString& path, const DtVariableBindingsList& variableBindings =
132  DtReaderWriter::nullVariableReference(), bool objectNavData = false) = 0;
133  virtual bool inNavArea(const DtVector& localPos) = 0;
134  virtual bool validPosition(const DtString& profile, const DtVector& localPos, DtNavTag* navTag = 0) = 0;
135 
136  //Returns true if this area is valid for the given navigation profile.
137  virtual bool validForProfile(const DtString& profile) const = 0;
138 
139  virtual DtNavDataDebugInfo* debugInfo() = 0;
140 
141  virtual void setExtent(DtExtent* e) = 0;
142  virtual DtExtent localExtent() = 0;
143 
145  virtual void cancelQuery(DtNavAreaQuery::Ptr) = 0;
146 
149  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterest(const DtString& profile, const DtVector& startLocalPos,
150  int tag = DtNavDataTagAny, double propagationRadius = 200.,
151  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
152 
155  virtual DtNavAreaQuery::Ptr findBestExitPoint(const DtString& profile, DtNavBot* searcher,
156  const DtVector& startLocalPos, const DtVector& destination,
157  int tag = DtNavDataTagAny, double propagationRadius = 200.,
158  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
159 
161  virtual bool findInsidePositionFromOutsidePosition(const DtString& profile,
162  double searchRadius, const DtVector& fromFromHere, DtVector& result, int& halfEdgeType) = 0;
163 
165  virtual DtNavAreaQuery::Ptr findBestPathTo(const DtString& profile, const DtVector& start,
166  const std::vector<DtVector>& localDestinationPositions, DtNavBot* searcher, int tag = -1,
167  DtSearchAreaPointCostModifierEvaluatorFcn = 0, DtPointOfInterestEvaluatorFcn = 0, DtPathCalculatedEvaluatorFcn = 0,
168  void* usrData = 0, bool startMovingWhenFound = false) = 0;
169 
172  virtual bool findFarthestPositionAlongHeading(const DtString& profile, const DtVector& start,
173  double heading, double maxDistance, DtVector& result, bool& reachedMaxDist) = 0;
174 
175  //User callback to check randomly generated points. The callback function
176  //should return true if the point is acceptable.
177  typedef bool (*DtLocalPointUserEvalCallback)(const DtVector& localVector, DtNavAreaQuery* query, void* userData);
178  static bool emptyCallback(const DtVector&, DtNavAreaQuery*, void*);
179 
180  //Generate some number of random points.
181  //If localAccessibilityPoint is set, all points must be navigable
182  //from the access point.
183  //If boundingArea is set, all points must be inside the area,
184  //ignoring elevation. Note that this will not cause points to be
185  //generated outside the navArea.
186  //If boundingArea is not set, and radius is set, points will be generated
187  //using radius as a maximum distance from accessibilityPoint.
188  //If minDistanceBetweenPoints is set, generated points will be tested
189  //against the rest of the set of random points to make sure none are within
190  //the given distance of each other.
191  //If placementRestriction is set to one of the MovementMode strings (e.g.
192  //DtMovementModePreferRoads), points will be chosen that match that criteria.
193  //If isStrict is true, only points matching the placementRestriction will be
194  //generated, even if we can't create enough to match the desired number.
195  //If tightlyPack is true, points closer to access point or bounding area center
196  //will be favored.
197  //If needLos is true, will try to choose points that should have LOS to the
198  //specified access point.
199  //If groundClamp is true, points will be ground clamped to the terrain at a point
200  //below the original point plus the height of the entity specified in nav generation.
201  //If leftOfLine, the points specified will be considered a line, and only points
202  //to the left of that line will be generated.
203  //If callbackFcn is set, this user function is called on each generated
204  //point, to test if each point is acceptable.
205  virtual DtNavAreaQuery::Ptr generateRandomPoints(const DtString& profile,
206  const DtVector& localAccessibilityPoint = DtVector::zero(),
207  double minRadius = -1,
208  double maxRadius = -1,
209  const DtLocalVertexList& boundingArea = DtLocalVertexList(),
210  unsigned numberOfPoints = 1,
211  double minDistanceBetweenPoints = 0.0,
212  const DtString& placementRestriction = DtString::nullString(),
213  bool isStrict = true,
214  bool tightlyPack = false,
215  bool needLos = false,
216  bool groundClamp = false,
217  const DtLocalVertexList& leftOfLine = DtLocalVertexList(),
218  DtLocalPointUserEvalCallback callbackFcn = emptyCallback,
219  void* userData = 0) = 0;
220 
222  virtual bool tagVolumesToBeIntegrated() const = 0;
223 
224  DtVrfObject* attachedObject() { return myAttachedObject; }
225  void setAttachedObject(DtVrfObject* object) { myAttachedObject = object; }
226 
231  virtual std::vector<DtVector> searchInArea(const DtString& profile,
232  const DtVector& startLocalPos, double radius, double postSpacing, DtNavBot* searcher,
233  DtPointOfInterestEvaluatorFcn evalFcn = 0, void* evalFcnUserData = 0, int tag = -1) = 0;
234 
236  virtual unsigned newNavTagVolumeId() = 0;
237 
239  virtual void associateNavTagVolumeIdWithObject(unsigned tagVolumeId, const DtUUID& objectUUID) = 0;
240 
243  virtual DtUUID uuidFromNavTagVolumeId(unsigned navTagId) = 0;
244 
247  virtual unsigned navTagVolumeIdFromUuid(const DtUUID& objectUUID) = 0;
248 
249 protected:
250  static DtNavAreaCreatorFcn theNavAreaCreatorFcn;
251 
253 
257 };

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)