Finally refactored all stores!
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include "assets/data/point_cloud_data.hpp"
|
||||
#include "assets/data_stores/point_cloud_store.hpp"
|
||||
|
||||
namespace assets
|
||||
namespace assets::detail
|
||||
{
|
||||
|
||||
template<bool Normal, bool Color, bool Reflectance>
|
||||
@@ -47,41 +47,27 @@ protected:
|
||||
protected:
|
||||
void reset();
|
||||
|
||||
z3d::vertex_index find_or_push_vertex(const component_indices& vertex_comp_indices);
|
||||
|
||||
[[nodiscard]] std::optional<texture_id> fetch_texture_id(
|
||||
const std::filesystem::path& mtl_dir,
|
||||
std::string_view filename,
|
||||
std::string_view texture_type_name
|
||||
);
|
||||
|
||||
private:
|
||||
path_id_lookups* m_id_lookups;
|
||||
data_stores* m_stores;
|
||||
data_type m_mesh{};
|
||||
std::vector<mesh_vertex_components::position> m_position_buffer{};
|
||||
std::vector<mesh_vertex_components::normal> m_normal_buffer{};
|
||||
std::vector<mesh_vertex_components::tex_coord> m_tex_coord_buffer{};
|
||||
std::unordered_map<component_indices, z3d::vertex_index> m_vertex_comp_indices_to_vertex_index{};
|
||||
data_type m_point_cloud{};
|
||||
std::filesystem::path m_last_pose_path{};
|
||||
pose_list_view m_last_pose_list{};
|
||||
};
|
||||
|
||||
[[nodiscard]] static ztu::result<pose_prefetch_lookup::index_type> parse_index(
|
||||
[[nodiscard]] static ztu::result<std::size_t> parse_scan_index(
|
||||
std::string_view filename
|
||||
);
|
||||
|
||||
ztu::result<std::pair<ztu::u32, std::chars_format>> analyze_component_format(
|
||||
std::string_view line
|
||||
);
|
||||
|
||||
void transform_point_cloud(
|
||||
std::span<point_cloud_vertex_components::position::value_type> points,
|
||||
const glm::mat4& pose
|
||||
);
|
||||
|
||||
private:
|
||||
std::error_code read_point_file(
|
||||
protected:
|
||||
[[nodiscard]] static std::error_code parse_file(
|
||||
const std::filesystem::path& filename,
|
||||
dynamic_point_cloud_buffer& point_cloud
|
||||
data_type& point_cloud
|
||||
);
|
||||
|
||||
static void transform_point_cloud(
|
||||
std::span<point_cloud_vertex_components::position> points,
|
||||
const pose_data& pose
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
@@ -39,9 +39,8 @@ protected:
|
||||
{
|
||||
public:
|
||||
parser_context(
|
||||
const pose_list_id_lookup& pose_list_lookup,
|
||||
const pose_list_store& pose_list_store,
|
||||
store_type& m_store,
|
||||
path_id_lookups& pose_list_lookup,
|
||||
data_stores& stores
|
||||
);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
@@ -56,9 +55,8 @@ protected:
|
||||
void remove_metadata_declarations();
|
||||
|
||||
private:
|
||||
pose_list_id_lookup const* m_pose_list_lookup;
|
||||
pose_list_store const* m_pose_list_store;
|
||||
store_type* m_store;
|
||||
path_id_lookups* m_pose_list_lookup;
|
||||
data_stores* m_stores;
|
||||
data_type m_buffer{};
|
||||
std::filesystem::path m_last_pose_path{};
|
||||
pose_list_view m_last_pose_list{};
|
||||
@@ -69,7 +67,7 @@ protected:
|
||||
std::string_view filename
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load_point_file(
|
||||
[[nodiscard]] static std::error_code parse_file(
|
||||
const std::filesystem::path& filename,
|
||||
data_type& point_cloud
|
||||
);
|
||||
@@ -93,4 +91,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/data_stores.hpp"
|
||||
#include "assets/path_id_lookups.hpp"
|
||||
#include "assets/data/pose_data.hpp"
|
||||
#include "util/result.hpp"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
@@ -14,30 +13,45 @@ namespace assets
|
||||
struct threedtk_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("3dtk_pose");
|
||||
using data_type = pose_list_data;
|
||||
using store_type = pose_list_store;
|
||||
using lookup_type = pose_list_id_lookup;
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
path_id_lookups& lookups
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
pose_data& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
[[nodiscard]] std::error_code load(
|
||||
path_id_lookups& lookups,
|
||||
data_stores& stores,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
static std::error_code parse_transform_info(
|
||||
std::ifstream& in,
|
||||
std::string& line,
|
||||
std::array<glm::vec3, 2>& transform_info
|
||||
class parser_context
|
||||
{
|
||||
public:
|
||||
parser_context(
|
||||
path_id_lookups& pose_list_lookup,
|
||||
data_stores& stores
|
||||
);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
|
||||
private:
|
||||
path_id_lookups* m_id_lookups;
|
||||
data_stores* m_stores;
|
||||
data_type m_pose{};
|
||||
std::string m_line_buffer{};
|
||||
};
|
||||
|
||||
static ztu::result<pose_data> parse_file(
|
||||
const std::filesystem::path& filename,
|
||||
std::string& line_buffer
|
||||
);
|
||||
|
||||
static ztu::result<pose_prefetch_lookup::index_type> parse_index(
|
||||
std::string_view filename
|
||||
);
|
||||
private:
|
||||
std::vector<lookup_type::const_pointer> m_path_buffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_loader : generic_3dtk_loader<false, false, false>
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct uos_loader : detail::generic_3dtk_loader<false, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_normal_loader : generic_3dtk_loader<true, false, false>
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct uos_normal_loader : detail::generic_3dtk_loader<true, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_normal");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_rgb_loader : generic_3dtk_loader<false, true, false>
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct uos_rgb_loader : detail::generic_3dtk_loader<false, true, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_rgb");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uosr_loader : generic_3dtk_loader<false, false, true>
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct uosr_loader : detail::generic_3dtk_loader<false, false, true>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uosr");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user