From 64f4e6515c969aff279cfd3301e7908cd597e54c Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Sun, 28 Nov 2021 13:20:36 -0800 Subject: [PATCH] Simplify. --- src/gltf/TextureBuilder.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gltf/TextureBuilder.cpp b/src/gltf/TextureBuilder.cpp index 3d39986..72bb78b 100644 --- a/src/gltf/TextureBuilder.cpp +++ b/src/gltf/TextureBuilder.cpp @@ -203,23 +203,22 @@ std::shared_ptr TextureBuilder::simple(int rawTexIndex, const std:: } } else if (!relativeFilename.empty()) { - std::string outputPath = outputFolder + "/" + relativeFilename; - auto dstAbs = FileUtils::GetAbsolutePath(outputPath); image = new ImageData(relativeFilename, relativeFilename); - auto srcAbs = FileUtils::GetAbsolutePath(rawTexture.fileLocation); - if (FileUtils::FileExists(outputPath) || srcAbs == dstAbs)) { - return nullptr; + std::string outputPath = outputFolder + "/" + relativeFilename; + if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) { + if (verboseOutput) { + fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath); + } + } else { + // no point commenting further on read/write error; CopyFile() does enough of that, and we + // certainly want to to add an image struct to the glTF JSON, with the correct relative path + // reference, even if the copy failed. } - if (!FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) { - return nullptr; - } - if (verboseOutput) { - fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath); - } - } + } if (!image) { return nullptr; } + std::shared_ptr texDat = gltf.textures.hold( new TextureData(textureName, *gltf.defaultSampler, *gltf.images.hold(image))); textureByIndicesKey.insert(std::make_pair(key, texDat));