Ported the obj parser.

This commit is contained in:
zy4n
2025-04-01 21:51:56 +02:00
parent bc065bc657
commit 27977c1738
34 changed files with 1676 additions and 1554 deletions

View File

@@ -5,8 +5,6 @@
#include "assets/data_stores.hpp"
#include "assets/path_id_lookups.hpp"
#include "assets/prefetch_lookup.hpp"
#include "assets/prefetch_queue.hpp"
#include "assets/data/material_data.hpp"
#include "assets/data/material_library_data.hpp"
#include "assets/data_stores/material_store.hpp"
@@ -50,14 +48,35 @@ struct mtl_parser
);
protected:
class prefetcher_context
{
public:
prefetcher_context(
path_id_lookups& lookups
);
void operator()(lookup_type::const_pointer entry) noexcept;
protected:
[[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_lookups;
std::vector<char> m_buffer{};
};
class parser_context
{
public:
parser_context(
const texture_id_lookup& texture_id_lookup,
material_id_lookup& material_id_lookup,
material_store& material_store,
store_type& store
path_id_lookups& lookups,
data_stores& stores
);
void operator()(lookup_type::const_pointer entry) noexcept;
@@ -72,21 +91,11 @@ protected:
);
private:
const texture_id_lookup* m_texture_id_lookup;
material_id_lookup* m_material_id_lookup;
material_store* m_material_store;
store_type* m_store;
path_id_lookups* m_lookups;
data_stores* m_stores;
data_type m_buffer{};
};
static void find_textures(
std::span<char> buffer,
std::filesystem::path& path_buffer,
const std::filesystem::path& base_directory,
std::ifstream& in,
ztu::string_list& texture_filenames
);
private:
std::vector<lookup_type::const_pointer> m_path_buffer;
};