diff --git a/libraries/baking/src/MaterialBaker.cpp b/libraries/baking/src/MaterialBaker.cpp index 79e31014fd..69e19224dd 100644 --- a/libraries/baking/src/MaterialBaker.cpp +++ b/libraries/baking/src/MaterialBaker.cpp @@ -133,7 +133,7 @@ void MaterialBaker::processMaterial() { QString extension = idx >= 0 ? cleanURL.mid(idx + 1).toLower() : ""; if (QImageReader::supportedImageFormats().contains(extension.toLatin1())) { - QPair textureKey(textureURL, type); + TextureKey textureKey(textureURL, type); if (!_textureBakers.contains(textureKey)) { auto baseTextureFileName = _textureFileNamer.createBaseTextureFileName(textureURL.fileName(), type); @@ -170,7 +170,7 @@ void MaterialBaker::handleFinishedTextureBaker() { auto baker = qobject_cast(sender()); if (baker) { - QPair textureKey = { baker->getTextureURL(), baker->getTextureType() }; + TextureKey textureKey = { baker->getTextureURL(), baker->getTextureType() }; if (!baker->hasErrors()) { // this TextureBaker is done and everything went according to plan qCDebug(material_baking) << "Re-writing texture references to" << baker->getTextureURL(); diff --git a/libraries/baking/src/MaterialBaker.h b/libraries/baking/src/MaterialBaker.h index 7a7411142e..3f25c21eb3 100644 --- a/libraries/baking/src/MaterialBaker.h +++ b/libraries/baking/src/MaterialBaker.h @@ -21,6 +21,8 @@ static const QString BAKED_MATERIAL_EXTENSION = ".baked.json"; +using TextureKey = QPair; + class MaterialBaker : public Baker { Q_OBJECT public: @@ -55,8 +57,8 @@ private: NetworkMaterialResourcePointer _materialResource; - QHash, QSharedPointer> _textureBakers; - QMultiHash, std::shared_ptr> _materialsNeedingRewrite; + QHash> _textureBakers; + QMultiHash> _materialsNeedingRewrite; QString _bakedOutputDir; QString _textureOutputDir; diff --git a/tools/oven/src/DomainBaker.cpp b/tools/oven/src/DomainBaker.cpp index b6adee28dc..12e2a1bafb 100644 --- a/tools/oven/src/DomainBaker.cpp +++ b/tools/oven/src/DomainBaker.cpp @@ -194,9 +194,10 @@ void DomainBaker::addTextureBaker(const QString& property, const QString& url, i if (QImageReader::supportedImageFormats().contains(extension.toLatin1())) { // grab a clean version of the URL without a query or fragment QUrl textureURL = QUrl(url).adjusted(QUrl::RemoveQuery | QUrl::RemoveFragment); + TextureKey key = { textureURL, type }; // setup a texture baker for this URL, as long as we aren't baking a texture already - if (!_textureBakers.contains(textureURL)) { + if (!_textureBakers.contains(key)) { // setup a baker for this texture QSharedPointer textureBaker { @@ -208,7 +209,7 @@ void DomainBaker::addTextureBaker(const QString& property, const QString& url, i connect(textureBaker.data(), &TextureBaker::finished, this, &DomainBaker::handleFinishedTextureBaker); // insert it into our bakers hash so we hold a strong pointer to it - _textureBakers.insert(textureURL, textureBaker); + _textureBakers.insert(key, textureBaker); // move the baker to a worker thread and kickoff the bake textureBaker->moveToThread(Oven::instance().getNextWorkerThread()); @@ -557,7 +558,7 @@ void DomainBaker::handleFinishedTextureBaker() { _entitiesNeedingRewrite.remove(baker->getTextureURL()); // drop our shared pointer to this baker so that it gets cleaned up - _textureBakers.remove(baker->getTextureURL()); + _textureBakers.remove({ baker->getTextureURL(), baker->getTextureType() }); // emit progress to tell listeners how many textures we have baked emit bakeProgress(++_completedSubBakes, _totalNumberOfSubBakes); diff --git a/tools/oven/src/DomainBaker.h b/tools/oven/src/DomainBaker.h index e8102ec7e8..5887838f5c 100644 --- a/tools/oven/src/DomainBaker.h +++ b/tools/oven/src/DomainBaker.h @@ -62,7 +62,7 @@ private: QJsonArray _entities; QHash> _modelBakers; - QHash> _textureBakers; + QHash> _textureBakers; QHash> _scriptBakers; QHash> _materialBakers;