|
NavMap
|
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(). | |
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.
| DistanceField | ( | const NavMap & | nm, |
| bool | from_boundary, | ||
| float | max_distance = std::numeric_limits<float>::infinity() ) |
| nm | Map (geometry and adjacency must be built). |
| from_boundary | Also seed the open edges (walls, drops, unmapped space). |
| max_distance | Distances beyond this are +inf (bounds the work of every update). |
| const std::vector< NavCelId > & changed | ( | ) | const |
| void compute | ( | const std::vector< NavCelId > & | seed_cells | ) |
Full computation from these seed cells.
| const std::vector< float > & distances | ( | ) | const |
| bool is_seed | ( | NavCelId | cid | ) | const |
Whether cid is currently a seed cell.
| float operator[] | ( | NavCelId | cid | ) | const |