Updated program to output name of gltf asset when printing errors

This commit is contained in:
Xiao Qi 2023-03-07 17:17:05 +08:00
parent d98fb3ceb8
commit 92105f1f31
3 changed files with 13 additions and 10 deletions

View File

@ -39,7 +39,7 @@ namespace SH_COMP
class MeshCompiler class MeshCompiler
{ {
static std::string filename;
static AccessorReference accessors; static AccessorReference accessors;
static BufferViewReference bufferViews; static BufferViewReference bufferViews;
static BufferData buffer; static BufferData buffer;

View File

@ -25,6 +25,7 @@
namespace SH_COMP namespace SH_COMP
{ {
std::string MeshCompiler::filename{""};
AccessorReference MeshCompiler::accessors{ nullptr }; AccessorReference MeshCompiler::accessors{ nullptr };
BufferViewReference MeshCompiler::bufferViews{ nullptr }; BufferViewReference MeshCompiler::bufferViews{ nullptr };
BufferData MeshCompiler::buffer{ nullptr }; BufferData MeshCompiler::buffer{ nullptr };
@ -38,14 +39,14 @@ namespace SH_COMP
bool result = loader.LoadASCIIFromFile(&model, &error, &warn, path.string()); bool result = loader.LoadASCIIFromFile(&model, &error, &warn, path.string());
if (!warn.empty()) if (!warn.empty())
std::cout << "[TinyGLTF Warning]: " << warn << std::endl; std::cout << "[TinyGLTF Warning] " << filename << " : " << warn << std::endl;
if (!error.empty()) if (!error.empty())
std::cout << "[TinyGLTF Error]: " << error << std::endl; std::cout << "[TinyGLTF Error] " << filename << " : " << error << std::endl;
if (!result) if (!result)
{ {
std::cout << "TinyGLTF failed to parse.\n"; std::cout << "TinyGLTF failed to parse: " << filename << "\n";
std::exit(1); std::exit(1);
} }
@ -87,7 +88,7 @@ namespace SH_COMP
} }
catch (std::out_of_range e) 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 try
@ -97,7 +98,7 @@ namespace SH_COMP
} }
catch(std::out_of_range e) 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(); auto const asset = new ModelAsset();
filename = path.filename().string();
LoadFromFile(path, *asset); LoadFromFile(path, *asset);
BuildHeaders(*asset); BuildHeaders(*asset);
MeshWriter::CompileMeshBinary(path, *asset); MeshWriter::CompileMeshBinary(path, *asset);
@ -223,7 +226,7 @@ namespace SH_COMP
{ {
if (data.animations.empty()) if (data.animations.empty())
{ {
std::cout << "[Model Compiler] Animations do not exist\n"; std::cout << "[Model Compiler] " << filename << ": Animations do not exist\n";
return; return;
} }
@ -267,7 +270,7 @@ namespace SH_COMP
{ {
if (data.skins.empty()) 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; return;
} }

View File

@ -18,7 +18,7 @@ int main(int argc, char* argv[])
{ {
std::vector<std::string> paths; std::vector<std::string> paths;
#if 0 #if 1
if (argc == 1) if (argc == 1)
{ {