gwnavruntime/pathfollower/targetonpathcomputer.h Source File

targetonpathcomputer.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 // primary contact: LAPA - secondary contact: NOBODY
8 #ifndef Navigation_TargetOnPathComputer_H
9 #define Navigation_TargetOnPathComputer_H
10 
11 
20 #include "gwnavruntime/world/bot.h"
23 
24 namespace Kaim
25 {
26 
27 enum ComputeTargetOnPathResult
28 {
29  KeepCurrentTarget = 0,
30  BetterTargetFound,
31  NoBetterTargetFound
32 };
33 
34 enum ComputeTargetOnPathSearchControl
35 {
36  ContinueSearch = 0,
37  StopSearch
38 };
39 
40 
49 // set to TargetOnPathNotReachable. No further action is done, you have to check the
52 template <class TraverseLogic>
53 class TargetOnPathComputer
54 {
55 public:
56  // ---------------------------------- Public Member Functions ----------------------------------
57 
59 
60  // Used specifically by the ShortcutTrajectory in order to skip, cf. World::SetNumberOfFramesForShortcutTrajectoryPeriodicUpdate()
61  static bool IsComputationRequiredThisFrame(Bot* bot, KyFloat32 simulationTimeInSeconds, TargetOnPath& targetOnPath);
62 
63  // Must be called before ComputeTargetOnPath
64  void SetupShortcutTrajectoryConfig(const ShortcutTrajectoryConfig& config);
65  KyResult ComputeTargetOnPath(Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl);
66  void Clear(Bot* bot);
67 
68 protected:
69 
70  enum ValidationResult
71  {
72  CandidateIsValid = 0,
73  InvalidCandidate_CanGoArrivedInWrongFloor,
74  InvalidCandidate_CanGoFailure,
75  InvalidCandidate_TooFarFromBot
76  };
77 
78  KyResult ComputeWhenNotOnMesh(Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl);
79  KyResult ComputeWhenOnMesh(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, KyFloat32 costFromBotToTOP, PathEdgeType currentEdgeType, ComputeTargetOnPathSearchControl forwardSearchControl);
80 
81  ComputeTargetOnPathResult Shortcut(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, KyFloat32 costFromBotToTOP, PathEdgeType currentEdgeType);
82  KyResult MakeSureTargetOnPathIsVisibleAndGetCostFromBotToTOP(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32& costFromBotToTOP);
83  KyResult CheckTargetOnPathIsVisibleAndGetCostFromBotToTOP(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32& costFromBotToTOP);
84  KyResult FindVisibleTargetOnPathBackwardWithCost(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32& costFromBotToTOP);
85  ComputeTargetOnPathSearchControl ShortcutOnNextSample(const Bot* bot, KyFloat32 simulationTimeInSeconds, ScopedDisplayList& displayList, TargetOnPath& candidate, TargetOnPath& bestCandidate, KyFloat32& costToBest);
86  ValidationResult ValidateCandidateAndGetCost(const Bot* bot, ScopedDisplayList& displayList, const Vec3f& candidatePosition, RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost);
87  bool TestCanGoWithCost(RayCanGoQuery<LocalCostAwareTraverseLogic<TraverseLogic> >& canGoQuery, ScopedDisplayList& displayList,
88  const Vec3f& start, const NavTrianglePtr& startTriangle, const Vec3f& dest, KyFloat32& cost);
89 
90 public: //internal
91  // This disregards backward edge type, it only check forward edge type that must be on NavMesh and bot must have a valid triangle
92  KyResult ComputeTargetOnPathOnNavMeshOnly(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl);
93 
94 private:
95  ShortcutTrajectoryConfig m_config;
96  LocalCostAwareTraverseLogicData m_localCostAwareTraverseLogicData;
97 };
98 
99 } // namespace Kaim
100 
101 
103 
104 #endif // Navigation_TargetOnPathComputer_H
This class is the world element that represent an active character in Gameware Navigation.
Definition: bot.h:150
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
This class updates Bot's target on path so that:
Definition: targetonpathcomputer.h:56
The RayCanGoQuery class tests whether or not a ray (with a width of 0) can pass along a straight line...
Definition: raycangoquery.h:24
RayCanGoMarginMode
Defines the different mode for the NavMesh border margin to be used in RayCanGo queries.
Definition: database.h:41
Definition: gamekitcrowddispersion.h:20
LocalCostAwareTraverseLogic is a wrapper around the traverse logic set by the user.
Definition: localcostawaretraverselogic.h:37
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
PathEdgeType
Defines the different kind of PathEdge within a Path.
Definition: path.h:26
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
Set of parameters used by the ShortcutTrajectory and TargetOnPathComputer classes to update Bot targe...
Definition: shortcuttrajectoryconfig.h:109
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23