gwnavruntime/pathfollower/trajectory.h Source File

trajectory.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: GUAL - secondary contact: NOBODY
8 #ifndef Navigation_Trajectory_H
9 #define Navigation_Trajectory_H
10 
11 
16 
17 
18 namespace Kaim
19 {
20 
21 class VisualDebugServer;
22 class SplineTrajectory;
23 class BaseShortcutTrajectory;
24 class FollowedCircleArcSpline;
25 class Bot;
26 class PositionOnLivePath;
27 class TargetOnPath;
28 
30 class Trajectory : public RefCountBase<Trajectory, MemStat_PathFollowing>
31 {
32  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_PathFollowing)
33 public:
34  // ---------------------------------- Public Member Functions ----------------------------------
35 
36  Trajectory(Bot* bot);
37  virtual ~Trajectory();
38 
39  void SetShortcutTrajectory(Ptr<BaseShortcutTrajectory> shortcutTrajectory);
40  void SetAvoidanceComputer(Ptr<IAvoidanceComputer> avoidanceComputer);
41 
42  TrajectoryMode GetTrajectoryMode() const { return m_trajectoryMode; }
43 
44  virtual void Compute(KyFloat32 simulationTimeInSeconds);
45 
46  Ptr<IAvoidanceComputer> GetAvoidanceComputer() { return m_avoidanceComputer; }
47  Vec2f GetIdealVelocity() const { return m_idealVelocity; }
48 
49  const FollowedCircleArcSpline* GetFollowedCircleArcSpline() const;
50 
51 
52 public: // internal
53 
54  void ClearOutput(const Vec2f& frontDirection);
55 
56 
57  virtual void Clear(); // fully clear the trajectory and default its config
58  virtual void ClearTrajectory(); // only clear the current computed trajectory
59 
60  virtual bool IsShortcutTrajectoryAllowingToSkipPathFollowingThisFrame(KyFloat32& simulationTimeInSeconds);
61 
62  virtual ResetTrajectoryStatus ResetTrajectory(const PositionOnLivePath& progressOnLivePath);
63  virtual ResetTrajectoryStatus CanResetTrajectory(const PositionOnLivePath& progressOnLivePath, TargetOnPath& directTargetOnPath);
64 
65  virtual void SendVisualDebugBlob(VisualDebugServer& visualDebugServer, VisualDebugSendChangeEvent changeEvent);
66 
67 
68  // ------------- Helper functions ---------------
69 
70  enum OutputVelocity
71  {
72  OutputVelocity_Stop,
73  OutputVelocity_SlowDownToTarget,
74  OutputVelocity_FullSpeed,
75  };
76 
78  static OutputVelocity ComputeStraightVelocityToTarget(Bot* bot, KyFloat32 simulationTimeInSeconds, const Vec3f& target, Vec3f& outputVelocity);
79  static OutputVelocity ComputeStraightVelocityToTarget2d(Bot* bot, KyFloat32 simulationTimeInSeconds, const Vec2f& target, Vec2f& outputVelocity);
80 
81 protected:
82  void SetTrajectoryMode(TrajectoryMode trajectoryMode); // called in compute if m_trajectoryMode differs from the one set in the bot config
83 
84 public: // internal
85  Bot* m_bot;
86  TrajectoryMode m_trajectoryMode;
87  Ptr<IAvoidanceComputer> m_avoidanceComputer;
88  Ptr<BaseShortcutTrajectory> m_shortcutTrajectory;
89  Ptr<SplineTrajectory> m_splineTrajectory;
90 
91  Vec2f m_idealVelocity; // trajectory ideal 2d velocity before avoidance (if applicable)
92 
93  TrajectoryMode m_previousTrajectoryModeForVisualDebug; //< used for visualDebugPurpose;
94 };
95 
96 } // namespace Kaim
97 
98 
99 #endif // Navigation_Trajectory_H
This class is the world element that represent an active character in Gameware Navigation.
Definition: bot.h:150
TrajectoryMode
Enum that defines the 2 possible trajectories modes.
Definition: botconfig.h:31
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
CircleArcSpline with computation information and current position of follow.
Definition: followedcirclearcspline.h:31
The VisualDebugServer manages the sending of data to clients.
Definition: visualdebugserver.h:254
This class aggregates all necessary information to describe a position on a LivePath, namely:
Definition: positiononlivepath.h:46
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
static OutputVelocity ComputeStraightVelocityToTarget(Bot *bot, KyFloat32 simulationTimeInSeconds, const Vec3f &target, Vec3f &outputVelocity)
Compute a velocity to reach a particular target.
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
ResetTrajectoryStatus
Definition: resettrajectorystatus.h:14