gwnavruntime/pathfollower/targetonpathcomputer.h Source File

targetonpathcomputer.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
9 
18 #include "gwnavruntime/world/bot.h"
21 
22 namespace Kaim
23 {
24 
25 enum ComputeTargetOnPathResult
26 {
27  KeepCurrentTarget = 0,
28  BetterTargetFound,
29  NoBetterTargetFound
30 };
31 
32 enum ComputeTargetOnPathSearchControl
33 {
34  ContinueSearch = 0,
35  StopSearch
36 };
37 
38 
47 // set to TargetOnPathNotReachable. No further action is done, you have to check the
50 template <class TraverseLogic>
52 {
53 public:
54  // ------------------------------ Functions -----------------------------
55 
57 
58  // Used specifically by the ShortcutTrajectory in order to skip, cf. World::SetNumberOfFramesForShortcutTrajectoryPeriodicUpdate()
59  static bool IsComputationRequiredThisFrame(Bot* bot, KyFloat32 timeToNextUpdate, const TargetOnPath& targetOnPath);
60 
61  // Must be called before ComputeTargetOnPath
62  void SetupShortcutTrajectoryConfig(const ShortcutTrajectoryConfig& config);
63  KyResult ComputeTargetOnPath(Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl);
64  void Clear(Bot* bot);
65 
66 protected:
67 
68  enum ValidationResult
69  {
70  CandidateIsValid = 0,
71  InvalidCandidate_CanGoArrivedInWrongFloor,
72  InvalidCandidate_CanGoFailure,
73  InvalidCandidate_TooFarFromBot
74  };
75 
76  KyResult ComputeWhenNotOnMesh(Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl);
77  KyResult ComputeWhenOnMesh(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, KyFloat32 costFromBotToTOP, PathEdgeType currentEdgeType, ComputeTargetOnPathSearchControl forwardSearchControl);
78 
79  ComputeTargetOnPathResult Shortcut(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, KyFloat32 costFromBotToTOP, PathEdgeType currentEdgeType);
80  KyResult MakeSureTargetOnPathIsVisibleAndGetCostFromBotToTOP(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32& costFromBotToTOP);
81  KyResult CheckTargetOnPathIsVisibleAndGetCostFromBotToTOP(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32& costFromBotToTOP);
82  KyResult FindVisibleTargetOnPathBackwardWithCost(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32& costFromBotToTOP);
83  ComputeTargetOnPathSearchControl ShortcutOnNextSample(const Bot* bot, DisplayList& displayList, TargetOnPath& candidate, TargetOnPath& bestCandidate, KyFloat32& costToBest);
84  ValidationResult ValidateCandidateAndGetCost(const Bot* bot, DisplayList& displayList, const Vec3f& candidatePosition, RayCanGoMarginMode rayCanGoMarginMode, KyFloat32& cost);
85  bool TestCanGoWithCost(RayCanGoQuery<LocalCostAwareTraverseLogic<TraverseLogic> >& canGoQuery, DisplayList& displayList,
86  const Vec3f& start, const NavTrianglePtr& startTriangle, const Vec3f& dest, KyFloat32& cost);
87 
88 public: //internal
89  // This disregards backward edge type, it only check forward edge type that must be on NavMesh and bot must have a valid triangle
90  KyResult ComputeTargetOnPathOnNavMeshOnly(const Bot* bot, TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl);
91 
92 private:
93  ShortcutTrajectoryConfig m_config;
94  LocalCostAwareTraverseLogicData m_localCostAwareTraverseLogicData;
95 };
96 
97 } // namespace Kaim
98 
99 
101 
This class is the world element that represent an active character in Autodesk Navigation.
Definition: bot.h:128
This class updates Bot's target on path so that:
Definition: targetonpathcomputer.h:51
The RayCanGoQuery tests if a ray can go from start to dest on the navmesh.
Definition: raycangoquery.h:20
RayCanGoMarginMode
Defines the different mode for the NavMesh border margin to be used in RayCanGo queries.
Definition: database.h:37
DisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:128
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
LocalCostAwareTraverseLogic is a wrapper around the traverse logic set by the user.
Definition: localcostawaretraverselogic.h:34
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
Set of parameters used by the ShortcutTrajectory and TargetOnPathComputer classes to update Bot targe...
Definition: shortcuttrajectoryconfig.h:89
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16