stuff...
This commit is contained in:
@@ -125,7 +125,7 @@ add_executable(z3d main.cpp
|
|||||||
include/assets/data/texture_data.hpp
|
include/assets/data/texture_data.hpp
|
||||||
source/assets/data/mesh_data.ipp
|
source/assets/data/mesh_data.ipp
|
||||||
source/assets/data/material_data.ipp
|
source/assets/data/material_data.ipp
|
||||||
include/assets/data/generic/vertex_array_data.hpp
|
include/assets/data/generic/component_array_set.hpp
|
||||||
source/assets/data/texture_data.ipp
|
source/assets/data/texture_data.ipp
|
||||||
source/assets/data/point_cloud_data.ipp
|
source/assets/data/point_cloud_data.ipp
|
||||||
include/assets/file_parsers/mtl_loader.hpp
|
include/assets/file_parsers/mtl_loader.hpp
|
||||||
@@ -232,6 +232,11 @@ add_executable(z3d main.cpp
|
|||||||
include/opengl/shading/uniform_block.hpp
|
include/opengl/shading/uniform_block.hpp
|
||||||
include/opengl/shading/uniform_blocks/mesh_uniform_blocks.hpp
|
include/opengl/shading/uniform_blocks/mesh_uniform_blocks.hpp
|
||||||
include/opengl/shading/uniform_blocks/point_cloud_uniform_blocks.hpp
|
include/opengl/shading/uniform_blocks/point_cloud_uniform_blocks.hpp
|
||||||
|
include/config/primitives.hpp
|
||||||
|
include/assets/data/generic/component_set.hpp
|
||||||
|
include/assets/data_views/generic/generic_mesh_view.hpp
|
||||||
|
include/assets/data_views/generic/generic_point_cloud_viwe.hpp
|
||||||
|
include/assets/identifiers.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(z3d PRIVATE include)
|
target_include_directories(z3d PRIVATE include)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
#include "config/primitives.hpp"
|
||||||
|
#include "assets/identifiers.hpp"
|
||||||
#include "assets/data_stores/texture_store.hpp"
|
#include "assets/data_stores/texture_store.hpp"
|
||||||
#include "assets/data/surface_properties.hpp"
|
#include "assets/data/surface_properties.hpp"
|
||||||
#include "util/enum_bitfield_operators.hpp"
|
#include "util/enum_bitfield_operators.hpp"
|
||||||
@@ -9,28 +11,27 @@
|
|||||||
namespace assets::material_components
|
namespace assets::material_components
|
||||||
{
|
{
|
||||||
using surface_properties = surface_properties;
|
using surface_properties = surface_properties;
|
||||||
using transparency = float;
|
using transparency = z3d::f32;
|
||||||
using ambient_color_texture = texture_store::id_type;
|
using ambient_color_texture = texture_id;
|
||||||
using diffuse_color_texture = texture_store::id_type;
|
using diffuse_color_texture = texture_id;
|
||||||
using specular_color_texture = texture_store::id_type;
|
using specular_color_texture = texture_id;
|
||||||
using shininess_texture = texture_store::id_type;
|
using shininess_texture = texture_id;
|
||||||
using alpha_texture = texture_store::id_type;
|
using alpha_texture = texture_id;
|
||||||
using bump_texture = texture_store::id_type;
|
using bump_texture = texture_id;
|
||||||
|
|
||||||
namespace indices
|
namespace indices
|
||||||
{
|
{
|
||||||
using type = std::size_t;
|
inline constexpr z3d::size surface_properties = 0;
|
||||||
inline constexpr type surface_properties = 0;
|
inline constexpr z3d::size transparency = 1;
|
||||||
inline constexpr type transparency = 1;
|
inline constexpr z3d::size ambient_color_texture = 2;
|
||||||
inline constexpr type ambient_color_texture = 2;
|
inline constexpr z3d::size diffuse_color_texture = 3;
|
||||||
inline constexpr type diffuse_color_texture = 3;
|
inline constexpr z3d::size specular_color_texture = 4;
|
||||||
inline constexpr type specular_color_texture = 4;
|
inline constexpr z3d::size shininess_texture = 5;
|
||||||
inline constexpr type shininess_texture = 5;
|
inline constexpr z3d::size alpha_texture = 6;
|
||||||
inline constexpr type alpha_texture = 6;
|
inline constexpr z3d::size bump_texture = 7;
|
||||||
inline constexpr type bump_texture = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class flags : std::uint8_t
|
enum class flags : z3d::u8
|
||||||
{
|
{
|
||||||
none = 0,
|
none = 0,
|
||||||
surface_properties = 1 << indices::surface_properties,
|
surface_properties = 1 << indices::surface_properties,
|
||||||
@@ -43,7 +44,7 @@ enum class flags : std::uint8_t
|
|||||||
bump_texture = 1 << indices::bump_texture
|
bump_texture = 1 << indices::bump_texture
|
||||||
};
|
};
|
||||||
|
|
||||||
using all = std::tuple<
|
using all = z3d::structure<
|
||||||
surface_properties,
|
surface_properties,
|
||||||
transparency,
|
transparency,
|
||||||
ambient_color_texture,
|
ambient_color_texture,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "config/primitives.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "util/enum_bitfield_operators.hpp"
|
#include "util/enum_bitfield_operators.hpp"
|
||||||
@@ -7,23 +8,22 @@
|
|||||||
namespace assets::mesh_vertex_components
|
namespace assets::mesh_vertex_components
|
||||||
{
|
{
|
||||||
|
|
||||||
using position = std::array<float, 3>;
|
using position = z3d::vec3;
|
||||||
using normal = std::array<float, 3>;
|
using normal = z3d::vec3;
|
||||||
using tex_coord = std::array<float, 2>;
|
using tex_coord = z3d::vec2;
|
||||||
using color = std::array<float, 3>;
|
using color = z3d::vec3;
|
||||||
using reflectance = std::array<float, 1>;
|
using reflectance = z3d::f32;
|
||||||
|
|
||||||
namespace indices
|
namespace indices
|
||||||
{
|
{
|
||||||
using type = std::size_t;
|
inline constexpr z3d::size position = 0;
|
||||||
inline constexpr type position = 0;
|
inline constexpr z3d::size normal = 1;
|
||||||
inline constexpr type normal = 1;
|
inline constexpr z3d::size tex_coord = 2;
|
||||||
inline constexpr type tex_coord = 2;
|
inline constexpr z3d::size color = 3;
|
||||||
inline constexpr type color = 3;
|
inline constexpr z3d::size reflectance = 4;
|
||||||
inline constexpr type reflectance = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class flags : std::uint8_t
|
enum class flags : z3d::u8
|
||||||
{
|
{
|
||||||
none = 0,
|
none = 0,
|
||||||
position = 1 << indices::position,
|
position = 1 << indices::position,
|
||||||
@@ -33,7 +33,13 @@ enum class flags : std::uint8_t
|
|||||||
reflectance = 1 << indices::reflectance
|
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>;
|
constexpr inline auto count = std::tuple_size_v<all>;
|
||||||
|
|
||||||
} // namespace mesh_vertex_components
|
} // namespace mesh_vertex_components
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "config/primitives.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "util/enum_bitfield_operators.hpp"
|
#include "util/enum_bitfield_operators.hpp"
|
||||||
@@ -7,21 +8,20 @@
|
|||||||
namespace assets::point_cloud_vertex_components
|
namespace assets::point_cloud_vertex_components
|
||||||
{
|
{
|
||||||
|
|
||||||
using position = std::array<float, 3>;
|
using position = z3d::vec3;
|
||||||
using normal = std::array<float, 3>;
|
using normal = z3d::vec3;
|
||||||
using color = std::array<float, 3>;
|
using color = z3d::vec3;
|
||||||
using reflectance = std::array<float, 1>;
|
using reflectance = z3d::f32;
|
||||||
|
|
||||||
namespace indices
|
namespace indices
|
||||||
{
|
{
|
||||||
using type = std::size_t;
|
inline constexpr z3d::size position = 0;
|
||||||
inline constexpr type position = 0;
|
inline constexpr z3d::size normal = 1;
|
||||||
inline constexpr type normal = 1;
|
inline constexpr z3d::size color = 2;
|
||||||
inline constexpr type color = 2;
|
inline constexpr z3d::size reflectance = 3;
|
||||||
inline constexpr type reflectance = 3;
|
|
||||||
} // namespace indices
|
} // namespace indices
|
||||||
|
|
||||||
enum class flags : std::uint8_t
|
enum class flags : z3d::u8
|
||||||
{
|
{
|
||||||
none = 0,
|
none = 0,
|
||||||
position = 1 << indices::position,
|
position = 1 << indices::position,
|
||||||
@@ -30,7 +30,12 @@ enum class flags : std::uint8_t
|
|||||||
reflectance = 1 << indices::reflectance
|
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>;
|
constexpr inline auto count = std::tuple_size_v<all>;
|
||||||
|
|
||||||
} // namespace point_cloud_vertex_components
|
} // namespace point_cloud_vertex_components
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "config/primitives.hpp"
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include "util/enum_bitfield_operators.hpp"
|
#include "util/enum_bitfield_operators.hpp"
|
||||||
@@ -7,10 +8,11 @@
|
|||||||
namespace assets::texture_components
|
namespace assets::texture_components
|
||||||
{
|
{
|
||||||
|
|
||||||
using red = std::uint8_t;
|
using red = z3d::u8;
|
||||||
using green = std::uint8_t;
|
using green = z3d::u8;
|
||||||
using blue = std::uint8_t;
|
using blue = z3d::u8;
|
||||||
using luminance = std::uint8_t;
|
using alpha = z3d::u8;
|
||||||
|
using luminance = z3d::u8;
|
||||||
|
|
||||||
enum class flags : std::uint8_t
|
enum class flags : std::uint8_t
|
||||||
{
|
{
|
||||||
@@ -22,7 +24,12 @@ enum class flags : std::uint8_t
|
|||||||
alpha = 1 << 5
|
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>;
|
constexpr inline auto count = std::tuple_size_v<all>;
|
||||||
|
|
||||||
} // namespace texture_components
|
} // 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 <optional>
|
||||||
|
|
||||||
#include "assets/components/material_components.hpp"
|
#include "assets/components/material_components.hpp"
|
||||||
#include "assets/data_stores/texture_store.hpp"
|
#include "generic/component_set.hpp"
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
struct material_data
|
struct material_data : detail::component_set<material_components::all>
|
||||||
{
|
{
|
||||||
|
|
||||||
material_data() = default;
|
material_data() = default;
|
||||||
|
|
||||||
material_components::surface_properties& initialized_surface_properties();
|
material_components::surface_properties& initialized_surface_properties();
|
||||||
|
|
||||||
[[nodiscard]] inline std::optional<material_components::surface_properties>& surface_properties();
|
[[nodiscard]] inline z3d::optional<material_components::surface_properties>& surface_properties();
|
||||||
[[nodiscard]] inline std::optional<material_components::transparency>& transparency();
|
[[nodiscard]] inline z3d::optional<material_components::transparency>& transparency();
|
||||||
[[nodiscard]] inline std::optional<material_components::ambient_color_texture>& ambient_color_texture_id();
|
[[nodiscard]] inline z3d::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 z3d::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 z3d::optional<material_components::specular_color_texture>& specular_color_texture_id();
|
||||||
[[nodiscard]] inline std::optional<material_components::shininess_texture>& shininess_texture_id();
|
[[nodiscard]] inline z3d::optional<material_components::shininess_texture>& shininess_texture_id();
|
||||||
[[nodiscard]] inline std::optional<material_components::alpha_texture>& alpha_texture_id();
|
[[nodiscard]] inline z3d::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::bump_texture>& bump_texture_id();
|
||||||
|
|
||||||
[[nodiscard]] inline const std::optional<material_components::surface_properties>& surface_properties() const;
|
[[nodiscard]] inline const z3d::optional<material_components::surface_properties>& surface_properties() const;
|
||||||
[[nodiscard]] inline const std::optional<material_components::transparency>& transparency() const;
|
[[nodiscard]] inline const z3d::optional<material_components::transparency>& transparency() const;
|
||||||
[[nodiscard]] inline const std::optional<material_components::ambient_color_texture>& ambient_color_texture_id() const;
|
[[nodiscard]] inline const z3d::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 z3d::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 z3d::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 z3d::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 z3d::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::bump_texture>& bump_texture_id() const;
|
||||||
|
|
||||||
inline void clear();
|
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
|
#pragma once
|
||||||
|
|
||||||
#include "util/string_lookup.hpp"
|
#include "util/string_lookup.hpp"
|
||||||
#include "assets/data_stores/material_store.hpp"
|
#include "assets/identifiers.hpp"
|
||||||
|
|
||||||
namespace assets
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "util/uix.hpp"
|
|
||||||
#include "assets/components/mesh_vertex_components.hpp"
|
#include "assets/components/mesh_vertex_components.hpp"
|
||||||
#include "generic/vertex_array_data.hpp"
|
#include "generic/component_array_set.hpp"
|
||||||
#include "assets/data_stores/material_store.hpp"
|
#include "assets/identifiers.hpp"
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
class mesh_data : public vertex_array_data<
|
class mesh_data : detail::component_array_set<
|
||||||
mesh_vertex_components::flags,
|
mesh_vertex_components::flags,
|
||||||
mesh_vertex_components::position,
|
mesh_vertex_components::all
|
||||||
mesh_vertex_components::normal,
|
|
||||||
mesh_vertex_components::tex_coord,
|
|
||||||
mesh_vertex_components::color,
|
|
||||||
mesh_vertex_components::reflectance
|
|
||||||
> {
|
> {
|
||||||
public:
|
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 z3d::vector<mesh_vertex_components::position>& positions();
|
||||||
[[nodiscard]] inline std::vector<mesh_vertex_components::normal>& normals();
|
[[nodiscard]] inline z3d::vector<mesh_vertex_components::normal>& normals();
|
||||||
[[nodiscard]] inline std::vector<mesh_vertex_components::tex_coord>& tex_coords();
|
[[nodiscard]] inline z3d::vector<mesh_vertex_components::tex_coord>& tex_coords();
|
||||||
[[nodiscard]] inline std::vector<mesh_vertex_components::color>& colors();
|
[[nodiscard]] inline z3d::vector<mesh_vertex_components::color>& colors();
|
||||||
[[nodiscard]] inline std::vector<mesh_vertex_components::reflectance>& reflectances();
|
[[nodiscard]] inline z3d::vector<mesh_vertex_components::reflectance>& reflectances();
|
||||||
[[nodiscard]] inline std::vector<triangle_type>& triangles();
|
[[nodiscard]] inline z3d::vector<z3d::index_triangle>& triangles();
|
||||||
[[nodiscard]] inline auto& material_id();
|
[[nodiscard]] inline auto& material();
|
||||||
|
|
||||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::position>& positions() const;
|
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::position>& positions() const;
|
||||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::normal>& normals() const;
|
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::normal>& normals() const;
|
||||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::tex_coord>& tex_coords() const;
|
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::tex_coord>& tex_coords() const;
|
||||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::color>& colors() const;
|
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::color>& colors() const;
|
||||||
[[nodiscard]] inline const std::vector<mesh_vertex_components::reflectance>& reflectances() const;
|
[[nodiscard]] inline const z3d::vector<mesh_vertex_components::reflectance>& reflectances() const;
|
||||||
[[nodiscard]] inline const std::vector<triangle_type>& triangles() const;
|
[[nodiscard]] inline const z3d::vector<z3d::index_triangle>& triangles() const;
|
||||||
[[nodiscard]] inline const auto& material_id() const;
|
[[nodiscard]] inline const auto& material() const;
|
||||||
|
|
||||||
inline void clear();
|
inline void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<triangle_type> m_triangles{};
|
z3d::vector<z3d::index_triangle> m_triangles{};
|
||||||
material_store::id_type m_material_id{};
|
material_id m_material_id{};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,14 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "generic/vertex_array_data.hpp"
|
#include "generic/component_array_set.hpp"
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
class point_cloud_data : public vertex_array_data<
|
class point_cloud_data : detail::component_array_set<
|
||||||
point_cloud_vertex_components::flags,
|
point_cloud_vertex_components::flags,
|
||||||
point_cloud_vertex_components::position,
|
point_cloud_vertex_components::all
|
||||||
point_cloud_vertex_components::normal,
|
|
||||||
point_cloud_vertex_components::color,
|
|
||||||
point_cloud_vertex_components::reflectance
|
|
||||||
> {
|
> {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] inline std::vector<point_cloud_vertex_components::position>& positions();
|
[[nodiscard]] inline std::vector<point_cloud_vertex_components::position>& positions();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "glm/mat4x4.hpp"
|
#include "config/primitives.hpp"
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
using pose_data = glm::mat4;
|
using pose_data = z3d::mat4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include "config/primitives.hpp"
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
struct shader_source_data
|
struct shader_source_data
|
||||||
{
|
{
|
||||||
std::vector<char> source{};
|
z3d::vector<char> source{};
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include "config/primitives.hpp"
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
struct surface_properties
|
struct surface_properties
|
||||||
{
|
{
|
||||||
std::array<float, 3> ambient_filter{ 0.7f, 0.7f, 0.7f };
|
z3d::vec3 ambient_filter{ 0.7f, 0.7f, 0.7f };
|
||||||
std::array<float, 3> diffuse_filter{ 0.466f, 0.466f, 0.7922f };
|
z3d::vec3 diffuse_filter{ 0.466f, 0.466f, 0.7922f };
|
||||||
std::array<float, 3> specular_filter{ 0.5974f, 0.2084f, 0.2084f };
|
z3d::vec3 specular_filter{ 0.5974f, 0.2084f, 0.2084f };
|
||||||
float shininess{ 100.2237f };
|
z3d::f32 shininess{ 100.2237f };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,21 +12,22 @@ namespace assets
|
|||||||
class texture_data
|
class texture_data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using value_type = std::uint8_t;
|
using value_type = z3d::u8;
|
||||||
using dim_type = std::int32_t;
|
using dim_type = z3d::i32;
|
||||||
using size_type = std::make_signed_t<std::size_t>;
|
using size_type = z3d::size;
|
||||||
using difference_type = size_type;
|
using difference_type = size_type;
|
||||||
using reference = value_type&;
|
using reference = value_type&;
|
||||||
using const_reference = const value_type&;
|
using const_reference = const value_type&;
|
||||||
using pointer = std::uint8_t*;
|
using pointer = value_type*;
|
||||||
using const_pointer = const std::uint8_t*;
|
using const_pointer = const value_type*;
|
||||||
using iterator = pointer;
|
using iterator = pointer;
|
||||||
using const_iterator = const_pointer;
|
using const_iterator = const_pointer;
|
||||||
|
using container_type = std::unique_ptr<value_type[]>;
|
||||||
|
|
||||||
texture_data() = default;
|
texture_data() = default;
|
||||||
|
|
||||||
inline texture_data(
|
inline texture_data(
|
||||||
std::unique_ptr<value_type[]>&& data,
|
container_type&& data,
|
||||||
dim_type width,
|
dim_type width,
|
||||||
dim_type height,
|
dim_type height,
|
||||||
texture_components::flags components
|
texture_components::flags components
|
||||||
@@ -73,7 +74,7 @@ public:
|
|||||||
void inline clear();
|
void inline clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<value_type[]> m_data{ nullptr };
|
container_type m_data{ nullptr };
|
||||||
dim_type m_width{ 0 }, m_height{ 0 };
|
dim_type m_width{ 0 }, m_height{ 0 };
|
||||||
texture_components::flags m_components{ texture_components::flags::none };
|
texture_components::flags m_components{ texture_components::flags::none };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,20 +6,19 @@
|
|||||||
#include "util/uix.hpp"
|
#include "util/uix.hpp"
|
||||||
#include "util/id_type.hpp"
|
#include "util/id_type.hpp"
|
||||||
|
|
||||||
template<typename T>
|
template<typename ID, typename T>
|
||||||
class generic_basic_store
|
class generic_basic_store
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using id_type = ztu::id_type_for<generic_basic_store, ztu::u32>;
|
|
||||||
using container_type = std::vector<T>;
|
using container_type = std::vector<T>;
|
||||||
using iterator_type = typename container_type::iterator;
|
using iterator_type = typename container_type::iterator;
|
||||||
using const_iterator = typename container_type::const_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();
|
[[nodiscard]] std::span<T> data();
|
||||||
|
|
||||||
@@ -31,8 +30,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<T> m_data;
|
std::vector<T> m_data;
|
||||||
std::vector<id_type> m_ids;
|
std::vector<ID> m_ids;
|
||||||
id_type m_next_data_id{ 1 };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INCLUDE_GENERIC_BASIC_STORE_IMPLEMENTATION
|
#define INCLUDE_GENERIC_BASIC_STORE_IMPLEMENTATION
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using count_type = ztu::u32;
|
using count_type = ztu::u32;
|
||||||
using component_flag_type = material_components::flags;
|
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 value_type = std::pair<id_type, material_view>;
|
||||||
using flag_count_type = std::tuple<component_flag_type>;
|
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 const_iterator = generic_material_store_iterator<std::add_const_t<Ts>...>;
|
||||||
using view_type = std::ranges::subrange<iterator_type>;
|
using view_type = std::ranges::subrange<iterator_type>;
|
||||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
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);
|
id_type add(const material_data& material);
|
||||||
|
|
||||||
@@ -144,7 +144,6 @@ private:
|
|||||||
std::vector<id_type> m_ids;
|
std::vector<id_type> m_ids;
|
||||||
std::tuple<std::vector<Ts>...> m_component_arrays;
|
std::tuple<std::vector<Ts>...> m_component_arrays;
|
||||||
std::vector<component_flag_type> m_component_flag_counts;
|
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:
|
public:
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using count_type = ztu::u32;
|
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 material_id_type = material_store::id_type;
|
||||||
using component_flag_type = mesh_vertex_components::flags;
|
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 value_type = std::pair<id_type, mesh_view>;
|
||||||
using flag_count_type = std::tuple<component_flag_type, count_type, count_type>;
|
using flag_count_type = std::tuple<component_flag_type, count_type, count_type>;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ class generic_mesh_store
|
|||||||
public:
|
public:
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using count_type = ztu::u32;
|
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 component_flag_type = mesh_vertex_components::flags;
|
||||||
using material_id_type = material_store::id_type;
|
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 const_iterator = generic_mesh_store_iterator<std::add_const_t<Ts>...>;
|
||||||
using view_type = std::ranges::subrange<iterator_type>;
|
using view_type = std::ranges::subrange<iterator_type>;
|
||||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
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);
|
id_type add(const mesh_data& mesh);
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ template<typename... Ts>
|
|||||||
class generic_point_cloud_store_iterator
|
class generic_point_cloud_store_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using size_type = std::size_t;
|
using size_type = z3d::size;
|
||||||
using count_type = ztu::u32;
|
using count_type = z3d::u32;
|
||||||
using component_flag_type = point_cloud_vertex_components::flags;
|
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 value_type = std::pair<id_type, point_cloud_view>;
|
||||||
using flag_count_type = std::tuple<component_flag_type, count_type, count_type>;
|
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 const_iterator = generic_point_cloud_store_iterator<std::add_const_t<Ts>...>;
|
||||||
using view_type = std::ranges::subrange<iterator_type>;
|
using view_type = std::ranges::subrange<iterator_type>;
|
||||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
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);
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <span>
|
#include "generic/generic_mesh_view.hpp"
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
#include "assets/components/mesh_vertex_components.hpp"
|
|
||||||
#include "assets/data/mesh_data.hpp"
|
|
||||||
#include "assets/data_stores/material_store.hpp"
|
|
||||||
|
|
||||||
namespace assets
|
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<
|
using mesh_view = detail::generic_mesh_view<
|
||||||
mesh_vertex_components::position,
|
mesh_vertex_components::all
|
||||||
mesh_vertex_components::normal,
|
|
||||||
mesh_vertex_components::tex_coord,
|
|
||||||
mesh_vertex_components::color,
|
|
||||||
mesh_vertex_components::reflectance
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <span>
|
#include "generic/generic_point_cloud_viwe.hpp"
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
|
||||||
|
|
||||||
namespace assets
|
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<
|
using point_cloud_view = detail::generic_point_cloud_view<
|
||||||
point_cloud_vertex_components::position,
|
point_cloud_vertex_components::all
|
||||||
point_cloud_vertex_components::normal,
|
|
||||||
point_cloud_vertex_components::color,
|
|
||||||
point_cloud_vertex_components::reflectance
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#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
|
#pragma once
|
||||||
|
|
||||||
#include "assets/data/material_data.hpp"
|
#include "assets/components/texture_components.hpp"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace assets
|
namespace assets
|
||||||
{
|
{
|
||||||
|
|
||||||
struct texture_view
|
struct texture_view
|
||||||
{
|
{
|
||||||
std::weak_ptr<std::uint8_t[]> data;
|
std::weak_ptr<z3d::u8[]> data;
|
||||||
int width, height;
|
z3d::i32 width, height;
|
||||||
texture_components::flags component_flags;
|
texture_components::flags component_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
#include "util/string_list.hpp"
|
#include "util/string_list.hpp"
|
||||||
#include "assets/prefetch_queue.hpp"
|
#include "assets/prefetch_queue.hpp"
|
||||||
|
|
||||||
#include "../../read_buffers"
|
#include "assets/data/point_cloud_data.hpp"
|
||||||
#include "../../data_stores"
|
#include "assets/data_stores/point_cloud_store.hpp"
|
||||||
#include "assets/prefetch_lookup.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>;
|
||||||
|
|
||||||
|
}
|
||||||
62
include/config/primitives.hpp
Normal file
62
include/config/primitives.hpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <array>
|
||||||
|
#include "glm/gtc/type_aligned.hpp"
|
||||||
|
#include "util/id_type.hpp"
|
||||||
|
|
||||||
|
namespace z3d
|
||||||
|
{
|
||||||
|
|
||||||
|
using u8 = std::uint8_t;
|
||||||
|
using u16 = std::uint16_t;
|
||||||
|
using u32 = std::uint32_t;
|
||||||
|
using u64 = std::uint64_t;
|
||||||
|
|
||||||
|
using i8 = std::int8_t;
|
||||||
|
using i16 = std::int16_t;
|
||||||
|
using i32 = std::int32_t;
|
||||||
|
using i64 = std::int64_t;
|
||||||
|
|
||||||
|
using size = ssize_t;
|
||||||
|
|
||||||
|
using f32 = float;
|
||||||
|
using f64 = double;
|
||||||
|
|
||||||
|
template<glm::length_t L, typename T>
|
||||||
|
using vec = glm::vec<L, T, glm::packed_highp>;
|
||||||
|
|
||||||
|
using vec2 = vec<2, f32>;
|
||||||
|
using vec3 = vec<3, f32>;
|
||||||
|
using vec4 = vec<4, f32>;
|
||||||
|
|
||||||
|
template<glm::length_t C, glm::length_t R, typename T>
|
||||||
|
using mat = glm::mat<C, R, T, glm::packed_highp>;
|
||||||
|
|
||||||
|
using mat3 = mat<4, 4, f32>;
|
||||||
|
using mat4 = mat<4, 4, f32>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using optional = std::optional<T>;
|
||||||
|
|
||||||
|
template<typename T, std::size_t Count>
|
||||||
|
using array = std::array<T, Count>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using vector = std::vector<T>;
|
||||||
|
|
||||||
|
template<class T, std::size_t Extent = std::dynamic_extent>
|
||||||
|
using array_view = std::span<T, Extent>;
|
||||||
|
|
||||||
|
template<typename... Ts>
|
||||||
|
using structure = std::tuple<Ts...>;
|
||||||
|
|
||||||
|
using string_view = std::string_view;
|
||||||
|
|
||||||
|
using vertex_index = u32;
|
||||||
|
using index_triangle = array<vertex_index, 3>;
|
||||||
|
|
||||||
|
template<int ID>
|
||||||
|
using identifier = ztu::id_type<u32, ID>;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,25 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace ztu
|
namespace ztu
|
||||||
{
|
{
|
||||||
template<class Parent, typename IndexType, int uuid = 0>
|
|
||||||
class id_type_for
|
template<typename Index, int ID>
|
||||||
|
class id_type
|
||||||
{
|
{
|
||||||
friend Parent;
|
explicit constexpr id_type(Index index) : index{ index } {}
|
||||||
|
|
||||||
using index_type = IndexType;
|
static constexpr id_type next()
|
||||||
|
{
|
||||||
|
static std::atomic<Index> next_index{ 1 };
|
||||||
|
return id_type{ next_index.fetch_add(1, std::memory_order_seq_cst) };
|
||||||
|
}
|
||||||
|
|
||||||
explicit constexpr id_type_for(index_type index) : index{ index } {}
|
Index index{};
|
||||||
|
|
||||||
index_type index{};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr id_type_for() = default;
|
constexpr id_type() = default;
|
||||||
constexpr auto operator<=>(const id_type_for&) const = default;
|
constexpr auto operator<=>(const id_type&) const = default;
|
||||||
|
|
||||||
constexpr operator bool() const
|
constexpr operator bool() const
|
||||||
{
|
{
|
||||||
return index == index_type{};
|
return index == Index{};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,75 +5,75 @@
|
|||||||
|
|
||||||
inline std::optional<assets::material_components::surface_properties>& assets::material_data::surface_properties()
|
inline std::optional<assets::material_components::surface_properties>& assets::material_data::surface_properties()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::surface_properties>(data);
|
return std::get<material_components::indices::surface_properties>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::transparency>& assets::material_data::transparency()
|
inline std::optional<assets::material_components::transparency>& assets::material_data::transparency()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::transparency>(data);
|
return std::get<material_components::indices::transparency>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::ambient_color_texture>& assets::material_data::ambient_color_texture_id()
|
inline std::optional<assets::material_components::ambient_color_texture>& assets::material_data::ambient_color_texture_id()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::ambient_color_texture>(data);
|
return std::get<material_components::indices::ambient_color_texture>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::diffuse_color_texture>& assets::material_data::diffuse_color_texture_id()
|
inline std::optional<assets::material_components::diffuse_color_texture>& assets::material_data::diffuse_color_texture_id()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::diffuse_color_texture>(data);
|
return std::get<material_components::indices::diffuse_color_texture>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::specular_color_texture>& assets::material_data::specular_color_texture_id()
|
inline std::optional<assets::material_components::specular_color_texture>& assets::material_data::specular_color_texture_id()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::specular_color_texture>(data);
|
return std::get<material_components::indices::specular_color_texture>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::shininess_texture>& assets::material_data::shininess_texture_id()
|
inline std::optional<assets::material_components::shininess_texture>& assets::material_data::shininess_texture_id()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::shininess_texture>(data);
|
return std::get<material_components::indices::shininess_texture>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::alpha_texture>& assets::material_data::alpha_texture_id()
|
inline std::optional<assets::material_components::alpha_texture>& assets::material_data::alpha_texture_id()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::alpha_texture>(data);
|
return std::get<material_components::indices::alpha_texture>(components);
|
||||||
}
|
}
|
||||||
inline std::optional<assets::material_components::bump_texture>& assets::material_data::bump_texture_id()
|
inline std::optional<assets::material_components::bump_texture>& assets::material_data::bump_texture_id()
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::bump_texture(data);
|
return std::get<material_components::indices::bump_texture(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::surface_properties>& assets::material_data::surface_properties() const
|
inline const std::optional<assets::material_components::surface_properties>& assets::material_data::surface_properties() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::surface_properties>(data);
|
return std::get<material_components::indices::surface_properties>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::transparency>& assets::material_data::transparency() const
|
inline const std::optional<assets::material_components::transparency>& assets::material_data::transparency() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::transparency>(data);
|
return std::get<material_components::indices::transparency>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::ambient_color_texture>& assets::material_data::ambient_color_texture_id() const
|
inline const std::optional<assets::material_components::ambient_color_texture>& assets::material_data::ambient_color_texture_id() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::ambient_color_texture>(data);
|
return std::get<material_components::indices::ambient_color_texture>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::diffuse_color_texture>& assets::material_data::diffuse_color_texture_id() const
|
inline const std::optional<assets::material_components::diffuse_color_texture>& assets::material_data::diffuse_color_texture_id() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::diffuse_color_texture>(data);
|
return std::get<material_components::indices::diffuse_color_texture>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::specular_color_texture>& assets::material_data::specular_color_texture_id() const
|
inline const std::optional<assets::material_components::specular_color_texture>& assets::material_data::specular_color_texture_id() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::specular_color_texture>(data);
|
return std::get<material_components::indices::specular_color_texture>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::shininess_texture>& assets::material_data::shininess_texture_id() const
|
inline const std::optional<assets::material_components::shininess_texture>& assets::material_data::shininess_texture_id() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::shininess_texture>(data);
|
return std::get<material_components::indices::shininess_texture>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::alpha_texture>& assets::material_data::alpha_texture_id() const
|
inline const std::optional<assets::material_components::alpha_texture>& assets::material_data::alpha_texture_id() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::alpha_texture>(data);
|
return std::get<material_components::indices::alpha_texture>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::optional<assets::material_components::bump_texture>& assets::material_data::bump_texture_id() const
|
inline const std::optional<assets::material_components::bump_texture>& assets::material_data::bump_texture_id() const
|
||||||
{
|
{
|
||||||
return std::get<material_components::indices::bump_texture>(data);
|
return std::get<material_components::indices::bump_texture>(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,11 +89,6 @@ inline assets::material_components::surface_properties& assets::material_data::i
|
|||||||
|
|
||||||
inline void assets::material_data::clear()
|
inline void assets::material_data::clear()
|
||||||
{
|
{
|
||||||
std::apply(
|
clear_components();
|
||||||
[](auto&... data_opt) {
|
|
||||||
(data_opt.reset(), ...);
|
|
||||||
},
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,62 +4,62 @@
|
|||||||
|
|
||||||
inline std::vector<assets::mesh_vertex_components::position>& assets::mesh_data::positions()
|
inline std::vector<assets::mesh_vertex_components::position>& assets::mesh_data::positions()
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::position>(vertices);
|
return std::get<mesh_vertex_components::indices::position>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<assets::mesh_vertex_components::normal>& assets::mesh_data::normals()
|
inline std::vector<assets::mesh_vertex_components::normal>& assets::mesh_data::normals()
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::normal>(vertices);
|
return std::get<mesh_vertex_components::indices::normal>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<assets::mesh_vertex_components::tex_coord>& assets::mesh_data::tex_coords()
|
inline std::vector<assets::mesh_vertex_components::tex_coord>& assets::mesh_data::tex_coords()
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::tex_coord>(vertices);
|
return std::get<mesh_vertex_components::indices::tex_coord>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<assets::mesh_vertex_components::color>& assets::mesh_data::colors()
|
inline std::vector<assets::mesh_vertex_components::color>& assets::mesh_data::colors()
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::color>(vertices);
|
return std::get<mesh_vertex_components::indices::color>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<assets::mesh_vertex_components::reflectance>& assets::mesh_data::reflectances()
|
inline std::vector<assets::mesh_vertex_components::reflectance>& assets::mesh_data::reflectances()
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::reflectance>(vertices);
|
return std::get<mesh_vertex_components::indices::reflectance>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<assets::mesh_data::triangle_type>& assets::mesh_data::triangles()
|
inline std::vector<z3d::index_triangle>& assets::mesh_data::triangles()
|
||||||
{
|
{
|
||||||
return m_triangles;
|
return m_triangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto& assets::mesh_data::material_id()
|
inline auto& assets::mesh_data::material()
|
||||||
{
|
{
|
||||||
return m_material_id;
|
return m_material_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::vector<assets::mesh_vertex_components::position>& assets::mesh_data::positions() const
|
inline const std::vector<assets::mesh_vertex_components::position>& assets::mesh_data::positions() const
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::position>(vertices);
|
return std::get<mesh_vertex_components::indices::position>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::vector<assets::mesh_vertex_components::normal>& assets::mesh_data::normals() const
|
inline const std::vector<assets::mesh_vertex_components::normal>& assets::mesh_data::normals() const
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::normal>(vertices);
|
return std::get<mesh_vertex_components::indices::normal>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::vector<assets::mesh_vertex_components::tex_coord>& assets::mesh_data::tex_coords() const
|
inline const std::vector<assets::mesh_vertex_components::tex_coord>& assets::mesh_data::tex_coords() const
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::tex_coord>(vertices);
|
return std::get<mesh_vertex_components::indices::tex_coord>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::vector<assets::mesh_vertex_components::color>& assets::mesh_data::colors() const
|
inline const std::vector<assets::mesh_vertex_components::color>& assets::mesh_data::colors() const
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::color>(vertices);
|
return std::get<mesh_vertex_components::indices::color>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::vector<assets::mesh_vertex_components::reflectance>& assets::mesh_data::reflectances() const
|
inline const std::vector<assets::mesh_vertex_components::reflectance>& assets::mesh_data::reflectances() const
|
||||||
{
|
{
|
||||||
return std::get<mesh_vertex_components::indices::reflectance>(vertices);
|
return std::get<mesh_vertex_components::indices::reflectance>(component_arrays);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::vector<assets::mesh_data::triangle_type>& assets::mesh_data::triangles() const
|
inline const std::vector<assets::mesh_data::triangle_type>& assets::mesh_data::triangles() const
|
||||||
@@ -67,14 +67,14 @@ inline const std::vector<assets::mesh_data::triangle_type>& assets::mesh_data::t
|
|||||||
return m_triangles;
|
return m_triangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const auto& assets::mesh_data::material_id() const
|
inline const auto& assets::mesh_data::material() const
|
||||||
{
|
{
|
||||||
return m_material_id;
|
return m_material_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void assets::mesh_data::clear()
|
inline void assets::mesh_data::clear()
|
||||||
{
|
{
|
||||||
clear_vertices();
|
clear_component_arrays();
|
||||||
m_triangles.clear();
|
m_triangles.clear();
|
||||||
m_material_id = {};
|
m_material_id = {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,5 +45,5 @@ inline const std::vector<assets::point_cloud_vertex_components::reflectance>& as
|
|||||||
|
|
||||||
inline void assets::point_cloud_data::clear()
|
inline void assets::point_cloud_data::clear()
|
||||||
{
|
{
|
||||||
clear_vertices();
|
clear_component_arrays();
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ assets::detail::generic_material_store<Ts...>::array_counts() const
|
|||||||
|
|
||||||
template<typename... Ts>
|
template<typename... Ts>
|
||||||
typename assets::detail::generic_material_store<Ts...>::id_type assets::detail::generic_material_store<Ts...>::add(
|
typename assets::detail::generic_material_store<Ts...>::id_type assets::detail::generic_material_store<Ts...>::add(
|
||||||
const material_data& material
|
const component_set& material
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const auto id = id_type{ m_next_data_id.index++ };
|
const auto id = id_type{ m_next_data_id.index++ };
|
||||||
|
|||||||
Reference in New Issue
Block a user