NavAgentSystem
Steers every NavAgentComponent toward its destination each frame.
- Module
- AINavigation
- Header
#include "AINavigation/NavAgentSystem.h"- Namespace
Mowo
Three operating modes, picked automatically based on what's available:
-
NavMesh + dtCrowd (preferred): one dtCrowd manages every agent. Avoidance, anticipation, and separation are handled by Detour. Per-tick we feed destinations in and read back positions — agents push around each other instead of overlapping.
-
NavMesh, no crowd (initialization failure path): fall back to single-agent Detour findPath + findStraightPath path-follow. No agent-to-agent avoidance.
-
No NavMesh: straight-line steering at agent.speed, ignoring everything. Same behavior the Scope-A skeleton had — keeps the system functional in unbaked scenes.
Type aliases
| Alias | Description |
|---|---|
using FSmartLinkHandler = std::function<void(const FSmartLinkEvent&)> |
Constructors
| Signature | Name | Description |
|---|---|---|
~NavAgentSystem() override | ~NavAgentSystem |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | DeclaresComponentAccess | Writes TransformComponent (direct steering + facing), so it serializes against every other Transform producer — that ordering is the point of declaring. |
ComponentMask | GetReadMask | |
ComponentMask | GetWriteMask | |
uint32_t | GetResourceWriteMask | A dtNavMeshQuery carries its own search state, so a path query is a write. |
void | Initialize | |
void | Shutdown | |
void | Update | |
void | SetNavMesh | Wired by Scene::SetNavMesh on bake / load / clear. |
Ref<NavMeshAsset> | GetNavMesh | |
Ref<NavMeshAsset> | GetNavMeshForAgent | The navmesh baked for this agent's size: its Agent Type by name, else the smallest baked radius it fits, else the widest. |
size_t | GetCrowdLaneCount | |
float | QueryPathLength | Length of the nav path from start to end along its waypoints, or a negative number when there is no nav mesh or no path — what an environment query's Pathfind test measures. |
bool | ProjectPoint | Nearest navmesh point under/over point: within half a metre horizontally and verticalExtent vertically. |
void | CollectReachablePoints | Centres of the polygons reachable from center within radius of path cost (Dijkstra over the navmesh), at most maxPoints of them. |
uint32_t | RequestPathAsync | |
uint32_t | RequestPathAsync | |
EPathRequestState | TakePathResult | Ready or Failed hands the result over (waypoints for Ready) and forgets the request; Pending leaves it queued; Unknown = no such request. |
void | CancelPathRequest | |
uint32_t | ProcessPathRequests | One budgeted pass over the queue; returns the search iterations spent. |
uint32_t | GetPendingPathRequestCount | |
uint32_t | AddSmartLinkHandler | |
void | RemoveSmartLinkHandler | |
const std::vector<FSmartLinkEvent>& | GetSmartLinkEvents | |
void | SyncLinks | |
size_t | GetStreamedTileCount | |
size_t | GetResidentStreamedTileCount | |
int32_t | AcquireFilterSlot |
Function details
~NavAgentSystem
~NavAgentSystem() overrideDeclaresComponentAccess
bool DeclaresComponentAccess() const overrideWrites TransformComponent (direct steering + facing), so it serializes against every other Transform producer — that ordering is the point of declaring.
GetReadMask
ComponentMask GetReadMask() const overrideGetWriteMask
ComponentMask GetWriteMask() const overrideGetResourceWriteMask
uint32_t GetResourceWriteMask() const overrideA dtNavMeshQuery carries its own search state, so a path query is a write.
Initialize
void Initialize(World* world) overrideShutdown
void Shutdown() overrideUpdate
void Update(float deltaTime) overrideSetNavMesh
void SetNavMesh(Ref<NavMeshAsset> nav)Wired by Scene::SetNavMesh on bake / load / clear. Rebuilds the dtCrowd whenever the underlying nav mesh changes — every agent re-adds itself on the next Update tick.
GetNavMesh
Ref<NavMeshAsset> GetNavMesh() constGetNavMeshForAgent
Ref<NavMeshAsset> GetNavMeshForAgent(const NavAgentComponent& agent) constThe navmesh baked for this agent's size: its Agent Type by name, else the smallest baked radius it fits, else the widest. The primary mesh when the scene carries no agent variants.
GetCrowdLaneCount
size_t GetCrowdLaneCount() constQueryPathLength
float QueryPathLength(const Vec3& start, const Vec3& end)Length of the nav path from start to end along its waypoints, or a negative number when there is no nav mesh or no path — what an environment query's Pathfind test measures.
ProjectPoint
bool ProjectPoint(const Vec3& point, float verticalExtent, Vec3& outProjected)Nearest navmesh point under/over point: within half a metre horizontally and verticalExtent vertically. False when no polygon is there — the point hangs in the air or sits inside a wall.
CollectReachablePoints
void CollectReachablePoints(const Vec3& center, float radius, int32_t maxPoints, std::vector<Vec3>& out)Centres of the polygons reachable from center within radius of path cost (Dijkstra over the navmesh), at most maxPoints of them.
RequestPathAsync
uint32_t RequestPathAsync(const Vec3& start, const Vec3& end, int32_t priority = 0)RequestPathAsync
uint32_t RequestPathAsync(const Vec3& start, const Vec3& end, int32_t priority, const FNavQueryFilterSpec& filter)TakePathResult
EPathRequestState TakePathResult(uint32_t requestId, std::vector<Vec3>& outWaypoints)Ready or Failed hands the result over (waypoints for Ready) and forgets the request; Pending leaves it queued; Unknown = no such request.
CancelPathRequest
void CancelPathRequest(uint32_t requestId)ProcessPathRequests
uint32_t ProcessPathRequests(uint32_t iterationBudget)One budgeted pass over the queue; returns the search iterations spent. Update calls it with the cvar budget; public so a driver can run the queue on its own clock.
GetPendingPathRequestCount
uint32_t GetPendingPathRequestCount() constAddSmartLinkHandler
uint32_t AddSmartLinkHandler(FSmartLinkHandler handler)RemoveSmartLinkHandler
void RemoveSmartLinkHandler(uint32_t handle)GetSmartLinkEvents
const std::vector<FSmartLinkEvent>& GetSmartLinkEvents() constSyncLinks
void SyncLinks()GetStreamedTileCount
size_t GetStreamedTileCount() constGetResidentStreamedTileCount
size_t GetResidentStreamedTileCount() constAcquireFilterSlot
static int32_t AcquireFilterSlot(std::vector<FNavQueryFilterSpec>& slots, const FNavQueryFilterSpec& spec, int32_t maxSlots)