VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
luaNavJob.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
8 #include "vrfLua/vrfLuaDefines.h"
9 #include "vrfLua/luaAsyncJob.h"
10 #include "vrfutil/scriptGeometry.h"
14 #include "vrfNavigation/navArea.h"
16 #include "vrfutil/rwUUID.h"
17 #include "vrfutil/movementModes.h"
19 
20 #include <luabind/luabind.hpp>
21 
22 class DtSimObject;
23 class DtCoverPointFinder;
25 
28 {
29 public:
30  typedef std::list<DtLocation3D> Points;
31 
33  DtLuaNavJob();
34 
36  virtual ~DtLuaNavJob() override;
37 
39  virtual luabind::object getObject(lua_State* L, int& index, std::string& message) override = 0;
40 
42  virtual luabind::object getDebugObject(lua_State* L) override { return luabind::newtable(L); };
43 
45  virtual void cancel(lua_State* L) override {};
46 
48  void addMessage(DtAlgorithmManager::Severity, std::string);
49 
53 
54  virtual DtString serialize() override;
55  virtual bool deserialize(const DtString&) override;
56 
57  virtual DtString objectType() const override = 0;
58 
59  //Tick the job.
60  virtual void run(const DtAlgorithmManager& mgr = DtAlgorithmManager()) = 0;
61 
62  virtual bool complete();
63 
64 protected:
65 
69  DtString navigationProfile,
70  DtLocation3D startPoint,
71  DtLocation3D accessPoint = DtLocation3D(DtVector::zero()),
72  Points boundingArea = Points());
73 
74  //Initialize the job. This version must be called by derived start functions.
75  virtual void start();
76 
78  virtual void taskComplete() = 0;
79 
80  //Common parameters for nav jobs.
85 
86  std::string myMessage;
87  bool myStarted = false;
88 
90 };
91 
95 {
96 public:
97  static std::shared_ptr<DtLuaNavRandomPointJob> Make(
99  DtString navigationProfile,
100  DtLocation3D startPoint,
101  double minDistanceFromStart,
102  double maxDistanceFromStart,
103  DtLocation3D accessPoint = DtLocation3D(DtVector::zero()),
104  Points boundingArea = Points(),
105  int numberOfPoints = 1,
106  double minDistanceBetweenPoints = 0.0,
107  DtString placementRestriction = DtMovementModeFree,
108  bool isStrict = true,
109  bool tightlyPack = false,
110  bool needLos = false,
111  bool groundClamp = false,
112  Points leftOfLine = Points(),
113  const DtSimObject* parentObject = 0);
114 
117 
119  virtual ~DtLuaNavRandomPointJob() override;
120 
122  virtual luabind::object getObject(lua_State* L, int& index, std::string& message) override;
123 
126  virtual luabind::object getDebugObject(lua_State* L) override;
127 
129  virtual void cancel(lua_State* L) override;
130 
134 
135  static DtAsciiSerializable* creator();
136 
137  //Returns LuaNavRandomPointJob
138  virtual DtString objectType() const override { return DtLuaNavRandomPointJobType; };
139 
140  //Initialize the job.
141  virtual void start() override;
142 
143  //Tick the job.
144  virtual void run(const DtAlgorithmManager& mgr = DtAlgorithmManager()) override;
145 
148  virtual bool beginPointGeneration();
149 
150  //Returns true when the job is done.
151  virtual bool complete() override;
152 
154  virtual void taskComplete() override;
155 
156 protected:
157 
161  DtString navigationProfile,
162  DtLocation3D startPoint,
163  double minDistanceFromStart,
164  double maxDistanceFromStart,
165  DtLocation3D accessPoint = DtLocation3D(DtVector::zero()),
166  Points boundingArea = Points(),
167  int numberOfPoints = 1,
168  double minDistanceBetweenPoints = 0.0,
169  DtString placementRestriction = DtMovementModeFree,
170  bool isStrict = true,
171  bool tightlyPack = false,
172  bool needLos = false,
173  bool groundClamp = false,
174  Points leftOfLine = Points(),
175  const DtSimObject* parentObject = 0);
176 
184  bool myNeedLos;
190  bool myRanOnce;
197 };
198 
201 {
202 public:
203  static std::shared_ptr<DtLuaNavPointOfInterestJob> Make(
205  DtString navigationProfile,
206  DtLocation3D startPoint,
207  DtUUID hostUuid,
208  int navTag = -1);
209 
212 
214  virtual ~DtLuaNavPointOfInterestJob() override;
215 
217  virtual luabind::object getObject(lua_State* L, int& index, std::string& message) override;
218 
222 
223  static DtAsciiSerializable* creator();
224 
225  //Returns LuaNavRandomPointJob
226  virtual DtString objectType() const override { return DtLuaNavRandomPointJobType; };
227 
228  //Initialize the job.
229  virtual void start() override;
230 
231  //Tick the job.
232  virtual void run(const DtAlgorithmManager& mgr = DtAlgorithmManager()) override;
233 
235  virtual void taskComplete() override;
236 
237 protected:
238 
242  DtString navigationProfile,
243  DtLocation3D startPoint,
244  int navTag = -1);
245 
246  int myNavTag;
249 };
250 
253 {
254 public:
255  static std::shared_ptr<DtLuaNavCoverPointJob> Make(
257  DtString navigationProfile,
258  DtLocation3D startPoint,
259  DtLocation3D coverFromPoint,
260  double threatRadius,
261  double distanceFromThreat,
262  double range,
263  unsigned numberOfPoints,
264  unsigned int queryQueuePriority);
265 
268 
270  virtual ~DtLuaNavCoverPointJob() override;
271 
273  virtual luabind::object getObject(lua_State* L, int& index, std::string& message) override;
274 
278 
279  static DtAsciiSerializable* creator();
280 
281  //Returns LuaNavCoverPointJob
282  virtual DtString objectType() const override { return DtLuaNavCoverPointJobType; };
283 
284  //Initialize the job.
285  virtual void start() override;
286 
287  //Tick the job.
288  virtual void run(const DtAlgorithmManager& mgr = DtAlgorithmManager()) override;
289 
291  virtual void taskComplete() override;
292 
293 protected:
294 
298  DtString navigationProfile,
299  DtLocation3D startPoint,
300  DtLocation3D threatPoint,
301  double threatRadius,
302  double distanceFromThreat,
303  double range,
304  unsigned numberOfPoints,
305  unsigned int queryQueuePriority);
306 
309  double myRange;
311  std::set<DtCoverPoint> myResultPoints;
315 
316  std::shared_ptr<DtCoverPointFinder> myPendingCoverPointFinder;
317 };
318 
320 {
321  bool useAbstractGraphs = true;
322  bool useChannels = false;
323  double channelRadius = 4.0;
325  double avoidanceRadius = 0.0;
329 };
330 
333 {
334 public:
335  static std::shared_ptr<DtLuaNavFindPathJob> Make(DtSimulationServices* mgr,
336  DtLocation3D startPoint,
337  DtLocation3D endPoint,
338  DtLuaNavFindPathParameters& parameters);
339 
342 
344  virtual ~DtLuaNavFindPathJob() override;
345 
347  virtual luabind::object getObject(lua_State* L, int& index, std::string& message) override;
348 
350  virtual luabind::object getDebugObject(lua_State* L) override;
351 
355 
356  static DtAsciiSerializable* creator();
357 
358  //Returns LuaNavCoverPointJob
359  virtual DtString objectType() const override { return DtLuaNavFindPathJobType; };
360 
361  //Initialize the job.
362  virtual void start() override;
363 
364  //Tick the job.
365  virtual void run(const DtAlgorithmManager& mgr = DtAlgorithmManager()) override;
366 
368  virtual void taskComplete() override;
369 
370 protected:
371 
374  DtLocation3D startPoint,
375  DtLocation3D endPoint,
376  DtLuaNavFindPathParameters& parameters);
377 
387  double myPathCost;
389 
391 };
392 
395 {
396 public:
397  static std::shared_ptr<DtLuaNavPlaceFormationJob> Make(
399  DtString navigationProfile,
400  std::vector<DtLocation3D> formationPoints,
401  double width);
402 
405 
407  virtual ~DtLuaNavPlaceFormationJob() override;
408 
410  virtual luabind::object getObject(lua_State* L, int& index, std::string& message) override;
411 
415 
416  static DtAsciiSerializable* creator();
417 
418  //Returns LuaNavRandomPointJob
419  virtual DtString objectType() const override { return DtLuaNavPlaceFormationJobType; };
420 
421  //Initialize the job.
422  virtual void start() override;
423 
424  //Tick the job.
425  virtual void run(const DtAlgorithmManager& mgr = DtAlgorithmManager()) override;
426 
428  virtual void taskComplete() override;
429 
430 protected:
431 
435  DtString navigationProfile,
436  std::vector<DtLocation3D> formationPoints,
437  double width);
438 
439  std::vector<DtLocation3D> myStartPoints;
440  std::vector<DtLocation3D> myResultPoints;
441  double myWidth;
443 };
444 
446 {
447 public:
450  virtual void tick();
451  virtual void addJob(std::shared_ptr<DtLuaNavJob> job);
452 protected:
453  std::list<std::shared_ptr<DtLuaNavJob> > myJobs;
454 };
double channelRadius
Definition: luaNavJob.h:323
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myGenerated
Definition: luaNavJob.h:388
std::shared_ptr< DtCoverPointFinder > myPendingCoverPointFinder
Definition: luaNavJob.h:316
virtual luabind::object getObject(lua_State *L, int &index, std::string &message) override=0
Retrieve value.
const DtString DtLuaNavCoverPointJobType
Definition: asciiSerializable.h:24
const char DtMovementModeFree[]
Definition: movementModes.h:11
Points myDebugPoints
Definition: luaNavJob.h:390
int myNavTag
Definition: luaNavJob.h:246
double avoidanceRadius
Definition: luaNavJob.h:325
Severity
Definition: algorithmManager.h:29
const DtString DtLuaNavFindPathJobType
Definition: asciiSerializable.h:25
virtual DtString objectType() const override
Should return the string name of this object. The object name should not be part of the serialization...
Definition: luaNavJob.h:282
Lua object class which represents a feature navigation task.
Definition: luaNavJob.h:200
double myMinDistanceBetweenPoints
Definition: luaNavJob.h:180
bool myRanOnce
Definition: luaNavJob.h:190
DtLocation3D avoidLocation
Definition: luaNavJob.h:324
DtLocation3D myThreatPoint
Definition: luaNavJob.h:310
std::list< DtLocation3D > Points
Definition: luaNavJob.h:30
Lua object class which finds a path to the specified location.
Definition: luaNavJob.h:332
This is the DtVrfObjectNavInterface subclass for objects which are actively querying the navigation s...
Definition: activeBotNavInterface.h:27
virtual void run(const DtAlgorithmManager &mgr=DtAlgorithmManager())=0
unsigned myQueryQueuePriority
Definition: luaNavJob.h:313
Lua object class which represents a feature navigation task.
Definition: luaNavJob.h:27
bool myIsStrict
Definition: luaNavJob.h:182
Points myPathPoints
Definition: luaNavJob.h:379
Definition: asciiSerializable.h:40
Interface for getting asynchronously computed data into Lua.
Definition: luaAsyncJob.h:27
virtual bool deserialize(const DtString &)=0
This function should take the string that was serialized via serialize() and fill this object with th...
Definition: luaNavJob.h:319
unsigned myNumberOfPoints
Definition: luaNavJob.h:312
int myNumberOfPoints
Definition: luaNavJob.h:177
virtual void cancel(lua_State *L) override
Cancels the job. By default this is a no-op, we let the job finish on its own.
Definition: luaNavJob.h:45
DtNavPathEvalFunction evalFcn
Definition: luaNavJob.h:328
Contains the DtUUID class declaration.
virtual void taskComplete()=0
Called by task object whenever it is done.
virtual DtString serialize()=0
The following characters are reserved and cannot be used in serialization: &#39;|&#39;, &#39;:&#39;.
double myAvoidanceRadius
Definition: luaNavJob.h:384
virtual void start()
virtual DtString objectType() const override
Should return the string name of this object. The object name should not be part of the serialization...
Definition: luaNavJob.h:226
double myThreatRadius
Definition: luaNavJob.h:307
virtual DtString objectType() const override
Should return the string name of this object. The object name should not be part of the serialization...
Definition: luaNavJob.h:138
DtLocation3D myStartPoint
Definition: luaNavJob.h:82
std::list< DtLocation3D > Points
Definition: luaTerrainReasoningJob.h:290
virtual luabind::object getDebugObject(lua_State *L) override
Retrieve debug data, if available. Default behavior is an empty table.
Definition: luaNavJob.h:42
Points myBoundingArea
Definition: luaNavJob.h:84
std::set< DtCoverPoint > myResultPoints
Definition: luaNavJob.h:311
DtLocation3D myEndPoint
Definition: luaNavJob.h:378
const DtSimObject * myParentObject
Definition: luaNavJob.h:189
Definition: asyncJobServer.h:37
bool myGenerated
Definition: luaNavJob.h:191
DtLocation3D myAvoidLocation
Definition: luaNavJob.h:383
double myChannelRadius
Definition: luaNavJob.h:382
Lua object class for finding random points within a nav area.
Definition: luaNavJob.h:94
double myMinDistanceFromStart
Definition: luaNavJob.h:178
bool useAbstractGraphs
Definition: luaNavJob.h:321
bool myNoNavArea
Definition: luaNavJob.h:193
bool myGenerated
Definition: luaNavJob.h:248
bool myGenerated
Definition: luaNavJob.h:314
bool myUseAbstractGraphs
Definition: luaNavJob.h:380
DtLocation3D myResultPoint
Definition: luaNavJob.h:247
DtLocalVertexList myBoundary
Definition: luaNavJob.h:195
#define DT_DLL_vrfLua
This file is used to determine how to build.
Definition: vrfLuaDefines.h:25
Lua object class which finds a cover point from the specified location.
Definition: luaNavJob.h:252
const DtString DtLuaNavRandomPointJobType
Definition: asciiSerializable.h:23
double myMaxDistanceFromStart
Definition: luaNavJob.h:179
std::vector< DtLocation3D > myResultPoints
Definition: luaNavJob.h:440
bool myGenerated
Definition: luaNavJob.h:442
std::string myMessage
Definition: luaNavJob.h:86
DtLocation3D myAccessPoint
Definition: luaNavJob.h:83
virtual DtString objectType() const override
Should return the string name of this object. The object name should not be part of the serialization...
Definition: luaNavJob.h:359
virtual luabind::object getObject(lua_State *L, int &index, std::string &message)=0
Retrieve current value.
DtLocalVertexList myLeftOfLineVertices
Definition: luaNavJob.h:196
double myRange
Definition: luaNavJob.h:309
Lua object class which represents a formation placement task.
Definition: luaNavJob.h:394
Points myResultPoints
Definition: luaNavJob.h:187
virtual DtString objectType() const =0
Should return the string name of this object. The object name should not be part of the serialization...
bool myTightlyPack
Definition: luaNavJob.h:183
std::shared_ptr< DtNavAreaQuery > Ptr
Definition: navArea.h:59
double myWidth
Definition: luaNavJob.h:441
virtual DtString objectType() const override
Should return the string name of this object. The object name should not be part of the serialization...
Definition: luaNavJob.h:419
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
double myDistanceFromThreat
Definition: luaNavJob.h:308
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
double myPathCost
Definition: luaNavJob.h:387
bool myNeedLos
Definition: luaNavJob.h:184
virtual void tick()
bool myGroundClamp
Definition: luaNavJob.h:185
DtActiveBotNavInterface * activeNavIf
Definition: luaNavJob.h:327
Points myLeftOfLine
Definition: luaNavJob.h:186
Definition: navInterfaceManager.h:20
DtString myNavigationProfile
Definition: luaNavJob.h:81
virtual bool complete()
std::vector< DtLocation3D > myStartPoints
Definition: luaNavJob.h:439
class DtLocalVertexList:
Definition: localVertexList.h:20
DtNavPathEvalFunction myPathEval
Definition: luaNavJob.h:386
DtNavAreaQuery::Ptr myQuery
Definition: luaNavJob.h:89
Definition: luaNavJob.h:445
Points myDebugPoints
Definition: luaNavJob.h:188
bool myDataAvailable
Definition: luaNavJob.h:192
Used to find the best cover point(s) to take cover from attacker at a specified location. If myBestCoverPoint is not DtVector::zero(), it will be the cover point to use.
Definition: coverPointFinder.h:36
DtVector myLocalAccessPoint
Definition: luaNavJob.h:194
DtActiveBotNavInterface * myNavIf
Definition: luaNavJob.h:385
bool useChannels
Definition: luaNavJob.h:322
General interface which can be passed into an algorithm to control its behavior.
Definition: algorithmManager.h:24
const DtString DtLuaNavPlaceFormationJobType
Definition: asciiSerializable.h:28
virtual void addJob(std::shared_ptr< DtLuaNavJob > job)
bool myUseChannels
Definition: luaNavJob.h:381
std::list< std::shared_ptr< DtLuaNavJob > > myJobs
Definition: luaNavJob.h:453
DtString navigationProfile
Definition: luaNavJob.h:326
A location3D is a point in space, i.e. a geocentric coordinate.
Definition: scriptGeometry.h:22
DtString myPlacementRestriction
Definition: luaNavJob.h:181

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)