Kaim::NavData Class Reference

Kaim::NavData Class Reference

#include <navdata.h>

Class Description

The NavData class is the object containing navigation data that will be added to one Database.

Navigation data is the information Bots and other AI components use to understand the terrain and their movement opportunities. This is comprised ofNavMesh (abstract representations of the areas considered navigable) and NavGraph (abstract representations of the topology of the terrain).

To be usable by bots, for query processing or other AI components, a NavData must be added to a Database and be "alive" in this Database, which means the addition must be effectively done (that may take several frames in async mode).

Read-Only navigation data (NavMeshElementBlob, NavGraphBlob, ...) are store within a BlobAggregate that can be shared through several instances of NavData in a multi World scenario with memory sharing. In this case, create one BlobAggregate for use in all worlds, then create a NavData object for each world where the NavData will be used. In a singleWorld scenario or multi World without memory sharing, use this class directly, do not use BlobAggregate.

The NavData class offers a mechanism for loading data from a .NavData files created by the Gameware Navigation Generation framework.

+ Examples:

Inherits Kaim::WorldElement.

Public Member Functions

enum  DatabaseStatus
 
 NavData (Database *database=0)
 
virtual ~NavData ()
 
DatabaseGetDatabase () const
 
DatabaseStatus GetDatabaseStatus () const
 
const KyGuidGetMainGuid () const
 
const String & GetSectorName () const
 
const String & GetGeneratorRelativeOutputDirectory () const
 

Memory loading or sharing Functions

KyResult Load (const char *fileName, FileOpenerBase *fileOpener=0)
 
KyResult Load (File *file)
 
KyResult LoadFromMemory (void *memory)
 
KyResult Save (const char *fileName, FileOpenerBase *fileOpener=0, Endianness::Type endianness=Endianness::BigEndian)
 
void SetBlobAggregate (BlobAggregate *BlobAggregate)
 

Main API Functions

KyResult Init (Database *database)
 
KyResult AddNavGraph (NavGraphBlobBuilder *navGraphBlobBuilder)
 
KyResult AddToDatabaseAsync ()
 
KyResult RemoveFromDatabaseAsync ()
 
KyResult AddToDatabaseImmediate ()
 
KyResult RemoveFromDatabaseImmediate ()
 
bool IsAliveInDatabase () const
 
bool IsCompatibleWith (const NavData &navData) const
 

Main API Functions

bool IsAddedToWorld () const
 
WorldGetWorld () const
 
KyUInt32 GetVisualDebugId () const
 
void * GetUserData () const
 
void SetUserData (void *userData)
 

Visual Debug

void SetCurrentVisualDebugLOD (VisualDebugLOD lod)
 
VisualDebugLOD GetCurrentVisualDebugLOD () const
 
VisualDebugLOD GetPreviousVisualDebugLod () const
 
void SendVisualDebug (VisualDebugServer &server)
 
void ForceSendAllVisualDebug ()
 

For internal use only

void SendForMaxLevelOfDetail (VisualDebugServer &server, const Vec3f &shapePosition)
 
void RegisterToVisualDebug ()
 
void UnRegisterFromVisualDebug ()
 
KyUInt32 GetIndexInCollection () const
 
void SetIndexInCollection (KyUInt32 indexInCollection)
 

Member Enumeration Documentation

Enumerates the different status a NavData can have in one Database.

Note that when a NavData is effectively removed from a Database, its status is set to NotReferencedInAnyDatabase

Member Function Documentation

KyResult Kaim::NavData::AddNavGraph ( NavGraphBlobBuilder navGraphBlobBuilder)

This function creates and add a NavGraphBlob to the BlobAggregate of this NavData.

If no BlobAggregate is present, one will be created (which means you can add a NavGraph to an empty NavData).

Precondition
ThisNavData must not have been added to a Database, or completely removed from the Database.
+ Examples:
KyResult Kaim::NavData::AddToDatabaseAsync ( )

This function does not modify the alive NavData in the Database immediately, the NavData won't be immediately alive in the Database and associated NavMesh/NavGraph won't be immediately "activated".

This will be done asynchronously during the the next calls to World::Update().

The addition of a NavaData is effectively done when GetDatabaseStatus()==AddedToDabase.

If you want the NavData to be immediately and effectively added, use AddToDatabaseImmediate() instead.

