From 92105f1f31498967ded2a18d12e4e85e98f3eec1 Mon Sep 17 00:00:00 2001 From: Xiao Qi Date: Tue, 7 Mar 2023 17:17:05 +0800 Subject: [PATCH] Updated program to output name of gltf asset when printing errors --- src/Libraries/MeshCompiler.h | 2 +- src/Libraries/MeshCompiler.hpp | 17 ++++++++++------- src/main.cpp | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Libraries/MeshCompiler.h b/src/Libraries/MeshCompiler.h index b873e80..94b110c 100644 --- a/src/Libraries/MeshCompiler.h +++ b/src/Libraries/MeshCompiler.h @@ -39,7 +39,7 @@ namespace SH_COMP class MeshCompiler { - + static std::string filename; static AccessorReference accessors; static BufferViewReference bufferViews; static BufferData buffer; diff --git a/src/Libraries/MeshCompiler.hpp b/src/Libraries/MeshCompiler.hpp index 3809cbe..fa1de3b 100644 --- a/src/Libraries/MeshCompiler.hpp +++ b/src/Libraries/MeshCompiler.hpp @@ -25,6 +25,7 @@ namespace SH_COMP { + std::string MeshCompiler::filename{""}; AccessorReference MeshCompiler::accessors{ nullptr }; BufferViewReference MeshCompiler::bufferViews{ nullptr }; BufferData MeshCompiler::buffer{ nullptr }; @@ -38,14 +39,14 @@ namespace SH_COMP bool result = loader.LoadASCIIFromFile(&model, &error, &warn, path.string()); if (!warn.empty()) - std::cout << "[TinyGLTF Warning]: " << warn << std::endl; + std::cout << "[TinyGLTF Warning] " << filename << " : " << warn << std::endl; if (!error.empty()) - std::cout << "[TinyGLTF Error]: " << error << std::endl; + std::cout << "[TinyGLTF Error] " << filename << " : " << error << std::endl; if (!result) { - std::cout << "TinyGLTF failed to parse.\n"; + std::cout << "TinyGLTF failed to parse: " << filename << "\n"; std::exit(1); } @@ -87,7 +88,7 @@ namespace SH_COMP } catch (std::out_of_range e) { - std::cout << "[Model Compiler] Failed to load critical data from gltf\n"; + std::cout << "[Model Compiler] Failed to load critical data from gltf: " << filename << "\n"; } try @@ -97,7 +98,7 @@ namespace SH_COMP } catch(std::out_of_range e) { - std::cout << "No weights and joints found for mesh: " << mesh.name << std::endl; + std::cout << "[Model Compiler] " << filename << ": No weights and joints found for mesh: " << mesh.name << std::endl; } } } @@ -212,6 +213,8 @@ namespace SH_COMP { auto const asset = new ModelAsset(); + filename = path.filename().string(); + LoadFromFile(path, *asset); BuildHeaders(*asset); MeshWriter::CompileMeshBinary(path, *asset); @@ -223,7 +226,7 @@ namespace SH_COMP { if (data.animations.empty()) { - std::cout << "[Model Compiler] Animations do not exist\n"; + std::cout << "[Model Compiler] " << filename << ": Animations do not exist\n"; return; } @@ -267,7 +270,7 @@ namespace SH_COMP { if (data.skins.empty()) { - std::cout << "[Model Compiler] Unable to load rigs without skin, aborting"; + std::cout << "[Model Compiler] " << filename << ": Unable to load rigs without skin, aborting"; return; } diff --git a/src/main.cpp b/src/main.cpp index 5571946..0aee0c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,8 +17,8 @@ int main(int argc, char* argv[]) { std::vector paths; - - #if 0 + + #if 1 if (argc == 1) {