NavMap
Loading...
Searching...
No Matches
DistanceField Class Reference

Distance from each NavCel to the nearest seed (seed NavCels and, optionally, the open edges of the mesh), kept up to date incrementally. More...

#include <DistanceField.hpp>

Public Member Functions

const std::vector< NavCelId > & changed () const
 NavCels whose distance changed in the last compute() / update().
void compute (const std::vector< NavCelId > &seed_cells)
 Full computation from these seed cells.
 DistanceField (const NavMap &nm, bool from_boundary, float max_distance=std::numeric_limits< float >::infinity())
const std::vector< float > & distances () const
bool is_seed (NavCelId cid) const
 Whether cid is currently a seed cell.
float operator[] (NavCelId cid) const
void update (const std::vector< NavCelId > &added, const std::vector< NavCelId > &removed)
 Incremental update: NavCels that became seeds and NavCels that stopped being seeds since the last compute() / update().

Detailed Description

Distance from each NavCel to the nearest seed (seed NavCels and, optionally, the open edges of the mesh), kept up to date incrementally.

With a finite max_distance the field is exact for this definition: the distance of a NavCel is the straight 3D distance from its centroid to the nearest seed (point, or open-edge segment) that reaches it through adjacent NavCels all within max_distance of that seed, so it never jumps to another floor or across a hole. Each seed paints its disc; removing one repaints the seeds within 2 * max_distance of it (found through a spatial index). Without max_distance it falls back to NavMap::distance_field() (nearest-feature propagation, approximate) and updates recompute everything.

Bound to the geometry of the NavMap it was built from: rebuild it if the geometry changes. The map must outlive it.

Constructor & Destructor Documentation

◆ DistanceField()

DistanceField ( const NavMap & nm,
bool from_boundary,
float max_distance = std::numeric_limits<float>::infinity() )
Parameters
nmMap (geometry and adjacency must be built).
from_boundaryAlso seed the open edges (walls, drops, unmapped space).
max_distanceDistances beyond this are +inf (bounds the work of every update).

Member Function Documentation

◆ changed()

const std::vector< NavCelId > & changed ( ) const

NavCels whose distance changed in the last compute() / update().

◆ compute()

void compute ( const std::vector< NavCelId > & seed_cells)

Full computation from these seed cells.

◆ distances()

const std::vector< float > & distances ( ) const

◆ is_seed()

bool is_seed ( NavCelId cid) const

Whether cid is currently a seed cell.

◆ operator[]()

float operator[] ( NavCelId cid) const

◆ update()

void update ( const std::vector< NavCelId > & added,
const std::vector< NavCelId > & removed )

Incremental update: NavCels that became seeds and NavCels that stopped being seeds since the last compute() / update().

Unknown or repeated ids are ignored.


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