fixes
This commit is contained in:
59
include/assets/components/material_components.hpp
Normal file
59
include/assets/components/material_components.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include "../dynamic_read_buffers"
|
||||
#include "assets/data/surface_properties.hpp"
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::material
|
||||
{
|
||||
using surface_properties = ::surface_properties;
|
||||
using transparency = float;
|
||||
using ambient_color_texture = ::dynamic_texture_data;
|
||||
using diffuse_color_texture = ::dynamic_texture_data;
|
||||
using specular_color_texture = ::dynamic_texture_data;
|
||||
using shininess_texture = ::dynamic_texture_data;
|
||||
using alpha_texture = ::dynamic_texture_data;
|
||||
using bump_texture = ::dynamic_texture_data;
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = std::size_t;
|
||||
inline constexpr type surface_properties = 0;
|
||||
inline constexpr type transparency = 1;
|
||||
inline constexpr type ambient_color_texture = 2;
|
||||
inline constexpr type diffuse_color_texture = 3;
|
||||
inline constexpr type specular_color_texture = 4;
|
||||
inline constexpr type shininess_texture = 5;
|
||||
inline constexpr type alpha_texture = 6;
|
||||
inline constexpr type bump_texture = 7;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
surface_properties = 1 << indices::surface_properties,
|
||||
transparency = 1 << indices::transparency,
|
||||
ambient_filter_texture = 1 << indices::ambient_color_texture,
|
||||
diffuse_filter_texture = 1 << indices::diffuse_color_texture,
|
||||
specular_filter_texture = 1 << indices::specular_color_texture,
|
||||
shininess_texture = 1 << indices::shininess_texture,
|
||||
alpha_texture = 1 << indices::alpha_texture,
|
||||
bump_texture = 1 << indices::bump_texture
|
||||
};
|
||||
|
||||
using all = std::tuple<
|
||||
surface_properties,
|
||||
transparency,
|
||||
ambient_color_texture,
|
||||
diffuse_color_texture,
|
||||
specular_color_texture,
|
||||
shininess_texture,
|
||||
alpha_texture,
|
||||
bump_texture
|
||||
>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace material_component
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::material::flags)
|
||||
39
include/assets/components/mesh_vertex_components.hpp
Executable file
39
include/assets/components/mesh_vertex_components.hpp
Executable file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::mesh_vertex {
|
||||
|
||||
using position = std::array<float, 3>;
|
||||
using normal = std::array<float, 3>;
|
||||
using tex_coord = std::array<float, 2>;
|
||||
using color = std::array<float, 3>;
|
||||
using reflectance = std::array<float, 1>;
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = std::size_t;
|
||||
inline constexpr type position = 0;
|
||||
inline constexpr type normal = 1;
|
||||
inline constexpr type tex_coord = 2;
|
||||
inline constexpr type color = 3;
|
||||
inline constexpr type reflectance = 4;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t {
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
normal = 1 << indices::normal,
|
||||
tex_coord = 1 << indices::tex_coord,
|
||||
color = 1 << indices::color,
|
||||
reflectance = 1 << indices::reflectance
|
||||
};
|
||||
|
||||
using all = std::tuple<position, normal, tex_coord, color, reflectance>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::mesh_vertex
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::mesh_vertex::flags)
|
||||
36
include/assets/components/point_cloud_vertex_components.hpp
Executable file
36
include/assets/components/point_cloud_vertex_components.hpp
Executable file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::point_cloud_vertex {
|
||||
|
||||
using position = std::array<float, 3>;
|
||||
using normal = std::array<float, 3>;
|
||||
using color = std::array<float, 3>;
|
||||
using reflectance = std::array<float, 1>;
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = std::size_t;
|
||||
inline constexpr type position = 0;
|
||||
inline constexpr type normal = 1;
|
||||
inline constexpr type color = 2;
|
||||
inline constexpr type reflectance = 3;
|
||||
} // namespace indices
|
||||
|
||||
enum class flags : std::uint8_t {
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
normal = 1 << indices::normal,
|
||||
color = 1 << indices::color,
|
||||
reflectance = 1 << indices::reflectance
|
||||
};
|
||||
|
||||
using all = std::tuple<position, normal, color, reflectance>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::point_cloud_vertex
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::point_cloud_vertex::flags)
|
||||
28
include/assets/components/texture_components.hpp
Normal file
28
include/assets/components/texture_components.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <cinttypes>
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::texture {
|
||||
|
||||
using red = std::uint8_t;
|
||||
using green = std::uint8_t;
|
||||
using blue = std::uint8_t;
|
||||
using luminance = std::uint8_t;
|
||||
|
||||
enum class flags : std::uint8_t {
|
||||
none = 0,
|
||||
luminance = 1 << 1,
|
||||
red = 1 << 2,
|
||||
green = 1 << 3,
|
||||
blue = 1 << 4,
|
||||
alpha = 1 << 5
|
||||
};
|
||||
|
||||
using all = std::tuple<red, green, blue, luminance>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::texture
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::texture::flags)
|
||||
11
include/assets/data/surface_properties.hpp
Normal file
11
include/assets/data/surface_properties.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
struct surface_properties
|
||||
{
|
||||
std::array<float, 3> ambient_filter{ 0.7f, 0.7f, 0.7f };
|
||||
std::array<float, 3> diffuse_filter{ 0.466f, 0.466f, 0.7922f };
|
||||
std::array<float, 3> specular_filter{ 0.5974f, 0.2084f, 0.2084f };
|
||||
float shininess{ 100.2237f };
|
||||
};
|
||||
30
include/assets/data_loaders/glsl_loader.hpp
Normal file
30
include/assets/data_loaders/glsl_loader.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_shader_buffer.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
struct glsl_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("glsl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_shader_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
53
include/assets/data_loaders/kitti_loader.hpp
Normal file
53
include/assets/data_loaders/kitti_loader.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
struct kitti_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_point_cloud_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
inline static constexpr auto frame_folder = "frames";
|
||||
|
||||
[[nodiscard]] static ztu::result<std::size_t> frame_id_from_filename(
|
||||
std::string_view filename
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load_point_file(
|
||||
const std::filesystem::path& filename,
|
||||
dynamic_point_cloud_buffer& point_cloud
|
||||
);
|
||||
|
||||
static void transform_point_cloud(
|
||||
std::span<components::point_cloud_vertex::position> points,
|
||||
const glm::mat4& pose
|
||||
);
|
||||
|
||||
[[nodiscard]] static ztu::result<std::string_view> parent_directory(std::string_view path);
|
||||
|
||||
|
||||
};
|
||||
37
include/assets/data_loaders/kitti_pose_loader.hpp
Normal file
37
include/assets/data_loaders/kitti_pose_loader.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_pose_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_pose_buffer.hpp"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
struct kitti_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti_pose");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
static constexpr auto pose_filename = std::string_view{ "pose.txt" };
|
||||
|
||||
static std::error_code parse_pose(
|
||||
std::ifstream& in,
|
||||
dynamic_pose_buffer& pose
|
||||
);
|
||||
};
|
||||
56
include/assets/data_loaders/mtl_loader.hpp
Normal file
56
include/assets/data_loaders/mtl_loader.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
namespace mtl_loader_error {
|
||||
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
mtl_cannot_open_file,
|
||||
mtl_cannot_open_texture,
|
||||
mtl_malformed_ambient_color,
|
||||
mtl_malformed_diffuse_color,
|
||||
mtl_malformed_specular_color,
|
||||
mtl_malformed_specular_exponent,
|
||||
mtl_malformed_dissolve,
|
||||
mlt_unknown_line_begin
|
||||
};
|
||||
|
||||
} // namespace mtl_loader_error
|
||||
|
||||
class mtl_loader {
|
||||
public:
|
||||
static constexpr auto name = std::string_view("mtl");
|
||||
|
||||
std::optional<dynamic_material_store::id_type> find_id(std::string_view name);
|
||||
|
||||
void clear_name_lookup();
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
// THis is not very elegant, but right now I do not see a better solution...
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_material_library_buffer& material_library_buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
ztu::string_lookup<dynamic_material_store::id_type> m_id_lookup;
|
||||
};
|
||||
42
include/assets/data_loaders/obj_loader.hpp
Executable file
42
include/assets/data_loaders/obj_loader.hpp
Executable file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
#include "assets/dynamic_data_loaders/dynamic_material_loader.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
|
||||
namespace obj_loader_error {
|
||||
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
obj_cannot_open_file,
|
||||
obj_malformed_vertex,
|
||||
obj_malformed_texture_coordinate,
|
||||
obj_malformed_normal,
|
||||
obj_malformed_face,
|
||||
obj_face_index_out_of_range,
|
||||
obj_unknown_line_begin
|
||||
};
|
||||
|
||||
} // namespace obj_loader_error
|
||||
|
||||
struct obj_loader {
|
||||
|
||||
static constexpr auto name = std::string_view("obj");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
components::mesh_vertex::flags enabled_components,
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
30
include/assets/data_loaders/stl_loader.hpp
Normal file
30
include/assets/data_loaders/stl_loader.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
|
||||
struct stl_loader {
|
||||
|
||||
static constexpr auto name = std::string_view("stl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
// space stuff that has to persist
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
40
include/assets/data_loaders/threedtk_pose_loader.hpp
Normal file
40
include/assets/data_loaders/threedtk_pose_loader.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_pose_buffer.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
#include "util/result.hpp"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
struct threedtk_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("3dtk_pose");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
static std::error_code parse_transform_info(
|
||||
std::ifstream& in,
|
||||
std::string& line,
|
||||
std::array<glm::vec3, 2>& transform_info
|
||||
);
|
||||
|
||||
static ztu::result<pose_prefetch_lookup::index_type> parse_index(
|
||||
std::string_view filename
|
||||
);
|
||||
};
|
||||
9
include/assets/data_loaders/uos_loader.hpp
Normal file
9
include/assets/data_loaders/uos_loader.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_loader : generic_3dtk_loader<false, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos");
|
||||
};
|
||||
|
||||
8
include/assets/data_loaders/uos_normal_loader.hpp
Normal file
8
include/assets/data_loaders/uos_normal_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_normal_loader : generic_3dtk_loader<true, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_normal");
|
||||
};
|
||||
8
include/assets/data_loaders/uos_rgb_loader.hpp
Normal file
8
include/assets/data_loaders/uos_rgb_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_rgb_loader : generic_3dtk_loader<false, true, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_rgb");
|
||||
};
|
||||
8
include/assets/data_loaders/uosr_loader.hpp
Normal file
8
include/assets/data_loaders/uosr_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uosr_loader : generic_3dtk_loader<false, false, true>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uosr");
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_library_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
|
||||
#include "assets/prefetch_lookups/material_library_prefetch_lookup.hpp"
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
|
||||
#include "assets/data_loaders/mtl_loader.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
class dynamic_material_library_loader : public base_dynamic_loader<
|
||||
components::material::flags,
|
||||
mtl_loader
|
||||
> {
|
||||
public:
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_material_library_store& store,
|
||||
dynamic_material_store& material_store,
|
||||
material_library_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_material_library_buffer m_buffer{};
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
|
||||
#include "assets/data_loaders/mtl_loader.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
#include "assets/prefetch_lookups/material_prefetch_lookup.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
class dynamic_material_loader : public base_dynamic_loader<
|
||||
components::material::flags
|
||||
// TODO no loaders
|
||||
> {
|
||||
public:
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_material_store& store,
|
||||
material_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_material_buffer m_buffer{};
|
||||
};
|
||||
35
include/assets/dynamic_data_loaders/dynamic_mesh_loader.hpp
Normal file
35
include/assets/dynamic_data_loaders/dynamic_mesh_loader.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "assets/data_loaders/obj_loader.hpp"
|
||||
#include "assets/data_loaders/stl_loader.hpp"
|
||||
#include "assets/prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
|
||||
|
||||
class dynamic_mesh_loader : public base_dynamic_loader<
|
||||
components::mesh_vertex::flags,
|
||||
obj_loader,
|
||||
stl_loader
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_mesh_store& store,
|
||||
mesh_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_mesh_buffer m_buffer{};
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
|
||||
#include "assets/data_loaders/kitti_loader.hpp"
|
||||
#include "assets/data_loaders/uos_loader.hpp"
|
||||
#include "assets/data_loaders/uos_normal_loader.hpp"
|
||||
#include "assets/data_loaders/uos_rgb_loader.hpp"
|
||||
#include "assets/data_loaders/uosr_loader.hpp"
|
||||
#include "assets/prefetch_lookups/point_cloud_prefetch_lookup.hpp"
|
||||
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
class dynamic_point_cloud_loader : public base_dynamic_loader<
|
||||
components::point_cloud_vertex::flags,
|
||||
kitti_loader,
|
||||
uos_loader,
|
||||
uos_normal_loader,
|
||||
uos_rgb_loader,
|
||||
uos_loader,
|
||||
uosr_loader
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_point_cloud_store& store,
|
||||
point_cloud_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_point_cloud_buffer m_buffer{};
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <filesystem>
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
#include "assets/components/texture_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
#include "assets/dynamic_data_loader_ctx.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/prefetch_lookups/texture_prefetch_lookup.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
/*
|
||||
* [[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_point_cloud_store& store,
|
||||
point_cloud_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
*/
|
||||
|
||||
class dynamic_texture_loader
|
||||
{
|
||||
public:
|
||||
using loader_id_type = ztu::id_type_for<dynamic_texture_loader, ztu::u8>;
|
||||
|
||||
explicit dynamic_texture_loader(components::texture::flags enabled_components);
|
||||
|
||||
[[nodiscard]] std::optional<loader_id_type> find_loader(const std::string_view& name);
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_texture_store& store,
|
||||
texture_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
ztu::string_lookup<loader_id_type> m_loader_id_lookup{};
|
||||
components::texture::flags m_enabled_components{ components::texture::flags::none };
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
#include "util/uix.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
template<typename C, class... Loaders>
|
||||
class base_dynamic_loader
|
||||
{
|
||||
public:
|
||||
using loader_id_type = ztu::id_type_for<base_dynamic_loader, ztu::u32>;
|
||||
|
||||
explicit base_dynamic_loader(C enabled_components);
|
||||
|
||||
[[nodiscard]] std::optional<loader_id_type> find_loader(std::string_view name);
|
||||
|
||||
[[nodiscard]] static consteval std::optional<loader_id_type> find_loader_static(std::string_view name);
|
||||
|
||||
template<loader_id_type ID>
|
||||
auto& get_loader();
|
||||
|
||||
protected:
|
||||
|
||||
template<typename F>
|
||||
ztu::result<dynamic_point_cloud_store::id_type> invoke_with_matching_loader(loader_id_type loader_id, F&& f);
|
||||
|
||||
std::tuple<Loaders...> m_loaders{};
|
||||
ztu::string_lookup<loader_id_type> m_loader_id_lookup{};
|
||||
C m_enabled_components{ 0 };
|
||||
};
|
||||
|
||||
#define INCLUDE_BASE_DYNAMIC_LOADER_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_loaders/generic/base_dynamic_loader.ipp"
|
||||
#undef INCLUDE_BASE_DYNAMIC_LOADER_IMPLEMENTATION
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_library_buffer.hpp"
|
||||
|
||||
using dynamic_material_library_store = generic_dynamic_store<dynamic_material_library_buffer>;
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "dynamic_texture_store.hpp"
|
||||
#include "generic/generic_dynamic_component_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_buffer.hpp"
|
||||
|
||||
class dynamic_material_store {
|
||||
using store_type = generic_dynamic_component_store<
|
||||
components::material::flags,
|
||||
components::material::surface_properties,
|
||||
components::material::transparency,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type
|
||||
>;
|
||||
|
||||
public:
|
||||
using id_type = store_type::id_type;
|
||||
using iterator_type = store_type::iterator_type;
|
||||
using const_iterator = store_type::const_iterator;
|
||||
|
||||
id_type add(const dynamic_material_buffer& data);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
store_type m_store;
|
||||
};
|
||||
37
include/assets/dynamic_data_stores/dynamic_mesh_store.hpp
Normal file
37
include/assets/dynamic_data_stores/dynamic_mesh_store.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_indexed_component_array_store.hpp"
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp"
|
||||
|
||||
class dynamic_mesh_store
|
||||
{
|
||||
using store_type = generic_dynamic_indexed_component_array_store<
|
||||
components::mesh_vertex::flags,
|
||||
ztu::u32,
|
||||
components::mesh_vertex::position,
|
||||
components::mesh_vertex::normal,
|
||||
components::mesh_vertex::tex_coord,
|
||||
components::mesh_vertex::color,
|
||||
components::mesh_vertex::reflectance
|
||||
>;
|
||||
|
||||
public:
|
||||
using id_type = store_type::id_type;
|
||||
using iterator_type = store_type::iterator_type;
|
||||
using const_iterator = store_type::const_iterator;
|
||||
|
||||
id_type add(const dynamic_mesh_buffer& mesh_buffer);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
store_type m_store;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_component_array_store.hpp"
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp"
|
||||
|
||||
|
||||
class dynamic_point_cloud_store
|
||||
{
|
||||
using store_type = generic_dynamic_component_array_store<
|
||||
components::point_cloud_vertex::flags,
|
||||
components::point_cloud_vertex::position,
|
||||
components::point_cloud_vertex::normal,
|
||||
components::point_cloud_vertex::color,
|
||||
components::point_cloud_vertex::reflectance
|
||||
>;
|
||||
|
||||
public:
|
||||
using id_type = store_type::id_type;
|
||||
using iterator_type = store_type::iterator_type;
|
||||
using const_iterator = store_type::const_iterator;
|
||||
|
||||
id_type add(const dynamic_point_cloud_buffer& point_cloud_buffer);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
store_type m_store;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
using dynamic_pose_store = generic_dynamic_store<glm::mat4>;
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
class dynamic_shader_store {
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.hpp"
|
||||
|
||||
using dynamic_texture_store = generic_dynamic_store<dynamic_texture_buffer>;
|
||||
37
include/assets/dynamic_data_stores/dynamic_vertex_store.hpp
Normal file
37
include/assets/dynamic_data_stores/dynamic_vertex_store.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include "util/id_type.hpp"
|
||||
#include "util/uix.hpp"
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class dynamic_vertex_store {
|
||||
public:
|
||||
using id_type = ztu::id_type_for<dynamic_vertex_store, ztu::u32>;
|
||||
|
||||
void add(
|
||||
C component_flags,
|
||||
std::span<const Ts>... components
|
||||
);
|
||||
|
||||
void build_vertex_buffer(
|
||||
std::vector<ztu::u8>& vertex_buffer,
|
||||
std::size_t& component_count,
|
||||
std::array<GLenum, sizeof...(Ts)>& component_types,
|
||||
std::array<GLint, sizeof...(Ts)>& component_lengths,
|
||||
GLsizei& stride
|
||||
) const;
|
||||
|
||||
protected:
|
||||
std::tuple<std::vector<Ts>...> m_component_buffers{};
|
||||
std::vector<std::size_t> vertex_counts;
|
||||
std::vector<C> m_components{ 0 };
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_model_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,149 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
#include <tuple>
|
||||
#include <span>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_array_store;
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class component_array_iterator {
|
||||
public:
|
||||
using value_type = std::tuple<std::span<Ts>...>;
|
||||
using size_type = std::size_t;
|
||||
using count_type = ztu::u32;
|
||||
using flag_count_type = std::pair<C, count_type>;
|
||||
using component_array_pointer_type = std::tuple<std::add_pointer_t<Ts>...>;
|
||||
using flag_count_pointer_type = const flag_count_type*;
|
||||
using offsets_type = std::array<size_type, sizeof...(Ts)>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
|
||||
private:
|
||||
friend generic_dynamic_component_array_store<C, Ts...>;
|
||||
|
||||
component_array_iterator(
|
||||
component_array_pointer_type components,
|
||||
flag_count_pointer_type flags,
|
||||
std::size_t index,
|
||||
const offsets_type& offsets
|
||||
);
|
||||
|
||||
public:
|
||||
constexpr component_array_iterator() noexcept = default;
|
||||
|
||||
constexpr component_array_iterator(const component_array_iterator&) noexcept = default;
|
||||
constexpr component_array_iterator(component_array_iterator&&) noexcept = default;
|
||||
|
||||
constexpr component_array_iterator& operator=(const component_array_iterator&) noexcept = default;
|
||||
constexpr component_array_iterator& operator=(component_array_iterator&&) noexcept = default;
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
component_array_iterator& operator++();
|
||||
component_array_iterator operator++(int);
|
||||
component_array_iterator& operator--();
|
||||
component_array_iterator operator--(int);
|
||||
|
||||
component_array_iterator& operator+=(difference_type n);
|
||||
component_array_iterator& operator-=(difference_type n);
|
||||
component_array_iterator operator+(difference_type n) const;
|
||||
component_array_iterator operator-(difference_type n) const;
|
||||
difference_type operator-(const component_array_iterator& other) const;
|
||||
|
||||
reference operator[](difference_type n) const;
|
||||
|
||||
bool operator==(const component_array_iterator& other) const;
|
||||
bool operator!=(const component_array_iterator& other) const;
|
||||
bool operator<(const component_array_iterator& other) const;
|
||||
bool operator<=(const component_array_iterator& other) const;
|
||||
bool operator>(const component_array_iterator& other) const;
|
||||
bool operator>=(const component_array_iterator& other) const;
|
||||
|
||||
protected:
|
||||
template <std::size_t I>
|
||||
static bool is_component_enabled(C flag);
|
||||
|
||||
template <std::size_t... Is>
|
||||
void calc_offsets(std::index_sequence<Is...>, difference_type n);
|
||||
|
||||
template <std::size_t... Is>
|
||||
reference dereference(std::index_sequence<Is...>) const;
|
||||
|
||||
template <std::size_t N>
|
||||
std::tuple_element_t<N, value_type> get_span() const;
|
||||
|
||||
private:
|
||||
value_type m_components{};
|
||||
const flag_count_type* m_flag_counts{};
|
||||
size_type m_index{};
|
||||
offsets_type m_offsets{};
|
||||
};
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_array_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_component_array_store, ztu::u32>;
|
||||
using count_type = ztu::u32;
|
||||
using iterator_type = component_array_iterator<C, Ts...>;
|
||||
using const_iterator = component_array_iterator<C, std::add_const_t<Ts>...>;
|
||||
using view_type = std::ranges::subrange<iterator_type>;
|
||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
||||
|
||||
id_type add(const std::tuple<std::vector<Ts>...>& component_arrays);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
iterator_type begin();
|
||||
|
||||
iterator_type end();
|
||||
|
||||
const_iterator begin() const;
|
||||
|
||||
const_iterator end() const;
|
||||
|
||||
const_iterator cbegin() const;
|
||||
|
||||
const_iterator cend() const;
|
||||
|
||||
view_type view();
|
||||
|
||||
const_view_type view() const;
|
||||
|
||||
protected:
|
||||
std::tuple<std::add_pointer_t<Ts>...> data_ptrs();
|
||||
|
||||
std::tuple<std::add_pointer_t<std::add_const_t<Ts>>...> data_ptrs() const;
|
||||
|
||||
std::array<std::size_t, sizeof...(Ts)> data_counts() const;
|
||||
|
||||
private:
|
||||
std::tuple<std::vector<Ts>...> m_component_arrays;
|
||||
std::vector<std::pair<C, ztu::u32>> m_component_flag_counts;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_component_array_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
@@ -0,0 +1,147 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
#include <tuple>
|
||||
#include <span>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_store;
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class component_iterator {
|
||||
public:
|
||||
|
||||
|
||||
using value_type = std::tuple<std::add_pointer_t<Ts>...>;
|
||||
using size_type = std::size_t;
|
||||
using offsets_type = std::array<size_type, sizeof...(Ts)>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
|
||||
private:
|
||||
friend generic_dynamic_component_store<C, Ts...>;
|
||||
|
||||
component_iterator(
|
||||
value_type components,
|
||||
const C* flags,
|
||||
std::size_t index,
|
||||
const offsets_type& offsets
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
constexpr component_iterator() noexcept = default;
|
||||
|
||||
constexpr component_iterator(const component_iterator&) noexcept = default;
|
||||
constexpr component_iterator(component_iterator&&) noexcept = default;
|
||||
|
||||
constexpr component_iterator& operator=(const component_iterator&) noexcept = default;
|
||||
constexpr component_iterator& operator=(component_iterator&&) noexcept = default;
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
component_iterator& operator++();
|
||||
component_iterator operator++(int);
|
||||
component_iterator& operator--();
|
||||
component_iterator operator--(int);
|
||||
|
||||
component_iterator& operator+=(difference_type n);
|
||||
component_iterator& operator-=(difference_type n);
|
||||
component_iterator operator+(difference_type n) const;
|
||||
component_iterator operator-(difference_type n) const;
|
||||
difference_type operator-(const component_iterator& other) const;
|
||||
|
||||
reference operator[](difference_type n) const;
|
||||
|
||||
bool operator==(const component_iterator& other) const;
|
||||
bool operator!=(const component_iterator& other) const;
|
||||
bool operator<(const component_iterator& other) const;
|
||||
bool operator<=(const component_iterator& other) const;
|
||||
bool operator>(const component_iterator& other) const;
|
||||
bool operator>=(const component_iterator& other) const;
|
||||
|
||||
protected:
|
||||
template <std::size_t I>
|
||||
static bool is_component_enabled(C flag);
|
||||
|
||||
template <std::size_t... Is>
|
||||
void calc_offsets(std::index_sequence<Is...>, difference_type n);
|
||||
|
||||
template <std::size_t... Is>
|
||||
reference dereference(std::index_sequence<Is...>) const;
|
||||
|
||||
template <std::size_t N>
|
||||
std::tuple_element_t<N, value_type> get_pointer() const;
|
||||
|
||||
private:
|
||||
value_type m_components{};
|
||||
const C* m_flags{};
|
||||
size_type m_index{};
|
||||
offsets_type m_offsets{};
|
||||
};
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_component_store, ztu::u32>;
|
||||
using iterator_type = component_iterator<C, Ts...>;
|
||||
using const_iterator = component_iterator<C, std::add_const_t<Ts>...>;
|
||||
using view_type = std::ranges::subrange<iterator_type>;
|
||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
||||
|
||||
id_type add(const std::tuple<std::optional<Ts>...>& data);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
iterator_type begin();
|
||||
|
||||
iterator_type end();
|
||||
|
||||
const_iterator begin() const;
|
||||
|
||||
const_iterator end() const;
|
||||
|
||||
const_iterator cbegin() const;
|
||||
|
||||
const_iterator cend() const;
|
||||
|
||||
view_type view();
|
||||
|
||||
const_view_type view() const;
|
||||
|
||||
protected:
|
||||
std::tuple<std::add_pointer_t<Ts>...> data_ptrs();
|
||||
|
||||
std::tuple<std::add_pointer_t<std::add_const_t<Ts>>...> data_ptrs() const;
|
||||
|
||||
std::array<std::size_t, sizeof...(Ts)> data_counts() const;
|
||||
|
||||
private:
|
||||
std::tuple<std::vector<Ts>...> m_components;
|
||||
std::vector<C> m_component_flags;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_COMPONENT_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic_dynamic_component_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_COMPONENT_STORE_IMPLEMENTATION
|
||||
@@ -0,0 +1,157 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
#include <tuple>
|
||||
#include <span>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
template<typename C, typename I, typename... Ts>
|
||||
class generic_dynamic_indexed_component_array_store;
|
||||
|
||||
template<typename C, typename I, typename... Ts>
|
||||
class indexed_component_array_iterator {
|
||||
public:
|
||||
using index_type = I;
|
||||
using value_type = std::tuple<std::span<I>, std::span<Ts>...>;
|
||||
using size_type = std::size_t;
|
||||
using count_type = ztu::u32;
|
||||
using flag_count_type = std::tuple<C, count_type, count_type>;
|
||||
using index_array_pointer_type = const index_type*;
|
||||
using component_array_pointer_type = std::tuple<std::add_pointer_t<Ts>...>;
|
||||
using flag_count_pointer_type = const flag_count_type*;
|
||||
|
||||
using offsets_type = std::array<size_type, 1 + sizeof...(Ts)>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
|
||||
private:
|
||||
friend generic_dynamic_indexed_component_array_store<C, I, Ts...>;
|
||||
|
||||
indexed_component_array_iterator(
|
||||
index_array_pointer_type indices,
|
||||
const component_array_pointer_type& components,
|
||||
flag_count_pointer_type flag_counts,
|
||||
std::size_t index,
|
||||
const offsets_type& offsets
|
||||
);
|
||||
|
||||
public:
|
||||
constexpr indexed_component_array_iterator() noexcept = default;
|
||||
|
||||
constexpr indexed_component_array_iterator(const indexed_component_array_iterator&) noexcept = default;
|
||||
constexpr indexed_component_array_iterator(indexed_component_array_iterator&&) noexcept = default;
|
||||
|
||||
constexpr indexed_component_array_iterator& operator=(const indexed_component_array_iterator&) noexcept = default;
|
||||
constexpr indexed_component_array_iterator& operator=(indexed_component_array_iterator&&) noexcept = default;
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
indexed_component_array_iterator& operator++();
|
||||
indexed_component_array_iterator operator++(int);
|
||||
indexed_component_array_iterator& operator--();
|
||||
indexed_component_array_iterator operator--(int);
|
||||
|
||||
indexed_component_array_iterator& operator+=(difference_type n);
|
||||
indexed_component_array_iterator& operator-=(difference_type n);
|
||||
indexed_component_array_iterator operator+(difference_type n) const;
|
||||
indexed_component_array_iterator operator-(difference_type n) const;
|
||||
difference_type operator-(const indexed_component_array_iterator& other) const;
|
||||
|
||||
reference operator[](difference_type n) const;
|
||||
|
||||
bool operator==(const indexed_component_array_iterator& other) const;
|
||||
bool operator!=(const indexed_component_array_iterator& other) const;
|
||||
bool operator<(const indexed_component_array_iterator& other) const;
|
||||
bool operator<=(const indexed_component_array_iterator& other) const;
|
||||
bool operator>(const indexed_component_array_iterator& other) const;
|
||||
bool operator>=(const indexed_component_array_iterator& other) const;
|
||||
|
||||
protected:
|
||||
template <std::size_t N>
|
||||
static bool is_component_enabled(C flag);
|
||||
|
||||
template <std::size_t... Is>
|
||||
void calc_offsets(std::index_sequence<Is...>, difference_type n);
|
||||
|
||||
template <std::size_t... Is>
|
||||
reference dereference(std::index_sequence<Is...>) const;
|
||||
|
||||
private:
|
||||
index_array_pointer_type m_indices{};
|
||||
component_array_pointer_type m_components{};
|
||||
flag_count_pointer_type m_flag_counts{};
|
||||
size_type m_index{};
|
||||
offsets_type m_offsets{};
|
||||
};
|
||||
|
||||
template<typename C, typename I, typename... Ts>
|
||||
class generic_dynamic_indexed_component_array_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_indexed_component_array_store, ztu::u32>;
|
||||
using count_type = ztu::u32;
|
||||
using iterator_type = indexed_component_array_iterator<C, I, Ts...>;
|
||||
using const_iterator = indexed_component_array_iterator<C, I, std::add_const_t<Ts>...>;
|
||||
using view_type = std::ranges::subrange<iterator_type>;
|
||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
||||
|
||||
id_type add(
|
||||
std::span<const I> indices,
|
||||
const std::tuple<std::vector<Ts>...>& component_arrays
|
||||
);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
iterator_type begin();
|
||||
|
||||
iterator_type end();
|
||||
|
||||
const_iterator begin() const;
|
||||
|
||||
const_iterator end() const;
|
||||
|
||||
const_iterator cbegin() const;
|
||||
|
||||
const_iterator cend() const;
|
||||
|
||||
view_type view();
|
||||
|
||||
const_view_type view() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
std::tuple<std::add_pointer_t<Ts>...> component_array_ptrs();
|
||||
|
||||
std::tuple<std::add_pointer_t<std::add_const_t<Ts>>...> component_array_ptrs() const;
|
||||
|
||||
std::array<std::size_t, 1 + sizeof...(Ts)> array_counts() const;
|
||||
|
||||
private:
|
||||
std::vector<I> m_indices;
|
||||
std::tuple<std::vector<Ts>...> m_component_arrays;
|
||||
std::vector<std::pair<C, ztu::u32>> m_component_flag_counts;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_INDEXED_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_indexed_component_array_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_INDEXED_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
template<typename T>
|
||||
class generic_dynamic_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_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);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
[[nodiscard]] std::span<T> data();
|
||||
|
||||
[[nodiscard]] std::span<const T> data() const;
|
||||
|
||||
void remove(iterator_type it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic_dynamic_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_STORE_IMPLEMENTATION
|
||||
48
include/assets/dynamic_read_buffers/dynamic_material_buffer.hpp
Executable file
48
include/assets/dynamic_read_buffers/dynamic_material_buffer.hpp
Executable file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
|
||||
struct dynamic_material_buffer {
|
||||
|
||||
dynamic_material_buffer() = default;
|
||||
|
||||
components::material::surface_properties& initialized_surface_properties();
|
||||
|
||||
[[nodiscard]] std::optional<components::material::surface_properties>& surface_properties();
|
||||
[[nodiscard]] std::optional<components::material::transparency>& transparency();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& ambient_color_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& diffuse_color_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& specular_color_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& shininess_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& alpha_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& bump_texture_id();
|
||||
|
||||
[[nodiscard]] const std::optional<components::material::surface_properties>& surface_properties() const;
|
||||
[[nodiscard]] const std::optional<components::material::transparency>& transparency() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& ambient_color_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& diffuse_color_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& specular_color_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& shininess_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& alpha_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& bump_texture_id() const;
|
||||
|
||||
std::tuple<
|
||||
std::optional<components::material::surface_properties>,
|
||||
std::optional<components::material::transparency>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>
|
||||
> data{
|
||||
std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt
|
||||
};
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
|
||||
using dynamic_material_library_buffer = ztu::string_lookup<dynamic_material_store::id_type>;
|
||||
46
include/assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp
Normal file
46
include/assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
|
||||
class dynamic_mesh_buffer : public dynamic_vertex_buffer<
|
||||
components::mesh_vertex::flags,
|
||||
components::mesh_vertex::position,
|
||||
components::mesh_vertex::normal,
|
||||
components::mesh_vertex::tex_coord,
|
||||
components::mesh_vertex::color,
|
||||
components::mesh_vertex::reflectance
|
||||
> {
|
||||
public:
|
||||
using index_type = ztu::u32;
|
||||
using triangle_type = std::array<index_type, 3>;
|
||||
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::position>& positions();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::normal>& normals();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::tex_coord>& tex_coords();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::color>& colors();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::reflectance>& reflectances();
|
||||
[[nodiscard]] std::vector<triangle_type>& triangles();
|
||||
[[nodiscard]] auto& material_id();
|
||||
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::position>& positions() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::normal>& normals() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::tex_coord>& tex_coords() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::color>& colors() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::reflectance>& reflectances() const;
|
||||
[[nodiscard]] const std::vector<triangle_type>& triangles() const;
|
||||
[[nodiscard]] const auto& material_id() const;
|
||||
|
||||
private:
|
||||
std::vector<triangle_type> m_triangles{};
|
||||
dynamic_material_store::id_type m_material_id{};
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp"
|
||||
|
||||
class dynamic_point_cloud_buffer : public dynamic_vertex_buffer<
|
||||
components::point_cloud_vertex::flags,
|
||||
components::point_cloud_vertex::position,
|
||||
components::point_cloud_vertex::normal,
|
||||
components::point_cloud_vertex::color,
|
||||
components::point_cloud_vertex::reflectance
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::position>& positions();
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::normal>& normals();
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::color>& colors();
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::reflectance>& reflectances();
|
||||
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::position>& positions() const;
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::normal>& normals() const;
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::color>& colors() const;
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::reflectance>& reflectances() const;
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
using dynamic_pose_buffer = glm::mat4;
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "GL/glew.h"
|
||||
|
||||
struct dynamic_shader_buffer
|
||||
{
|
||||
std::vector<char> source{};
|
||||
GLenum type{ GL_INVALID_ENUM };
|
||||
};
|
||||
77
include/assets/dynamic_read_buffers/dynamic_texture_buffer.hpp
Executable file
77
include/assets/dynamic_read_buffers/dynamic_texture_buffer.hpp
Executable file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <bit>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include "assets/components/texture_components.hpp"
|
||||
|
||||
class dynamic_texture_buffer {
|
||||
public:
|
||||
using value_type = std::uint8_t;
|
||||
using dim_type = std::int32_t;
|
||||
using size_type = std::make_signed_t<std::size_t>;
|
||||
using difference_type = size_type;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using pointer = std::uint8_t*;
|
||||
using const_pointer = const std::uint8_t*;
|
||||
using iterator = pointer;
|
||||
using const_iterator = const_pointer;
|
||||
|
||||
dynamic_texture_buffer() = default;
|
||||
|
||||
dynamic_texture_buffer(
|
||||
std::unique_ptr<value_type>&& data,
|
||||
dim_type width,
|
||||
dim_type height,
|
||||
components::texture::flags components
|
||||
);
|
||||
|
||||
dynamic_texture_buffer(const dynamic_texture_buffer&);
|
||||
|
||||
dynamic_texture_buffer(dynamic_texture_buffer&&) noexcept;
|
||||
|
||||
[[nodiscard]] dynamic_texture_buffer& operator=(const dynamic_texture_buffer&);
|
||||
|
||||
[[nodiscard]] dynamic_texture_buffer& operator=(dynamic_texture_buffer&&) noexcept;
|
||||
|
||||
[[nodiscard]] components::texture::flags components() const;
|
||||
|
||||
[[nodiscard]] dim_type width() const;
|
||||
|
||||
[[nodiscard]] dim_type height() const;
|
||||
|
||||
[[nodiscard]] std::pair<dim_type, dim_type> dimensions() const;
|
||||
|
||||
[[nodiscard]] size_type pixel_count() const;
|
||||
|
||||
[[nodiscard]] size_type component_count() const;
|
||||
|
||||
[[nodiscard]] size_type size() const;
|
||||
|
||||
[[nodiscard]] const_iterator begin() const;
|
||||
|
||||
[[nodiscard]] iterator begin();
|
||||
|
||||
[[nodiscard]] const_iterator end() const;
|
||||
|
||||
[[nodiscard]] iterator end();
|
||||
|
||||
[[nodiscard]] const_iterator cbegin() const;
|
||||
|
||||
[[nodiscard]] const_iterator cend() const;
|
||||
|
||||
[[nodiscard]] const_pointer data() const;
|
||||
|
||||
[[nodiscard]] pointer data();
|
||||
|
||||
private:
|
||||
std::unique_ptr<value_type[]> m_data{ nullptr };
|
||||
dim_type m_width{ 0 }, m_height{ 0 };
|
||||
components::texture::flags m_components{ components::texture::flags::none };
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "GL/glew.h"
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
struct dynamic_vertex_buffer {
|
||||
std::tuple<std::vector<Ts>...> vertices{};
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
20
include/assets/prefetch_lookup.hpp
Normal file
20
include/assets/prefetch_lookup.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "prefetch_lookups/material_library_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/material_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/point_cloud_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/shader_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/texture_prefetch_lookup.hpp"
|
||||
|
||||
struct prefetch_lookup
|
||||
{
|
||||
texture_prefetch_lookup textures;
|
||||
material_library_prefetch_lookup material_libraries;
|
||||
material_prefetch_lookup materials;
|
||||
mesh_prefetch_lookup meshes;
|
||||
pose_prefetch_lookup poses;
|
||||
point_cloud_prefetch_lookup point_clouds;
|
||||
shader_prefetch_lookup shaders;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
|
||||
|
||||
using material_library_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_material_library_store::id_type>;
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
|
||||
using material_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_material_store::id_type>;
|
||||
7
include/assets/prefetch_lookups/mesh_prefetch_lookup.hpp
Normal file
7
include/assets/prefetch_lookups/mesh_prefetch_lookup.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
|
||||
using mesh_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_mesh_store::id_type>;
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
|
||||
using point_cloud_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_point_cloud_store::id_type>;
|
||||
58
include/assets/prefetch_lookups/pose_prefetch_lookup.hpp
Normal file
58
include/assets/prefetch_lookups/pose_prefetch_lookup.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "assets/dynamic_data_stores/dynamic_pose_store.hpp"
|
||||
#include "util/uix.hpp"
|
||||
|
||||
class pose_prefetch_lookup {
|
||||
public:
|
||||
using index_type = ztu::u32;
|
||||
using directory_lookup = std::unordered_map<std::filesystem::path, index_type>;
|
||||
using directory_iterator = std::pair<directory_lookup::iterator, index_type>;
|
||||
using index_lookup = std::vector<index_type>;
|
||||
using index_iterator = index_lookup::iterator;
|
||||
using lookup_type = std::vector<dynamic_pose_store::id_type>;
|
||||
using iterator = lookup_type::iterator;
|
||||
|
||||
void emplace(
|
||||
const std::filesystem::path& directory,
|
||||
index_type index,
|
||||
dynamic_pose_store::id_type id
|
||||
);
|
||||
|
||||
void emplace_hint_dir(
|
||||
directory_iterator directory_it,
|
||||
const std::filesystem::path& directory,
|
||||
index_type index,
|
||||
dynamic_pose_store::id_type id
|
||||
);
|
||||
|
||||
void emplace_hint_dir_index(
|
||||
directory_iterator directory_it,
|
||||
index_iterator index_it,
|
||||
index_type index,
|
||||
dynamic_pose_store::id_type id
|
||||
);
|
||||
|
||||
std::pair<directory_iterator, bool> find_directory(
|
||||
const std::filesystem::path& directory
|
||||
);
|
||||
|
||||
std::pair<index_iterator, dynamic_pose_store::id_type> find_index(
|
||||
directory_iterator directory_it,
|
||||
index_type index
|
||||
);
|
||||
|
||||
protected:
|
||||
directory_iterator emplace_dir(
|
||||
directory_iterator directory_it,
|
||||
const std::filesystem::path& directory
|
||||
);
|
||||
|
||||
private:
|
||||
directory_lookup m_directory_lookup;
|
||||
index_lookup m_directory_indices; // count before indices, indices sorted per dir
|
||||
lookup_type m_pose_ids; // offset by 1
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_st
|
||||
|
||||
using texture_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_texture_store::id_type>;
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
|
||||
using texture_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_texture_store::id_type>;
|
||||
28
include/assets/prefetch_queue.hpp
Normal file
28
include/assets/prefetch_queue.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
struct file_dir_list
|
||||
{
|
||||
ztu::string_list files;
|
||||
ztu::string_list directories;
|
||||
};
|
||||
|
||||
struct prefetch_queue
|
||||
{
|
||||
file_dir_list obj_queue;
|
||||
file_dir_list stl_queue;
|
||||
|
||||
file_dir_list mtl_queue;
|
||||
|
||||
file_dir_list uosr_queue;
|
||||
file_dir_list uos_rgb_queue;
|
||||
file_dir_list uos_normal_queue;
|
||||
file_dir_list uos_queue;
|
||||
file_dir_list kitti_queue;
|
||||
|
||||
file_dir_list threedtk_pose_queue;
|
||||
file_dir_list kitti_pose_queue;
|
||||
|
||||
file_dir_list glsl_queue;
|
||||
};
|
||||
Reference in New Issue
Block a user