A baked navigation mesh used for pathfinding and obstacle simulation.
More...
#include <knavmesh.h>
|
| | kNavMesh () |
| | Constructs an empty, unbaked navigation mesh.
|
| | ~kNavMesh () |
| | Destroys the navmesh and releases all baked Recast/Detour data.
|
| bool | bake (const std::vector< float > &verts, const std::vector< int > &tris, const kNavBuildConfig &config={}, const std::vector< kNavLink > &links={}) |
| | Builds the navigation mesh from raw triangle geometry.
|
| void | clear () |
| | Destroys the baked data and resets to an unbaked state.
|
| bool | isBaked () const |
| | Returns true if the mesh has been successfully baked.
|
| std::vector< kVec3 > | findPath (const kVec3 &start, const kVec3 &end, int maxPoints=256) const |
| | Finds a smoothed path along the navmesh from start to end.
|
| kVec3 | findNearestPoint (const kVec3 &pos, const kVec3 &extents=kVec3(2.f, 4.f, 2.f)) const |
| | Finds the nearest point on the navmesh surface to pos.
|
| bool | isPointOnMesh (const kVec3 &pos, const kVec3 &extents=kVec3(2.f, 4.f, 2.f)) const |
| | Returns true if pos is on (or very near) the navmesh.
|
| void | getDebugLines (std::vector< kVec3 > &outSegments) const |
| | Extracts the navmesh surface as world-space line segments for debug visualisation (wireframe).
|
| void * | getNavMesh () const |
| | Returns the internal dtNavMesh pointer (opaque).
|
| void * | getNavMeshQuery () const |
| | Returns the internal dtNavMeshQuery pointer (opaque).
|
| void * | getTileCache () const |
| | Returns the internal dtTileCache pointer (null for non-tiled builds).
|
A baked navigation mesh used for pathfinding and obstacle simulation.
Create one kNavMesh per scene. Call bake() with your world geometry, then pass the mesh to kNavManager::init() to drive agents and obstacles.
std::vector<float> verts;
std::vector<int> tris;
nav->
bake(verts, tris, cfg);
kNavMesh()
Constructs an empty, unbaked navigation mesh.
std::vector< kVec3 > findPath(const kVec3 &start, const kVec3 &end, int maxPoints=256) const
Finds a smoothed path along the navmesh from start to end.
bool bake(const std::vector< float > &verts, const std::vector< int > &tris, const kNavBuildConfig &config={}, const std::vector< kNavLink > &links={})
Builds the navigation mesh from raw triangle geometry.
All parameters that control the Recast bake pipeline.
Definition knavmesh.h:44
float agentRadius
Agent cylinder radius (m).
Definition knavmesh.h:51
◆ kNavMesh()
| kemena::kNavMesh::kNavMesh |
( |
| ) |
|
Constructs an empty, unbaked navigation mesh.
◆ ~kNavMesh()
| kemena::kNavMesh::~kNavMesh |
( |
| ) |
|
Destroys the navmesh and releases all baked Recast/Detour data.
◆ bake()
| bool kemena::kNavMesh::bake |
( |
const std::vector< float > & | verts, |
|
|
const std::vector< int > & | tris, |
|
|
const kNavBuildConfig & | config = {}, |
|
|
const std::vector< kNavLink > & | links = {} ) |
Builds the navigation mesh from raw triangle geometry.
- Parameters
-
| verts | Flat vertex buffer: x0,y0,z0, x1,y1,z1, ... |
| tris | Flat index buffer: i0,i1,i2, i3,i4,i5, ... |
| config | Voxelisation and agent parameters. |
| links | Optional off-mesh connections (ladders, jumps, …). |
- Returns
- true on success.
◆ clear()
| void kemena::kNavMesh::clear |
( |
| ) |
|
Destroys the baked data and resets to an unbaked state.
◆ findNearestPoint()
| kVec3 kemena::kNavMesh::findNearestPoint |
( |
const kVec3 & | pos, |
|
|
const kVec3 & | extents = kVec3(2.f, 4.f, 2.f) ) const |
Finds the nearest point on the navmesh surface to pos.
- Parameters
-
| extents | Half-extents of the AABB search region. |
- Returns
- Snapped position, or
pos unchanged if nothing is found.
◆ findPath()
| std::vector< kVec3 > kemena::kNavMesh::findPath |
( |
const kVec3 & | start, |
|
|
const kVec3 & | end, |
|
|
int | maxPoints = 256 ) const |
Finds a smoothed path along the navmesh from start to end.
- Parameters
-
| maxPoints | Maximum number of waypoints in the returned path. |
- Returns
- World-space waypoints from start to end. Empty if unreachable.
◆ getDebugLines()
| void kemena::kNavMesh::getDebugLines |
( |
std::vector< kVec3 > & | outSegments | ) |
const |
Extracts the navmesh surface as world-space line segments for debug visualisation (wireframe).
- Parameters
-
| outSegments | Filled with pairs of points; each consecutive pair (0,1), (2,3), … is one line. Cleared first. |
◆ getNavMesh()
| void * kemena::kNavMesh::getNavMesh |
( |
| ) |
const |
Returns the internal dtNavMesh pointer (opaque).
◆ getNavMeshQuery()
| void * kemena::kNavMesh::getNavMeshQuery |
( |
| ) |
const |
Returns the internal dtNavMeshQuery pointer (opaque).
◆ getTileCache()
| void * kemena::kNavMesh::getTileCache |
( |
| ) |
const |
Returns the internal dtTileCache pointer (null for non-tiled builds).
◆ isBaked()
| bool kemena::kNavMesh::isBaked |
( |
| ) |
const |
Returns true if the mesh has been successfully baked.
◆ isPointOnMesh()
| bool kemena::kNavMesh::isPointOnMesh |
( |
const kVec3 & | pos, |
|
|
const kVec3 & | extents = kVec3(2.f, 4.f, 2.f) ) const |
Returns true if pos is on (or very near) the navmesh.
The documentation for this class was generated from the following file: