gwnavruntime/pathfollower/trajectory.h Source File

trajectory.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 
13 
14 namespace Kaim
15 {
16 
17 class VisualDebugServer;
18 class SplineTrajectory;
19 class BaseShortcutTrajectory;
20 class FollowedCircleArcSpline;
21 class Bot;
22 class PositionOnLivePath;
23 class TargetOnPath;
24 
26 class Trajectory : public RefCountBase<Trajectory, MemStat_PathFollowing>
27 {
28  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_PathFollowing)
29 
30 public:
31  // ------------------------------ Functions -----------------------------
32 
33  Trajectory(Bot* bot);
34  ~Trajectory();
35 
36  void SetShortcutTrajectory(Ptr<BaseShortcutTrajectory> shortcutTrajectory);
37  void SetAvoidanceComputer(Ptr<IAvoidanceComputer> avoidanceComputer);
38 
39  TrajectoryMode GetTrajectoryMode() const { return m_trajectoryMode; }
40 
41  void Compute(KyFloat32 simulationTimeInSeconds, KyUInt32 worldUpdateIdx);
42 
43  Ptr<IAvoidanceComputer> GetAvoidanceComputer() { return m_avoidanceComputer; }
44  Vec2f GetIdealVelocity() const { return m_idealVelocity; }
45 
46  const FollowedCircleArcSpline* GetFollowedCircleArcSpline() const;
47 
48 public: // internal
49  void ClearOutput(const Vec2f& frontDirection);
50 
51  void Clear(); // fully clear the trajectory and default its config
52  void ClearTrajectory(); // only clear the current computed trajectory
53 
54  bool WillUpdatePathFollowThisFrame(KyFloat32 simulationTimeInSeconds, KyUInt32 worldUpdateIdx, KyUInt32 updatePeriod);
55 
56  ResetTrajectoryStatus ResetTrajectory(const PositionOnLivePath& progressOnLivePath);
57  ResetTrajectoryStatus CanResetTrajectory(const PositionOnLivePath& progressOnLivePath, TargetOnPath& directTargetOnPath);
58 
59  void SendVisualDebugBlob(VisualDebugServer& visualDebugServer, VisualDebugSendChangeEvent changeEvent);
60 
61  // ------------- Helper functions ---------------
62 
63  enum OutputVelocity { OutputVelocity_Stop, OutputVelocity_SlowDownToTarget, OutputVelocity_FullSpeed };
65  static OutputVelocity ComputeStraightVelocityToTarget(Bot* bot, KyFloat32 simulationTimeInSeconds, const Vec3f& target, Vec3f& outputVelocity);
66  static OutputVelocity ComputeStraightVelocityToTarget2d(Bot* bot, KyFloat32 simulationTimeInSeconds, const Vec2f& target, Vec2f& outputVelocity);
67 
68 protected:
69  void SetTrajectoryMode(TrajectoryMode trajectoryMode); // called in compute if m_trajectoryMode differs from the one set in the bot config
70 
71 public: // internal
72  Bot* m_bot;
73  TrajectoryMode m_trajectoryMode;
74  Ptr<IAvoidanceComputer> m_avoidanceComputer;
75  Ptr<BaseShortcutTrajectory> m_shortcutTrajectory;
76  Ptr<SplineTrajectory> m_splineTrajectory;
77 
78  Vec2f m_idealVelocity; // trajectory ideal 2d velocity before avoidance (if applicable)
79 
80  TrajectoryMode m_previousTrajectoryModeForVisualDebug; //< used for visualDebugPurpose;
81 };
82 
83 } // namespace Kaim
84 
85 
This class is the world element that represent an active character in Autodesk Navigation.
Definition: bot.h:128
TrajectoryMode
Enum that defines the 2 possible Trajectory modes.
Definition: botconfig.h:26
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
2d vector using KyFloat32.
Definition: vec2f.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
CircleArcSpline with computation information and current position of follow.
Definition: followedcirclearcspline.h:30
This class aggregates all necessary information to describe a position on a LivePath, namely:
Definition: positiononlivepath.h:43
static OutputVelocity ComputeStraightVelocityToTarget(Bot *bot, KyFloat32 simulationTimeInSeconds, const Vec3f &target, Vec3f &outputVelocity)
Compute a velocity to reach a particular target.
Definition: trajectory.cpp:20
This class computes the trajectory either with ShortcutTrajectory or with SplineTrajectory.
Definition: trajectory.h:26
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
ResetTrajectoryStatus
Definition: resettrajectorystatus.h:13