diff --git a/libraries/model-baking/src/FBXBaker.cpp b/libraries/model-baking/src/FBXBaker.cpp index e7dffea158..bbd490447b 100644 --- a/libraries/model-baking/src/FBXBaker.cpp +++ b/libraries/model-baking/src/FBXBaker.cpp @@ -374,11 +374,7 @@ void FBXBaker::rewriteAndBakeSceneTextures() { // figure out the URL to this texture, embedded or external auto urlToTexture = getTextureURL(textureFileInfo, fileTexture); - if (!_unbakedTextures.contains(urlToTexture)) { - // add the deduced url to the texture, associated with the resulting baked texture file name, - // to our hash of textures needing to be baked - _unbakedTextures.insert(urlToTexture, bakedTextureFileName); - + if (!_bakingTextures.contains(urlToTexture)) { // bake this texture asynchronously bakeTexture(urlToTexture, textureType, _uniqueOutputPath + BAKED_OUTPUT_SUBFOLDER); } @@ -404,7 +400,7 @@ void FBXBaker::bakeTexture(const QUrl& textureURL, gpu::TextureType textureType, connect(bakingTexture.data(), &Baker::finished, this, &FBXBaker::handleBakedTexture); // keep a shared pointer to the baking texture - _bakingTextures.insert(bakingTexture); + _bakingTextures.insert(textureURL, bakingTexture); // start baking the texture on one of our available worker threads bakingTexture->moveToThread(_textureThreadGetter()); @@ -456,8 +452,8 @@ void FBXBaker::handleBakedTexture() { } - // now that this texture has been baked and handled, we can remove that TextureBaker from our list - _unbakedTextures.remove(bakedTexture->getTextureURL()); + // now that this texture has been baked and handled, we can remove that TextureBaker from our hash + _bakingTextures.remove(bakedTexture->getTextureURL()); checkIfTexturesFinished(); } else { @@ -468,7 +464,7 @@ void FBXBaker::handleBakedTexture() { _pendingErrorEmission = true; // now that this texture has been baked, even though it failed, we can remove that TextureBaker from our list - _unbakedTextures.remove(bakedTexture->getTextureURL()); + _bakingTextures.remove(bakedTexture->getTextureURL()); checkIfTexturesFinished(); } @@ -476,7 +472,7 @@ void FBXBaker::handleBakedTexture() { // we have errors to attend to, so we don't do extra processing for this texture // but we do need to remove that TextureBaker from our list // and then check if we're done with all textures - _unbakedTextures.remove(bakedTexture->getTextureURL()); + _bakingTextures.remove(bakedTexture->getTextureURL()); checkIfTexturesFinished(); } @@ -525,7 +521,7 @@ void FBXBaker::checkIfTexturesFinished() { // check if we're done everything we need to do for this FBX // and emit our finished signal if we're done - if (_unbakedTextures.isEmpty()) { + if (_bakingTextures.isEmpty()) { // remove the embedded media folder that the FBX SDK produces when reading the original removeEmbeddedMediaFolder(); diff --git a/libraries/model-baking/src/FBXBaker.h b/libraries/model-baking/src/FBXBaker.h index 903720a0a9..5ec6427bfb 100644 --- a/libraries/model-baking/src/FBXBaker.h +++ b/libraries/model-baking/src/FBXBaker.h @@ -88,12 +88,9 @@ private: static FBXSDKManagerUniquePointer _sdkManager; fbxsdk::FbxScene* _scene { nullptr }; - QHash _unbakedTextures; + QMultiHash> _bakingTextures; QHash _textureNameMatchCount; - QSet> _bakingTextures; - QFutureSynchronizer _textureBakeSynchronizer; - TextureBakerThreadGetter _textureThreadGetter; bool _copyOriginals { true }; diff --git a/tools/oven/src/DomainBaker.cpp b/tools/oven/src/DomainBaker.cpp index eea73bb1b6..07df9870aa 100644 --- a/tools/oven/src/DomainBaker.cpp +++ b/tools/oven/src/DomainBaker.cpp @@ -239,7 +239,8 @@ void DomainBaker::bakeSkybox(QUrl skyboxURL, QJsonValueRef entity) { // setup a baker for this skybox QSharedPointer skyboxBaker { - new TextureBaker(skyboxURL, gpu::CUBE_TEXTURE, _contentOutputPath) + new TextureBaker(skyboxURL, gpu::CUBE_TEXTURE, _contentOutputPath), + &TextureBaker::deleteLater }; // make sure our handler is called when the skybox baker is done diff --git a/tools/oven/src/ui/DomainBakeWidget.cpp b/tools/oven/src/ui/DomainBakeWidget.cpp index baea4c80a2..382e99f14e 100644 --- a/tools/oven/src/ui/DomainBakeWidget.cpp +++ b/tools/oven/src/ui/DomainBakeWidget.cpp @@ -41,6 +41,20 @@ DomainBakeWidget::DomainBakeWidget(QWidget* parent, Qt::WindowFlags flags) : setupUI(); } +DomainBakeWidget::~DomainBakeWidget() { + // if we're going down, our bakers are about to too + // enumerate them, send a cancelled status to the results table, and remove them + auto it = _bakers.begin(); + while (it != _bakers.end()) { + auto resultRow = it->second; + auto resultsWindow = qApp->getMainWindow()->showResultsWindow(); + + resultsWindow->changeStatusForRow(resultRow, "Cancelled"); + + it = _bakers.erase(it); + } +} + void DomainBakeWidget::setupUI() { // setup a grid layout to hold everything QGridLayout* gridLayout = new QGridLayout; diff --git a/tools/oven/src/ui/DomainBakeWidget.h b/tools/oven/src/ui/DomainBakeWidget.h index 16b0c76c11..b37ed490bc 100644 --- a/tools/oven/src/ui/DomainBakeWidget.h +++ b/tools/oven/src/ui/DomainBakeWidget.h @@ -25,7 +25,8 @@ class DomainBakeWidget : public QWidget { public: DomainBakeWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); - + ~DomainBakeWidget(); + private slots: void chooseFileButtonClicked(); void chooseOutputDirButtonClicked();