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

@@ -1,4 +1,6 @@
#include "viewer/instance.hpp"
/*
*#include "viewer/instance.hpp"
#include "util/logger.hpp"
#include <condition_variable>
#include <thread>
@@ -10,7 +12,6 @@
#include "viewer/asset_types.hpp"
#include "viewer/dynamic_shader_program_loading.hpp"
#include "util/logger.hpp"
/*
void controller_task(
int args_count, char* args[],
viewer::instance* z3d,
@@ -180,7 +181,7 @@ void controller_task(
// TODO fix
std::this_thread::sleep_for(20h);
}*/
}
void controller_task(
@@ -391,7 +392,7 @@ int main(int args_count, char* args[]) {
std::string progress_title = "Initializing...";
float progress_ratio = 0.0f;
/*auto controller_thread = std::thread(
auto controller_thread = std::thread(
controller_task,
args_count,
args,
@@ -400,7 +401,7 @@ int main(int args_count, char* args[]) {
&progress_lock,
&progress_title,
&progress_ratio
);*/
);
auto loader = viewer::asset_loader{};
@@ -429,3 +430,54 @@ int main(int args_count, char* args[]) {
return EXIT_SUCCESS;
}
*/
#include "assets/file_parsers/obj_parser.hpp"
#include "assets/file_parsers/mtl_parser.hpp"
#include <iostream>
int main() {
assets::path_id_lookups lookups{};
assets::data_stores stores{};
lookups.meshes.try_emplace("/home/zy4n/Downloads/test.obj");
assets::obj_parser obj_parser{};
assets::mtl_parser mtl_parser{};
const auto time = [](auto title, auto&& f)
{
namespace chr = std::chrono;
using clock = chr::high_resolution_clock;
using floating_ms = chr::duration<double, std::milli>;
const auto begin = clock::now();
f();
const auto end = clock::now();
const auto ms = chr::duration_cast<floating_ms>(end - begin).count();
std::cout << title << ": " << ms << "ms" << std::endl;
};
time("obj prefetch", [&] {
std::ignore = obj_parser.prefetch(lookups);
});
time("mtl prefetch", [&] {
std::ignore = mtl_parser.prefetch(lookups);
});
time("mtl parsing", [&] {
std::ignore = mtl_parser.load(lookups, stores);
});
time("obj parsing", [&] {
std::ignore = obj_parser.load(lookups, stores);
});
}