This commit is contained in:
ZY4N
2024-12-22 16:58:40 +01:00
parent 2704814de2
commit db8db8f9d7
161 changed files with 17102 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
#ifndef INCLUDE_POINT_CLOUD_BATCH_IMPLEMENTATION
# error Never include this file directly include 'point_cloud_batch.hpp'
#endif
inline point_cloud_batch::id_type point_cloud_batch::add(
const zgl::point_cloud_handle& point_cloud,
const aabb& bounding_box,
const zgl::model_matrix_handle& transform
) {
const auto new_id = m_next_id++;
m_point_clouds.push_back(point_cloud);
m_transforms.push_back(transform);
m_bounding_boxes.push_back(bounding_box);
m_id_lookup.push_back(new_id);
return new_id;
}
std::optional<aabb> point_cloud_batch::bounding_box(id_type id)
{
const auto lookup_it = std::ranges::find(m_id_lookup, id);
if (lookup_it == m_id_lookup.end())
{
return std::nullopt;
}
const auto index = lookup_it - m_id_lookup.begin();
const auto& base_bounding_box = m_bounding_boxes[index];
const auto& transform = m_transforms[index];
return base_bounding_box.transformed(transform);
}
inline bool point_cloud_batch::remove(id_type id)
{
const auto lookup_it = std::ranges::find(m_id_lookup, id);
if (lookup_it == m_id_lookup.end())
{
return false;
}
const auto index = lookup_it - m_id_lookup.begin();
m_id_lookup.erase(m_id_lookup.begin() + index);
m_point_clouds.erase(m_point_clouds.begin() + index);
m_transforms.erase(m_transforms.begin() + index);
return true;
}
inline std::span<const zgl::point_cloud_handle> point_cloud_batch::point_clouds() const
{
return m_point_clouds;
}
inline std::span<const zgl::model_matrix_handle> point_cloud_batch::transforms() const
{
return m_transforms;
}
inline std::span<const aabb> point_cloud_batch::bounding_boxes() const
{
return m_bounding_boxes;
}