class

NavMeshAsset

Baked navigation mesh. Owns: - The serialized Detour blob (m_blob) — what gets written to disk and re-loaded on scene open. - A live dtNavMesh built from that blob (m_navMesh) — what queries run against. - A shared dtNavMeshQuery handle wrapping the nav mesh (m_query). - Debug-viz triangles (m_triangles) for editor overlay.

Module
AINavigation
Header
#include "AINavigation/NavMeshAsset.h"
Namespace
Mowo

Memory ownership: the blob bytes are also passed to dtNavMesh::init (DT_TILE_FREE_DATA), so on Unload Detour frees them — we must NOT free m_blob ourselves once it's been handed off. The pre-handoff "rejected" path (init failure) does free.

Constructors

SignatureNameDescription
NavMeshAsset() = defaultNavMeshAsset
~NavMeshAsset() override~NavMeshAsset

Public functions

ReturnsNameDescription
boolLoadAsset interface
voidUnload
boolCreateGPU
boolIsBaked
dtNavMesh*GetNavMesh
dtNavMeshQuery*GetNavMeshQuery
dtTileCache*GetTileCache
boolHasDynamicObstacles
const std::vector<NavMeshTriangle>&GetTrianglesDebug viz
Vec3GetBoundsMin
Vec3GetBoundsMax
const NavMeshBakeSettings&GetBakeSettings
boolSetFromBakedDataPopulation (called by NavMeshBuilder after a successful bake) Takes ownership of navData — the bytes are handed to dtNavMesh with DT_TILE_FREE_DATA so Detour owns them after this call.
boolSetFromTiledNavMeshTiled bake variant: takes a pre-built multi-tile dtNavMesh and adopts it.
boolSetFromTileCacheDynamic-obstacle variant: adopts both the live dtNavMesh and the dtTileCache that owns the compressed-layer storage.
voidClearDrop everything — frees query, nav mesh (Detour also frees the blob), debug triangles and the agent variants.
voidSetAgentVariantNavmeshes for the other agent types in the bake settings.
Ref<NavMeshAsset>GetAgentVariant
const std::vector<FNavAgentVariant>&GetAgentVariants
std::stringAgentTypeNameThe name of the agent type settings bakes for ("Default" when the scene lists none).
voidSetAgentNameThe agent type this mesh was baked for.
std::stringGetAgentName
voidAppendDebugTrisAppend more debug-viz tris to the existing buffer.
boolSaveToFileDisk I/O (custom .navmesh blob — versioned magic + Detour bytes + bounds + debug tris).

Function details

C++
NavMeshAsset() = default
C++
~NavMeshAsset() override

Load

C++
bool Load(const std::string& path) override

Asset interface

Unload

C++
void Unload() override

CreateGPU

C++
bool CreateGPU(const GPUContext& ctx) override

IsBaked

C++
bool IsBaked() const

GetNavMesh

C++
dtNavMesh* GetNavMesh() const

GetNavMeshQuery

C++
dtNavMeshQuery* GetNavMeshQuery() const

GetTileCache

C++
dtTileCache* GetTileCache() const

HasDynamicObstacles

C++
bool HasDynamicObstacles() const

GetTriangles

C++
const std::vector<NavMeshTriangle>& GetTriangles() const

Debug viz

GetBoundsMin

C++
Vec3 GetBoundsMin() const

GetBoundsMax

C++
Vec3 GetBoundsMax() const

GetBakeSettings

C++
const NavMeshBakeSettings& GetBakeSettings() const

SetFromBakedData

C++
bool SetFromBakedData(unsigned char* navData, int navDataSize, std::vector<NavMeshTriangle> debugTris, Vec3 boundsMin, Vec3 boundsMax, NavMeshBakeSettings settings)

Population (called by NavMeshBuilder after a successful bake) Takes ownership of navData — the bytes are handed to dtNavMesh with DT_TILE_FREE_DATA so Detour owns them after this call. Used by the solo-mesh bake (single tile).

SetFromTiledNavMesh

C++
bool SetFromTiledNavMesh(dtNavMesh* navMesh, std::vector<NavMeshTriangle> debugTris, Vec3 boundsMin, Vec3 boundsMax, NavMeshBakeSettings settings)

Tiled bake variant: takes a pre-built multi-tile dtNavMesh and adopts it. The mesh's tiles already carry DT_TILE_FREE_DATA, so dtFreeNavMesh in Clear/dtor releases them. Caller must not touch navMesh after this returns true (we own it).

SetFromTileCache

C++
bool SetFromTileCache(dtNavMesh* navMesh, dtTileCache* tileCache, std::vector<NavMeshTriangle> debugTris, Vec3 boundsMin, Vec3 boundsMax, NavMeshBakeSettings settings)

Dynamic-obstacle variant: adopts both the live dtNavMesh and the dtTileCache that owns the compressed-layer storage. NavAgentSystem ticks the cache each frame; NavMeshObstacleSystem talks to it when components are added / moved / destroyed. Caller must not touch either pointer after this returns true.

Clear

C++
void Clear()

Drop everything — frees query, nav mesh (Detour also frees the blob), debug triangles and the agent variants.

SetAgentVariant

C++
void SetAgentVariant(const std::string& agentName, float agentRadius, Ref<NavMeshAsset> nav)

Navmeshes for the other agent types in the bake settings. The primary is the active agent type; NavAgentSystem runs one crowd per variant.

GetAgentVariant

C++
Ref<NavMeshAsset> GetAgentVariant(const std::string& agentName) const

GetAgentVariants

C++
const std::vector<FNavAgentVariant>& GetAgentVariants() const

AgentTypeName

C++
static std::string AgentTypeName(const NavMeshBakeSettings& settings)

The name of the agent type settings bakes for ("Default" when the scene lists none).

SetAgentName

C++
void SetAgentName(const std::string& name)

The agent type this mesh was baked for. The .navmesh file does not carry the scene's agent list, so a loader that knows it names the mesh; otherwise it reads from the bake settings.

GetAgentName

C++
std::string GetAgentName() const

AppendDebugTris

C++
void AppendDebugTris(std::vector<NavMeshTriangle> more)

Append more debug-viz tris to the existing buffer. Used by partial rebakes that want to add the newly-baked tile tris on top of the asset's existing display set.

SaveToFile

C++
bool SaveToFile(const std::string& vfsPath) const

Disk I/O (custom .navmesh blob — versioned magic + Detour bytes + bounds + debug tris). VFS-friendly: same path the Asset system hands us in Load().

Generated from AINavigation/NavMeshAsset.h via ainavigation.json · Oct 27, 2026Version 1.0.0