gwnavruntime/world/basenavigationprofile.h Source File

basenavigationprofile.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 
18 
19 namespace Kaim
20 {
21 
22 class Bot;
23 
28 class BaseNavigationProfile : public RefCountBase<BaseNavigationProfile, MemStat_Bot>
29 {
30 public:
31  BaseNavigationProfile() : m_profileId(KyUInt32MAXVAL) {}
32 
33  void SetProfileId(KyUInt32 profileId) { m_profileId = profileId; }
34  KyUInt32 GetProfileId() const { return m_profileId; }
35 
36  // ------------------------ PathFinding ------------------------
37  virtual Ptr<BaseAStarQuery> CreateAStarQuery() = 0;
38 
39  // ------------------------ PathProgress ------------------------
40 
42  virtual Ptr<BasePathProgressComputer> GetSharedPathProgressComputer() = 0;
43 
45  virtual Ptr<IPathEventListObserver> GetSharedPathEventListObserver() = 0;
46 
48  virtual Ptr<IPositionOnPathValidator> GetSharedPositionOnPathValidator() = 0;
49 
50  // ------------------------ Trajectory ------------------------
51 
53  virtual Ptr<Trajectory> CreateTrajectory(Bot* bot) = 0;
54 
56  virtual Ptr<IAvoidanceComputer> GetSharedAvoidanceComputer() = 0;
57 
59  virtual Ptr<IAvoidanceSolver> GetSharedAvoidanceSolver() = 0;
60 
62  virtual Ptr<IAvoidanceFilter> GetSharedAvoidanceFilter() = 0;
63 
64  // ------------------------ Queries ------------------------
65  virtual Ptr<BaseRayCanGoQuery> CreateRayCanGoQuery() = 0;
66 
67  // ------------------------ Bot Queries ------------------------
68  virtual Vec3f ComputeMoveOnNavMesh(Bot* bot, const Vec3f& velocity, KyFloat32 simulationTimeInSeconds) = 0;
69 
70 protected:
71  KyUInt32 m_profileId;
72 };
73 
74 
76 class BotNavigation : public RefCountBase<BotNavigation, MemStat_Bot>
77 {
78 public:
79  BotNavigation() : m_navigationProfileId(KyUInt32MAXVAL), m_navigationProfile(nullptr) {}
80 
81  void Init(BaseNavigationProfile* navigationProfile);
82 
83  KyUInt32 GetProfileId() { return m_navigationProfile->GetProfileId(); }
84  BaseNavigationProfile* GetProfile() { return m_navigationProfile; }
85 
86  Ptr<BaseAStarQuery> GetOrCreateAStarQuery();
87  Ptr<BasePathProgressComputer> GetOrCreatePathProgessComputer();
88  Ptr<Trajectory> GetOrCreateTrajectory(Bot* bot);
89 
90  Vec3f ComputeMoveOnNavMesh(Bot* bot, const Vec3f& velocity, KyFloat32 simulationTimeInSeconds);
91 
92 private:
93  KyUInt32 m_navigationProfileId;
94  BaseNavigationProfile* m_navigationProfile;
95 
96  Ptr<BaseAStarQuery> m_aStarQuery;
97  Ptr<BasePathProgressComputer> m_pathProgressComputer;
98  Ptr<Trajectory> m_trajectory;
99 };
100 
104 {
105  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Bot)
106 
107 public:
108  BotNavigationCollection() : m_navigationProfiles(nullptr) {}
109 
110  // initialized with World::m_navigationProfiles
111  void Init(KyArray<Ptr<BaseNavigationProfile> >* navigationProfiles) { m_navigationProfiles = navigationProfiles; }
112 
113  Ptr<BaseAStarQuery> GetOrCreateAStarQuery(KyUInt32 navigationProfileId);
114  Ptr<BasePathProgressComputer> GetOrCreatePathProgessComputer(KyUInt32 navigationProfileId);
115  Ptr<Trajectory> GetOrCreateTrajectory(KyUInt32 navigationProfileId, Bot* bot);
116 
117  Vec3f ComputeMoveOnNavMesh(KyUInt32 navigationProfileId, Bot* bot, const Vec3f& velocity, KyFloat32 simulationTimeInSeconds);
118 
119 private:
120  bool CanUseNavigationProfileId(KyUInt32 navigationProfileId)
121  {
122  return m_navigationProfiles != nullptr && navigationProfileId < m_navigationProfiles->GetCount();
123  }
124 
125  Ptr<BotNavigation> GetOrCreateBotNavigation(KyUInt32 navigationProfileId);
126 
127 private:
128  KyArray<Ptr<BaseNavigationProfile> >* m_navigationProfiles;
129  KyArray<Ptr<BotNavigation> > m_botNavigations;
130 };
131 
132 
133 }
134 
BaseNavigationProfile and its derivation NavigationProfile is a class that simplifies ...
Definition: basenavigationprofile.h:28
This class is the world element that represent an active character in Autodesk Navigation.
Definition: bot.h:128
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
virtual Ptr< IPathEventListObserver > GetSharedPathEventListObserver()=0
IPathEventListObserver is called in BasePathProgressComputer::Update()
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
virtual Ptr< IAvoidanceSolver > GetSharedAvoidanceSolver()=0
AvoidanceSolver::Solve() is called in the AvoidanceComputer.
virtual Ptr< IAvoidanceFilter > GetSharedAvoidanceFilter()=0
IAvoidanceFilter::Filter() is called in the AvoidanceComputer.
virtual Ptr< Trajectory > CreateTrajectory(Bot *bot)=0
Trajectory::Compute() is called in Bot::UpdatePathFollowing() after BasePathProgressComputer::Update(...
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
BotNavigationCollection contains 1 BotNavigation per (Base)NavigationProfile and a pointer on m_navig...
Definition: basenavigationprofile.h:103
virtual Ptr< BasePathProgressComputer > GetSharedPathProgressComputer()=0
BasePathProgressComputer::Update() is called in Bot::UpdatePathFollowing()
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
virtual Ptr< IAvoidanceComputer > GetSharedAvoidanceComputer()=0
AvoidanceComputer::Compute() is called in Trajectory::Compute()
virtual Ptr< IPositionOnPathValidator > GetSharedPositionOnPathValidator()=0
IPositionOnPathValidator is called in BasePathProgressComputer::Update()
Per Bot data that correspond to the usage of a NavigationProfile in a Bot.
Definition: basenavigationprofile.h:76
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16