stuff...
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
#include "assets/identifiers.hpp"
|
||||
#include "assets/data_stores/texture_store.hpp"
|
||||
#include "assets/data/surface_properties.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
@@ -9,28 +11,27 @@
|
||||
namespace assets::material_components
|
||||
{
|
||||
using surface_properties = surface_properties;
|
||||
using transparency = float;
|
||||
using ambient_color_texture = texture_store::id_type;
|
||||
using diffuse_color_texture = texture_store::id_type;
|
||||
using specular_color_texture = texture_store::id_type;
|
||||
using shininess_texture = texture_store::id_type;
|
||||
using alpha_texture = texture_store::id_type;
|
||||
using bump_texture = texture_store::id_type;
|
||||
using transparency = z3d::f32;
|
||||
using ambient_color_texture = texture_id;
|
||||
using diffuse_color_texture = texture_id;
|
||||
using specular_color_texture = texture_id;
|
||||
using shininess_texture = texture_id;
|
||||
using alpha_texture = texture_id;
|
||||
using bump_texture = texture_id;
|
||||
|
||||
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;
|
||||
inline constexpr z3d::size surface_properties = 0;
|
||||
inline constexpr z3d::size transparency = 1;
|
||||
inline constexpr z3d::size ambient_color_texture = 2;
|
||||
inline constexpr z3d::size diffuse_color_texture = 3;
|
||||
inline constexpr z3d::size specular_color_texture = 4;
|
||||
inline constexpr z3d::size shininess_texture = 5;
|
||||
inline constexpr z3d::size alpha_texture = 6;
|
||||
inline constexpr z3d::size bump_texture = 7;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
enum class flags : z3d::u8
|
||||
{
|
||||
none = 0,
|
||||
surface_properties = 1 << indices::surface_properties,
|
||||
@@ -43,7 +44,7 @@ enum class flags : std::uint8_t
|
||||
bump_texture = 1 << indices::bump_texture
|
||||
};
|
||||
|
||||
using all = std::tuple<
|
||||
using all = z3d::structure<
|
||||
surface_properties,
|
||||
transparency,
|
||||
ambient_color_texture,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
@@ -7,23 +8,22 @@
|
||||
namespace assets::mesh_vertex_components
|
||||
{
|
||||
|
||||
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>;
|
||||
using position = z3d::vec3;
|
||||
using normal = z3d::vec3;
|
||||
using tex_coord = z3d::vec2;
|
||||
using color = z3d::vec3;
|
||||
using reflectance = z3d::f32;
|
||||
|
||||
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;
|
||||
inline constexpr z3d::size position = 0;
|
||||
inline constexpr z3d::size normal = 1;
|
||||
inline constexpr z3d::size tex_coord = 2;
|
||||
inline constexpr z3d::size color = 3;
|
||||
inline constexpr z3d::size reflectance = 4;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
enum class flags : z3d::u8
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
@@ -33,7 +33,13 @@ enum class flags : std::uint8_t
|
||||
reflectance = 1 << indices::reflectance
|
||||
};
|
||||
|
||||
using all = std::tuple<position, normal, tex_coord, color, reflectance>;
|
||||
using all = z3d::structure<
|
||||
position,
|
||||
normal,
|
||||
tex_coord,
|
||||
color,
|
||||
reflectance
|
||||
>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace mesh_vertex_components
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
@@ -7,21 +8,20 @@
|
||||
namespace assets::point_cloud_vertex_components
|
||||
{
|
||||
|
||||
using position = std::array<float, 3>;
|
||||
using normal = std::array<float, 3>;
|
||||
using color = std::array<float, 3>;
|
||||
using reflectance = std::array<float, 1>;
|
||||
using position = z3d::vec3;
|
||||
using normal = z3d::vec3;
|
||||
using color = z3d::vec3;
|
||||
using reflectance = z3d::f32;
|
||||
|
||||
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;
|
||||
inline constexpr z3d::size position = 0;
|
||||
inline constexpr z3d::size normal = 1;
|
||||
inline constexpr z3d::size color = 2;
|
||||
inline constexpr z3d::size reflectance = 3;
|
||||
} // namespace indices
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
enum class flags : z3d::u8
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
@@ -30,7 +30,12 @@ enum class flags : std::uint8_t
|
||||
reflectance = 1 << indices::reflectance
|
||||
};
|
||||
|
||||
using all = std::tuple<position, normal, color, reflectance>;
|
||||
using all = z3d::structure<
|
||||
position,
|
||||
normal,
|
||||
color,
|
||||
reflectance
|
||||
>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace point_cloud_vertex_components
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
#include <tuple>
|
||||
#include <cinttypes>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
@@ -7,10 +8,11 @@
|
||||
namespace assets::texture_components
|
||||
{
|
||||
|
||||
using red = std::uint8_t;
|
||||
using green = std::uint8_t;
|
||||
using blue = std::uint8_t;
|
||||
using luminance = std::uint8_t;
|
||||
using red = z3d::u8;
|
||||
using green = z3d::u8;
|
||||
using blue = z3d::u8;
|
||||
using alpha = z3d::u8;
|
||||
using luminance = z3d::u8;
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
@@ -22,7 +24,12 @@ enum class flags : std::uint8_t
|
||||
alpha = 1 << 5
|
||||
};
|
||||
|
||||
using all = std::tuple<red, green, blue, luminance>;
|
||||
using all = z3d::structure<
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
luminance
|
||||
>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace texture_components
|
||||
|
||||
33
include/assets/data/generic/component_array_set.hpp
Normal file
33
include/assets/data/generic/component_array_set.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
namespace assets::detail
|
||||
{
|
||||
|
||||
template<typename C, typename T>
|
||||
class component_array_set {};
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class component_array_set<C, z3d::structure<Ts...>>
|
||||
{
|
||||
component_array_set() = default;
|
||||
|
||||
protected:
|
||||
void clear_component_arrays()
|
||||
{
|
||||
std::apply(
|
||||
[](auto&... component_array)
|
||||
{
|
||||
(component_array.clear(), ...);
|
||||
},
|
||||
component_arrays
|
||||
);
|
||||
}
|
||||
|
||||
C component_flags;
|
||||
z3d::structure<z3d::vector<Ts>...> component_arrays{};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
32
include/assets/data/generic/component_set.hpp
Normal file
32
include/assets/data/generic/component_set.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
namespace assets::detail {
|
||||
|
||||
template<typename T>
|
||||
class component_set {};
|
||||
|
||||
|
||||
template<typename... Ts>
|
||||
class component_set<z3d::structure<Ts...>>
|
||||
{
|
||||
public:
|
||||
component_set() = default;
|
||||
|
||||
protected:
|
||||
void clear_components()
|
||||
{
|
||||
std::apply(
|
||||
[](std::optional<Ts>&... component)
|
||||
{
|
||||
(component.reset(), ...);
|
||||
},
|
||||
components
|
||||
);
|
||||
}
|
||||
|
||||
z3d::structure<z3d::optional<Ts...>> components{};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
struct vertex_array_data
|
||||
{
|
||||
C component_flags;
|
||||
std::tuple<std::vector<Ts>...> vertices{};
|
||||
|
||||
protected:
|
||||
void clear_vertices()
|
||||
{
|
||||
std::apply(
|
||||
[](auto&... vertex_opt) {
|
||||
(vertex_opt.clear(), ...);
|
||||
},
|
||||
vertices
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -3,50 +3,37 @@
|
||||
#include <optional>
|
||||
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/data_stores/texture_store.hpp"
|
||||
#include "generic/component_set.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct material_data
|
||||
struct material_data : detail::component_set<material_components::all>
|
||||
{
|
||||
|
||||
material_data() = default;
|
||||
|
||||
material_components::surface_properties& initialized_surface_properties();
|
||||
|
||||
[[nodiscard]] inline std::optional<material_components::surface_properties>& surface_properties();
|
||||
[[nodiscard]] inline std::optional<material_components::transparency>& transparency();
|
||||
[[nodiscard]] inline std::optional<material_components::ambient_color_texture>& ambient_color_texture_id();
|
||||
[[nodiscard]] inline std::optional<material_components::diffuse_color_texture>& diffuse_color_texture_id();
|
||||
[[nodiscard]] inline std::optional<material_components::specular_color_texture>& specular_color_texture_id();
|
||||
[[nodiscard]] inline std::optional<material_components::shininess_texture>& shininess_texture_id();
|
||||
[[nodiscard]] inline std::optional<material_components::alpha_texture>& alpha_texture_id();
|
||||
[[nodiscard]] inline std::optional<material_components::bump_texture>& bump_texture_id();
|
||||
[[nodiscard]] inline z3d::optional<material_components::surface_properties>& surface_properties();
|
||||
[[nodiscard]] inline z3d::optional<material_components::transparency>& transparency();
|
||||
[[nodiscard]] inline z3d::optional<material_components::ambient_color_texture>& ambient_color_texture_id();
|
||||
[[nodiscard]] inline z3d::optional<material_components::diffuse_color_texture>& diffuse_color_texture_id();
|
||||
[[nodiscard]] inline z3d::optional<material_components::specular_color_texture>& specular_color_texture_id();
|
||||
[[nodiscard]] inline z3d::optional<material_components::shininess_texture>& shininess_texture_id();
|
||||
[[nodiscard]] inline z3d::optional<material_components::alpha_texture>& alpha_texture_id();
|
||||
[[nodiscard]] inline z3d::optional<material_components::bump_texture>& bump_texture_id();
|
||||
|
||||
[[nodiscard]] inline const std::optional<material_components::surface_properties>& surface_properties() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::transparency>& transparency() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::ambient_color_texture>& ambient_color_texture_id() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::diffuse_color_texture>& diffuse_color_texture_id() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::specular_color_texture>& specular_color_texture_id() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::shininess_texture>& shininess_texture_id() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::alpha_texture>& alpha_texture_id() const;
|
||||
[[nodiscard]] inline const std::optional<material_components::bump_texture>& bump_texture_id() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::surface_properties>& surface_properties() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::transparency>& transparency() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::ambient_color_texture>& ambient_color_texture_id() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::diffuse_color_texture>& diffuse_color_texture_id() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::specular_color_texture>& specular_color_texture_id() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::shininess_texture>& shininess_texture_id() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::alpha_texture>& alpha_texture_id() const;
|
||||
[[nodiscard]] inline const z3d::optional<material_components::bump_texture>& bump_texture_id() const;
|
||||
|
||||
inline void clear();
|
||||
|
||||
std::tuple<
|
||||
std::optional<material_components::surface_properties>,
|
||||
std::optional<material_components::transparency>,
|
||||
std::optional<material_components::ambient_color_texture>,
|
||||
std::optional<material_components::diffuse_color_texture>,
|
||||
std::optional<material_components::specular_color_texture>,
|
||||
std::optional<material_components::shininess_texture>,
|
||||
std::optional<material_components::alpha_texture>,
|
||||
std::optional<material_components::bump_texture>
|
||||
> data{
|
||||
std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "assets/data_stores/material_store.hpp"
|
||||
#include "assets/identifiers.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using material_library_data = ztu::string_lookup<material_store::id_type>;
|
||||
using material_library_data = ztu::string_lookup<material_id>;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "generic/vertex_array_data.hpp"
|
||||
#include "assets/data_stores/material_store.hpp"
|
||||
#include "generic/component_array_set.hpp"
|
||||
#include "assets/identifiers.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
class mesh_data : public vertex_array_data<
|
||||
class mesh_data : detail::component_array_set<
|
||||
mesh_vertex_components::flags,
|
||||
mesh_vertex_components::position,
|
||||
mesh_vertex_components::normal,
|
||||
mesh_vertex_components::tex_coord,
|
||||
mesh_vertex_components::color,
|
||||
mesh_vertex_components::reflectance
|
||||
mesh_vertex_components::all
|
||||
> {
|
||||
public:
|
||||
using index_type = ztu::u32;
|
||||
using triangle_type = std::array<index_type, 3>;
|
||||
|
||||
[[nodiscard]] inline std::vector<mesh_vertex_components::position>& positions();
|
||||
[[nodiscard]] inline std::vector<mesh_vertex_components::normal>& normals();
|
||||
[[nodiscard]] inline std::vector<mesh_vertex_components::tex_coord>& tex_coords();
|
||||
[[nodiscard]] inline std::vector<mesh_vertex_components::color>& colors();
|
||||
[[nodiscard]] inline std::vector<mesh_vertex_components::reflectance>& reflectances();
|
||||
[[nodiscard]] inline std::vector<triangle_type>& triangles();
|
||||
[[nodiscard]] inline auto& material_id();
|
||||
[[nodiscard]] inline z3d::vector<mesh_vertex_components::position>& positions();
|
||||
[[nodiscard]] inline z3d::vector<mesh_vertex_components::normal>& normals();
|
||||
[[nodiscard]] inline z3d::vector<mesh_vertex_components::tex_coord>& tex_coords();
|
||||
[[nodiscard]] inline z3d::vector<mesh_vertex_components::color>& colors();
|
||||
[[nodiscard]] inline z3d::vector<mesh_vertex_components::reflectance>& reflectances();
|
||||
[[nodiscard]] inline z3d::vector<z3d::index_triangle>& triangles();
|
||||
[[nodiscard]] inline auto& material();
|
||||
|
||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::position>& positions() const;
|
||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::normal>& normals() const;
|
||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::tex_coord>& tex_coords() const;
|
||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::color>& colors() const;
|
||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::reflectance>& reflectances() const;
|
||||
[[nodiscard]] inline const std::vector<triangle_type>& triangles() const;
|
||||
[[nodiscard]] inline const auto& material_id() const;
|
||||
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::position>& positions() const;
|
||||
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::normal>& normals() const;
|
||||
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::tex_coord>& tex_coords() const;
|
||||
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::color>& colors() const;
|
||||
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::reflectance>& reflectances() const;
|
||||
[[nodiscard]] inline const z3d::vector<z3d::index_triangle>& triangles() const;
|
||||
[[nodiscard]] inline const auto& material() const;
|
||||
|
||||
inline void clear();
|
||||
|
||||
private:
|
||||
std::vector<triangle_type> m_triangles{};
|
||||
material_store::id_type m_material_id{};
|
||||
z3d::vector<z3d::index_triangle> m_triangles{};
|
||||
material_id m_material_id{};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -4,17 +4,14 @@
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "generic/vertex_array_data.hpp"
|
||||
#include "generic/component_array_set.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
class point_cloud_data : public vertex_array_data<
|
||||
point_cloud_vertex_components::flags,
|
||||
point_cloud_vertex_components::position,
|
||||
point_cloud_vertex_components::normal,
|
||||
point_cloud_vertex_components::color,
|
||||
point_cloud_vertex_components::reflectance
|
||||
class point_cloud_data : detail::component_array_set<
|
||||
point_cloud_vertex_components::flags,
|
||||
point_cloud_vertex_components::all
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] inline std::vector<point_cloud_vertex_components::position>& positions();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "glm/mat4x4.hpp"
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using pose_data = glm::mat4;
|
||||
using pose_data = z3d::mat4;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct shader_source_data
|
||||
{
|
||||
std::vector<char> source{};
|
||||
z3d::vector<char> source{};
|
||||
|
||||
void clear()
|
||||
{
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
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 };
|
||||
z3d::vec3 ambient_filter{ 0.7f, 0.7f, 0.7f };
|
||||
z3d::vec3 diffuse_filter{ 0.466f, 0.466f, 0.7922f };
|
||||
z3d::vec3 specular_filter{ 0.5974f, 0.2084f, 0.2084f };
|
||||
z3d::f32 shininess{ 100.2237f };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,21 +12,22 @@ namespace assets
|
||||
class texture_data
|
||||
{
|
||||
public:
|
||||
using value_type = std::uint8_t;
|
||||
using dim_type = std::int32_t;
|
||||
using size_type = std::make_signed_t<std::size_t>;
|
||||
using value_type = z3d::u8;
|
||||
using dim_type = z3d::i32;
|
||||
using size_type = z3d::size;
|
||||
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 pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using iterator = pointer;
|
||||
using const_iterator = const_pointer;
|
||||
using container_type = std::unique_ptr<value_type[]>;
|
||||
|
||||
texture_data() = default;
|
||||
|
||||
inline texture_data(
|
||||
std::unique_ptr<value_type[]>&& data,
|
||||
container_type&& data,
|
||||
dim_type width,
|
||||
dim_type height,
|
||||
texture_components::flags components
|
||||
@@ -73,7 +74,7 @@ public:
|
||||
void inline clear();
|
||||
|
||||
private:
|
||||
std::unique_ptr<value_type[]> m_data{ nullptr };
|
||||
container_type m_data{ nullptr };
|
||||
dim_type m_width{ 0 }, m_height{ 0 };
|
||||
texture_components::flags m_components{ texture_components::flags::none };
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
23
include/assets/data_views/generic/generic_mesh_view.hpp
Normal file
23
include/assets/data_views/generic/generic_mesh_view.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/data_stores/material_store.hpp"
|
||||
|
||||
namespace assets::detail
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct generic_mesh_view {};
|
||||
|
||||
template<typename... Ts>
|
||||
struct generic_mesh_view<z3d::structure<Ts...>>
|
||||
{
|
||||
mesh_vertex_components::flags component_flags;
|
||||
z3d::array_view<z3d::index_triangle> triangles;
|
||||
z3d::structure<z3d::array_view<Ts>...> vertex_component_arrays;
|
||||
z3d::vertex_index vertex_count;
|
||||
material_store::id_type material_id;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
namespace assets::detail
|
||||
{
|
||||
|
||||
template<typename... Ts>
|
||||
struct generic_point_cloud_view
|
||||
{
|
||||
point_cloud_vertex_components::flags vertex_component_flags;
|
||||
z3d::structure<z3d::array_view<Ts>...> vertex_component_arrays;
|
||||
z3d::vertex_index point_count;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,34 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <tuple>
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/data/mesh_data.hpp"
|
||||
#include "assets/data_stores/material_store.hpp"
|
||||
#include "generic/generic_mesh_view.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename... Ts>
|
||||
struct generic_mesh_view
|
||||
{
|
||||
mesh_vertex_components::flags component_flags;
|
||||
std::span<mesh_data::index_type> indices;
|
||||
std::tuple<std::span<Ts>...> vertex_component_arrays;
|
||||
std::size_t vertex_count;
|
||||
material_store::id_type material_id;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using mesh_view = detail::generic_mesh_view<
|
||||
mesh_vertex_components::position,
|
||||
mesh_vertex_components::normal,
|
||||
mesh_vertex_components::tex_coord,
|
||||
mesh_vertex_components::color,
|
||||
mesh_vertex_components::reflectance
|
||||
mesh_vertex_components::all
|
||||
>;
|
||||
|
||||
}
|
||||
@@ -1,29 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <tuple>
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "generic/generic_point_cloud_viwe.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename... Ts>
|
||||
struct generic_point_cloud_view
|
||||
{
|
||||
point_cloud_vertex_components::flags vertex_component_flags;
|
||||
std::tuple<std::span<Ts>...> vertex_component_arrays;
|
||||
std::size_t point_count;
|
||||
};
|
||||
}
|
||||
|
||||
using point_cloud_view = detail::generic_point_cloud_view<
|
||||
point_cloud_vertex_components::position,
|
||||
point_cloud_vertex_components::normal,
|
||||
point_cloud_vertex_components::color,
|
||||
point_cloud_vertex_components::reflectance
|
||||
point_cloud_vertex_components::all
|
||||
>;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
using shader_source_view = std::string_view;
|
||||
using shader_source_view = z3d::string_view;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/data/material_data.hpp"
|
||||
#include "assets/components/texture_components.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct texture_view
|
||||
{
|
||||
std::weak_ptr<std::uint8_t[]> data;
|
||||
int width, height;
|
||||
std::weak_ptr<z3d::u8[]> data;
|
||||
z3d::i32 width, height;
|
||||
texture_components::flags component_flags;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "util/string_list.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
|
||||
#include "../../read_buffers"
|
||||
#include "../../data_stores"
|
||||
#include "assets/data/point_cloud_data.hpp"
|
||||
#include "assets/data_stores/point_cloud_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
|
||||
|
||||
|
||||
16
include/assets/identifiers.hpp
Normal file
16
include/assets/identifiers.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "config/primitives.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using material_id = z3d::identifier<0>;
|
||||
using material_library_id = z3d::identifier<1>;
|
||||
using mesh_id = z3d::identifier<2>;
|
||||
using point_cloud_id = z3d::identifier<3>;
|
||||
using pose_id = z3d::identifier<4>;
|
||||
using shader_source_id = z3d::identifier<5>;
|
||||
using texture_id = z3d::identifier<6>;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user