Kaim::Bot Class Reference
#include <bot.h>
This class is the world element that represent an active character in Autodesk Navigation.
It manages character pathfinding and pathfollowing.
Inherits Kaim::WorldElement.
|
Ptr< BaseAStarQuery > | GetAStarQuery () |
| These functions should be used for advanced path finding scenarios. More...
|
|
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 Bot. More...
|
|
KyResult | InitAStarQuery (Ptr< BaseAStarQuery > &astarQuery, const Vec3f &destPos, const NavGraphEdgePtr &startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode=NAVGRAPHEDGE_BIDIRECTIONAL, const PathFinderConfig *pathFinderConfig=nullptr) |
| Initialize a BaseAStarQuery for the Bot, not that the query must use the same TraverseLogic than your Bot. More...
|
|
KyResult | ComputePathAsync (IPathFinderQuery *pathFinderQuery) |
| Launches a new path computation with a pathFinderQuery. More...
|
|
KyResult | InjectPath (Path *newPath) |
| Set a new Path, considered as the path to follow, at the next World::Update. More...
|
|
void | CancelComputePathAsync () |
| Cancel the current path computation. More...
|
|
bool | IsComputingPath () const |
| Call this method each time you want to compute a new Path. More...
|
|
BaseNavigationProfile * | GetFollowedPathNavigationProfile () |
| Get the NavigationProfile of the currently followed Path. More...
|
|
void * | GetBotTraverseLogicUserData () const |
|
void | SetBotTraverseLogicUserData (void *traverseLogicUserData) |
|
|
bool | HasReachedPosition (const Vec3f &position, KyFloat32 precisionRadius) const |
| The position is reached when the segment between a Bot previous and current position intersects the cylinder centered on the position with precisionRadius and database generation height. More...
|
|
void | SetDoComputeProgressOnPath (bool doUpdateProgressOnPath) |
| When set to true, m_progressOnLivePath will be automatically updated in Bot::UpdatePathFollowing() based on a geometric criterion which is the bot crossing bisector line or plane (if in NavMesh or not) of the path edges. More...
|
|
bool | GetDoComputeProgressOnPath () const |
|
void | SetDoValidateCheckPoint (bool doValidateCheckPoint) |
| When set to true, the Bot ProgressOnPath will be block at PathEvent CheckPoints until the IPositionOnPathValidator instance of the NavigationPofile returns true. More...
|
|
bool | GetDoValidateCheckPoint () const |
|
void | SetDoComputeTrajectory (bool doComputeTrajectory) |
| When set to false, the Bot will no more compute the Trajectory. More...
|
|
bool | GetDoComputeTrajectory () const |
|
void | ForceRecomputeTrajectory () |
|
void | SetBlocking (bool isBlocking) |
| Trigger a TagVolume integration or deintegration. More...
|
|
bool | IsBlocking () const |
|
Vec3f | ComputeMoveOnNavMesh (const Vec3f &velocity, KyFloat32 simulationTimeInSeconds) |
| returns true as long as SetBlocking(true) was called or the integrated TagVolume has not be deintegrated yet since SetBlocking(false) was called. More...
|
|
template<class TraverseLogic > |
Vec3f | ComputeMoveOnNavMeshWithTraverseLogic (const Vec3f &velocity, KyFloat32 simulationTimeInSeconds) |
| Helper function to compute the position the bot would reach if you apply the velocity for simulationTimeInSeconds from its last spatialized position (cf. More...
|
|
|
bool | IsAddedToWorld () const |
|
World * | GetWorld () const |
|
KyUInt32 | GetVisualDebugId () const |
|
void * | GetUserData () const |
|
void | SetUserData (void *userData) |
|
|
void | SendForMaxLevelOfDetail (VisualDebugServer &server, const Vec3f &shapePosition) |
|
void | RegisterToVisualDebug () |
|
void | UnRegisterFromVisualDebug () |
|
KyUInt32 | GetIndexInCollection () const |
|
void | SetIndexInCollection (KyUInt32 indexInCollection) |
|
calls Init(initConfig, botConfig)
void Kaim::Bot::AddToDatabase |
( |
| ) |
|
Adds the Bot to the Database (and thus to the World).
It becomes active in the simulation, it is updated, and it is taken into account by other Bots. This increments the RefCount of this instance. NOTE: this method has immediate effect: ensure to call this outside of any Autodesk Navigation computation (World::Update() or threaded query computation). However, the spatialization is not updated immediately, this will be done in next World::Update().
void Kaim::Bot::CancelComputePathAsync |
( |
| ) |
|
|
inline |
Cancel the current path computation.
You must call this method each time you want to compute a new path whereas the previous path computation query has not been completed.
void Kaim::Bot::Clear |
( |
| ) |
|
Prepares this instance for destruction and / or reuse: sets all members to their default values and clears: the spatialization, the path, the trajectory.
void Kaim::Bot::ClearFollowedPath |
( |
| ) |
|
Clears the current LivePath and associated events.
Sets the PathFollowing component controls to default: target on path and Trajectory will be computed when a new path will be provided.
Launches an asynchronous path computation from the Bot position to destPos.
If the Bot is already computing a Path, this computation is canceled, and a we try to launch a new path computation. The launched PathFinderQuery will be an instance returned by the CreateAStarQuery() fonction of the current NavigationProfile. If the AStarQuery cannot be initialized because of the Query Framework (We may have to wait for the next World::Update() for the query to be flushed from the QueryQueue), this function returns KY_ERROR. In this case, you could try to call it next frame. Note that this function calls internally the ComputePathAsync function. If you had previously called ComputePathAsync() with a custom IPathFinderQuery then it will be canceled and replaced by the AStarQuery. Optionally, you can force the path to start with a given NavGraph edge. If pathFinderConfig not provided, this bot's PathFinderConfig will be used. Return KY_ERROR if Bot is blocking, see SetBlocking()
Vec3f Kaim::Bot::ComputeMoveOnNavMesh |
( |
const Vec3f & |
velocity, |
|
|
KyFloat32 |
simulationTimeInSeconds |
|
) |
| |
returns true as long as SetBlocking(true) was called or the integrated TagVolume has not be deintegrated yet since SetBlocking(false) was called.
Helper function to compute the position the bot would reach if you apply the velocity for simulationTimeInSeconds from its last spatialized position (cf. GetSpatializedPosition()) Use this function to guarantee that the bot stays on a reachable valid position (we make use of the MoveOnNavMeshQuery) Autodesk Navigation never moves the bot on its own, so you still need to call SetPosition/SetVelocity/SetFrontDirection This version use the TraverseLogic set on the current NavigationProfile
template<class TraverseLogic >
Vec3f Kaim::Bot::ComputeMoveOnNavMeshWithTraverseLogic |
( |
const Vec3f & |
velocity, |
|
|
KyFloat32 |
simulationTimeInSeconds |
|
) |
| |
|
inline |
Helper function to compute the position the bot would reach if you apply the velocity for simulationTimeInSeconds from its last spatialized position (cf.
GetSpatializedPosition()) Use this function to guarantee that the bot stays on a reachable valid position (we make use of the MoveOnNavMeshQuery) Autodesk Navigation never moves the bot on its own, so you still need to call SetPosition/SetVelocity/SetFrontDirection This version use the TraverseLogic you provide, and therefore save a virtual call i.e faster
Launches a new path computation with a pathFinderQuery.
WARNING : This query must have been bound to the database in which the bot has been added and must be initialized. If this bot is computing a path (See IsComputingNewPath() this compputation will be canceled.
Following function helps setting up the PathFollowing when user wants to take control of the Bot These functions computes an interval on which the Bot is going to follow the path in a particular way under control of the user.
this interval is computed based on the entry and the exit of NavTag along the path. This interval is called ManualControlInterval. Usage: if (bot->EnterManualControl(navTag) < ManualControlStatus_Pending) return; // Bot was not able to enter manual control; while (bot->ExitManualControl() < ResetTrajectoryStatus_Success) // Navigation cannot take back control, Bot didn't exit ManualControl GameContinueToMoveBotByItselfOrRecomputeAPath(); // Game should continue to move the Bot by its own logic or recompute a path. Call this function if you wish to take manual control of the Bot, i.e. if you don't need a trajectory to be computed and progress should ignore checkpoints e.g. a SmartObject takes control of the Bot. The entry point of the ManualControlInterval will be set to m_progressOnLivePath. No exit point will be computed, m_progressOnLivePath will be used at exit point, which means that ExitManualControl will rely solely on the geometric update of the m_progressOnLivePath during the Manual Control. Prefer EnterManualControl(const NavTag& navTag) which allows to force the exit point at the end of the NavTag on the path, particularly if during the Manual Control, the Bot has a trajectory that goes outside the Path (jump, animations...).
Call this function if you wish to take manual control of the Bot on a given NavTag i.e.
if you don't need a trajectory to be computed and progress should ignore checkpoints e.g. a SmartObject takes control of the Bot. The entry and exit point of the ManualControlInterval will computed from m_progressOnLivePath based on the next or current portion of path that is on the given NavTag. On ExitManualControl, m_progressOnLivePath will be force to the exit point, if the trajectory can be reset at this point.
- Returns
- ManualControlStatus indicates if the Bot is now under Manual Control or not. The following two values indicates the Bot is considered under ManualControl ManualControl_Valid indicates that both entry and exit points are found and valid, it is now up to the user to compute a trajectory ManualControl_Pending indicates that entry point is known and exit points remains under validation due to the path not being valid either after this point, they both will be updated on next updates. Other values indicate that the Bot cannot enter ManualControl.
If EnterManualControl() was called without NavTag then the current m_progressOnLivePath is used.
During the Manual control, m_progressOnLivePath was updated as usual i.e. only based on geometric criterion. If EnterManualControl() was called with a specific NavTag then the m_progressOnLivePath is set to the NavTag Exit whatever its position is.
- Returns
- ResetTrajectoryStatus indicates if ManualControl successfully ended or if Bot remains under ManualControl. Hence, if the value is greater or equals to ResetTrajectoryStatus_Success, m_trajectory was successfully reset, ManualControl ends and m_trajectory will be updated each frame from now on. Otherwise, the trajectory cannot be reset from the exit point, typically user can recompute a path or keep moving the Bot.
void Kaim::WorldElement::ForceSendAllVisualDebug |
( |
| ) |
|
|
inlineinherited |
Call this when something impacts all your visual debug data.
It will set the event to VisualDebugSendChangeEvent_ForceSendAll. (called internally when connecting with a VisualDebug client).
These functions should be used for advanced path finding scenarios.
With them you can set the IPathFinder query you want (not only an AStarQuery). You have to initialize your Query by yourself before calling the ComputePathAsync() function.
const BotOutput& Kaim::Bot::GetBotOutput |
( |
| ) |
const |
|
inline |
const Vec2f& Kaim::Bot::GetFrontDirection |
( |
| ) |
const |
|
inline |
The moving direction from BotInput passed by the user.
Returns the triangle corresponding to SetPosition() into m_database.
const Vec3f& Kaim::Bot::GetPosition |
( |
| ) |
const |
|
inline |
The position from BotInput passed by the user.
const NavTag * Kaim::Bot::GetPreviousEventNavTag |
( |
| ) |
const |
Returns a pointer to the navTag along the path before m_progressOnLivePath.
If positionOnLivePath is on a PathEvent, it returns the NavTag between this PathEvent and the previous. Note: if positionOnLivePath is at the lower bound of the validity interval, it will return nullptr.
const Vec3f& Kaim::Bot::GetPreviousPosition |
( |
| ) |
const |
|
inline |
KyFloat32 Kaim::Bot::GetRemainingDistanceFromProgressToEndOfPath |
( |
| ) |
const |
Return the remaining distance from the ProgressOnPath to the end of the followed path along the path.
It can return -1.f if there's no path or GetProgressOnLivePathStatus is not valid
const NavTag * Kaim::Bot::GetUpcomingEventNavTag |
( |
| ) |
const |
Returns a pointer to the navTag along the path after m_progressOnLivePath.
If positionOnLivePath is on a PathEvent, it returns the NavTag between this PathEvent and the next. Note: if positionOnLivePath is at the upper bound of the validity interval, it will return nullptr.
const PositionOnPath * Kaim::Bot::GetUpcomingEventPositionOnPath |
( |
| ) |
const |
Returns a pointer to the PositionOnPath of the PathEvent along the path after m_progressOnLivePath.
If m_progressOnLivePath is on a PathEvent, it returns the PositionOnPath of the next PathEvent. Note: if positionOnLivePath is at the upper bound of the validity interval, it will return nullptr.
const Vec3f& Kaim::Bot::GetVelocity |
( |
| ) |
const |
|
inline |
The velocity vector from BotInput passed by the user.
VisualDebugServer * Kaim::Bot::GetVisualDebugServer |
( |
| ) |
const |
Get the VisualDebugServer.
bool Kaim::Bot::HasReachedPosition |
( |
const Vec3f & |
position, |
|
|
KyFloat32 |
precisionRadius |
|
) |
| const |
The position is reached when the segment between a Bot previous and current position intersects the cylinder centered on the position with precisionRadius and database generation height.
Initiates the Bot, but does not add it to the world.
If m_database is already set, Clear() is called to clean this instance up and prepare it for re-use.
Set a new Path, considered as the path to follow, at the next World::Update.
If the bot not is computing a path when this function is called, the path computation will be canceled to prevent the provided path from being overwritten by the path computation when it completes. You can pass nullptr to end path following, but non-null paths with 0 nodes will be rejected. Return KY_ERROR if Bot is blocking, see SetBlocking()
bool Kaim::Bot::IsComputingPath |
( |
| ) |
const |
|
inline |
Call this method each time you want to compute a new Path.
If it returns true you must call ClearFollowedPath() before querying a new path computation (or wait for the previous query completion).
void Kaim::Bot::RemoveFromDatabase |
( |
| ) |
|
Removes the Bot from the Database (and thus from the World).
It is removed from the simulation, updates stop, and it is ignored by other Bots. This decrements the RefCount of this instance. NOTE: this method has immediate effect: ensure to call this outside of any Autodesk Navigation computation (Kaim::World::Update or threaded query computation). The spatialization information are immediately invalidated too.
void Kaim::Bot::SetAvoidanceConfig |
( |
const AvoidanceConfig & |
avoidanceConfig | ) |
|
The Trajectory will be recomputed after this call.
void Kaim::Bot::SetBlocking |
( |
bool |
isBlocking | ) |
|
|
inline |
Trigger a TagVolume integration or deintegration.
By default it makes exclusive navtags, but instead, BotInitConfig::m_blockingNavTag
should be set as walkable and the TraverseLogic should forbid this navtag. New path or query to compute a path will be accepted by the Bot only once SetBlocking(false)
has been called and TagVolume been deintegrated. Otherwise, ComputeNewDestination will return KY_ERROR. BotOutput::IsPathRecomputationNeeded() will return true when TagVolume has been deintegrated if paths computation or injection were requested, so user can recompute them at this moment.
The path will not be recomputed after this call. The ChannelComputerConfig will be used by the next ComputeAStarAsync() calls.
The Trajectory will be recomputed the frame after this call.
void Kaim::WorldElement::SetCurrentVisualDebugLOD |
( |
VisualDebugLOD |
lod | ) |
|
|
inlineinherited |
Set the visual debug level of details to use for this WorldElement instance.
Generally, setting this to VisualDebugLOD_Minimal, sends almost nothing but position and status, whereas setting it to VisualDebugLOD_Maximal sends all available debug information including spatialization and some internal algorithm results.
void Kaim::Bot::SetDoComputeProgressOnPath |
( |
bool |
doUpdateProgressOnPath | ) |
|
When set to true, m_progressOnLivePath will be automatically updated in Bot::UpdatePathFollowing() based on a geometric criterion which is the bot crossing bisector line or plane (if in NavMesh or not) of the path edges.
When set to false, it is the user's responsibility to move it forward properly, m_progressOnLivePath's positionOnPath won't be updated at all! Beware to check GetProgressOnPathStatus(), this status will be maintained to let the user know if m_progressOnLivePath is totally invalidated. You can set this to false when the Bot enters a specific NavTag associated with a custom movement you want to control on your side (ex for SmartObjects: foors, ladders...) and that you want to get have m_progressOnLivePath to move accordingly to your logic instead of the geometrical criterion. Set to true by default.
void Kaim::Bot::SetDoComputeTrajectory |
( |
bool |
doComputeTrajectory | ) |
|
When set to false, the Bot will no more compute the Trajectory.
You can set this to false typically when the Bot enters a specific NavTag associated with a custom movement you want to control on your side (ex for SmartObjects: foors, ladders...). Set to true by default.
void Kaim::Bot::SetDoValidateCheckPoint |
( |
bool |
doValidateCheckPoint | ) |
|
|
inline |
When set to true, the Bot ProgressOnPath will be block at PathEvent CheckPoints until the IPositionOnPathValidator instance of the NavigationPofile returns true.
When set to false, the Bot will ignore PathEvent CheckPoints. You can set this to false typically when the Bot enters a specific NavTag associated with a custom movement you want to control on your side (ex for SmartObjects: foors, ladders...). However, the ProgressOnPath is still computed in order to keep track of the progression on the path if m_doComputeProgressOnPath. Set to true by default.
void Kaim::Bot::SetEnableAvoidance |
( |
bool |
enable | ) |
|
void Kaim::Bot::SetForceMinimizedSpatializationCoherency |
( |
bool |
forceMinimizeCoherency | ) |
|
|
inline |
By default, Spatialization coherency is maximized, you can force minimization here.
i.e. in order to maximized spatialization coherency, finding the Bot's new triangle is done based on the current triangle in a continuous manner with large altitude range (using Database::GetPositionSpatialisationRange()), this is the proper way to spatialized a Bot following a Path edge on NavMesh as expected. However, when following a Path edge out of NavMesh, particularly when going from NavMesh to NavMesh in a discontinuous manner e.g. transitioning from a floor to another floor via a graph, it is preferable not to favor triangles of the original floor, in that case the spatialization coherency is automatically minimized (the Bot SpatializationRange is reduced) So, it can be useful to call SetForceMinimizedSpatializationCoherency(true) temporarily to manually force minimization of spatialization coherency,
void Kaim::Bot::SetFrontDirection |
( |
const Vec2f & |
frontDirection | ) |
|
|
inline |
Optional: your entities might face a direction that is different from the velocity.
The frontDirection is expected to be a normalized vector.
void Kaim::Bot::SetHeight |
( |
KyFloat32 |
height | ) |
|
Height is only used to send the correct visualDebug.
void Kaim::Bot::SetLocalMaxCostMultiplierOnPathDistance |
( |
KyFloat32 |
localMaxCostMultiplierOnPathDistance | ) |
|
void Kaim::Bot::SetMaxDesiredLinearSpeed |
( |
KyFloat32 |
maxDesiredLinearSpeed | ) |
|
The Trajectory will be recomputed the frame after this call.
void Kaim::Bot::SetNewPathNavigationProfileId |
( |
KyUInt32 |
navigationProfileId | ) |
|
|
inline |
These functions are used to have the bot finding a Path very easily by only providing your AstarQuery and then the destination without going into the details of the different available Pathfinder queries and all their parameters.
As an helper, they are typically used during your first integration steps. Sets the NavigationProfile that will be used in the new ComputeAStarAsync() and InitAStarQuery() calls. SetNewPathToDestNavigationProfile() does not compute any new path, an explicit call to ComputeAStarAsync() is necessary.
void Kaim::Bot::SetPathFinderConfig |
( |
const PathFinderConfig & |
pathFinderConfig | ) |
|
The Path will not be recomputed after this call. The PathFinderConfig will be used by the next ComputeAStarAsync() calls.
The PathProgressConfig::m_pathValidationDistanceMinBackward and PathProgressConfig::m_pathValidationMinDistanceForward impact the computation of the events on the Path.
The PathEventList will be recomputed the frame after this call.
void Kaim::Bot::SetPosition |
( |
const Vec3f & |
position | ) |
|
|
inline |
These methods have to be called to update Bot position, velocity and front direction.
it has to be called each time the corresponding character is updated in the game engine. Note that for convenience velocity and frontDirection can be automatically computed from position and velocity respectively. As Autodesk Navigation never moves a bot, call this function to update the Bot position. It will also back up the position at World::Update into m_previousPosition
void Kaim::Bot::SetPositionAndVelocity |
( |
const Vec3f & |
position, |
|
|
KyFloat32 |
simulationTimeInSeconds |
|
) |
| |
|
inline |
For convenience, deduce velocity from previous position.
void Kaim::Bot::SetPositionAndVelocityAndFrontDirection |
( |
const Vec3f & |
position, |
|
|
KyFloat32 |
simulationTimeInSeconds |
|
) |
| |
|
inline |
For convenience, set position and deduce velocity from previous position as well as frontDirection.
void Kaim::Bot::SetRadius |
( |
KyFloat32 |
radius | ) |
|
Radius only impacts other surrounding bots avoidance.
If avoidance is computed every frame, there is nothing to do. If avoidance is computed some time to time then avoidance computation of all surrounding bots should theoritically be re-computed next frame.
The Trajectory will be recomputed the frame after this call.
The Trajectory will be recomputed the frame after this call.
Set the TrajectoryFailureMode, nothing in particular will be recomputed after this call.
void Kaim::Bot::SetTrajectoryMinimalMoveDistance |
( |
KyFloat32 |
trajectoryMinimalMoveDistance | ) |
|
Trajectory will be recomputed the frame after this call.
If the trajectory mode switches from TrajectoryMode_Shortcut to TrajectoryMode_Spline, this requires a path recompute that needs to be called explicitly by the user.
void Kaim::Bot::SetVelocity |
( |
const Vec3f & |
velocity | ) |
|
|
inline |
The actual velocity of your entity might differ from the one we gave you in the trajectory because of physics, animation, gameplay...
We use this velocity for avoidance purposes. The velocity must include the speed in meters per seconds.
void Kaim::Bot::SetVelocityAndFrontDirection |
( |
const Vec3f & |
velocity | ) |
|
|
inline |
For convenience, set velocity and deduce frontDirection from it.
The documentation for this class was generated from the following files:
- gwnavruntime/world/bot.h
- gwnavruntime/world/bot.cpp
- gwnavruntime/world/bot.inl