gwnavruntime/world/basenavigationprofile.h Source File

basenavigationprofile.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: NONE
8 #ifndef Navigation_BaseNavigationProfile_H
9 #define Navigation_BaseNavigationProfile_H
10 
20 
21 
22 namespace Kaim
23 {
24 
25 class Bot;
26 
31 class BaseNavigationProfile : public RefCountBase<BaseNavigationProfile, MemStat_Bot>
32 {
33 public:
35 
36  void SetProfileId(KyUInt32 profileId) { m_profileId = profileId; }
37  KyUInt32 GetProfileId() const { return m_profileId; }
38 
39  // ------------------------ PathFinding ------------------------
40  virtual Ptr<BaseAStarQuery> CreateAStarQuery() = 0;
41 
42  // ------------------------ PathProgress ------------------------
43 
45  virtual Ptr<BasePathProgressComputer> GetSharedPathProgressComputer() = 0;
46 
48  virtual Ptr<IPathEventListObserver> GetSharedPathEventListObserver() = 0;
49 
51  virtual Ptr<IPositionOnPathValidator> GetSharedPositionOnPathValidator() = 0;
52 
53  // ------------------------ Trajectory ------------------------
54 
56  virtual Ptr<Trajectory> CreateTrajectory(Bot* bot) = 0;
57 
59  virtual Ptr<IAvoidanceComputer> GetSharedAvoidanceComputer() = 0;
60 
62  virtual Ptr<IAvoidanceSolver> GetSharedAvoidanceSolver() = 0;
63 
65  virtual Ptr<IAvoidanceFilter> GetSharedAvoidanceFilter() = 0;
66 
67  // ------------------------ Queries ------------------------
68  virtual Ptr<BaseRayCanGoQuery> CreateRayCanGoQuery() = 0;
69 
70  // ------------------------ Bot Queries ------------------------
71  virtual Vec3f ComputeMoveOnNavMesh(Bot* bot, const Vec3f& velocity, KyFloat32 simulationTimeInSeconds) = 0;
72 
73 public: //internal
74  virtual bool HasTraverseLogicNoObsoleteFunctions() const = 0;
75 
76 public:
77  KyUInt32 m_profileId;
78 };
79 
80 
82 class BotNavigation : public RefCountBase<BotNavigation, MemStat_Bot>
83 {
84 public:
85  BotNavigation() : m_navigationProfileId(KyUInt32MAXVAL), m_navigationProfile(KY_NULL) {}
86 
87  void Init(BaseNavigationProfile* navigationProfile);
88 
89  KyUInt32 GetProfileId() { return m_navigationProfile->GetProfileId(); }
90  BaseNavigationProfile* GetProfile() { return m_navigationProfile; }
91 
92  Ptr<BaseAStarQuery> GetOrCreateAStarQuery();
93  Ptr<BasePathProgressComputer> GetOrCreatePathProgessComputer();
94  Ptr<Trajectory> GetOrCreateTrajectory(Bot* bot);
95 
96  Vec3f ComputeMoveOnNavMesh(Bot* bot, const Vec3f& velocity, KyFloat32 simulationTimeInSeconds);
97 
98 private:
99  KyUInt32 m_navigationProfileId;
100  BaseNavigationProfile* m_navigationProfile;
101 
102  Ptr<BaseAStarQuery> m_aStarQuery;
103  Ptr<BasePathProgressComputer> m_pathProgressComputer;
104  Ptr<Trajectory> m_trajectory;
105 };
106 
107 
108 class BotNavigationCollection
109 {
111 
112 public:
113  BotNavigationCollection() : m_navigationProfiles(KY_NULL) {}
114 
115  // initialized with World::m_navigationProfiles
116  void Init(KyArray<Ptr<BaseNavigationProfile> >* navigationProfiles) { m_navigationProfiles = navigationProfiles; }
117 
118  Ptr<BaseAStarQuery> GetOrCreateAStarQuery(KyUInt32 navigationProfileId);
119  Ptr<BasePathProgressComputer> GetOrCreatePathProgessComputer(KyUInt32 navigationProfileId);
120  Ptr<Trajectory> GetOrCreateTrajectory(KyUInt32 navigationProfileId, Bot* bot);
121 
122  Vec3f ComputeMoveOnNavMesh(KyUInt32 navigationProfileId, Bot* bot, const Vec3f& velocity, KyFloat32 simulationTimeInSeconds);
123 
124 private:
125  bool CanUseNavigationProfileId(KyUInt32 navigationProfileId)
126  {
127  return m_navigationProfiles != KY_NULL && navigationProfileId < m_navigationProfiles->GetCount();
128  }
129 
130  Ptr<BotNavigation> GetOrCreateBotNavigation(KyUInt32 navigationProfileId);
131 
132 private:
133  KyArray<Ptr<BaseNavigationProfile> >* m_navigationProfiles;
134  KyArray<Ptr<BotNavigation> > m_botNavigations;
135 };
136 
137 
138 }
139 
140 #endif
BaseNavigationProfile and its derivation NavigationProfile is a class that simplifies ...
Definition: basenavigationprofile.h:34
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:118
#define KY_NULL
Null value.
Definition: types.h:247
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(...
virtual Ptr< BasePathProgressComputer > GetSharedPathProgressComputer()=0
BasePathProgressComputer::Update() is called in Bot::UpdatePathFollowing()
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
virtual Ptr< IAvoidanceComputer > GetSharedAvoidanceComputer()=0
AvoidanceComputer::Compute() is called in Trajectory::Compute()
virtual Ptr< IPositionOnPathValidator > GetSharedPositionOnPathValidator()=0
IPositionOnPathValidator is called in BasePathProgressComputer::Update()
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43