MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ insert()

template<typename PointT >
uint32_t MayaFlux::Kinesis::SpatialIndex< PointT >::insert ( const PointT &  position)

Insert a new entity at the given position.

Parameters
positionInitial coordinates.
Returns
Stable entity id, never reused after remove().

Definition at line 95 of file SpatialIndex.cpp.

96{
97 uint32_t id = m_next_id++;
98 uint32_t slot {};
99
100 if (!m_free_slots.empty()) {
101 slot = m_free_slots.back();
102 m_free_slots.pop_back();
103 m_positions[slot] = position;
104 m_slot_to_id[slot] = id;
105 } else {
106 slot = static_cast<uint32_t>(m_positions.size());
107 m_positions.push_back(position);
108 m_slot_to_id.push_back(id);
109 }
110
111 m_id_to_slot[id] = slot;
112
113 if constexpr (!detail::PointTraits<PointT>::fixed_dimension) {
114 if (m_positions.size() == 1) {
115 uint32_t dims = detail::get_dimensions(position);
117 }
118 }
119
120 return id;
121}
glm::vec3 position
uint32_t id
std::vector< uint32_t > m_free_slots
std::vector< PointT > m_positions
std::unordered_map< uint32_t, uint32_t > m_id_to_slot
std::vector< uint32_t > m_slot_to_id
uint32_t get_dimensions(const PointT &p)
constexpr uint32_t MAX_GRID_DIMENSIONS

References MayaFlux::Kinesis::detail::get_dimensions(), id, MayaFlux::Kinesis::detail::MAX_GRID_DIMENSIONS, and position.

+ Here is the call graph for this function: