Template Struct index3d_hash

Struct Documentation

template<typename cell_coord_t = int32_t>
struct index3d_hash

Hash functor and comparator for index3d_t, usable with both std::unordered_map / tsl::robin_map (hash) and std::map (comparator).

The hash function is the optimized spatial hash from: Teschner et al., “Optimized spatial hashing for collision detection of

deformable objects”, VMV 2003. It mixes the three integer coordinates with large prime multipliers and truncates to 20 bits, giving good distribution for typical voxel grids.

The operator()(k1,k2) overload provides a strict weak ordering on index3d_t (X-primary, Y-secondary, Z-tertiary) for std::map.

Public Functions

inline std::size_t operator()(const index3d_t<cell_coord_t> &k) const noexcept

Hash operator for unordered maps:

inline bool operator()(const index3d_t<cell_coord_t> &k1, const index3d_t<cell_coord_t> &k2) const noexcept

k1 < k2? for std::map containers