Started obj port and gave up.
This commit is contained in:
@@ -30,10 +30,7 @@ protected:
|
||||
class parser_context
|
||||
{
|
||||
public:
|
||||
parser_context(
|
||||
store_type& m_store,
|
||||
std::mutex& m_store_mutex
|
||||
);
|
||||
parser_context(store_type& m_store);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
|
||||
@@ -48,7 +45,6 @@ protected:
|
||||
|
||||
private:
|
||||
store_type* m_store;
|
||||
std::mutex* m_store_mutex;
|
||||
shader_source_data m_buffer{};
|
||||
std::vector<std::string_view> m_value_buffer{};
|
||||
std::vector<std::size_t> m_declaration_value_count_buffer{};
|
||||
@@ -60,50 +56,29 @@ protected:
|
||||
std::vector<char>& source
|
||||
);
|
||||
|
||||
static void tokenize_declarations(
|
||||
std::string_view source,
|
||||
std::vector<std::string_view>& value_buffer,
|
||||
std::vector<std::size_t>& declaration_value_count_buffer,
|
||||
std::array<std::size_t, 4>& declaration_type_index_buffer
|
||||
);
|
||||
|
||||
static [[nodiscard]] bool parse_metadata_from_tokens(
|
||||
const std::vector<std::string_view>& value_buffer,
|
||||
const std::vector<std::size_t>& declaration_value_count_buffer,
|
||||
const std::array<std::size_t, 4>& declaration_type_index_buffer,
|
||||
shader_source_data& buffer
|
||||
);
|
||||
|
||||
static void remove_metadata_declarations(
|
||||
const std::vector<std::string_view>& value_buffer,
|
||||
const std::vector<std::size_t>& declaration_value_count_buffer,
|
||||
const std::array<std::size_t, 4>& declaration_type_index_buffer,
|
||||
std::vector<char>& source
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_geometry_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
model_geometry::types& geometry_type
|
||||
shader_source_data::metadata& meta
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_stage_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_components::stage& stage
|
||||
shader_source_data::metadata& meta
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_components_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_data& buffer
|
||||
shader_source_data::metadata& meta
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_static_enable_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_data& buffer
|
||||
shader_source_data::metadata& meta
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_dynamic_enable_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_data& buffer
|
||||
shader_source_data::metadata& meta
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_component_tokens(
|
||||
|
||||
@@ -42,7 +42,6 @@ protected:
|
||||
const pose_list_id_lookup& pose_list_lookup,
|
||||
const pose_list_store& pose_list_store,
|
||||
store_type& m_store,
|
||||
std::mutex& m_store_mutex
|
||||
);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
@@ -60,7 +59,6 @@ protected:
|
||||
pose_list_id_lookup const* m_pose_list_lookup;
|
||||
pose_list_store const* m_pose_list_store;
|
||||
store_type* m_store;
|
||||
std::mutex* m_store_mutex;
|
||||
data_type m_buffer{};
|
||||
std::filesystem::path m_last_pose_path{};
|
||||
pose_list_view m_last_pose_list{};
|
||||
|
||||
@@ -33,10 +33,7 @@ private:
|
||||
class parser_context
|
||||
{
|
||||
public:
|
||||
parser_context(
|
||||
store_type& m_store,
|
||||
std::mutex& m_store_mutex
|
||||
);
|
||||
parser_context(store_type& m_store);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
|
||||
@@ -45,7 +42,6 @@ private:
|
||||
|
||||
private:
|
||||
store_type* m_store;
|
||||
std::mutex* m_store_mutex;
|
||||
data_type m_buffer{};
|
||||
};
|
||||
|
||||
|
||||
@@ -57,8 +57,7 @@ protected:
|
||||
const texture_id_lookup& texture_id_lookup,
|
||||
material_id_lookup& material_id_lookup,
|
||||
material_store& material_store,
|
||||
store_type& store,
|
||||
std::mutex& store_mutex
|
||||
store_type& store
|
||||
);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
@@ -77,7 +76,6 @@ protected:
|
||||
material_id_lookup* m_material_id_lookup;
|
||||
material_store* m_material_store;
|
||||
store_type* m_store;
|
||||
std::mutex* m_store_mutex;
|
||||
data_type m_buffer{};
|
||||
};
|
||||
|
||||
|
||||
@@ -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