This commit is contained in:
ZY4N
2025-03-28 13:09:34 +01:00
parent 6f60cc11c8
commit d18b40a7fc
34 changed files with 393 additions and 272 deletions

View File

@@ -6,20 +6,19 @@
#include "util/uix.hpp"
#include "util/id_type.hpp"
template<typename T>
template<typename ID, typename T>
class generic_basic_store
{
public:
using id_type = ztu::id_type_for<generic_basic_store, ztu::u32>;
using container_type = std::vector<T>;
using iterator_type = typename container_type::iterator;
using const_iterator = typename container_type::const_iterator;
id_type add(const T& data);
ID add(const T& data);
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
[[nodiscard]] std::pair<iterator_type, bool> find(ID id);
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
[[nodiscard]] std::pair<const_iterator, bool> find(ID id) const;
[[nodiscard]] std::span<T> data();
@@ -31,8 +30,7 @@ public:
private:
std::vector<T> m_data;
std::vector<id_type> m_ids;
id_type m_next_data_id{ 1 };
std::vector<ID> m_ids;
};
#define INCLUDE_GENERIC_BASIC_STORE_IMPLEMENTATION

View File

@@ -18,7 +18,7 @@ public:
using size_type = std::size_t;
using count_type = ztu::u32;
using component_flag_type = material_components::flags;
using id_type = ztu::id_type_for<generic_material_store<std::remove_const_t<Ts>...>, ztu::u32>;
using id_type = material_id;
using value_type = std::pair<id_type, material_view>;
using flag_count_type = std::tuple<component_flag_type>;
@@ -105,7 +105,7 @@ public:
using const_iterator = generic_material_store_iterator<std::add_const_t<Ts>...>;
using view_type = std::ranges::subrange<iterator_type>;
using const_view_type = std::ranges::subrange<const_iterator>;
using id_type = ztu::id_type_for<generic_material_store, ztu::u32>;
using id_type = material_id;
id_type add(const material_data& material);
@@ -144,7 +144,6 @@ private:
std::vector<id_type> m_ids;
std::tuple<std::vector<Ts>...> m_component_arrays;
std::vector<component_flag_type> m_component_flag_counts;
id_type m_next_data_id{ 1 };
};
}

View File

@@ -17,10 +17,10 @@ class generic_mesh_store_iterator
public:
using size_type = std::size_t;
using count_type = ztu::u32;
using index_type = mesh_data::index_type;
using index_type = z3d::vertex_index;
using material_id_type = material_store::id_type;
using component_flag_type = mesh_vertex_components::flags;
using id_type = ztu::id_type_for<generic_mesh_store<std::remove_const_t<Ts...>>, ztu::u32>;
using id_type = mesh_id;
using value_type = std::pair<id_type, mesh_view>;
using flag_count_type = std::tuple<component_flag_type, count_type, count_type>;
@@ -107,7 +107,7 @@ class generic_mesh_store
public:
using size_type = std::size_t;
using count_type = ztu::u32;
using index_type = mesh_data::index_type;
using index_type = z3d::vertex_index;
using component_flag_type = mesh_vertex_components::flags;
using material_id_type = material_store::id_type;
@@ -115,7 +115,7 @@ public:
using const_iterator = generic_mesh_store_iterator<std::add_const_t<Ts>...>;
using view_type = std::ranges::subrange<iterator_type>;
using const_view_type = std::ranges::subrange<const_iterator>;
using id_type = ztu::id_type_for<generic_mesh_store, ztu::u32>;
using id_type = mesh_id;
id_type add(const mesh_data& mesh);

View File

@@ -19,10 +19,10 @@ template<typename... Ts>
class generic_point_cloud_store_iterator
{
public:
using size_type = std::size_t;
using count_type = ztu::u32;
using size_type = z3d::size;
using count_type = z3d::u32;
using component_flag_type = point_cloud_vertex_components::flags;
using id_type = ztu::id_type_for<generic_point_cloud_store<std::remove_const_t<Ts>...>, ztu::u32>;
using id_type = point_cloud_id;
using value_type = std::pair<id_type, point_cloud_view>;
using flag_count_type = std::tuple<component_flag_type, count_type, count_type>;
@@ -109,7 +109,7 @@ public:
using const_iterator = generic_point_cloud_store_iterator<std::add_const_t<Ts>...>;
using view_type = std::ranges::subrange<iterator_type>;
using const_view_type = std::ranges::subrange<const_iterator>;
using id_type = ztu::id_type_for<generic_point_cloud_store, ztu::u32>;
using id_type = point_cloud_id;
id_type add(const point_cloud_data& point_cloud);