Fix for converted texture output folder creation and empty filepath

This commit is contained in:
K. S. Ernest (iFire) Lee 2021-11-28 11:41:51 -08:00
parent 661c99c9cb
commit b89d4cd0e0
3 changed files with 14 additions and 5 deletions

View File

@ -180,7 +180,6 @@ std::shared_ptr<TextureData> TextureBuilder::simple(int rawTexIndex, const std::
const RawTexture& rawTexture = raw.GetTexture(rawTexIndex); const RawTexture& rawTexture = raw.GetTexture(rawTexIndex);
const std::string textureName = FileUtils::GetFileBase(rawTexture.name); const std::string textureName = FileUtils::GetFileBase(rawTexture.name);
const std::string relativeFilename = FileUtils::GetFileName(rawTexture.fileLocation); const std::string relativeFilename = FileUtils::GetFileName(rawTexture.fileLocation);
ImageData* image = nullptr; ImageData* image = nullptr;
if (options.outputBinary) { if (options.outputBinary) {
auto bufferView = gltf.AddBufferViewForFile(*gltf.defaultBuffer, rawTexture.fileLocation); auto bufferView = gltf.AddBufferViewForFile(*gltf.defaultBuffer, rawTexture.fileLocation);

View File

@ -26,7 +26,13 @@ class TextureBuilder {
const GltfOptions& options, const GltfOptions& options,
const std::string& outputFolder, const std::string& outputFolder,
GltfModel& gltf) GltfModel& gltf)
: raw(raw), options(options), outputFolder(outputFolder), gltf(gltf) {} : raw(raw), options(options), outputFolder(outputFolder), gltf(gltf) {
if (!outputFolder.empty()) {
if (outputFolder[outputFolder.size() - 1] == '/') {
this->outputFolder = outputFolder.substr(0, outputFolder.size() - 1) ;
}
}
}
~TextureBuilder() {} ~TextureBuilder() {}
std::shared_ptr<TextureData> combine( std::shared_ptr<TextureData> combine(
@ -70,7 +76,7 @@ class TextureBuilder {
private: private:
const RawModel& raw; const RawModel& raw;
const GltfOptions& options; const GltfOptions& options;
const std::string outputFolder; std::string outputFolder;
GltfModel& gltf; GltfModel& gltf;
std::map<std::string, std::shared_ptr<TextureData>> textureByIndicesKey; std::map<std::string, std::shared_ptr<TextureData>> textureByIndicesKey;

View File

@ -70,4 +70,8 @@ inline boost::optional<std::string> GetFileSuffix(const std::string& path) {
return extension.string().substr(1); return extension.string().substr(1);
} }
inline bool MakeDir(const std::string& path) {
return boost::filesystem::create_directories(boost::filesystem::path(path));
}
} // namespace FileUtils } // namespace FileUtils