Fix baked models not mapping to correct textures

This commit is contained in:
sabrina-shanman 2019-03-12 11:24:56 -07:00
parent 5b504c4759
commit b42c6d1352
2 changed files with 6 additions and 4 deletions

View file

@ -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;
}

View file

@ -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);