From 10439bd40a968e297b909cc2b72370f627a496fb Mon Sep 17 00:00:00 2001 From: Jesse Vander Does Date: Mon, 13 May 2019 21:27:45 -0700 Subject: [PATCH] Set binary output based on extension, fixed optional value check --- src/FBX2glTF.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/FBX2glTF.cpp b/src/FBX2glTF.cpp index 319908b..19e5f5b 100644 --- a/src/FBX2glTF.cpp +++ b/src/FBX2glTF.cpp @@ -291,20 +291,27 @@ int main(int argc, char* argv[]) { // the path of the actual .glb or .gltf file std::string modelPath; const auto& suffix = FileUtils::GetFileSuffix(outputPath); - if (gltfOptions.outputBinary || suffix.value() == "glb") { + + // set to binary output to true if extension is glb + if (suffix.has_value() && suffix.value() == "glb") { + gltfOptions.outputBinary = true; + } + + if (gltfOptions.outputBinary) { // add .glb to output path, unless it already ends in exactly that if (suffix.has_value() && suffix.value() == "glb") { modelPath = outputPath; } else { modelPath = outputPath + ".glb"; } - } else if(suffix.value() == "gltf") { + // if the extension is gltf set the output folder to the parent directory + } else if(suffix.has_value() && suffix.value() == "gltf") { modelPath = outputPath; outputFolder = FileUtils::getFolder(outputPath) + "/"; } else { // in gltf mode, we create a folder and write into that outputFolder = fmt::format("{}_out/", outputPath.c_str()); - modelPath = outputFolder + FileUtils::GetFileName(outputPath) + ".gltf"; + modelPath = outputFolder + FileUtils::GetFileName(outputPath) + ".gltf"; } if (!FileUtils::CreatePath(modelPath.c_str())) { fmt::fprintf(stderr, "ERROR: Failed to create folder: %s'\n", outputFolder.c_str());