Ported the obj parser.
This commit is contained in:
@@ -3,28 +3,65 @@
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "assets/data_stores.hpp"
|
||||
#include "assets/data"
|
||||
#include "../data_stores"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/data/mesh_data.hpp"
|
||||
#include "assets/data_stores.hpp"
|
||||
#include "assets/path_id_lookups.hpp"
|
||||
#include "util/vector_hash.hpp"
|
||||
|
||||
struct stl_loader {
|
||||
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]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
path_id_lookups& lookups
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
// space stuff that has to persist
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
[[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<texture_id> 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<mesh_vertex_components::position, z3d::vertex_index> m_vertex_index_lookup{};
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<lookup_type::const_pointer> m_path_buffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user