#pragma once #include #include #include #include #include "assets/data_stores.hpp" #include "assets/data/mesh_data.hpp" #include "assets/data_stores.hpp" #include "assets/path_id_lookups.hpp" #include "util/vector_hash.hpp" namespace assets { struct stl_loader { static constexpr auto name = std::string_view("stl"); using data_type = mesh_data; using store_type = mesh_store; using lookup_type = mesh_id_lookup; [[nodiscard]] std::error_code prefetch( path_id_lookups& lookups ); [[nodiscard]] std::error_code load( path_id_lookups& lookups, data_stores& stores, bool pedantic = false ); protected: class parser_context { public: parser_context( path_id_lookups& m_id_lookups, data_stores& m_stores ); void operator()(lookup_type::const_pointer entry) noexcept; protected: void reset(); z3d::vertex_index find_or_push_vertex(const component_indices& vertex_comp_indices); [[nodiscard]] std::optional fetch_texture_id( const std::filesystem::path& mtl_dir, std::string_view filename, std::string_view texture_type_name ); private: path_id_lookups* m_id_lookups; data_stores* m_stores; data_type m_mesh{}; std::unordered_map m_vertex_index_lookup{}; }; private: std::vector m_path_buffer; }; }