mirror of
https://github.com/overte-org/overte.git
synced 2025-06-15 20:39:07 +02:00
use QCoreApplication for oven when headless version is used
This commit is contained in:
parent
0af8507ce2
commit
2a597eb715
14 changed files with 193 additions and 100 deletions
|
@ -14,13 +14,14 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
#include "OvenCLIApplication.h"
|
||||||
#include "ModelBakingLoggingCategory.h"
|
#include "ModelBakingLoggingCategory.h"
|
||||||
#include "Oven.h"
|
|
||||||
#include "BakerCLI.h"
|
#include "BakerCLI.h"
|
||||||
#include "FBXBaker.h"
|
#include "FBXBaker.h"
|
||||||
#include "TextureBaker.h"
|
#include "TextureBaker.h"
|
||||||
|
|
||||||
BakerCLI::BakerCLI(Oven* parent) : QObject(parent) {
|
BakerCLI::BakerCLI(OvenCLIApplication* parent) : QObject(parent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString& type) {
|
void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString& type) {
|
||||||
|
@ -50,14 +51,18 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString&
|
||||||
|
|
||||||
// create our appropiate baker
|
// create our appropiate baker
|
||||||
if (isFBX) {
|
if (isFBX) {
|
||||||
_baker = std::unique_ptr<Baker> { new FBXBaker(inputUrl, []() -> QThread* { return qApp->getNextWorkerThread(); }, outputPath) };
|
_baker = std::unique_ptr<Baker> {
|
||||||
_baker->moveToThread(qApp->getNextWorkerThread());
|
new FBXBaker(inputUrl,
|
||||||
|
[]() -> QThread* { return Oven::instance().getNextWorkerThread(); },
|
||||||
|
outputPath)
|
||||||
|
};
|
||||||
|
_baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
} else if (isSupportedImage) {
|
} else if (isSupportedImage) {
|
||||||
_baker = std::unique_ptr<Baker> { new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath) };
|
_baker = std::unique_ptr<Baker> { new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath) };
|
||||||
_baker->moveToThread(qApp->getNextWorkerThread());
|
_baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;
|
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;
|
||||||
QApplication::exit(OVEN_STATUS_CODE_FAIL);
|
QCoreApplication::exit(OVEN_STATUS_CODE_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke the bake method on the baker thread
|
// invoke the bake method on the baker thread
|
||||||
|
@ -81,5 +86,5 @@ void BakerCLI::handleFinishedBaker() {
|
||||||
errorFile.close();
|
errorFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QApplication::exit(exitCode);
|
QCoreApplication::exit(exitCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "Baker.h"
|
#include "Baker.h"
|
||||||
#include "Oven.h"
|
#include "OvenCLIApplication.h"
|
||||||
|
|
||||||
static const int OVEN_STATUS_CODE_SUCCESS { 0 };
|
static const int OVEN_STATUS_CODE_SUCCESS { 0 };
|
||||||
static const int OVEN_STATUS_CODE_FAIL { 1 };
|
static const int OVEN_STATUS_CODE_FAIL { 1 };
|
||||||
|
@ -30,7 +30,7 @@ class BakerCLI : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BakerCLI(Oven* parent);
|
BakerCLI(OvenCLIApplication* parent);
|
||||||
void bakeFile(QUrl inputUrl, const QString& outputPath, const QString& type = QString::null);
|
void bakeFile(QUrl inputUrl, const QString& outputPath, const QString& type = QString::null);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -201,7 +201,7 @@ void DomainBaker::enumerateEntities() {
|
||||||
}
|
}
|
||||||
QSharedPointer<FBXBaker> baker {
|
QSharedPointer<FBXBaker> baker {
|
||||||
new FBXBaker(modelURL, []() -> QThread* {
|
new FBXBaker(modelURL, []() -> QThread* {
|
||||||
return qApp->getNextWorkerThread();
|
return Oven::instance().getNextWorkerThread();
|
||||||
}, _contentOutputPath + subDirName + "/baked", _contentOutputPath + subDirName + "/original"),
|
}, _contentOutputPath + subDirName + "/baked", _contentOutputPath + subDirName + "/original"),
|
||||||
&FBXBaker::deleteLater
|
&FBXBaker::deleteLater
|
||||||
};
|
};
|
||||||
|
@ -214,7 +214,7 @@ void DomainBaker::enumerateEntities() {
|
||||||
|
|
||||||
// move the baker to the baker thread
|
// move the baker to the baker thread
|
||||||
// and kickoff the bake
|
// and kickoff the bake
|
||||||
baker->moveToThread(qApp->getNextWorkerThread());
|
baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
QMetaObject::invokeMethod(baker.data(), "bake");
|
QMetaObject::invokeMethod(baker.data(), "bake");
|
||||||
|
|
||||||
// keep track of the total number of baking entities
|
// keep track of the total number of baking entities
|
||||||
|
@ -285,7 +285,7 @@ void DomainBaker::bakeSkybox(QUrl skyboxURL, QJsonValueRef entity) {
|
||||||
_skyboxBakers.insert(skyboxURL, skyboxBaker);
|
_skyboxBakers.insert(skyboxURL, skyboxBaker);
|
||||||
|
|
||||||
// move the baker to a worker thread and kickoff the bake
|
// move the baker to a worker thread and kickoff the bake
|
||||||
skyboxBaker->moveToThread(qApp->getNextWorkerThread());
|
skyboxBaker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
QMetaObject::invokeMethod(skyboxBaker.data(), "bake");
|
QMetaObject::invokeMethod(skyboxBaker.data(), "bake");
|
||||||
|
|
||||||
// keep track of the total number of baking entities
|
// keep track of the total number of baking entities
|
||||||
|
|
|
@ -11,33 +11,15 @@
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
#include <QtCore/QCommandLineParser>
|
|
||||||
|
|
||||||
#include <image/Image.h>
|
#include <image/Image.h>
|
||||||
|
|
||||||
#include "ui/OvenMainWindow.h"
|
|
||||||
#include "Oven.h"
|
#include "Oven.h"
|
||||||
#include "BakerCLI.h"
|
|
||||||
|
|
||||||
static const QString OUTPUT_FOLDER = "/Users/birarda/code/hifi/lod/test-oven/export";
|
Oven* Oven::_staticInstance { nullptr };
|
||||||
|
|
||||||
static const QString CLI_INPUT_PARAMETER = "i";
|
Oven::Oven() {
|
||||||
static const QString CLI_OUTPUT_PARAMETER = "o";
|
_staticInstance = this;
|
||||||
static const QString CLI_TYPE_PARAMETER = "t";
|
|
||||||
|
|
||||||
Oven::Oven(int argc, char* argv[]) :
|
|
||||||
QApplication(argc, argv)
|
|
||||||
{
|
|
||||||
// parse the command line parameters
|
|
||||||
QCommandLineParser parser;
|
|
||||||
|
|
||||||
parser.addOptions({
|
|
||||||
{ CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" },
|
|
||||||
{ CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" },
|
|
||||||
{ CLI_TYPE_PARAMETER, "Type of asset.", "type" }
|
|
||||||
});
|
|
||||||
parser.addHelpOption();
|
|
||||||
parser.process(*this);
|
|
||||||
|
|
||||||
// enable compression in image library
|
// enable compression in image library
|
||||||
image::setColorTexturesCompressionEnabled(true);
|
image::setColorTexturesCompressionEnabled(true);
|
||||||
|
@ -47,41 +29,27 @@ Oven::Oven(int argc, char* argv[]) :
|
||||||
|
|
||||||
// setup our worker threads
|
// setup our worker threads
|
||||||
setupWorkerThreads(QThread::idealThreadCount());
|
setupWorkerThreads(QThread::idealThreadCount());
|
||||||
|
|
||||||
// check if we were passed any command line arguments that would tell us just to run without the GUI
|
|
||||||
if (parser.isSet(CLI_INPUT_PARAMETER) || parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
|
||||||
if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
|
||||||
BakerCLI* cli = new BakerCLI(this);
|
|
||||||
QUrl inputUrl(QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER)));
|
|
||||||
QUrl outputUrl(QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER)));
|
|
||||||
QString type = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString::null;
|
|
||||||
cli->bakeFile(inputUrl, outputUrl.toString(), type);
|
|
||||||
} else {
|
|
||||||
parser.showHelp();
|
|
||||||
QApplication::quit();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// setup the GUI
|
|
||||||
_mainWindow = new OvenMainWindow;
|
|
||||||
_mainWindow->show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Oven::~Oven() {
|
Oven::~Oven() {
|
||||||
// cleanup the worker threads
|
// quit and wait on the worker threads
|
||||||
for (auto i = 0; i < _workerThreads.size(); ++i) {
|
for (auto& thread : _workerThreads) {
|
||||||
_workerThreads[i]->quit();
|
thread->quit();
|
||||||
_workerThreads[i]->wait();
|
thread->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_staticInstance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Oven::setupWorkerThreads(int numWorkerThreads) {
|
void Oven::setupWorkerThreads(int numWorkerThreads) {
|
||||||
|
_workerThreads.reserve(numWorkerThreads);
|
||||||
|
|
||||||
for (auto i = 0; i < numWorkerThreads; ++i) {
|
for (auto i = 0; i < numWorkerThreads; ++i) {
|
||||||
// setup a worker thread yet and add it to our concurrent vector
|
// setup a worker thread yet and add it to our concurrent vector
|
||||||
auto newThread = new QThread(this);
|
auto newThread = std::unique_ptr<QThread> { new QThread };
|
||||||
newThread->setObjectName("Oven Worker Thread " + QString::number(i + 1));
|
newThread->setObjectName("Oven Worker Thread " + QString::number(i + 1));
|
||||||
|
|
||||||
_workerThreads.push_back(newThread);
|
_workerThreads.push_back(std::move(newThread));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +60,13 @@ QThread* Oven::getNextWorkerThread() {
|
||||||
// (for the FBX Baker Thread to have room), and cycle through them to hand a usable running thread back to our callers.
|
// (for the FBX Baker Thread to have room), and cycle through them to hand a usable running thread back to our callers.
|
||||||
|
|
||||||
auto nextIndex = ++_nextWorkerThreadIndex;
|
auto nextIndex = ++_nextWorkerThreadIndex;
|
||||||
auto nextThread = _workerThreads[nextIndex % _workerThreads.size()];
|
auto& nextThread = _workerThreads[nextIndex % _workerThreads.size()];
|
||||||
|
|
||||||
// start the thread if it isn't running yet
|
// start the thread if it isn't running yet
|
||||||
if (!nextThread->isRunning()) {
|
if (!nextThread->isRunning()) {
|
||||||
nextThread->start();
|
nextThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nextThread;
|
return nextThread.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,27 +12,15 @@
|
||||||
#ifndef hifi_Oven_h
|
#ifndef hifi_Oven_h
|
||||||
#define hifi_Oven_h
|
#define hifi_Oven_h
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
|
||||||
|
|
||||||
#include <TBBHelpers.h>
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#if defined(qApp)
|
class Oven {
|
||||||
#undef qApp
|
|
||||||
#endif
|
|
||||||
#define qApp (static_cast<Oven*>(QCoreApplication::instance()))
|
|
||||||
|
|
||||||
class OvenMainWindow;
|
|
||||||
|
|
||||||
class Oven : public QApplication {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Oven(int argc, char* argv[]);
|
Oven();
|
||||||
~Oven();
|
~Oven();
|
||||||
|
|
||||||
OvenMainWindow* getMainWindow() const { return _mainWindow; }
|
static Oven& instance() { return *_staticInstance; }
|
||||||
|
|
||||||
QThread* getNextWorkerThread();
|
QThread* getNextWorkerThread();
|
||||||
|
|
||||||
|
@ -40,11 +28,12 @@ private:
|
||||||
void setupWorkerThreads(int numWorkerThreads);
|
void setupWorkerThreads(int numWorkerThreads);
|
||||||
void setupFBXBakerThread();
|
void setupFBXBakerThread();
|
||||||
|
|
||||||
OvenMainWindow* _mainWindow;
|
std::vector<std::unique_ptr<QThread>> _workerThreads;
|
||||||
QList<QThread*> _workerThreads;
|
|
||||||
|
|
||||||
std::atomic<uint> _nextWorkerThreadIndex;
|
std::atomic<uint> _nextWorkerThreadIndex;
|
||||||
int _numWorkerThreads;
|
int _numWorkerThreads;
|
||||||
|
|
||||||
|
static Oven* _staticInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
49
tools/oven/src/OvenCLIApplication.cpp
Normal file
49
tools/oven/src/OvenCLIApplication.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//
|
||||||
|
// OvenCLIApplication.cpp
|
||||||
|
// tools/oven/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/20/18.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QtCore/QCommandLineParser>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
|
#include "BakerCLI.h"
|
||||||
|
|
||||||
|
#include "OvenCLIApplication.h"
|
||||||
|
|
||||||
|
static const QString CLI_INPUT_PARAMETER = "i";
|
||||||
|
static const QString CLI_OUTPUT_PARAMETER = "o";
|
||||||
|
static const QString CLI_TYPE_PARAMETER = "t";
|
||||||
|
|
||||||
|
OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) :
|
||||||
|
QCoreApplication(argc, argv)
|
||||||
|
{
|
||||||
|
// parse the command line parameters
|
||||||
|
QCommandLineParser parser;
|
||||||
|
|
||||||
|
parser.addOptions({
|
||||||
|
{ CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" },
|
||||||
|
{ CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" },
|
||||||
|
{ CLI_TYPE_PARAMETER, "Type of asset.", "type" }
|
||||||
|
});
|
||||||
|
|
||||||
|
parser.addHelpOption();
|
||||||
|
parser.process(*this);
|
||||||
|
|
||||||
|
if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
||||||
|
BakerCLI* cli = new BakerCLI(this);
|
||||||
|
QUrl inputUrl(QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER)));
|
||||||
|
QUrl outputUrl(QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER)));
|
||||||
|
QString type = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString::null;
|
||||||
|
cli->bakeFile(inputUrl, outputUrl.toString(), type);
|
||||||
|
} else {
|
||||||
|
parser.showHelp();
|
||||||
|
QCoreApplication::quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
tools/oven/src/OvenCLIApplication.h
Normal file
27
tools/oven/src/OvenCLIApplication.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// OvenCLIApplication.h
|
||||||
|
// tools/oven/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/20/18.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_OvenCLIApplication_h
|
||||||
|
#define hifi_OvenCLIApplication_h
|
||||||
|
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
#include "Oven.h"
|
||||||
|
|
||||||
|
class OvenCLIApplication : public QCoreApplication, public Oven {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
OvenCLIApplication(int argc, char* argv[]);
|
||||||
|
|
||||||
|
static OvenCLIApplication* instance() { return dynamic_cast<OvenCLIApplication*>(QCoreApplication::instance()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_OvenCLIApplication_h
|
19
tools/oven/src/OvenGUIApplication.cpp
Normal file
19
tools/oven/src/OvenGUIApplication.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
//
|
||||||
|
// OvenGUIApplication.cpp
|
||||||
|
// tools/src/oven
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/20/18.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "OvenGUIApplication.h"
|
||||||
|
|
||||||
|
OvenGUIApplication::OvenGUIApplication(int argc, char* argv[]) :
|
||||||
|
QApplication(argc, argv)
|
||||||
|
{
|
||||||
|
// setup the GUI
|
||||||
|
_mainWindow.show();
|
||||||
|
}
|
33
tools/oven/src/OvenGUIApplication.h
Normal file
33
tools/oven/src/OvenGUIApplication.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// OvenGUIApplication.h
|
||||||
|
// tools/oven/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/20/18.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_OvenGUIApplication_h
|
||||||
|
#define hifi_OvenGUIApplication_h
|
||||||
|
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
|
#include "ui/OvenMainWindow.h"
|
||||||
|
|
||||||
|
#include "Oven.h"
|
||||||
|
|
||||||
|
class OvenGUIApplication : public QApplication, public Oven {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
OvenGUIApplication(int argc, char* argv[]);
|
||||||
|
|
||||||
|
static OvenGUIApplication* instance() { return dynamic_cast<OvenGUIApplication*>(QApplication::instance()); }
|
||||||
|
|
||||||
|
OvenMainWindow* getMainWindow() { return &_mainWindow; }
|
||||||
|
private:
|
||||||
|
OvenMainWindow _mainWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_OvenGUIApplication_h
|
|
@ -8,7 +8,8 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
#include "Oven.h"
|
#include "OvenCLIApplication.h"
|
||||||
|
#include "OvenGUIApplication.h"
|
||||||
|
|
||||||
#include <SettingInterface.h>
|
#include <SettingInterface.h>
|
||||||
|
|
||||||
|
@ -19,6 +20,12 @@ int main (int argc, char** argv) {
|
||||||
// init the settings interface so we can save and load settings
|
// init the settings interface so we can save and load settings
|
||||||
Setting::init();
|
Setting::init();
|
||||||
|
|
||||||
Oven app(argc, argv);
|
// figure out if we're launching our GUI application or just the simple command line interface
|
||||||
|
if (argc > 1) {
|
||||||
|
OvenCLIApplication app { argc, argv };
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
} else {
|
||||||
|
OvenGUIApplication app { argc, argv };
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
|
|
||||||
#include <QtWidgets/QStackedWidget>
|
#include <QtWidgets/QStackedWidget>
|
||||||
|
|
||||||
#include "../Oven.h"
|
#include "../OvenGUIApplication.h"
|
||||||
#include "OvenMainWindow.h"
|
|
||||||
|
|
||||||
#include "BakeWidget.h"
|
#include "BakeWidget.h"
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ BakeWidget::~BakeWidget() {
|
||||||
auto it = _bakers.begin();
|
auto it = _bakers.begin();
|
||||||
while (it != _bakers.end()) {
|
while (it != _bakers.end()) {
|
||||||
auto resultRow = it->second;
|
auto resultRow = it->second;
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
|
|
||||||
resultsWindow->changeStatusForRow(resultRow, "Cancelled");
|
resultsWindow->changeStatusForRow(resultRow, "Cancelled");
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include "../Oven.h"
|
#include "../OvenGUIApplication.h"
|
||||||
#include "OvenMainWindow.h"
|
|
||||||
|
|
||||||
#include "DomainBakeWidget.h"
|
#include "DomainBakeWidget.h"
|
||||||
|
|
||||||
|
@ -223,14 +222,14 @@ void DomainBakeWidget::bakeButtonClicked() {
|
||||||
connect(domainBaker.get(), &DomainBaker::bakeProgress, this, &DomainBakeWidget::handleBakerProgress);
|
connect(domainBaker.get(), &DomainBaker::bakeProgress, this, &DomainBakeWidget::handleBakerProgress);
|
||||||
|
|
||||||
// move the baker to the next available Oven worker thread
|
// move the baker to the next available Oven worker thread
|
||||||
auto nextThread = qApp->getNextWorkerThread();
|
auto nextThread = Oven::instance().getNextWorkerThread();
|
||||||
domainBaker->moveToThread(nextThread);
|
domainBaker->moveToThread(nextThread);
|
||||||
|
|
||||||
// kickoff the domain baker on its thread
|
// kickoff the domain baker on its thread
|
||||||
QMetaObject::invokeMethod(domainBaker.get(), "bake");
|
QMetaObject::invokeMethod(domainBaker.get(), "bake");
|
||||||
|
|
||||||
// add a pending row to the results window to show that this bake is in process
|
// add a pending row to the results window to show that this bake is in process
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
auto resultsRowName = _domainNameLineEdit->text().isEmpty() ? fileToBakeURL.fileName() : _domainNameLineEdit->text();
|
auto resultsRowName = _domainNameLineEdit->text().isEmpty() ? fileToBakeURL.fileName() : _domainNameLineEdit->text();
|
||||||
auto resultsRow = resultsWindow->addPendingResultRow(resultsRowName, outputDirectory);
|
auto resultsRow = resultsWindow->addPendingResultRow(resultsRowName, outputDirectory);
|
||||||
|
|
||||||
|
@ -250,7 +249,7 @@ void DomainBakeWidget::handleBakerProgress(int baked, int total) {
|
||||||
auto resultRow = it->second;
|
auto resultRow = it->second;
|
||||||
|
|
||||||
// grab the results window, don't force it to be brought to the top
|
// grab the results window, don't force it to be brought to the top
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow(false);
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow(false);
|
||||||
|
|
||||||
int percentage = roundf(float(baked) / float(total) * 100.0f);
|
int percentage = roundf(float(baked) / float(total) * 100.0f);
|
||||||
|
|
||||||
|
@ -269,7 +268,7 @@ void DomainBakeWidget::handleFinishedBaker() {
|
||||||
|
|
||||||
if (it != _bakers.end()) {
|
if (it != _bakers.end()) {
|
||||||
auto resultRow = it->second;
|
auto resultRow = it->second;
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
|
|
||||||
if (baker->hasErrors()) {
|
if (baker->hasErrors()) {
|
||||||
auto errors = baker->getErrors();
|
auto errors = baker->getErrors();
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
#include "../Oven.h"
|
#include "../OvenGUIApplication.h"
|
||||||
#include "OvenMainWindow.h"
|
|
||||||
|
|
||||||
#include "ModelBakeWidget.h"
|
#include "ModelBakeWidget.h"
|
||||||
|
|
||||||
|
@ -208,12 +207,12 @@ void ModelBakeWidget::bakeButtonClicked() {
|
||||||
// everything seems to be in place, kick off a bake for this model now
|
// everything seems to be in place, kick off a bake for this model now
|
||||||
auto baker = std::unique_ptr<FBXBaker> {
|
auto baker = std::unique_ptr<FBXBaker> {
|
||||||
new FBXBaker(modelToBakeURL, []() -> QThread* {
|
new FBXBaker(modelToBakeURL, []() -> QThread* {
|
||||||
return qApp->getNextWorkerThread();
|
return Oven::instance().getNextWorkerThread();
|
||||||
}, bakedOutputDirectory.absolutePath(), originalOutputDirectory.absolutePath())
|
}, bakedOutputDirectory.absolutePath(), originalOutputDirectory.absolutePath())
|
||||||
};
|
};
|
||||||
|
|
||||||
// move the baker to the FBX baker thread
|
// move the baker to the FBX baker thread
|
||||||
baker->moveToThread(qApp->getNextWorkerThread());
|
baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
|
|
||||||
// invoke the bake method on the baker thread
|
// invoke the bake method on the baker thread
|
||||||
QMetaObject::invokeMethod(baker.get(), "bake");
|
QMetaObject::invokeMethod(baker.get(), "bake");
|
||||||
|
@ -222,7 +221,7 @@ void ModelBakeWidget::bakeButtonClicked() {
|
||||||
connect(baker.get(), &FBXBaker::finished, this, &ModelBakeWidget::handleFinishedBaker);
|
connect(baker.get(), &FBXBaker::finished, this, &ModelBakeWidget::handleFinishedBaker);
|
||||||
|
|
||||||
// add a pending row to the results window to show that this bake is in process
|
// add a pending row to the results window to show that this bake is in process
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
auto resultsRow = resultsWindow->addPendingResultRow(modelToBakeURL.fileName(), outputDirectory);
|
auto resultsRow = resultsWindow->addPendingResultRow(modelToBakeURL.fileName(), outputDirectory);
|
||||||
|
|
||||||
// keep a unique_ptr to this baker
|
// keep a unique_ptr to this baker
|
||||||
|
@ -244,7 +243,7 @@ void ModelBakeWidget::handleFinishedBaker() {
|
||||||
|
|
||||||
if (it != _bakers.end()) {
|
if (it != _bakers.end()) {
|
||||||
auto resultRow = it->second;
|
auto resultRow = it->second;
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
|
|
||||||
if (baker->hasErrors()) {
|
if (baker->hasErrors()) {
|
||||||
resultsWindow->changeStatusForRow(resultRow, baker->getErrors().join("\n"));
|
resultsWindow->changeStatusForRow(resultRow, baker->getErrors().join("\n"));
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
#include "../Oven.h"
|
#include "../OvenGUIApplication.h"
|
||||||
#include "OvenMainWindow.h"
|
|
||||||
|
|
||||||
#include "SkyboxBakeWidget.h"
|
#include "SkyboxBakeWidget.h"
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ void SkyboxBakeWidget::bakeButtonClicked() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// move the baker to a worker thread
|
// move the baker to a worker thread
|
||||||
baker->moveToThread(qApp->getNextWorkerThread());
|
baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
|
|
||||||
// invoke the bake method on the baker thread
|
// invoke the bake method on the baker thread
|
||||||
QMetaObject::invokeMethod(baker.get(), "bake");
|
QMetaObject::invokeMethod(baker.get(), "bake");
|
||||||
|
@ -193,7 +192,7 @@ void SkyboxBakeWidget::bakeButtonClicked() {
|
||||||
connect(baker.get(), &TextureBaker::finished, this, &SkyboxBakeWidget::handleFinishedBaker);
|
connect(baker.get(), &TextureBaker::finished, this, &SkyboxBakeWidget::handleFinishedBaker);
|
||||||
|
|
||||||
// add a pending row to the results window to show that this bake is in process
|
// add a pending row to the results window to show that this bake is in process
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
auto resultsRow = resultsWindow->addPendingResultRow(skyboxToBakeURL.fileName(), outputDirectory);
|
auto resultsRow = resultsWindow->addPendingResultRow(skyboxToBakeURL.fileName(), outputDirectory);
|
||||||
|
|
||||||
// keep a unique_ptr to this baker
|
// keep a unique_ptr to this baker
|
||||||
|
@ -211,7 +210,7 @@ void SkyboxBakeWidget::handleFinishedBaker() {
|
||||||
|
|
||||||
if (it != _bakers.end()) {
|
if (it != _bakers.end()) {
|
||||||
auto resultRow = it->second;
|
auto resultRow = it->second;
|
||||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
auto resultsWindow = OvenGUIApplication::instance()->getMainWindow()->showResultsWindow();
|
||||||
|
|
||||||
if (baker->hasErrors()) {
|
if (baker->hasErrors()) {
|
||||||
resultsWindow->changeStatusForRow(resultRow, baker->getErrors().join("\n"));
|
resultsWindow->changeStatusForRow(resultRow, baker->getErrors().join("\n"));
|
||||||
|
|
Loading…
Reference in a new issue