16#ifndef NAVMAP_CORE__NAVMAP_HPP_
17#define NAVMAP_CORE__NAVMAP_HPP_
38#include <unordered_map>
81 inline size_t size()
const {
return x.size();}
91 return {
x[id],
y[id],
z[id]};
102 std::vector<uint8_t>
r;
103 std::vector<uint8_t>
g;
104 std::vector<uint8_t>
b;
105 std::vector<uint8_t>
a;
132 virtual const std::string &
name()
const = 0;
135 virtual size_t size()
const = 0;
144 virtual std::shared_ptr<LayerViewBase>
clone()
const = 0;
156 const std::size_t word = cid / 64;
160 const std::uint64_t bit = std::uint64_t{1} << (cid % 64);
217 const std::string &
name()
const override {
return name_;}
240 std::shared_ptr<LayerViewBase>
clone()
const override
242 return std::make_shared<LayerView<T>>(*this);
250inline std::uint64_t fnv1a64_bytes(
251 const void * data, std::size_t n,
252 std::uint64_t seed = 1469598103934665603ULL)
254 const auto * p =
static_cast<const std::uint8_t *
>(data);
255 std::uint64_t h = seed;
256 for (std::size_t i = 0; i < n; ++i) {
257 h ^= p[i]; h *= 1099511628211ULL;
268 const std::size_t n =
data_.size();
269 std::uint64_t h = navmap::detail::fnv1a64_bytes(&n,
sizeof(n));
272 std::is_trivially_copyable<T>::value,
273 "LayerView<T> requires trivially copyable T.");
274 h = navmap::detail::fnv1a64_bytes(
data_.data(), n *
sizeof(T), h);
298 for (
const auto & [name, view] : other.layers_) {
299 layers_.emplace(name, view ? view->clone() : nullptr);
305 if (
this != &other) {
307 layers_.swap(tmp.layers_);
326 const std::string & name,
330 auto it = layers_.find(name);
331 if (it != layers_.end()) {
332 return std::dynamic_pointer_cast<LayerView<T>>(it->second);
334 auto view = std::make_shared<LayerView<T>>(name, nitems, type);
335 layers_[name] = view;
344 std::shared_ptr<LayerViewBase>
get(
const std::string & name)
const
346 auto it = layers_.find(name);
347 return it == layers_.end() ? nullptr : it->second;
354 std::vector<std::string>
list()
const
356 std::vector<std::string> out;
357 out.reserve(layers_.size());
358 for (
const auto & kv : layers_) {
359 out.push_back(kv.first);
370 return layers_.erase(name) > 0;
382 for (
auto & kv : layers_) {
384 v->data_.resize(nitems);
385 kv.second->mark_all_changed();
389 v->data_.resize(nitems);
390 kv.second->mark_all_changed();
394 v->data_.resize(nitems);
395 kv.second->mark_all_changed();
399 v->data_.resize(nitems);
400 kv.second->mark_all_changed();
407 std::unordered_map<std::string, std::shared_ptr<LayerViewBase>> layers_;
439 Eigen::Vector3f
normal{0.0f, 0.0f, 1.0f};
442 std::numeric_limits<uint32_t>::max(),
443 std::numeric_limits<uint32_t>::max(),
444 std::numeric_limits<uint32_t>::max()
612 ensure_geometry_fingerprint_();
641 return {
navcels[cid].neighbor[0],
656 const Eigen::Vector3f & o,
657 const Eigen::Vector3f & d,
660 Eigen::Vector3f & hit_pt)
const;
669 const std::vector<Ray> & rays,
670 std::vector<RayHit> & out,
671 bool first_hit_only =
true)
const;
719 const Eigen::Vector3f & p_world,
720 size_t & surface_idx,
722 Eigen::Vector3f & bary,
723 Eigen::Vector3f * hit_pt)
const;
742 const Eigen::Vector3f & p_world,
743 size_t & surface_idx,
745 Eigen::Vector3f & bary,
746 Eigen::Vector3f * hit_pt,
764 const Eigen::Vector3f & p_world,
765 size_t & surface_idx,
767 Eigen::Vector3f & closest_point,
769 int restrict_surface = -1)
const;
795 uint32_t
add_vertex(
const Eigen::Vector3f & p);
815 static constexpr std::size_t
kInvalidLink = std::numeric_limits<std::size_t>::max();
824 bool bidirectional =
true);
831 const std::vector<SurfaceLink> &
links()
const {
return links_;}
850 const std::vector<NavCelId> & seed_cells,
bool from_boundary,
851 float max_distance = std::numeric_limits<float>::infinity())
const;
854 static constexpr std::size_t
kNoSurface = std::numeric_limits<std::size_t>::max();
878 const std::string & name,
879 const std::string & description = {},
880 const std::string & unit = {},
881 T default_value = T{})
885 if (!existed || v->data().size() !=
navcels.size()) {
886 v->data().assign(
navcels.size(), default_value);
887 v->mark_all_changed();
890 meta.description = description;
892 meta.per_cell =
true;
897 bool has_layer(
const std::string & name)
const;
900 std::size_t
layer_size(
const std::string & name)
const;
916 if (
static_cast<size_t>(cid) < view->data().size()) {
917 view->data()[cid] = value;
918 view->mark_changed(cid);
941 if (
auto view = std::dynamic_pointer_cast<
LayerView<T>>(base)) {
942 const auto & buf = view->data();
943 if (
static_cast<size_t>(cid) < buf.size()) {
952 if (
auto v8 = std::dynamic_pointer_cast<LayerView<uint8_t>>(base)) {
953 const auto & buf = v8->data();
954 if (
static_cast<size_t>(cid) >= buf.size()) {
return def;}
955 v =
static_cast<double>(buf[cid]);
956 }
else if (
auto vf = std::dynamic_pointer_cast<LayerView<float>>(base)) {
957 const auto & buf = vf->data();
958 if (
static_cast<size_t>(cid) >= buf.size()) {
return def;}
959 v =
static_cast<double>(buf[cid]);
960 }
else if (
auto vd = std::dynamic_pointer_cast<LayerView<double>>(base)) {
961 const auto & buf = vd->data();
962 if (
static_cast<size_t>(cid) >= buf.size()) {
return def;}
964 }
else if (
auto vi = std::dynamic_pointer_cast<LayerView<int16_t>>(base)) {
965 const auto & buf = vi->data();
966 if (
static_cast<size_t>(cid) >= buf.size()) {
return def;}
967 v =
static_cast<double>(buf[cid]);
975 if constexpr (std::is_floating_point_v<T>) {
976 return static_cast<T
>(v);
977 }
else if constexpr (std::is_integral_v<T>) {
978 const double lo =
static_cast<double>(std::numeric_limits<T>::lowest());
979 const double hi =
static_cast<double>(std::numeric_limits<T>::max());
980 double vv = v < lo ? lo : (v > hi ? hi : v);
981 return static_cast<T
>(std::llround(vv));
983 static_assert(
sizeof(T) == 0,
"Unsupported layer type");
992 std::optional<LayerMeta>
get_layer_meta(
const std::string & name)
const;
1019 const std::string & name,
1020 const Eigen::Vector3f & p_world,
1021 double def = std::numeric_limits<double>::quiet_NaN())
const;
1030 template<
typename T>
1034 std::fill(view->data().begin(), view->data().end(), value);
1035 view->mark_all_changed();
1048 template<
typename T>
1049 bool layer_copy(
const std::string & src,
const std::string & dst)
1058 auto src_view = std::dynamic_pointer_cast<LayerView<T>>(src_base);
1071 if (src_view->data().size() != dst_view->data().size()) {
1076 if (!src_view->data().empty() &&
1077 src_view->data().data() == dst_view->data().data())
1083 const bool same_hash = (src_view->content_hash() == dst_view->content_hash());
1089 dst_view->set_data(src_view->data());
1109 template<
typename T>
1111 const std::string & name,
1112 const std::string & description,
1113 const std::string & unit,
1114 const std::string & src_layer)
1117 if (dst->data().size() !=
navcels.size()) {
1118 dst->data().assign(
navcels.size(), T{});
1121 meta.description = description;
1123 meta.per_cell =
true;
1133 const std::size_t n = dst->size();
1134 for (
NavCelId cid = 0; cid < n; ++cid) {
1135 double v =
layer_get<double>(src_layer, cid, std::numeric_limits<double>::quiet_NaN());
1136 if (std::isnan(v)) {v = 0.0;}
1138 if constexpr (std::is_floating_point_v<T>) {
1139 dst->data()[cid] =
static_cast<T
>(v);
1140 }
else if constexpr (std::is_integral_v<T>) {
1141 const double lo =
static_cast<double>(std::numeric_limits<T>::lowest());
1142 const double hi =
static_cast<double>(std::numeric_limits<T>::max());
1143 if (v < lo) {v = lo;}
1144 if (v > hi) {v = hi;}
1145 dst->data()[cid] =
static_cast<T
>(std::llround(v));
1147 static_assert(
sizeof(T) == 0,
"Unsupported layer type");
1161 const Eigen::Vector3f & p_world,
1162 std::size_t & surface_idx,
1164 Eigen::Vector3f & bary,
1165 Eigen::Vector3f * hit_pt,
1166 const LocateOpts & opts)
const;
1185 template<
typename T>
1187 const Eigen::Vector3f & p_world,
1189 const std::string & layer_name,
1197 std::size_t surface_idx = 0;
1199 Eigen::Vector3f bary{};
1200 Eigen::Vector3f hit_pt{};
1201 if (!
locate_navcel(p_world, surface_idx, start_cid, bary, &hit_pt)) {
1205 const float cx = hit_pt.x();
1206 const float cy = hit_pt.y();
1218 if (layer->data().size() !=
navcels.size()) {
1219 const_cast<std::vector<T> &
>(layer->data()).resize(
navcels.size(), T{});
1223 const float minx = cx - half, maxx = cx + half;
1224 const float miny = cy - half, maxy = cy + half;
1227 auto tri_aabb_intersects_box = [&](
NavCelId cid) ->
bool {
1228 const auto & tri =
navcels[
static_cast<std::size_t
>(cid)];
1235 const float tminx = std::min({p0.x(), p1.x(), p2.x()});
1236 const float tmaxx = std::max({p0.x(), p1.x(), p2.x()});
1237 const float tminy = std::min({p0.y(), p1.y(), p2.y()});
1238 const float tmaxy = std::max({p0.y(), p1.y(), p2.y()});
1239 if (tmaxx < minx || tminx > maxx || tmaxy < miny || tminy > maxy) {
1245 auto inside_area = [&](
const Eigen::Vector3f & c) ->
bool {
1246 const float dx = c.x() - cx;
1247 const float dy = c.y() - cy;
1249 return (dx * dx + dy * dy) <= r2;
1251 return (std::abs(dx) <= half) && (std::abs(dy) <= half);
1255 std::vector<char> visited(
navcels.size(), 0);
1256 std::deque<NavCelId> q;
1257 q.push_back(start_cid);
1258 visited[
static_cast<std::size_t
>(start_cid)] = 1;
1260 auto & data = layer->mutable_data();
1262 while (!q.empty()) {
1263 const NavCelId cid = q.front(); q.pop_front();
1265 if (!tri_aabb_intersects_box(cid)) {
1270 if (inside_area(c)) {
1271 data[
static_cast<std::size_t
>(cid)] = value;
1275 const std::size_t nidx =
static_cast<std::size_t
>(ncid);
1276 if (nidx <
navcels.size() && !visited[nidx] && tri_aabb_intersects_box(ncid)) {
1288 void ensure_geometry_fingerprint_()
const;
1289 static std::uint64_t hash_geometry_bytes_(
1290 const float * x, std::size_t nx,
1291 const float * y, std::size_t ny,
1292 const float * z, std::size_t nz,
1293 const std::uint32_t * v0, std::size_t nv0,
1294 const std::uint32_t * v1, std::size_t nv1,
1295 const std::uint32_t * v2, std::size_t nv2);
1297 mutable bool geometry_dirty_{
true};
1298 mutable std::uint64_t geometry_fp_{0};
1302 const Eigen::Vector3f & o,
const Eigen::Vector3f & d,
float t_max,
1303 RayHit & out)
const;
1305 std::size_t nonmanifold_edges_{0};
1308 std::vector<std::uint32_t> navcel_surface_;
1313 std::vector<BVHNode> surface_tree_;
1314 std::vector<std::uint32_t> surface_tree_prims_;
1315 std::size_t surface_tree_surfaces_{0};
1316 void build_surface_tree_();
1317 bool surface_tree_valid_()
const
1319 return !surface_tree_.empty() && surface_tree_surfaces_ ==
surfaces.size();
1321 std::vector<SurfaceLink> links_;
1322 mutable std::vector<std::vector<std::uint32_t>> link_index_;
1323 mutable bool link_index_dirty_{
true};
1324 void build_navcel_surface_index_();
1332 void build_surface_bvh(Surface & s);
1345 bool surface_raycast(
1347 const Eigen::Vector3f & o,
1348 const Eigen::Vector3f & d,
1351 Eigen::Vector3f & hit_pt,
1352 float t_max = std::numeric_limits<float>::infinity())
const;
1364 bool locate_by_walking(
1366 const Eigen::Vector3f & p,
1368 Eigen::Vector3f & bary,
1369 Eigen::Vector3f * hit_pt,
1370 float planar_eps)
const;
1382 bool surface_closest_navcel(
1384 const Eigen::Vector3f & p,
1386 Eigen::Vector3f & q,
1387 float & best_sq)
const;
1392 const Eigen::Vector3f & p_world,
1393 size_t & surface_idx,
1395 Eigen::Vector3f & bary,
1396 Eigen::Vector3f * hit_pt)
const
Low-level geometry utilities for NavMap cells (triangles), AABB and basic queries such as ray-triangl...
NavMap()
Copy constructor: deep copy of geometry, surfaces, layers and metadata.
Definition NavMap.cpp:49
Registry of named layers (per-NavCel).
Definition NavMap.hpp:289
bool remove(const std::string &name)
Remove a layer by name.
Definition NavMap.hpp:368
void resize_all(size_t nitems)
Resize all known typed layers to nitems.
Definition NavMap.hpp:380
std::shared_ptr< LayerViewBase > get(const std::string &name) const
Get an existing layer by name (untyped view).
Definition NavMap.hpp:344
std::vector< std::string > list() const
List layer names currently in the registry.
Definition NavMap.hpp:354
std::shared_ptr< LayerView< T > > add_or_get(const std::string &name, size_t nitems, LayerType type)
Add a new typed layer or return an existing one with the same name.
Definition NavMap.hpp:325
LayerRegistry & operator=(const LayerRegistry &other)
Definition NavMap.hpp:303
LayerRegistry(LayerRegistry &&) noexcept=default
std::array< NavCelId, 3 > get_neighbors(NavCelId cid) const
Return the three neighbor NavCel ids of triangle cid.
Definition NavMap.hpp:639
Surface create_surface_obj(const std::string &frame_id) const
Create a standalone Surface object (not yet added to the map).
Definition NavMap.cpp:1019
std::uint64_t geometry_id() const
Fingerprint of the geometry (vertex positions and triangles), 64-bit FNV-1a.
Definition NavMap.hpp:610
void raycast_many(const std::vector< Ray > &rays, std::vector< RayHit > &out, bool first_hit_only=true) const
Batched raycast.
Definition NavMap.cpp:634
void add_navcel_to_surface(std::size_t surface_index, NavCelId cid)
Add an existing nav cell id to a surface.
Definition NavMap.cpp:1062
Eigen::Vector3f navcel_centroid(NavCelId cid) const
Triangle centroid (computed on the fly).
Definition NavMap.cpp:1069
bool layer_copy(const std::string &src, const std::string &dst)
Copy values from one layer into another.
Definition NavMap.hpp:1049
LayerRegistry layers
Per-NavCel layers (runtime registry).
Definition NavMap.hpp:567
std::vector< NavCel > navcels
All triangles (global indexing).
Definition NavMap.hpp:565
NavCelId add_navcel(uint32_t v0, uint32_t v1, uint32_t v2)
Append a triangle (NavCel) and return its id.
Definition NavMap.cpp:1054
bool is_unknown(const std::string &name, NavCelId cid) const
Whether layer name holds its unknown value at cid (false if it has none).
Definition NavMap.cpp:1358
bool remove_surface(std::size_t surface_index)
Remove a Surface by index.
Definition NavMap.cpp:1038
bool locate_navcel_core(const Eigen::Vector3f &p_world, std::size_t &surface_idx, NavCelId &cid, Eigen::Vector3f &bary, Eigen::Vector3f *hit_pt, const LocateOpts &opts) const
Forward to the existing low-level locator (implemented in .cpp).
Definition NavMap.cpp:754
std::optional< Colors > colors
Optional per-vertex colors.
Definition NavMap.hpp:564
std::shared_ptr< LayerView< T > > add_layer(const std::string &name, const std::string &description, const std::string &unit, const std::string &src_layer)
Create (or get) a typed per-NavCel layer, initialized from another layer.
Definition NavMap.hpp:1110
std::size_t surface_of(NavCelId cid) const
Index of the surface owning cid, or kNoSurface.
Definition NavMap.cpp:1103
void clear_links()
Definition NavMap.cpp:1299
bool locate_navcel(const Eigen::Vector3f &p_world, size_t &surface_idx, NavCelId &cid, Eigen::Vector3f &bary, Eigen::Vector3f *hit_pt) const
Locate the triangle under / near a world point (convenience).
Definition NavMap.hpp:1391
std::string layer_type_name(const std::string &name) const
Human-readable type name for a layer ("float", "double", "uint8", ...).
Definition NavMap.cpp:1332
std::size_t add_surface(const Surface &s)
Append an existing Surface (by value).
Definition NavMap.cpp:1026
bool has_same_geometry(const NavMap &other) const
Fast check for identical geometry (vertices and NavCel indices).
Definition NavMap.cpp:111
double sample_layer_at(const std::string &name, const Eigen::Vector3f &p_world, double def=std::numeric_limits< double >::quiet_NaN()) const
Sample a per-NavCel layer at a world position.
Definition NavMap.cpp:1373
void layer_clear(const std::string &name, T value=T{})
Reset all values in a layer to a given value.
Definition NavMap.hpp:1031
std::vector< NavCelId > navcel_neighbors(NavCelId cid) const
Return up to 3 neighbor cell ids (skips invalid entries).
Definition NavMap.cpp:1078
std::size_t nonmanifold_edges() const
Edges shared by more than two NavCels in the last adjacency build.
Definition NavMap.hpp:626
bool set_area(const Eigen::Vector3f &p_world, T value, const std::string &layer_name, AreaShape shape, float size)
Set a per-NavCel layer to a constant value over a 2D area.
Definition NavMap.hpp:1186
uint32_t add_vertex(const Eigen::Vector3f &p)
Append a vertex and return its index.
Definition NavMap.cpp:1045
std::vector< Surface > surfaces
Surfaces (partitions of navcels).
Definition NavMap.hpp:566
const std::vector< SurfaceLink > & links() const
Definition NavMap.hpp:831
std::size_t add_link(NavCelId from, NavCelId to, LinkType type=LinkType::GENERIC, float length=-1.0f, bool bidirectional=true)
Add a link from from to to.
Definition NavMap.cpp:1280
std::shared_ptr< LayerView< T > > add_layer(const std::string &name, const std::string &description={}, const std::string &unit={}, T default_value=T{})
Create (or get) a typed per-NavCel layer with a default value.
Definition NavMap.hpp:877
bool closest_navcel(const Eigen::Vector3f &p_world, size_t &surface_idx, NavCelId &cid, Eigen::Vector3f &closest_point, float &sqdist, int restrict_surface=-1) const
Find the closest triangle to a point.
Definition NavMap.cpp:916
void mark_vertex_updated(PointId)
Mark a vertex as updated (reserved for future cache invalidation).
Definition NavMap.hpp:632
std::vector< float > distance_field(const std::vector< NavCelId > &seed_cells, bool from_boundary, float max_distance=std::numeric_limits< float >::infinity()) const
Distance (m, 3D) from each NavCel centroid to the nearest seed.
Definition NavMap.cpp:1218
void set_layer_unknown(const std::string &name, double value)
Declare the value of layer name that means "not observed" (NaN allowed).
Definition NavMap.cpp:1353
T navcel_value(NavCelId cid, const LayerView< T > &layer) const
Read the value of a typed per-NavCel layer at triangle cid.
Definition NavMap.hpp:683
static constexpr std::size_t kInvalidLink
Value returned by add_link() when a NavCel id is out of range.
Definition NavMap.hpp:815
std::vector< std::string > list_layers() const
List all layer names currently stored.
Definition NavMap.cpp:1368
std::optional< LayerMeta > get_layer_meta(const std::string &name) const
Return metadata for a layer if present (implementation-defined).
Definition NavMap.cpp:1346
NavMap & operator=(const NavMap &other)
Copy assignment optimized to avoid geometry duplication.
Definition NavMap.cpp:127
bool locate_navcel(const Eigen::Vector3f &p_world, size_t &surface_idx, NavCelId &cid, Eigen::Vector3f &bary, Eigen::Vector3f *hit_pt, const LocateOpts &opts) const
Locate the triangle under / near a world point.
Positions positions
Vertex positions (SoA).
Definition NavMap.hpp:563
void layer_set(const std::string &name, NavCelId cid, T value)
Set a per-cell value (creates/retypes the layer if needed).
Definition NavMap.hpp:913
std::size_t create_surface(std::string frame_id)
Create a new empty Surface and append it to the map.
Definition NavMap.cpp:1012
const std::vector< std::uint32_t > & links_from(NavCelId cid) const
Indices of the links that can be taken from cid (both ends of bidirectional ones).
Definition NavMap.cpp:1305
static constexpr std::size_t kNoSurface
Value returned by surface_of() for a NavCel in no surface.
Definition NavMap.hpp:854
void build_adjacency()
Build topological adjacency between neighboring NavCels.
Definition NavMap.cpp:251
bool has_layer(const std::string &name) const
Check whether a layer named name exists.
Definition NavMap.cpp:1321
NavMap()
Copy constructor: deep copy of geometry, surfaces, layers and metadata.
Definition NavMap.cpp:49
std::size_t layer_size(const std::string &name) const
Number of entries in a layer (should equal navcels.size()).
Definition NavMap.cpp:1326
bool raycast(const Eigen::Vector3f &o, const Eigen::Vector3f &d, NavCelId &hit_cid, float &t, Eigen::Vector3f &hit_pt) const
Raycast against all surfaces to find the closest hit.
Definition NavMap.cpp:562
void rebuild_geometry_accels()
Recompute derived geometry and acceleration structures.
Definition NavMap.cpp:440
bool remove_link(std::size_t index)
Remove link index (the last link takes its index). False if out of range.
Definition NavMap.cpp:1290
T layer_get(const std::string &name, NavCelId cid, T def=T{}) const
Get a per-cell value as the requested type.
Definition NavMap.hpp:938
std::unordered_map< std::string, LayerMeta > layer_meta
Optional metadata per layer.
Definition NavMap.hpp:568
Definition Combine.hpp:39
LayerType
Runtime type tag for a layer's scalar storage.
Definition NavMap.hpp:117
@ F64
Definition NavMap.hpp:117
@ F32
Definition NavMap.hpp:117
@ U8
Definition NavMap.hpp:117
@ I16
Definition NavMap.hpp:117
AreaShape
Shape selector for area-writing APIs.
Definition NavMap.hpp:522
@ RECTANGULAR
Definition NavMap.hpp:522
@ CIRCULAR
Definition NavMap.hpp:522
LinkType
Main container for navigable surfaces, geometry, and layers.
Definition NavMap.hpp:543
@ ELEVATOR
Definition NavMap.hpp:543
@ STAIRS
Definition NavMap.hpp:543
@ DOOR
Definition NavMap.hpp:543
@ GENERIC
Definition NavMap.hpp:543
@ RAMP
Definition NavMap.hpp:543
constexpr LayerType layer_type_tag()
Helper to map C++ scalar type to navmap::LayerType tag.
uint32_t NavCelId
Index of a triangle (NavCel) within the global mesh.
Definition NavMap.hpp:59
uint32_t PointId
Index into the per-vertex position arrays (SoA).
Definition NavMap.hpp:57
LayerView(std::string name, size_t nitems, LayerType t)
Construct a typed view.
Definition NavMap.hpp:213
Options for the locate functions.
Definition NavMap.hpp:698
Axis-aligned bounding box.
Definition Geometry.hpp:165
Node in a per-surface bounding volume hierarchy (BVH).
Definition NavMap.hpp:455
int right
Right child index (or -1 for leaf).
Definition NavMap.hpp:458
int start
Start index in primitive array (leaf only).
Definition NavMap.hpp:459
bool is_leaf() const
Definition NavMap.hpp:461
int count
Number of primitives in leaf (0 for inner nodes).
Definition NavMap.hpp:460
int left
Left child index (or -1 for leaf).
Definition NavMap.hpp:457
AABB box
Bounding box of this node (world coordinates).
Definition NavMap.hpp:456
Optional per-vertex colors (RGBA, 8-bit per channel).
Definition NavMap.hpp:101
std::vector< uint8_t > r
Red channel.
Definition NavMap.hpp:102
std::vector< uint8_t > a
Alpha channel.
Definition NavMap.hpp:105
std::vector< uint8_t > g
Green channel.
Definition NavMap.hpp:103
std::vector< uint8_t > b
Blue channel.
Definition NavMap.hpp:104
Non-templated base for runtime layer handling.
Definition NavMap.hpp:125
void mark_all_changed() const noexcept
Record that the whole layer changed.
Definition NavMap.hpp:168
bool all_changed() const noexcept
Whether the whole layer changed (then changed() is not meaningful).
Definition NavMap.hpp:171
std::vector< NavCelId > changed_
Definition NavMap.hpp:190
virtual LayerType type() const =0
virtual const std::string & name() const =0
virtual std::uint64_t content_hash() const =0
Return 64-bit content hash (cached; recomputed lazily).
const std::vector< NavCelId > & changed() const noexcept
Cells changed one by one since the last clear_changes(), in order of first change.
Definition NavMap.hpp:174
std::vector< std::uint64_t > changed_bits_
Definition NavMap.hpp:191
std::uint64_t hash_cache_
Definition NavMap.hpp:188
void clear_changes() const
Forget the recorded changes (call it once every consumer has seen them).
Definition NavMap.hpp:179
void mark_dirty() const noexcept
Mark content dirty (forces hash recompute on next query).
Definition NavMap.hpp:141
virtual std::shared_ptr< LayerViewBase > clone() const =0
Independent copy of this layer (data, name, type, cached hash and pending changes).
virtual size_t size() const =0
virtual ~LayerViewBase()=default
bool all_changed_
Definition NavMap.hpp:189
bool hash_dirty_
Definition NavMap.hpp:187
bool has_changes() const noexcept
Definition NavMap.hpp:176
void mark_changed(NavCelId cid) const
Record that cell cid changed (deduplicated).
Definition NavMap.hpp:152
Typed layer view storing one T value per NavCel.
Definition NavMap.hpp:202
std::uint64_t content_hash() const override
Return 64-bit content hash (cached; recomputed lazily).
Definition NavMap.hpp:265
const std::vector< T > & data() const
Definition NavMap.hpp:229
void set_data(const std::vector< T > &v)
Definition NavMap.hpp:237
std::string name_
Layer name (key in the registry).
Definition NavMap.hpp:203
std::vector< T > data_
Values, one per NavCel.
Definition NavMap.hpp:204
LayerType type_
Runtime type tag (must match T).
Definition NavMap.hpp:205
LayerType type() const override
Definition NavMap.hpp:216
const std::string & name() const override
Definition NavMap.hpp:217
const T & operator[](NavCelId cid) const
Definition NavMap.hpp:223
std::vector< T > & mutable_data() const
Definition NavMap.hpp:233
T & operator[](NavCelId cid)
Definition NavMap.hpp:222
size_t size() const override
Definition NavMap.hpp:218
LayerView(std::string name, size_t nitems, LayerType t)
Construct a typed view.
Definition NavMap.hpp:213
std::vector< T > & data()
Definition NavMap.hpp:227
std::shared_ptr< LayerViewBase > clone() const override
Independent copy of this layer (data, name, type, cached hash and pending changes).
Definition NavMap.hpp:240
Navigation cell (triangle) with geometry and adjacency.
Definition NavMap.hpp:437
uint32_t layer_dirty_mask
Reserved for future per-layer flags.
Definition NavMap.hpp:446
Eigen::Vector3f normal
Unit normal of the triangle.
Definition NavMap.hpp:439
NavCelId neighbor[3]
Neighbor cids across edges 0,1,2.
Definition NavMap.hpp:441
float area
Triangle area (m²).
Definition NavMap.hpp:440
PointId v[3]
Indices into navmap::Positions.
Definition NavMap.hpp:438
Options for the locate functions.
Definition NavMap.hpp:698
std::optional< NavCelId > hint_cid
Optional triangle hint for walking.
Definition NavMap.hpp:699
std::optional< size_t > hint_surface
Optional surface hint.
Definition NavMap.hpp:700
bool use_downward_ray
Downward ray on fallback (else upward).
Definition NavMap.hpp:703
float height_eps
Z tolerance for vertical fallback (meters).
Definition NavMap.hpp:702
float planar_eps
In-plane barycentric tolerance.
Definition NavMap.hpp:701
Structure-of-arrays for storing 3D vertex positions.
Definition NavMap.hpp:75
Eigen::Vector3f at(PointId id) const
Returns vertex id as a 3D vector.
Definition NavMap.hpp:89
size_t size() const
Definition NavMap.hpp:81
std::vector< float > x
X coordinates (meters).
Definition NavMap.hpp:76
std::vector< float > z
Z coordinates (meters).
Definition NavMap.hpp:78
std::vector< float > y
Y coordinates (meters).
Definition NavMap.hpp:77
Result of a raycast against the NavMap.
Definition NavMap.hpp:500
Eigen::Vector3f p
World coordinates of intersection.
Definition NavMap.hpp:505
bool hit
True if the ray hit any triangle.
Definition NavMap.hpp:501
size_t surface
Index of surface hit.
Definition NavMap.hpp:502
NavCelId cid
Id of the NavCel hit.
Definition NavMap.hpp:503
float t
Distance along the ray (units of d).
Definition NavMap.hpp:504
Simple ray (origin + direction).
Definition NavMap.hpp:489
Eigen::Vector3f o
Origin of the ray (world).
Definition NavMap.hpp:490
Eigen::Vector3f d
Direction of the ray (unit length recommended).
Definition NavMap.hpp:491
Connection between two NavCels that do not share an edge (stairs, an elevator, a door between surface...
Definition NavMap.hpp:552
NavCelId to
Definition NavMap.hpp:554
NavCelId from
Definition NavMap.hpp:553
float length
Travel length (m).
Definition NavMap.hpp:556
LinkType type
Definition NavMap.hpp:555
bool bidirectional
Also from to to from.
Definition NavMap.hpp:557
A connected set of NavCels in a common reference frame.
Definition NavMap.hpp:471
std::vector< BVHNode > bvh
BVH nodes for this surface.
Definition NavMap.hpp:476
AABB aabb
Bounds of the surface geometry.
Definition NavMap.hpp:474
std::vector< NavCelId > navcels
NavCels belonging to this surface (global ids).
Definition NavMap.hpp:473
std::string frame_id
Frame id of this surface.
Definition NavMap.hpp:472
std::vector< int > prim_indices
Compact list of cids used by BVH leaves.
Definition NavMap.hpp:475