Kaim::World Class Reference

Kaim::World Class Reference

#include <world.h>

Class Description

Inherits Kaim::RefCountBaseNTS< C, Stat >.

Main API Functions

 World (KyUInt32 databaseCount=1)
 
virtual ~World ()
 
void SetUserData (void *userData)
 
void * GetUserData ()
 

Update

void Update (KyFloat32 simulationTimeInSeconds=0.016f)
 Updates the World. More...
 
KyUInt32 GetUpdateCount () const
 Retrieves the number of times Update() has been called. More...
 

VisualDebug

Returns statistics on CPU consumption during Update() and its steps.

With KY_CONFIG_RELEASE, it returns nullptr;

KyResult StartVisualDebug (const VisualDebugServerConfig &visualDebugServerConfig)
 VisualDebugging is only enabled with KY_CONFIG_DEBUG and KY_CONFIG_DEV With KY_CONFIG_RELEASE, functions related to VisualDebugging are replaced by empty inlined functions for convenience, However, it can still be judicious to guard your own code that uses VisualDebugging with a check against KY_CONFIG_RELEASE. More...
 
void StopVisualDebug ()
 
void NewVisualDebugFrame (KyUInt32 gameFrameIndex=0xFFFFFFFF)
 
VisualDebugServer * GetVisualDebugServer ()
 
VisualDebugRegistry * GetElementRegistry ()
 Returns the registry in this World of instances of WorldElement that can be visually debugged in the Navigation Lab. More...
 
DisplayListManagerGetDisplayListManager ()
 Get the DisplayListManager that is required when creating a DisplayList. More...
 
VisualDebugAttributesManager * GetAttributesManager ()
 Get the attributesManager that is required when creating an attribute group. More...
 

WorldElement Getters

KyUInt32 GetDatabasesCount () const
 
DatabaseGetDatabase (KyUInt32 index)
 
KyUInt32 GetPointsOfInterestCount () const
 
PointOfInterestGetPointOfInterest (KyUInt32 index)
 
KyUInt32 GetCylinderObstaclesCount () const
 
CylinderObstacleGetCylinderObstacle (KyUInt32 index)
 
KyUInt32 GetBoxObstaclesCount () const
 
BoxObstacleGetBoxObstacle (KyUInt32 index)
 
KyUInt32 GetTagVolumesCount () const
 
KyUInt32 GetTagVolumesToBeIntegratedCount () const
 
KyUInt32 GetTagVolumesIntegratedCount () const
 
KyUInt32 GetTagVolumesToBeRemovedCount () const
 
TagVolumeGetTagVolumesToBeIntegrated (KyUInt32 index)
 
TagVolumeGetTagVolumesIntegrated (KyUInt32 index)
 
TagVolumeGetTagVolumesToBeRemoved (KyUInt32 index)
 
KyUInt32 GetQueryQueueArraysCount () const
 
QueryQueueArrayGetQueryQueueArray (KyUInt32 index)
 
KyUInt32 GetQueryPendingOperationCount () const
 

NavigationProfile

KyUInt32 AddNavigationProfile (Ptr< BaseNavigationProfile > navigationProfile)
 
Ptr< BaseNavigationProfileGetNavigationProfile (KyUInt32 profileId)
 

Async Queries

void SetAsyncQueryDispatcher (IAsyncQueryDispatcher *asyncQueryDispatcher)
 Set a new IAsyncQueryDispatcher instance to be used by this World: More...
 
IAsyncQueryDispatcherGetAsyncQueryDispatcher ()
 
void PushAsyncQuery (IQuery *query, AsyncQueryDispatchId asyncQueryDispatchId=AsyncQueryDispatchId_Default, Bot *bot=nullptr)
 Pushes an IQuery in the right QueryQueue accordingly to World's IAsyncQueryDispatcher. More...
 
void CancelAsyncQuery (IQuery *query)
 This function should be called only for queries currently in a query queue which can be checked by calling query->IsInAQueryQueue(). More...
 
void ProcessQueuesOutsideWorldUpdate ()
 
