From b42c6d1352d815699d10c9af9da0eaf6ba59a171 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Tue, 12 Mar 2019 11:24:56 -0700 Subject: [PATCH] Fix baked models not mapping to correct textures --- libraries/baking/src/ModelBaker.cpp | 5 +++++ libraries/baking/src/TextureBaker.cpp | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/baking/src/ModelBaker.cpp b/libraries/baking/src/ModelBaker.cpp index f3954c98da..ac69653e45 100644 --- a/libraries/baking/src/ModelBaker.cpp +++ b/libraries/baking/src/ModelBaker.cpp @@ -305,6 +305,8 @@ void ModelBaker::bakeSourceCopy() { auto outputMapping = _mapping; outputMapping[FST_VERSION_FIELD] = FST_VERSION; outputMapping[FILENAME_FIELD] = _bakedModelURL.fileName(); + // All textures will be found in the same directory as the model + outputMapping[TEXDIR_FIELD] = "."; hifi::ByteArray fstOut = FSTReader::writeMapping(outputMapping); QFile fstOutputFile { outputFSTURL }; @@ -403,6 +405,9 @@ QString ModelBaker::compressTexture(QString modelTextureFileName, image::Texture // ensuring that the baked texture will have a unique name // even if there was another texture with the same name at a different path baseTextureFileName = createBaseTextureFileName(modelTextureFileInfo); + // If two textures have the same URL but are used differently, we need to process them separately + QString addMapChannel = QString::fromStdString("_" + std::to_string(textureType)); + baseTextureFileName += addMapChannel; _remappedTexturePaths[urlToTexture] = baseTextureFileName; } diff --git a/libraries/baking/src/TextureBaker.cpp b/libraries/baking/src/TextureBaker.cpp index db54cbdf98..8591cbd0aa 100644 --- a/libraries/baking/src/TextureBaker.cpp +++ b/libraries/baking/src/TextureBaker.cpp @@ -128,11 +128,8 @@ void TextureBaker::processTexture() { TextureMeta meta; - // If two textures have the same URL but are used differently, we need to process them separately - QString addMapChannel = QString::fromStdString("_" + std::to_string(_textureType)); - _baseFilename += addMapChannel; - QString newFilename = _textureURL.fileName(); + QString addMapChannel = QString::fromStdString("_" + std::to_string(_textureType)); newFilename.replace(QString("."), addMapChannel + "."); QString originalCopyFilePath = _outputDirectory.absoluteFilePath(newFilename);