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
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "prefetch_lookups/material_library_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/material_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/point_cloud_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/shader_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/texture_prefetch_lookup.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct prefetch_lookup
|
||||
{
|
||||
texture_prefetch_lookup textures;
|
||||
material_library_prefetch_lookup material_libraries;
|
||||
material_prefetch_lookup materials;
|
||||
mesh_prefetch_lookup meshes;
|
||||
pose_prefetch_lookup poses;
|
||||
point_cloud_prefetch_lookup point_clouds;
|
||||
shader_source_prefetch_lookup shader_sources;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/data_stores/material_library_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using material_library_prefetch_lookup = std::unordered_map<std::filesystem::path, material_library_store::id_type>;
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/data_stores/material_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using material_prefetch_lookup = std::unordered_map<std::filesystem::path, material_store::id_type>;
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/data_stores/mesh_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using mesh_prefetch_lookup = std::unordered_map<std::filesystem::path, mesh_store::id_type>;
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/data_stores/point_cloud_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using point_cloud_prefetch_lookup = std::unordered_map<std::filesystem::path, point_cloud_store::id_type>;
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "assets/data_stores/pose_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
class pose_prefetch_lookup
|
||||
{
|
||||
public:
|
||||
using index_type = ztu::u32;
|
||||
using directory_lookup = std::unordered_map<std::filesystem::path, index_type>;
|
||||
using directory_iterator = std::pair<directory_lookup::iterator, index_type>;
|
||||
using index_lookup = std::vector<index_type>;
|
||||
using index_iterator = index_lookup::iterator;
|
||||
using lookup_type = std::vector<pose_store::id_type>;
|
||||
using iterator = lookup_type::iterator;
|
||||
|
||||
void emplace(
|
||||
const std::filesystem::path& directory,
|
||||
index_type index,
|
||||
pose_store::id_type id
|
||||
);
|
||||
|
||||
void emplace_hint_dir(
|
||||
directory_iterator directory_it,
|
||||
index_type index,
|
||||
pose_store::id_type id
|
||||
);
|
||||
|
||||
void emplace_hint_dir_index(
|
||||
directory_iterator directory_it,
|
||||
index_iterator index_it,
|
||||
index_type index,
|
||||
pose_store::id_type id
|
||||
);
|
||||
|
||||
std::pair<directory_iterator, bool> find_directory(
|
||||
const std::filesystem::path& directory
|
||||
);
|
||||
|
||||
std::pair<index_iterator, pose_store::id_type> find_index(
|
||||
directory_iterator directory_it,
|
||||
index_type index
|
||||
);
|
||||
|
||||
directory_iterator emplace_dir(
|
||||
directory_iterator directory_it,
|
||||
const std::filesystem::path& directory
|
||||
);
|
||||
|
||||
private:
|
||||
directory_lookup m_directory_lookup;
|
||||
index_lookup m_directory_indices; // count before indices, indices sorted per dir
|
||||
lookup_type m_pose_ids; // offset by 1
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/data_stores/shader_source_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using shader_source_prefetch_lookup = std::unordered_map<std::filesystem::path, shader_source_store::id_type>;
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/data_stores/texture_store.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
using texture_prefetch_lookup = std::unordered_map<std::filesystem::path, texture_store::id_type>;
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct file_dir_list
|
||||
{
|
||||
ztu::string_list files;
|
||||
ztu::string_list directories;
|
||||
};
|
||||
|
||||
|
||||
struct prefetch_queue
|
||||
{
|
||||
file_dir_list obj_queue;
|
||||
file_dir_list stl_queue;
|
||||
|
||||
file_dir_list mtl_queue;
|
||||
|
||||
file_dir_list uosr_queue;
|
||||
file_dir_list uos_rgb_queue;
|
||||
file_dir_list uos_normal_queue;
|
||||
file_dir_list uos_queue;
|
||||
file_dir_list kitti_queue;
|
||||
|
||||
file_dir_list threedtk_pose_queue;
|
||||
file_dir_list kitti_pose_queue;
|
||||
|
||||
file_dir_list glsl_queue;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user