void SetWorldUpdateThreadId (ThreadId threadId)
 
ThreadId GetWorldUpdateThreadId () const
 

RemoveAll...

void RemoveAndCancellAll ()
 Remove all Bots, PointOfInterest, CylinderObstacles, BoxObstacles, TagVolumes, and NavData; and cancel all queries. More...
 
void RemoveAllBots ()
 
void RemoveAllPointsOfInterest ()
 
void RemoveAllCylinderObstacles ()
 
void RemoveAllBoxObstacles ()
 
void RemoveAllTagVolumes ()
 
void ClearDatabase (KyUInt32 databaseIndex)
 

Specific optimization to the ShortcutTrajectory

KyUInt32 GetNumberOfFramesForShortcutTrajectoryPeriodicUpdate () const
 Theses functions are only useful for bots with ShortcutTrajectory. More...
 
void SetNumberOfFramesForShortcutTrajectoryPeriodicUpdate (KyUInt32 numberOfFrames)
 Set the number of frames between two updates of the PathFollowing for all bots with TrajectoryMode_Shortcut. More...
 

Specific optimization

void ForceClearWorkingMemory ()
 Cancel all queries and only free WorkingMemory for all databases and query queues owned by this world. More...
 

For internal use only

void * m_userData
 
KyArray< Ptr< BaseNavigationProfile > > m_navigationProfiles
 
KyUInt32 m_updateCount
 
KyUInt32 m_nbFramesForShortcutTrajectoryPeriodicUpdate
 
KyUInt32 m_databaseCount
 
KyArray< Ptr< Database >, MemStat_WorldFwk > m_databases
 
Ptr< DatabaseBindingm_allDatabaseBinding
 
Ptr< CollisionWorldm_collisionWorld
 
TrackedCollection< Ptr< PointOfInterest >, MemStat_PointOfInterest > m_pointsOfInterests
 
TrackedCollection< Ptr< CylinderObstacle >, MemStat_CylinderObstacle > m_cylinderObstacles
 
TrackedCollection< Ptr< BoxObstacle >, MemStat_BoxObstacle > m_boxObstacles
 
TrackedCollection< Ptr< QueryQueueArray >, MemStat_QuerySystem > m_queryQueueArrays
 
TrackedCollection< Ptr< TagVolume >, MemStat_TagVolume > m_tagVolumesToBeIntegrated
 
TrackedCollection< Ptr< TagVolume >, MemStat_TagVolume > m_tagVolumesIntegrated
 
TrackedCollection< Ptr< TagVolume >, MemStat_TagVolume > m_tagVolumesToBeRemoved
 
WorldElementSpatializer * m_worldElementSpatializer
 
Ptr< BaseNavigationProfilem_defaultNavigationProfile
 
Ptr< BotConfigm_defaultPathFollowerConfig
 
VisualDebugServerConfig m_visualDebugServerConfig
 
VisualDebugServer * m_visualDebugServer
 
bool m_wasConnected
 
DisplayListManagerm_displayListManager
 
VisualDebugRegistry * m_visualDebugRegistry
 
VisualDebugAttributesManager * m_visualDebugAttributesManager
 
WorldStatistics * m_statistics
 
DatabaseUpdateManager * m_databaseUpdateManager
 
AvoidanceWorkspace m_avoidanceWorkspace
 
Ptr< IAsyncQueryDispatcherm_asyncQueryDispatcher
 
bool m_isInWorldUpdate
 
ThreadId m_worldUpdateThreadId
 

Constructor & Destructor Documentation

Kaim::World::World ( KyUInt32  databaseCount = 1)
explicit
Parameters
databaseCountThe number of databases added to this world, must be greater than or equal to 1.

Member Function Documentation

void Kaim::World::CancelAsyncQuery ( IQuery query)

This function should be called only for queries currently in a query queue which can be checked by calling query->IsInAQueryQueue().

void Kaim::World::ForceClearWorkingMemory ( )

Cancel all queries and only free WorkingMemory for all databases and query queues owned by this world.