It increments this->RefCount It returns KY_ERROR if the NavData has no chance to be successfully added to the Database.

KY_SUCCESS otherwise, check m_databaseStatus to know when it is effectively alive in the database.

+ Examples:
KyResult Kaim::NavData::AddToDatabaseImmediate ( )

Add the NavData to the Database outside the World::Update().

The NavData addition is fully performed and the NavData becomes alive in the Database just after this call.

It must not be used when you have some asynchronousQuery running outside the World::Update().

It must not be used if you have called AddToDatabaseAsync() or RemoveFromDatabaseAsync() with other NavData.

As this function calls for an immediate update of the database, it can cause CPU peaks.

It increments this->RefCount It returns KY_SUCCESS if the NavData is successfully added to the database. KY_ERROR otherwise.

+ Examples:
void Kaim::WorldElement::ForceSendAllVisualDebug ( )
inherited

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).

const String& Kaim::NavData::GetGeneratorRelativeOutputDirectory ( ) const

Returns the relative output directory used to load the file when visual debugging.

Typically, it is provided to the generator when this NavData was built

const KyGuid* Kaim::NavData::GetMainGuid ( ) const

Gives the Guid used to identify the NavMesh contained in this NavData.

return KY_NULL if no NavMesh is contained, SectorName will be used instead for identifying the NavData.

const String& Kaim::NavData::GetSectorName ( ) const

Returns the Name passed to Kaim::GeneratorSector.

Used for VisualDebug to access the NavData and ClientInput files.

Used for VisualDebug to access the NavData and ClientInput files.

It is used to identify .NavData files containing only NavGraphs

KyResult Kaim::NavData::Init ( Database database)

Associates current instance to a Database.

This function may return KY_ERROR if the current instance of NavData has already been added to a Database.

If a valid Database is passed to the constructor, you do not need to call this function.

+ Examples:
bool Kaim::NavData::IsAliveInDatabase ( ) const
inline

Indicates whether the specified NavData has been effectively added to the Database and not effectively removed yet from the Database.

That means that, through the Database, it will be used for Query processing and Bot PathFollowing, etc...

It corresponds to these 3 DatabaseStatus : AddedToDabase_Alive, ToBeRemoved_Alive, BeingRemoved_Alive.

bool Kaim::NavData::IsCompatibleWith ( const NavData navData) const

Indicates whether the specified NavData was created with the same generation parameters as this object.

If this method returns true, the two NavData objects can be loaded into the same Database at the same time.

KyResult Kaim::NavData::Load ( const char *  fileName,
FileOpenerBase fileOpener = 0 
)

To use in single World scenario, or multi world scenario without NavData memory sharing.

Must be called before adding the NavData to its associated Database.

+ Examples:
KyResult Kaim::NavData::RemoveFromDatabaseAsync ( )

This function does not modify the alive NavData in the Database immediately.

The NavData won't be immediately removed from the database and associated NavMesh/NavGraph won't be immediately "de-activated". This will done asynchronously during the the next calls to World::Update().

The removal of a NavaData is effectively done when GetDatabaseStatus()==NotReferencedInAnyDatabase.

If you want the NavData to be immediately and effectively removed, use RemoveFromDatabaseImmediate() instead.

It may decrements this->RefCount

KyResult Kaim::NavData::RemoveFromDatabaseImmediate ( )

Remove the NavData from the Database outside the World::Update().

The NavData removal is fully performed and the NavData is nor more alive in the Database after this call.

It must not be used when you have some asynchronousQuery running outside the World::Update().

It must not be used if you have called AddToDatabaseAsync() or RemoveFromDatabaseAsync() with other NavData.

As this function calls for an immediate update of the database, it can cause CPU peaks.

It decrements this->RefCount

KyResult Kaim::NavData::Save ( const char *  fileName,
FileOpenerBase fileOpener = 0,
Endianness::Type  endianness = Endianness::BigEndian 
)

This function is here to save a graph-only NavData, at runtime or in Generation Post Process.

(This function should probably be called SaveGraphOnlyNavData.) Note that it forces m_sectorName to be the simple filename without extension.

+ Examples:
void Kaim::NavData::SetBlobAggregate ( BlobAggregate *  BlobAggregate)

To use in multi World scenario with NavData memory sharing.

Must be called before adding the NavData to its associated Database.

+ Examples:
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.


The documentation for this class was generated from the following file: