worked on obj and mtl prefetching nad parsing

This commit is contained in:
ZY4N
2024-12-26 20:20:02 +01:00
parent b385b3b1c8
commit 447146b7f5
16 changed files with 606 additions and 376 deletions

View File

@@ -11,23 +11,25 @@ struct dynamic_material_buffer {
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]] inline std::optional<components::material::surface_properties>& surface_properties();
[[nodiscard]] inline std::optional<components::material::transparency>& transparency();
[[nodiscard]] inline std::optional<dynamic_texture_store::id_type>& ambient_color_texture_id();
[[nodiscard]] inline std::optional<dynamic_texture_store::id_type>& diffuse_color_texture_id();
[[nodiscard]] inline std::optional<dynamic_texture_store::id_type>& specular_color_texture_id();
[[nodiscard]] inline std::optional<dynamic_texture_store::id_type>& shininess_texture_id();
[[nodiscard]] inline std::optional<dynamic_texture_store::id_type>& alpha_texture_id();
[[nodiscard]] inline 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;
[[nodiscard]] inline const std::optional<components::material::surface_properties>& surface_properties() const;
[[nodiscard]] inline const std::optional<components::material::transparency>& transparency() const;
[[nodiscard]] inline const std::optional<dynamic_texture_store::id_type>& ambient_color_texture_id() const;
[[nodiscard]] inline const std::optional<dynamic_texture_store::id_type>& diffuse_color_texture_id() const;
[[nodiscard]] inline const std::optional<dynamic_texture_store::id_type>& specular_color_texture_id() const;
[[nodiscard]] inline const std::optional<dynamic_texture_store::id_type>& shininess_texture_id() const;
[[nodiscard]] inline const std::optional<dynamic_texture_store::id_type>& alpha_texture_id() const;
[[nodiscard]] inline const std::optional<dynamic_texture_store::id_type>& bump_texture_id() const;
inline void clear();
std::tuple<
std::optional<components::material::surface_properties>,

View File

@@ -5,7 +5,7 @@
#include "util/uix.hpp"
#include "assets/components/mesh_vertex_components.hpp"
#include "assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp"
#include "generic/dynamic_vertex_buffer.hpp"
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
class dynamic_mesh_buffer : public dynamic_vertex_buffer<
@@ -20,21 +20,23 @@ 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]] inline std::vector<components::mesh_vertex::position>& positions();
[[nodiscard]] inline std::vector<components::mesh_vertex::normal>& normals();
[[nodiscard]] inline std::vector<components::mesh_vertex::tex_coord>& tex_coords();
[[nodiscard]] inline std::vector<components::mesh_vertex::color>& colors();
[[nodiscard]] inline std::vector<components::mesh_vertex::reflectance>& reflectances();
[[nodiscard]] inline std::vector<triangle_type>& triangles();
[[nodiscard]] inline 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;
[[nodiscard]] inline const std::vector<components::mesh_vertex::position>& positions() const;
[[nodiscard]] inline const std::vector<components::mesh_vertex::normal>& normals() const;
[[nodiscard]] inline const std::vector<components::mesh_vertex::tex_coord>& tex_coords() const;
[[nodiscard]] inline const std::vector<components::mesh_vertex::color>& colors() const;
[[nodiscard]] inline const std::vector<components::mesh_vertex::reflectance>& reflectances() const;
[[nodiscard]] inline const std::vector<triangle_type>& triangles() const;
[[nodiscard]] inline const auto& material_id() const;
inline void clear();
private:
std::vector<triangle_type> m_triangles{};

View File

@@ -4,7 +4,7 @@
#include <array>
#include <vector>
#include "assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp"
#include "generic/dynamic_vertex_buffer.hpp"
class dynamic_point_cloud_buffer : public dynamic_vertex_buffer<
components::point_cloud_vertex::flags,
@@ -14,15 +14,17 @@ class dynamic_point_cloud_buffer : public dynamic_vertex_buffer<
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]] inline std::vector<components::point_cloud_vertex::position>& positions();
[[nodiscard]] inline std::vector<components::point_cloud_vertex::normal>& normals();
[[nodiscard]] inline std::vector<components::point_cloud_vertex::color>& colors();
[[nodiscard]] inline 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;
[[nodiscard]] inline const std::vector<components::point_cloud_vertex::position>& positions() const;
[[nodiscard]] inline const std::vector<components::point_cloud_vertex::normal>& normals() const;
[[nodiscard]] inline const std::vector<components::point_cloud_vertex::color>& colors() const;
[[nodiscard]] inline const std::vector<components::point_cloud_vertex::reflectance>& reflectances() const;
inline void clear();
};
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION

View File

@@ -7,4 +7,10 @@ struct dynamic_shader_buffer
{
std::vector<char> source{};
GLenum type{ GL_INVALID_ENUM };
inline void clear()
{
source.clear();
type = GL_INVALID_ENUM;
}
};

View File

@@ -21,50 +21,52 @@ public:
dynamic_texture_buffer() = default;
dynamic_texture_buffer(
inline 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&);
inline dynamic_texture_buffer(const dynamic_texture_buffer&);
dynamic_texture_buffer(dynamic_texture_buffer&&) noexcept;
inline dynamic_texture_buffer(dynamic_texture_buffer&&) noexcept;
[[nodiscard]] dynamic_texture_buffer& operator=(const dynamic_texture_buffer&);
[[nodiscard]] inline dynamic_texture_buffer& operator=(const dynamic_texture_buffer&);
[[nodiscard]] dynamic_texture_buffer& operator=(dynamic_texture_buffer&&) noexcept;
[[nodiscard]] inline dynamic_texture_buffer& operator=(dynamic_texture_buffer&&) noexcept;
[[nodiscard]] components::texture::flags components() const;
[[nodiscard]] inline components::texture::flags components() const;
[[nodiscard]] dim_type width() const;
[[nodiscard]] inline dim_type width() const;
[[nodiscard]] dim_type height() const;
[[nodiscard]] inline dim_type height() const;
[[nodiscard]] std::pair<dim_type, dim_type> dimensions() const;
[[nodiscard]] inline std::pair<dim_type, dim_type> dimensions() const;
[[nodiscard]] size_type pixel_count() const;
[[nodiscard]] inline size_type pixel_count() const;
[[nodiscard]] size_type component_count() const;
[[nodiscard]] inline size_type component_count() const;
[[nodiscard]] size_type size() const;
[[nodiscard]] inline size_type size() const;
[[nodiscard]] const_iterator begin() const;
[[nodiscard]] inline const_iterator begin() const;
[[nodiscard]] iterator begin();
[[nodiscard]] inline iterator begin();
[[nodiscard]] const_iterator end() const;
[[nodiscard]] inline const_iterator end() const;
[[nodiscard]] iterator end();
[[nodiscard]] inline iterator end();
[[nodiscard]] const_iterator cbegin() const;
[[nodiscard]] inline const_iterator cbegin() const;
[[nodiscard]] const_iterator cend() const;
[[nodiscard]] inline const_iterator cend() const;
[[nodiscard]] const_pointer data() const;
[[nodiscard]] inline const_pointer data() const;
[[nodiscard]] pointer data();
[[nodiscard]] inline pointer data();
void inline clear();
private:
std::unique_ptr<value_type[]> m_data{ nullptr };

View File

@@ -8,8 +8,15 @@
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
protected:
inline void clear_vertices()
{
std::apply(
[](auto&... vertex_opt) {
(vertex_opt.clear(), ...);
},
vertices
);
}
};