Be sure that all of your object relying on command not processed yet handle cancellation properly (cf QueryProcessStatus::QueryCanceled) . Fully processed queries will get their IOnDone::OnDone called.

VisualDebugAttributesManager * Kaim::World::GetAttributesManager ( )
inline

Get the attributesManager that is required when creating an attribute group.

BoxObstacle * Kaim::World::GetBoxObstacle ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
CylinderObstacle * Kaim::World::GetCylinderObstacle ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
DisplayListManager * Kaim::World::GetDisplayListManager ( )
inline
VisualDebugRegistry * Kaim::World::GetElementRegistry ( )
inline

Returns the registry in this World of instances of WorldElement that can be visually debugged in the Navigation Lab.

KyUInt32 Kaim::World::GetNumberOfFramesForShortcutTrajectoryPeriodicUpdate ( ) const
inline

Theses functions are only useful for bots with ShortcutTrajectory.

It allows to skip ProgressOnPath and ShortcutTrajectory computations that are usually done each frame. Note that on some events the bot can be updated more often than the given number. For instance, if changes occur on the Path or to be sure not to miss its current target. Gives the number of frames between two updates of the PathFollowing for each bot.

PointOfInterest * Kaim::World::GetPointOfInterest ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
QueryQueueArray * Kaim::World::GetQueryQueueArray ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
TagVolume * Kaim::World::GetTagVolumesIntegrated ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
TagVolume * Kaim::World::GetTagVolumesToBeIntegrated ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
TagVolume * Kaim::World::GetTagVolumesToBeRemoved ( KyUInt32  index)
inline
Precondition
index must be valid, we don't check it there.
KyUInt32 Kaim::World::GetUpdateCount ( ) const
inline

Retrieves the number of times Update() has been called.

void Kaim::World::PushAsyncQuery ( IQuery query,
AsyncQueryDispatchId  asyncQueryDispatchId = AsyncQueryDispatchId_Default,
Bot bot = nullptr 
)

Pushes an IQuery in the right QueryQueue accordingly to World's IAsyncQueryDispatcher.

void Kaim::World::RemoveAndCancellAll ( )

Remove all Bots, PointOfInterest, CylinderObstacles, BoxObstacles, TagVolumes, and NavData; and cancel all queries.

void Kaim::World::SetAsyncQueryDispatcher ( IAsyncQueryDispatcher asyncQueryDispatcher)

Set a new IAsyncQueryDispatcher instance to be used by this World:

void Kaim::World::SetNumberOfFramesForShortcutTrajectoryPeriodicUpdate ( KyUInt32  numberOfFrames)
inline

Set the number of frames between two updates of the PathFollowing for all bots with TrajectoryMode_Shortcut.

Default value is 1 in order to get an update each frame. If 0 is passed, it is defaulted to 1. For instance, by setting a value of 5, UpdateBotPathFollowing will call the ProgressOnPathComputer and the Trajectory one frame on 5, this will make UpdateBotPathFollowing being around 3 times faster since the number of RayCanGo used to maintained the TargetOnPathStatus is exactly divided by 5, but some other components are already skipping some frames, hence their cost is not divided by 5.

KyResult Kaim::World::StartVisualDebug ( const VisualDebugServerConfig visualDebugServerConfig)

VisualDebugging is only enabled with KY_CONFIG_DEBUG and KY_CONFIG_DEV With KY_CONFIG_RELEASE, functions related to VisualDebugging are replaced by empty inlined functions for convenience, However, it can still be judicious to guard your own code that uses VisualDebugging with a check against KY_CONFIG_RELEASE.

Starts the visual debug server. You can start it at any time.

+ Examples:
void Kaim::World::Update ( KyFloat32  simulationTimeInSeconds = 0.016f)

Updates the World.

It is possible to use Autodesk Navigation as a NavMesh/NavGraph Query toolbox without calling World::Update(). But to easily support Bots, obstacles, DynamicNavMesh, etc., a World::Update() call is required every frame.

+ Examples:

The documentation for this class was generated from the following files:
  • gwnavruntime/world/world.h
  • gwnavruntime/world/world.cpp