gwnavruntime/pathfollower/baseshortcuttrajectory.h Source File

baseshortcuttrajectory.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_BaseShortcutTrajectory_H
9 #define Navigation_BaseShortcutTrajectory_H
10 
14 
15 
16 namespace Kaim
17 {
18 
19 class VisualDebugServer;
20 class Bot;
21 class Trajectory;
22 class TargetOnPath;
23 
24 enum ShortcutTrajectoryComputeMode
25 {
26  ShortcutMode_MustUpdateTargetOnPath, // classical shortcut needed
27  ShortcutMode_UseCurrentTargetOnPath, // no need for classical shortcut to update the TargetOnPath, but it must be used
28  ShortcutMode_SnapOnPath, // snap on path
29 };
30 
36 class BaseShortcutTrajectory : public RefCountBase<BaseShortcutTrajectory, MemStat_PathFollowing>
37 {
38  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_PathFollowing)
40 public:
41  // ---------------------------------- Public Member Functions ----------------------------------
43  : m_trajectory(trajectory)
44  , m_useTargetProvidedByUser(false)
45  , m_target(0.0f, 0.0f, 0.0f)
46  , m_lastUpdateIdx(0)
47  , m_trajectoryComputeMode(ShortcutMode_MustUpdateTargetOnPath)
48  , m_useMinimalTargetUpdate(false)
49  , m_visualDebugBlobSent(false)
50  {}
51 
52  virtual ~BaseShortcutTrajectory() = 0;
53 
54  void Compute(KyFloat32 simulationTimeInSeconds);
55  void Clear(); // fully clear the trajectory and default its config
56  void ClearTrajectory(); // only clear the current computed trajectory
57 
58  const Vec3f& GetTrajectoryTarget() const { return m_target; }
59 
60  void ForceTargetToTargetOnPath();
61  void ForceTargetToPosition(const Vec3f& forcedTarget);
62 
63 public: // internal
64  Bot* GetBot() const;
65 
66  void SendVisualDebugBlob(VisualDebugServer& visualDebugServer, VisualDebugSendChangeEvent changeEvent);
67  void RemoveAllVisualDebugBeforeTrajectoryChange(VisualDebugServer& visualDebugServer);
68 
69  void UpdateTarget(KyFloat32 simulationTimeInSeconds);
70  void InitTargetOnPathIfNeeded();
71  void UpdateTrajectoryComputeMode();
72  ShortcutTrajectoryComputeMode GetComputeModeToApply() const;
73  bool CanUseTargetOnPath() const;
74  void ComputeStraightTrajectory(KyFloat32 simulationTimeInSeconds);
75  void ComputeAvoidanceTrajectory(KyFloat32 simulationTimeInSeconds);
76  void ComputeSnapOnPathTrajectory(KyFloat32 simulationTimeInSeconds);
77 
78  virtual KyResult ComputeTargetOnPath(KyFloat32 simulationTimeInSeconds) = 0;
79 
80  virtual bool IsShortcutTrajectoryAllowingToSkipPathFollowingThisFrame(KyFloat32& simulationTimeInSeconds) = 0;
81  // Used in Trajectory::CanResetTrajectory to instantiate a TargetOnPathComputer and compute a TargetOnPath calling ComputeTargetOnPathOnNavMeshOnly
82  // which disregards backward edge type, it only check forward edge type that must be on NavMesh and bot must have a valid triangle
83  virtual KyResult ComputeTargetOnPathOnNavMeshOnly(TargetOnPath& targetOnPath, KyFloat32 simulationTimeInSeconds, ComputeTargetOnPathSearchControl forwardSearchControl) const = 0;
84 
85 public: // internal
86  Trajectory* m_trajectory;
87  ShortcutTrajectoryConfig m_config;
88  Ptr<IAvoidanceComputer> m_avoidanceComputer;
89  TargetOnPath m_targetOnPath;
90  bool m_useTargetProvidedByUser;
91  Vec3f m_target;
92  KyUInt32 m_lastUpdateIdx;
93  ShortcutTrajectoryComputeMode m_trajectoryComputeMode;
94  bool m_useMinimalTargetUpdate; // when TargetOnPath is updated only when the bot reaches the TargetOnPath, or if it becomes necessary to update it e.g. when avoiding other entities.
95 
96  bool m_visualDebugBlobSent;
97 };
98 
99 
100 } // namespace Kaim
101 
102 
103 #endif // Navigation_Trajectory_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 computes minimal trajectory made of just one velocity.
Definition: baseshortcuttrajectory.h:37
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
The VisualDebugServer manages the sending of data to clients.
Definition: visualdebugserver.h:254
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Set of parameters used by the ShortcutTrajectory and TargetOnPathComputer classes to update Bot targe...
Definition: shortcuttrajectoryconfig.h:109
This class computes the trajectory either with ShortcutTrajectory or with SplineTrajectory.
Definition: trajectory.h:30
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