Kemena3D
Loading...
Searching...
No Matches
kemena::kNavObstacle Class Reference

A dynamic cylinder obstacle carved into the navmesh at runtime. More...

#include <knavobstacle.h>

Public Member Functions

 kNavObstacle ()
 Constructs an empty, uninitialised obstacle (no tile-cache binding).
 ~kNavObstacle ()
 Destroys the obstacle, removing it from the tile cache if still valid.
kVec3 getPosition () const
 Returns the obstacle's current world-space centre position.
float getRadius () const
 Returns the obstacle cylinder's radius.
float getHeight () const
 Returns the obstacle cylinder's height.
void setPosition (const kVec3 &pos)
 Moves the obstacle to a new world-space position.
bool isValid () const
 Returns true if the obstacle is registered in the tile cache.
bool init (void *tileCache, const kVec3 &position, float radius, float height)
 Registers the obstacle as a cylinder in the given tile cache.
void uninit ()
 Removes the obstacle from the tile cache and marks it invalid.
unsigned int getObstacleRef () const
 Returns the underlying Detour obstacle reference.

Detailed Description

A dynamic cylinder obstacle carved into the navmesh at runtime.

Obstacles require a tiled navmesh (kNavBuildConfig::tileSize > 0). Do not create directly — obtain via kNavManager::addObstacle().

kNavObstacle* obs = navManager->addObstacle(pos, 0.8f, 2.0f);
obs->setPosition(newPos); // moves the obstacle
navManager->removeObstacle(obs); // carves back in
void setPosition(const kVec3 &pos)
Moves the obstacle to a new world-space position.
kNavObstacle()
Constructs an empty, uninitialised obstacle (no tile-cache binding).

Constructor & Destructor Documentation

◆ kNavObstacle()

kemena::kNavObstacle::kNavObstacle ( )

Constructs an empty, uninitialised obstacle (no tile-cache binding).

◆ ~kNavObstacle()

kemena::kNavObstacle::~kNavObstacle ( )

Destroys the obstacle, removing it from the tile cache if still valid.

Member Function Documentation

◆ getHeight()

float kemena::kNavObstacle::getHeight ( ) const

Returns the obstacle cylinder's height.

Returns
The height in world units.

◆ getObstacleRef()

unsigned int kemena::kNavObstacle::getObstacleRef ( ) const

Returns the underlying Detour obstacle reference.

Returns
The opaque dtObstacleRef handle as an unsigned integer.

◆ getPosition()

kVec3 kemena::kNavObstacle::getPosition ( ) const

Returns the obstacle's current world-space centre position.

Returns
The cached position last set via init() or setPosition().

◆ getRadius()

float kemena::kNavObstacle::getRadius ( ) const

Returns the obstacle cylinder's radius.

Returns
The radius in world units.

◆ init()

bool kemena::kNavObstacle::init ( void * tileCache,
const kVec3 & position,
float radius,
float height )

Registers the obstacle as a cylinder in the given tile cache.

Stores the position/radius/height and calls dtTileCache::addObstacle(). Intended for internal use by kNavManager; callers should obtain obstacles via kNavManager::addObstacle() instead.

Parameters
tileCacheOpaque pointer to the owning dtTileCache.
positionWorld-space centre position of the cylinder.
radiusCylinder radius in world units.
heightCylinder height in world units.
Returns
true if the obstacle was successfully added to the tile cache.

◆ isValid()

bool kemena::kNavObstacle::isValid ( ) const

Returns true if the obstacle is registered in the tile cache.

◆ setPosition()

void kemena::kNavObstacle::setPosition ( const kVec3 & pos)

Moves the obstacle to a new world-space position.

Internally removes the old dtObstacleRef and adds a new one. Affected tiles are flagged for re-baking on the next kNavManager::update() call. Has no effect if the obstacle is not bound to a tile cache or is currently invalid.

Parameters
posThe new world-space centre position for the obstacle.

◆ uninit()

void kemena::kNavObstacle::uninit ( )

Removes the obstacle from the tile cache and marks it invalid.

Safe to call multiple times; does nothing if not currently valid.


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