Started obj port and gave up.
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
#include "../data_loaders"
|
||||
#include "../data_stores"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/data/mesh_data.hpp"
|
||||
#include "assets/data_stores.hpp"
|
||||
#include "assets/path_id_lookups.hpp"
|
||||
#include <set>
|
||||
|
||||
namespace obj_loader_error {
|
||||
|
||||
namespace assets::obj_loader_error
|
||||
{
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
cannot_open_file,
|
||||
@@ -22,34 +22,34 @@ enum class codes {
|
||||
use_material_without_material_library,
|
||||
unknown_material_name
|
||||
};
|
||||
|
||||
} // namespace obj_loader_error
|
||||
|
||||
struct obj_loader {
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct obj_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("obj");
|
||||
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
|
||||
// TODO port this mess to the new interface
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
path_id_lookups& lookups
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_shader_source_store& store,
|
||||
[[nodiscard]] std::error_code load(
|
||||
path_id_lookups& lookups,
|
||||
data_stores& stores,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
using index_type = dynamic_mesh_buffer::index_type;
|
||||
using vertex_type = std::array<index_type, 3>;
|
||||
|
||||
struct indexed_vertex_type
|
||||
{
|
||||
vertex_type vertex;
|
||||
index_type buffer_index;
|
||||
z3d::index_triangle vertex;
|
||||
z3d::vertex_index buffer_index;
|
||||
|
||||
friend auto operator<=>(const indexed_vertex_type& a, const indexed_vertex_type& b) {
|
||||
return a.vertex <=> b.vertex;
|
||||
@@ -60,6 +60,38 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
|
||||
protected:
|
||||
void reset();
|
||||
|
||||
[[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:
|
||||
const path_id_lookups* m_id_lookups;
|
||||
data_stores* m_stores;
|
||||
data_type m_buffer{};
|
||||
data_type m_read_buffer{};
|
||||
std::set<indexed_vertex_type> vertex_ids{};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static void find_materials(
|
||||
std::span<char> buffer,
|
||||
std::filesystem::path& path_buffer,
|
||||
@@ -80,3 +112,4 @@ protected:
|
||||
bool pedantic
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user