#include <navdata.h>
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.
Inherits Kaim::WorldElement.
Public Member Functions | |
enum | DatabaseStatus |
NavData (Database *database=0) | |
virtual | ~NavData () |
Database * | GetDatabase () const |
DatabaseStatus | GetDatabaseStatus () const |
const KyGuid * | GetMainGuid () 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 |
World * | GetWorld () 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) |
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).
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.
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.
|
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 |
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
|
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 |
KyResult Kaim::NavData::Load | ( | const char * | fileName, |
FileOpenerBase * | fileOpener = 0 |
||
) |
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.
void Kaim::NavData::SetBlobAggregate | ( | BlobAggregate * | BlobAggregate | ) |
|
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.