gwnavruntime/world/bot.h Source File

bot.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 
27 
28 namespace Kaim
29 {
30 
31 class Database;
32 class BaseNavigationProfile;
33 class BasePathProgressComputer;
34 class BaseAStarQuery;
35 class IPathEventListObserver;
36 class IMovePositionOnLivePathPredicate;
37 class IPathFinderQuery;
38 class Bot;
39 class SplineInputBlobDumpConfig;
40 class DisplayListManager;
41 
43 class BotOutput
44 {
47 
48 public: // internal
49  BotOutput();
50  void Reset(const Vec2f& frontDirection = Vec2f::Zero());
51 
52 public:
53  // --- Path status ---
54 
55  bool IsPathRecomputationNeeded() const; // tells if a path must be recomputed
56  UpperBoundType GetUpperBoundType() const; // current type of the upperBound
57  PositionOnPath GetUpperBound() const; // position of the UpperBound
58 
59 public:
60  // --- Bot movement ---
61 
62  Vec3f m_outputVelocity; // 2d in NavMesh, 3d in OutOfNavMesh
63  Vec2f m_outputFrontDirection; // normalized Vec2f
64 
65  // --- Avoidance ---
66 
67  AvoidanceResult m_avoidanceResult; // previously AvoidanceResult
68  bool m_hasCollided; // did the avoidance solved a collision
69 
70 public: // internal
71  Bot* m_bot;
72 };
73 
74 
77 {
79 
80 public:
81  // ------------------------------ Functions -----------------------------
82 
83  BotInitConfig() { SetDefaults(); }
84 
88  void SetDefaults()
89  {
90  m_userData = nullptr;
91  m_database = nullptr;
92  m_databaseBinding = nullptr;
93  m_startFrontDirection = Vec2f::UnitX();
95 
96  m_blockingNavTag.Clear();
97  m_blockingNavTag.SetAsExclusive();
98  }
99 
100 
101  // ---------------------------------- Public Data Members ----------------------------------
102 
103  void* m_userData;
104 
107 
110  Ptr<DatabaseBinding> m_databaseBinding;
111 
114 
115  Vec3f m_startPosition;
116  Vec3f m_startVelocity;
117  Vec2f m_startFrontDirection;
118 
123  DynamicNavTag m_blockingNavTag;
124 };
125 
128 class Bot : public WorldElement
129 {
130  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Bot)
132 
133 public:
134  static WorldElementType GetStaticType() { return TypeBot; }
135  virtual WorldElementType GetType() const { return TypeBot; }
136 
137  virtual const char* GetTypeName() const { return "Bot"; }
138 
139  // ---------------------------------- Initialization / Clearing ----------------------------------
140 
141  Bot();
142 
144  Bot(const BotInitConfig& initConfig);
145 
147  Bot(const BotInitConfig& initConfig, const BotConfig& botConfig);
148 
149  virtual ~Bot();
150 
152  void Init(const BotInitConfig& initConfig);
153 
157  void Init(const BotInitConfig& initConfig, const BotConfig& botConfig);
158 
161  void Clear();
162 
170  void AddToDatabase();
171 
178  void RemoveFromDatabase();
179 
180 
181  // ---------------------------------- BotInput ----------------------------------
185 
188  void SetPosition(const Vec3f& position);
189 
193  void SetVelocity(const Vec3f& velocity);
194 
197  void SetFrontDirection(const Vec2f& frontDirection);
198 
200  void SetPositionAndVelocityAndFrontDirection(const Vec3f& position, KyFloat32 simulationTimeInSeconds);
201 
203  void SetPositionAndVelocity(const Vec3f& position, KyFloat32 simulationTimeInSeconds);
204 
206  void SetVelocityAndFrontDirection(const Vec3f& velocity);
207 
208  // ---------------------------------- BotOutput ----------------------------------
209 
210  const BotOutput& GetBotOutput() const { return m_botOutput; }
211 
212 
213  // ---------------------------------- Getters ----------------------------------
214 
215  const Vec3f& GetPosition() const { return m_position; }
216  const Vec2f& GetFrontDirection() const { return m_frontDirection; }
217  const Vec3f& GetVelocity() const { return m_velocity; }
218 
219  const SpatializedCylinder& GetSpatializedCylinder() const { return m_spatializedCylinder; }
220 
222  // This can be used to achieve much more precise arrival detection and check point validation.
223  const Vec3f& GetPreviousPosition() const { return m_previousPosition; }
224 
225  NavTrianglePtr GetNavTrianglePtr() const { return GetNavTrianglePtr(m_database); }
226  const ChannelSectionPtr& GetChannelSectionPtr() const { return m_positionInChannel; }
227 
228  Database* GetDatabase() const { return m_database; }
229  IPathFinderQuery* GetPathFinderQuery() { return m_pathFinderQuery; }
230  BasePathProgressComputer* GetPathProgressComputer() const { return m_pathProgressComputer; }
231  Trajectory* GetTrajectory() const { return m_trajectory; }
232 
233  const PositionOnLivePath& GetProgressOnLivePath() const { return m_progressOnLivePath; }
234  ProgressOnPathStatus GetProgressOnLivePathStatus() const { return m_progressOnPathStatus; }
235  static const char* GetProgressOnLivePathStatusDescription(ProgressOnPathStatus status);
236 
240 
241  const BotConfig& GetConfig() const { return *m_botConfig; }
242 
244  DisplayListManager* GetDisplayListManager() const;
245 
247  VisualDebugServer* GetVisualDebugServer() const;
248 
249  // ---------------------------------- Bot Shape Config ----------------------------------
250 
254  void SetRadius(KyFloat32 radius);
255  KyFloat32 GetRadius() const { return m_botConfig->m_radius; }
256 
258  void SetHeight(KyFloat32 height);
259  KyFloat32 GetHeight() const { return m_botConfig->m_height; }
260 
261  // ---------------------------------- Trajectory Mode ----------------------------------
262 
266  void SetTrajectoryMode(TrajectoryMode trajectoryMode);
267  TrajectoryMode GetTrajectoryMode() const { return m_botConfig->m_trajectoryMode; }
268 
269  // ---------------------------------- PathFind Config ----------------------------------
270 
272  void SetPathFinderConfig(const PathFinderConfig& pathFinderConfig);
273  const PathFinderConfig& GetPathFinderConfig() const { return m_botConfig->m_pathFinderConfig; }
274 
276  void SetChannelComputerConfig(const ChannelComputerConfig& channelComputerConfig);
277  const ChannelComputerConfig& GetChannelComputerConfig() const { return m_botConfig->m_channelComputerConfig; }
278 
279  // ---------------------------------- Path Progress Config ----------------------------------
280 
283  void SetPathProgressConfig(const PathProgressConfig& pathProgressConfig);
284  const PathProgressConfig& GetPathProgressConfig() const { return m_botConfig->m_pathProgressConfig; }
285 
286  // ---------------------------------- Trajectory Config ----------------------------------
287 
289  void SetMaxDesiredLinearSpeed(KyFloat32 maxDesiredLinearSpeed);
290  KyFloat32 GetMaxDesiredLinearSpeed() const { return m_botConfig->m_maxDesiredLinearSpeed; }
291 
293  void SetTrajectoryFailureMode(TrajectoryFailureMode trajectoryFailureMode);
294  TrajectoryFailureMode GetTrajectoryFailureMode() const { return m_botConfig->m_trajectoryFailureMode; }
295 
297  void SetShortcutTrajectoryConfig(const ShortcutTrajectoryConfig& shortcutTrajectoryConfig);
298  const ShortcutTrajectoryConfig& GetShortcutTrajectoryConfig() const { return m_botConfig->m_shortcutTrajectoryConfig; }
299 
301  void SetSplineTrajectoryConfig(const SplineTrajectoryConfig& splineTrajectoryConfig);
302  const SplineTrajectoryConfig& GetSplineTrajectoryConfig() const { return m_botConfig->m_splineTrajectoryConfig; }
303 
304  // ---------------------------------- Trajectory Avoidance ----------------------------------
305 
307  void SetEnableAvoidance(bool enable);
308  bool GetEnableAvoidance() const { return m_botConfig->m_enableAvoidance; }
309 
311  void SetColliderCollectorConfig(const ColliderCollectorConfig& colliderCollectorConfig);
312  const ColliderCollectorConfig& GetColliderCollectorConfig() const { return m_botConfig->m_colliderCollectorConfig; }
313 
315  void SetAvoidanceConfig(const AvoidanceConfig& avoidanceConfig);
316  const AvoidanceConfig& GetAvoidanceConfig() const { return m_botConfig->m_avoidanceConfig; }
317 
318  // ---------------------------------- Advanced Config ----------------------------------
319 
321  void SetTrajectoryMinimalMoveDistance(KyFloat32 trajectoryMinimalMoveDistance);
322  KyFloat32 GetTrajectoryMinimalMoveDistance() const { return m_botConfig->m_trajectoryMinimalMoveDistance; }
323 
326  void SetLocalMaxCostMultiplierOnPathDistance(KyFloat32 localMaxCostMultiplierOnPathDistance);
327  KyFloat32 GetLocalMaxCostMultiplierOnPathDistance() const { return m_botConfig->m_pathProgressConfig.m_advancedConfig.m_localMaxCostMultiplierOnPathDistance; }
328 
329 
330  // ---------------------------------- Basic PathFinding functions ----------------------------------
334 
337  void SetNewPathNavigationProfileId(KyUInt32 navigationProfileId) { m_newPathToDestNavigationProfileId = navigationProfileId; }
338  KyUInt32 GetNewPathNavigationProfileId() const { return m_newPathToDestNavigationProfileId; }
339 
350  KyResult ComputeAStarQueryAsync(const Vec3f& destPos, const PathFinderConfig* pathFinderConfig = nullptr);
351  KyResult ComputeAStarQueryAsync(const Vec3f& destPos, const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode = NAVGRAPHEDGE_BIDIRECTIONAL,
352  const PathFinderConfig* pathFinderConfig = nullptr);
353 
354  // ---------------------------------- Advanced PathFinding functions ----------------------------------
357 
358  Ptr<BaseAStarQuery> GetAStarQuery() { return m_botNavigationCollection.GetOrCreateAStarQuery(m_newPathToDestNavigationProfileId); }
359 
364  KyResult InitAStarQuery(Ptr<BaseAStarQuery>& astarQuery, const Vec3f& destPos, const PathFinderConfig* pathFinderConfig = nullptr);
365 
370  KyResult InitAStarQuery(Ptr<BaseAStarQuery>& astarQuery, const Vec3f& destPos,
371  const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode = NAVGRAPHEDGE_BIDIRECTIONAL,
372  const PathFinderConfig* pathFinderConfig = nullptr);
373 
377  KyResult ComputePathAsync(IPathFinderQuery* pathFinderQuery);
378 
384  KyResult InjectPath(Path* newPath);
385 
389  void CancelComputePathAsync() { m_livePath.CancelAsyncPathComputation(); }
390 
394  bool IsComputingPath() const { return m_livePath.IsComputingNewPath(); }
395 
398 
399  void* GetBotTraverseLogicUserData() const { return m_traverseLogicUserData; }
400  void SetBotTraverseLogicUserData(void* traverseLogicUserData) { m_traverseLogicUserData = traverseLogicUserData; }
401 
402  // ---------------------------------- LivePath Management ----------------------------------
403 
404  const LivePath& GetLivePath() const { return m_livePath; }
405  const PathEventList& GetPathEventList() const { return m_livePath.GetPathEventList(); }
406  const PathValidityInterval& GetPathValidityInterval() const { return m_livePath.m_validityInterval; }
407  Path* GetFollowedPath() const { return m_livePath.GetFollowedPath(); }
408  PathSource GetFollowedPathSource() const { return m_livePath.GetFollowedPathSource(); }
409  ChannelArray* GetChannelArray() const { return m_livePath.GetChannelArray(); }
410 
414  void ClearFollowedPath();
415 
422  const PositionOnPath* GetUpcomingEventPositionOnPath() const;
423 
429  const NavTag* GetUpcomingEventNavTag() const;
430 
436  const NavTag* GetPreviousEventNavTag() const;
437 
438 
439  // ---------------------------------- Path Following ----------------------------------
440 
444  bool HasReachedPosition(const Vec3f& position, KyFloat32 precisionRadius) const;
445 
454  void SetDoComputeProgressOnPath(bool doUpdateProgressOnPath);
455  bool GetDoComputeProgressOnPath() const { return m_doComputeProgressOnPath; }
456 
464  void SetDoValidateCheckPoint(bool doValidateCheckPoint);
465  bool GetDoValidateCheckPoint() const { return m_doValidateCheckPoint; }
466 
471  void SetDoComputeTrajectory(bool doComputeTrajectory);
472  bool GetDoComputeTrajectory() const { return m_doComputeTrajectory; }
473  void ForceRecomputeTrajectory();
474 
480  void SetBlocking(bool isBlocking);
481  bool IsBlocking() const;
482 
487  Vec3f ComputeMoveOnNavMesh(const Vec3f& velocity, KyFloat32 simulationTimeInSeconds);
488 
493  template<class TraverseLogic>
494  Vec3f ComputeMoveOnNavMeshWithTraverseLogic(const Vec3f& velocity, KyFloat32 simulationTimeInSeconds);
495 
496  // ---------------------------------- Manual Control helper ----------------------------------
506 
516 
528  ManualControlStatus EnterManualControl(const NavTag* navTag);
529  ManualControlStatus EnterManualControl(const DynamicNavTag* navTag);
530 
538 
548  void SetForceMinimizedSpatializationCoherency(bool forceMinimizeCoherency) { m_forceMinimizedSpatializationCoherency = forceMinimizeCoherency; }
549  bool GetForceMinimizedSpatializationCoherency() const { return m_forceMinimizedSpatializationCoherency; }
550 
551 public: // internal
552  // Main function of the Bot. Called for each bot in World::Update() every frame
553  void UpdatePathFollowing(KyFloat32 simulationTimeInSeconds);
554 
555  void ComputeTrajectory(KyFloat32 simulationTimeInSeconds);
556 
557  // Tests if the trajectory can be reset from the given positionOnLivePath, if possible set m_progressOnLivePath to positionOnLivePath
558  // Called internally by ExitManualControl
559  ResetTrajectoryStatus ResetTrajectory(const PositionOnLivePath& positionOnLivePath);
560 
561  virtual void DoSendVisualDebug(VisualDebugServer& server, VisualDebugSendChangeEvent changeEvent); // Inherited from WorldElement
562 
563  // Bot spatialization through its SpatializedCylinder, must only be called into World::Update
564  void UpdateSpatialization();
565 
566  void SetupTagVolumeInitConfig(TagVolumeInitConfig& tagVolumeInitConfig);
567  void OnTagVolumeIntegration();
568  void OnTagVolumeDeIntegration();
569 
570  DatabaseBinding* GetDatabaseBinding();
571 
572  // LivePath management
573  LivePath& GetLivePath() { return m_livePath; }
574  PathEventList& GetPathEventList() { return m_livePath.GetPathEventList(); }
575  void FlagPathAsPotentiallyDirty() { m_livePath.ForceValidityIntervalRecompute(); } // Called in EventBroadcaster to trigger a path validity check after NavData has changed
576 
577  void ComputeBotRadiusAndHeight();
578 
579  // return the triangle corresponding to m_position in the given Database, this database must be one of the DatabaseBinding, this function can imply a lazy update
580  NavTrianglePtr GetNavTrianglePtr(Database* boundDatabase) const;
581 
582 public:
583  // KY_DEPRECATED since 2.17.0
584  KY_DEPRECATED(const ChannelComputerConfig& GetChannelComputerConfigConfig() const) { return GetChannelComputerConfig(); } // Renamed
585  KY_DEPRECATED(KyResult InitAStarQueryForBot(Ptr<BaseAStarQuery>& astarQuery, const Vec3f& destPos, const PathFinderConfig* pathFinderConfig = nullptr)) { return InitAStarQuery(astarQuery, destPos, pathFinderConfig); }
586  KY_DEPRECATED(KyResult InitAStarQueryForBot(Ptr<BaseAStarQuery>& astarQuery, const Vec3f& destPos, const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode = NAVGRAPHEDGE_BIDIRECTIONAL, const PathFinderConfig* pathFinderConfig = nullptr)) { return InitAStarQuery(astarQuery, destPos, startNavGraphEdgePtr, navGraphEdgePathfindMode, pathFinderConfig); }
587  KY_DEPRECATED(KyResult ComputeNewPathToDestination(const Vec3f& destPos, const PathFinderConfig* pathFinderConfig = nullptr)) { return ComputeAStarQueryAsync(destPos, pathFinderConfig); }
588  KY_DEPRECATED(KyResult ComputeNewPathToDestination(const Vec3f& destPos, const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode = NAVGRAPHEDGE_BIDIRECTIONAL, const PathFinderConfig* pathFinderConfig = nullptr)) { return ComputeAStarQueryAsync(destPos, startNavGraphEdgePtr, navGraphEdgePathfindMode, pathFinderConfig); }
589  KY_DEPRECATED(KyResult ComputeNewPathAsync(IPathFinderQuery* pathFinderQuery)); // Beware this behaves differently from ComputePathAsync which now cancels a computing query.
590  KY_DEPRECATED(void CancelAsyncPathComputation()) { CancelComputePathAsync(); } // Renamed
591  KY_DEPRECATED(KyResult InjectNewPath(Path* newPath)); // Beware this behaves differently from InjectPath which now cancels a computing query.
592  KY_DEPRECATED(bool CanAcceptNewPathComputation()) { return CanAcceptNewPath(); } // Renamed since it concerns Computing or injecting a new path
593  KY_DEPRECATED(bool IsComputingNewPath() const) { return IsComputingPath(); } // Renamed
594 
595 private:
596  void SetDefaults();
597 
598  // check if new path computation and or injection can be accepted and raise flags accordingly.
599  bool CanAcceptNewPath();
600  void ClearPathFindingAndFollowingStates();
601  void SetupBotRadiusCappedToGenerationMetrics();
602  void SetupBotHeightCappedToGenerationMetrics();
603  void SendPathFinderErrorDisplayList();
604  void ReplaceFollowedPathWithNewPath();
605  void SetTrajectory(Trajectory* trajectory);
606  void DoClearFollowedPath(IPathEventListObserver::DestructionPurpose);
607 
608  SpatializationUpdateCoherency GetSpatializationUpdateCoherency() const;
609  void UpdateBotPositionSpatializationButNotFloors() const;
610 
611 public: // internal
612  Database* m_database;
613  void* m_traverseLogicUserData;
614 
615  Ptr<IPathFinderQuery> m_pathFinderQuery;
616 
617  // current navigation components
618  Ptr<BasePathProgressComputer> m_pathProgressComputer;
619  Ptr<Trajectory> m_trajectory;
620 
621  // Members relative to Path and Spatialization.
622  LivePath m_livePath; // Maintain Path and runtime information such as its validity
623  SpatializedCylinder m_spatializedCylinder; // Spatialization of the bot in Databases, contains position, velocity and navTriangle at last World::Update()
624  ChannelSectionPtr m_positionInChannel; // Position of the bot in ChannelArray
625  PositionOnLivePath m_progressOnLivePath; // Progress of the bot along the path so far, it never goes backward on the path
626  ProgressOnPathStatus m_progressOnPathStatus; // Status relative to m_progressOnLivePath
627  Vec3f m_previousPosition; // Position passed the previous frame. Used for arrival and checkpoint validation.
628  ManualControlInterval m_manualControlInterval;
629  KyFloat32 m_localMaxCostMultiplierOnPath; // Used by LocalCostAwarTraverseLogic
630 
631  // position, velocity and direction provided by user to be applied on SpatializedCylinder in next World::Update
632  Vec3f m_position; // user input position
633  Vec3f m_velocity; // user input velocity
634  Vec2f m_frontDirection; // user input frontDirection
635 
636  // output position, velocity and direction recommended by Navigation to be applied after World::Update call
637  BotOutput m_botOutput;
638 
639  // NavigationProfiles
640  KyUInt32 m_newPathToDestNavigationProfileId;
641  BotNavigationCollection m_botNavigationCollection; // the per-Bot per-NavigationProfile data
642 
643  // flags to force recompute on next Update
644  mutable BotNeedFullComputeFlags m_botNeedFullComputeFlags;
645 
646  // ColliderCollector per bot data
647  Vec3f m_lastCollectorPosition;
648  Ptr<QueryDynamicOutput> m_collectorOutput;
649 
650  KyFloat32 m_forcePassageTimer; // for internal use, negative value indicates the passage is being forced, positive value indicates when waiting, 0 otherwise
651  KyFloat32 m_colliderTimer; // Increase when colliding, decrease when not, never negative
652 
653 private:
654  Ptr<BotConfig> m_botConfig;
655 
656  bool m_forceMinimizedSpatializationCoherency;
657 
658  // NavTriangles (per bound database) based on user input position i.e. the NavTriangle for m_position which can differ from m_spatializedCylinder,
659  // also note that m_spatializedCylinder is referenced into NavFloor whereas m_positionSpatialization is not!
660  mutable PointSpatialization m_positionSpatialization;
661 
662  bool m_isBlocking;
663  DynamicNavTag m_blockingNavTag;
664  TagVolumeTrigger<Bot> m_tagVolumeTrigger;
665 
666  bool m_doComputeProgressOnPath;
667  bool m_doValidateCheckPoint;
668  bool m_doComputeTrajectory;
669 
670  // VisualDebug
671  BotVisualDebug m_visualDebug;
672 
673 public: // debug
674  Ptr<SplineInputBlobDumpConfig> m_advancedDebug_InputBlobDumpConfig;
675 };
676 
677 } // namespace Kaim
678 
680 
const Vec3f & GetPreviousPosition() const
Returns the Bot position known at the previous World::Update.
Definition: bot.h:223
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
TrajectoryMode
Enum that defines the 2 possible Trajectory modes.
Definition: botconfig.h:26
Base class for all pathfinder queries.
Definition: ipathfinderquery.h:34
KyFloat32 GetRemainingDistanceFromProgressToEndOfPath() const
Return the remaining distance from the ProgressOnPath to the end of the followed path along the path...
Definition: bot.cpp:287
void SetShortcutTrajectoryConfig(const ShortcutTrajectoryConfig &shortcutTrajectoryConfig)
The Trajectory will be recomputed the frame after this call.
Definition: bot.cpp:716
void SetDoComputeProgressOnPath(bool doUpdateProgressOnPath)
When set to true, m_progressOnLivePath will be automatically updated in Bot::UpdatePathFollowing() ba...
Definition: bot.cpp:862
This class aggregates all necessary information about a position on a Path.
Definition: positiononpath.h:29
void SetDoValidateCheckPoint(bool doValidateCheckPoint)
When set to true, the Bot ProgressOnPath will be block at PathEvent CheckPoints until the IPositionOn...
Definition: bot.inl:50
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
void SetEnableAvoidance(bool enable)
EnableAvoidance impacts the Trajectory, the Trajectory will be recomputed after this call...
Definition: bot.cpp:674
static Vec2f UnitX()
Returns {1.0f, 0.0f}.
Definition: vec2f.h:97
void SetMaxDesiredLinearSpeed(KyFloat32 maxDesiredLinearSpeed)
The Trajectory will be recomputed the frame after this call.
Definition: bot.cpp:647
Ptr< BaseAStarQuery > GetAStarQuery()
These functions should be used for advanced path finding scenarios.
Definition: bot.h:358
void SetVelocity(const Vec3f &velocity)
The actual velocity of your entity might differ from the one we gave you in the trajectory because of...
Definition: bot.inl:99
void SetPositionAndVelocity(const Vec3f &position, KyFloat32 simulationTimeInSeconds)
For convenience, deduce velocity from previous position.
Definition: bot.inl:111
TrajectoryFailureMode
Enum that defines the 2 possible behaviors in case the Trajectory cannot follow the path e...
Definition: botconfig.h:34
void SetDoComputeTrajectory(bool doComputeTrajectory)
When set to false, the Bot will no more compute the Trajectory.
Definition: bot.cpp:875
KyResult InitAStarQuery(Ptr< BaseAStarQuery > &astarQuery, const Vec3f &destPos, const PathFinderConfig *pathFinderConfig=nullptr)
Initialize a BaseAStarQuery for the Bot, not that the query must use the same TraverseLogic than your...
Definition: bot.cpp:543
DisplayListManager * GetDisplayListManager() const
Get the DisplayListManager that is required when creating a DisplayList.
Definition: bot.cpp:244
void SetLocalMaxCostMultiplierOnPathDistance(KyFloat32 localMaxCostMultiplierOnPathDistance)
Set the distance along the path from the ProgressOnPath used to compute the local maximum cost multip...
Definition: bot.cpp:668
void AddToDatabase()
Adds the Bot to the Database (and thus to the World).
Definition: bot.cpp:183
void SetTrajectoryMode(TrajectoryMode trajectoryMode)
Trajectory will be recomputed the frame after this call.
Definition: bot.cpp:637
KyResult ComputeAStarQueryAsync(const Vec3f &destPos, const PathFinderConfig *pathFinderConfig=nullptr)
Launches an asynchronous path computation from the Bot position to destPos.
Definition: bot.inl:33
void SetBlocking(bool isBlocking)
Trigger a TagVolume integration or deintegration.
Definition: bot.inl:66
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
Database * m_database
Mandatory: you must provide a valid Database on which the Bot will move.
Definition: bot.h:106
ProgressOnPathStatus
Enumerates the possible status values of Bot Position on path.
Definition: progressonpathstatus.h:13
const Vec3f & GetPosition() const
The position from BotInput passed by the user.
Definition: bot.h:215
Vec3f ComputeMoveOnNavMesh(const Vec3f &velocity, KyFloat32 simulationTimeInSeconds)
returns true as long as SetBlocking(true) was called or the integrated TagVolume has not be deintegra...
Definition: bot.cpp:897
void SetFrontDirection(const Vec2f &frontDirection)
Optional: your entities might face a direction that is different from the velocity.
Definition: bot.inl:100
KyResult InjectPath(Path *newPath)
Set a new Path, considered as the path to follow, at the next World::Update.
Definition: bot.inl:21
NavTrianglePtr GetNavTrianglePtr() const
Returns the triangle corresponding to SetPosition() into m_database.
Definition: bot.h:225
AvoidanceResult
Enumerates the possible results of a call to IAvoidanceComputer::Compute().
Definition: iavoidancecomputer.h:18
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
BotOutput gathers the most important outputs of a bot for easy access.
Definition: bot.h:43
KyResult ComputePathAsync(IPathFinderQuery *pathFinderQuery)
Launches a new path computation with a pathFinderQuery.
Definition: bot.inl:38
void SetAvoidanceConfig(const AvoidanceConfig &avoidanceConfig)
The Trajectory will be recomputed after this call.
Definition: bot.cpp:748
KyUInt32 m_startNewPathNavigationProfileId
NavigationProfile that will be used in the GetAstarQuery() calls.
Definition: bot.h:113
void SetColliderCollectorConfig(const ColliderCollectorConfig &colliderCollectorConfig)
The Trajectory will be recomputed the frame after this call.
Definition: bot.cpp:737
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:57
2d vector using KyFloat32.
Definition: vec2f.h:18
PathSource
Enumerates the possible source for a new Path.
Definition: livepath.h:39
void SetTrajectoryMinimalMoveDistance(KyFloat32 trajectoryMinimalMoveDistance)
Set the Bot TrajectoryMinimalMoveDistance (cf BotConfig::m_trajectoryMinimalMoveDistance), nothing in particular will be recomputed after this call.
Definition: bot.cpp:662
void SetRadius(KyFloat32 radius)
Radius only impacts other surrounding bots avoidance.
Definition: bot.cpp:622
void SetPositionAndVelocityAndFrontDirection(const Vec3f &position, KyFloat32 simulationTimeInSeconds)
For convenience, set position and deduce velocity from previous position as well as frontDirection...
Definition: bot.inl:102
void CancelComputePathAsync()
Cancel the current path computation.
Definition: bot.h:389
#define KY_DEPRECATED(expr)
The compiler issues a warning when a deprecated function or typedef is used.
Definition: types.h:93
Navigation return code class.
Definition: types.h:108
void ForceValidityIntervalRecompute()
Call this method to force an update of the PathValidityInterval.
Definition: livepath.inl:35
BaseNavigationProfile * GetFollowedPathNavigationProfile()
Get the NavigationProfile of the currently followed Path.
Definition: bot.cpp:853
WorldElementType
Enumerates the WorldElement types.
Definition: worldelementtype.h:13
ResetTrajectoryStatus ExitManualControl()
If EnterManualControl() was called without NavTag then the current m_progressOnLivePath is used...
Definition: bot.cpp:916
Base internal class used to represent elements that can be added to a World, such as instances of Dat...
Definition: worldelement.h:41
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
ManualControlStatus EnterManualControl()
Following function helps setting up the PathFollowing when user wants to take control of the Bot Thes...
Definition: bot.cpp:902
Ptr< DatabaseBinding > m_databaseBinding
The Databases where the Bot will be spatialized.
Definition: bot.h:110
Class that aggregates most important parameters that allow to configure the PathFinding of a Bot...
Definition: pathfinderconfig.h:19
Class used to provide Bot initialization parameters.
Definition: bot.h:76
bool IsComputingNewPath() const
Returns true if a path computation has been launched with the PathFinderQuery and the followed path h...
Definition: livepath.inl:31
void SetNewPathNavigationProfileId(KyUInt32 navigationProfileId)
These functions are used to have the bot finding a Path very easily by only providing your AstarQuery...
Definition: bot.h:337
const SpatializedCylinder & GetSpatializedCylinder() const
The SpatializedCylinder used to spatialiazed the Bot in the bound Databases.
Definition: bot.h:219
Internal representation of world elements, using a vertical cylinder shape.
Definition: spatializedcylinder.h:44
void SetPathFinderConfig(const PathFinderConfig &pathFinderConfig)
The Path will not be recomputed after this call. The PathFinderConfig will be used by the next Comput...
Definition: bot.cpp:684
static Vec2f Zero()
Returns {0.0f, 0.0f}.
Definition: vec2f.h:93
void RemoveFromDatabase()
Removes the Bot from the Database (and thus from the World).
Definition: bot.cpp:196
const NavTag * GetUpcomingEventNavTag() const
Returns a pointer to the navTag along the path after m_progressOnLivePath.
Definition: bot.cpp:303
void ClearFollowedPath()
Clears the current LivePath and associated events.
Definition: bot.cpp:257
const BotOutput & GetBotOutput() const
Returns the output computed during last World::Update()
Definition: bot.h:210
VisualDebugServer * GetVisualDebugServer() const
Get the VisualDebugServer.
Definition: bot.cpp:249
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
Class that aggregates all parameters that allow to configure the PathFinding and the PathFollowing of...
Definition: botconfig.h:37
void SetSplineTrajectoryConfig(const SplineTrajectoryConfig &splineTrajectoryConfig)
The Trajectory will be recomputed the frame after this call.
Definition: bot.cpp:726
const PositionOnPath * GetUpcomingEventPositionOnPath() const
Returns a pointer to the PositionOnPath of the PathEvent along the path after m_progressOnLivePath.
Definition: bot.cpp:298
DynamicNavTag m_blockingNavTag
NavTag used for the TagVolume triggered if Bot::SetBlocking(true) is called.
Definition: bot.h:123
void SetDefaults()
Sets all members to their default value.
Definition: bot.h:88
void SetPathProgressConfig(const PathProgressConfig &pathProgressConfig)
The PathProgressConfig::m_pathValidationDistanceMinBackward and PathProgressConfig::m_pathValidationM...
Definition: bot.cpp:703
void SetTrajectoryFailureMode(TrajectoryFailureMode trajectoryFailureMode)
Set the TrajectoryFailureMode, nothing in particular will be recomputed after this call...
Definition: bot.cpp:656
DestructionPurpose
Explains the reason the PathEventList is about to be destroyed.
Definition: ipatheventlistobserver.h:59
void Init(const BotInitConfig &initConfig)
uses a default constructed BotConfig
Definition: bot.cpp:87
bool IsComputingPath() const
Call this method each time you want to compute a new Path.
Definition: bot.h:394
void SetVelocityAndFrontDirection(const Vec3f &velocity)
For convenience, set velocity and deduce frontDirection from it.
Definition: bot.inl:120
ManualControlStatus
Definition: manualcontrolinterval.h:17
const Vec3f & GetVelocity() const
The velocity vector from BotInput passed by the user.
Definition: bot.h:217
bool HasReachedPosition(const Vec3f &position, KyFloat32 precisionRadius) const
The position is reached when the segment between a Bot previous and current position intersects the c...
Definition: bot.cpp:316
Each instance of this class uniquely identifies a single and mono-directionnal NavGraphEdge in a NavG...
Definition: navgraphedgeptr.h:20
void SetHeight(KyFloat32 height)
Height is only used to send the correct visualDebug.
Definition: bot.cpp:630
const Vec2f & GetFrontDirection() const
The moving direction from BotInput passed by the user.
Definition: bot.h:216
void Clear()
Prepares this instance for destruction and / or reuse: sets all members to their default values and c...
Definition: bot.cpp:145
Vec3f ComputeMoveOnNavMeshWithTraverseLogic(const Vec3f &velocity, KyFloat32 simulationTimeInSeconds)
Helper function to compute the position the bot would reach if you apply the velocity for simulationT...
Definition: bot.inl:53
The class representing a path.
Definition: path.h:62
void SetPosition(const Vec3f &position)
These methods have to be called to update Bot position, velocity and front direction.
Definition: bot.inl:91
float KyFloat32
float
Definition: types.h:32
const NavTag * GetPreviousEventNavTag() const
Returns a pointer to the navTag along the path before m_progressOnLivePath.
Definition: bot.cpp:308
3d vector using 32bits floating points.
Definition: vec3f.h:16
ResetTrajectoryStatus
Definition: resettrajectorystatus.h:13
void SetChannelComputerConfig(const ChannelComputerConfig &channelComputerConfig)
The path will not be recomputed after this call. The ChannelComputerConfig will be used by the next C...
Definition: bot.cpp:693
void SetForceMinimizedSpatializationCoherency(bool forceMinimizeCoherency)
By default, Spatialization coherency is maximized, you can force minimization here.
Definition: bot.h:548