mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-15 12:59:22 +02:00
Replaced baker in OvenCLI with an std::unique_ptr
This commit is contained in:
parent
99e9e10882
commit
0c7ffa0ac6
2 changed files with 10 additions and 12 deletions
|
@ -40,30 +40,25 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) {
|
|||
}
|
||||
|
||||
// create our appropiate baker
|
||||
Baker* baker;
|
||||
|
||||
if (isFBX) {
|
||||
baker = new FBXBaker(inputUrl, outputPath, []() -> QThread* {
|
||||
return qApp->getNextWorkerThread();
|
||||
});
|
||||
baker->moveToThread(qApp->getFBXBakerThread());
|
||||
_baker = std::unique_ptr<Baker> { new FBXBaker(inputUrl, outputPath, []() -> QThread* { return qApp->getNextWorkerThread(); }) };
|
||||
_baker->moveToThread(qApp->getFBXBakerThread());
|
||||
} else if (isSupportedImage) {
|
||||
baker = new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath);
|
||||
baker->moveToThread(qApp->getNextWorkerThread());
|
||||
_baker = std::unique_ptr<Baker> { new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath) };
|
||||
_baker->moveToThread(qApp->getNextWorkerThread());
|
||||
} else {
|
||||
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
// invoke the bake method on the baker thread
|
||||
QMetaObject::invokeMethod(baker, "bake");
|
||||
QMetaObject::invokeMethod(_baker.get(), "bake");
|
||||
|
||||
// make sure we hear about the results of this baker when it is done
|
||||
connect(baker, &Baker::finished, this, &BakerCLI::handleFinishedBaker);
|
||||
connect(_baker.get(), &Baker::finished, this, &BakerCLI::handleFinishedBaker);
|
||||
}
|
||||
|
||||
void BakerCLI::handleFinishedBaker() {
|
||||
qCDebug(model_baking) << "Finished baking file.";
|
||||
sender()->deleteLater();
|
||||
QApplication::quit();
|
||||
}
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include "Baker.h"
|
||||
#include "Oven.h"
|
||||
|
||||
class BakerCLI : public QObject {
|
||||
|
@ -24,8 +25,10 @@ public:
|
|||
void bakeFile(QUrl inputUrl, const QString outputPath);
|
||||
|
||||
private slots:
|
||||
void handleFinishedBaker();
|
||||
void handleFinishedBaker();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Baker> _baker;
|
||||
};
|
||||
|
||||
#endif // hifi_BakerCLI_h
|
Loading…
Reference in a new issue