diff --git a/navmap_core/include/navmap_core/NavMap.hpp b/navmap_core/include/navmap_core/NavMap.hpp index 7a155d0..6ad0a41 100644 --- a/navmap_core/include/navmap_core/NavMap.hpp +++ b/navmap_core/include/navmap_core/NavMap.hpp @@ -199,6 +199,39 @@ struct LayerView : LayerViewBase ///@} }; +/** @cond INTERNAL */ +namespace detail +{ +inline std::uint64_t fnv1a64_bytes( + const void * data, std::size_t n, + std::uint64_t seed = 1469598103934665603ULL) +{ + const auto * p = static_cast(data); + std::uint64_t h = seed; + for (std::size_t i = 0; i < n; ++i) { + h ^= p[i]; h *= 1099511628211ULL; + } + return h; +} +} // namespace detail +/** @endcond */ + +template +std::uint64_t LayerView::content_hash() const +{ + if (!hash_dirty_) {return hash_cache_;} + const std::size_t n = data_.size(); + std::uint64_t h = navmap::detail::fnv1a64_bytes(&n, sizeof(n)); + if (n) { + static_assert(std::is_trivially_copyable::value, + "LayerView requires trivially copyable T."); + h = navmap::detail::fnv1a64_bytes(data_.data(), n * sizeof(T), h); + } + hash_cache_ = h; + hash_dirty_ = false; + return hash_cache_; +} + /** * \brief Registry of named layers (per-NavCel). * diff --git a/navmap_core/src/navmap_core/NavMap.cpp b/navmap_core/src/navmap_core/NavMap.cpp index 6a47303..0eb0380 100644 --- a/navmap_core/src/navmap_core/NavMap.cpp +++ b/navmap_core/src/navmap_core/NavMap.cpp @@ -25,39 +25,6 @@ namespace navmap { -/** @cond INTERNAL */ -namespace navmap -{namespace detail -{ -inline std::uint64_t fnv1a64_bytes( - const void * data, std::size_t n, - std::uint64_t seed = 1469598103934665603ULL) -{ - const auto * p = static_cast(data); - std::uint64_t h = seed; - for (std::size_t i = 0; i < n; ++i) { - h ^= p[i]; h *= 1099511628211ULL; - } - return h; -} -}} // namespaces -/** @endcond */ - -template -std::uint64_t LayerView::content_hash() const -{ - if (!hash_dirty_) {return hash_cache_;} - const std::size_t n = data_.size(); - std::uint64_t h = navmap::detail::fnv1a64_bytes(&n, sizeof(n)); - if (n) { - static_assert(std::is_trivially_copyable::value, - "LayerView requires trivially copyable T."); - h = navmap::detail::fnv1a64_bytes(data_.data(), n * sizeof(T), h); - } - hash_cache_ = h; - hash_dirty_ = false; - return hash_cache_; -} namespace { @@ -472,7 +439,7 @@ bool NavMap::raycast( { bool any = false; float best_t = std::numeric_limits::infinity(); - Vec3 best_p; + Vec3 best_p = Vec3::Zero(); NavCelId best_cid = 0; for (const auto & s : surfaces) {