mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 06:04:42 +02:00
add domain bake to results table
This commit is contained in:
parent
2b188427f1
commit
83eb37b814
8 changed files with 106 additions and 21 deletions
20
libraries/model-baking/src/Baker.cpp
Normal file
20
libraries/model-baking/src/Baker.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// Baker.cpp
|
||||
// libraries/model-baking/src
|
||||
//
|
||||
// Created by Stephen Birarda on 4/14/17.
|
||||
// Copyright 2017 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 "ModelBakingLoggingCategory.h"
|
||||
|
||||
#include "Baker.h"
|
||||
|
||||
void Baker::handleError(const QString& error) {
|
||||
qCCritical(model_baking).noquote() << error;
|
||||
_errorList.append(error);
|
||||
emit finished();
|
||||
}
|
35
libraries/model-baking/src/Baker.h
Normal file
35
libraries/model-baking/src/Baker.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// Baker.h
|
||||
// libraries/model-baking/src
|
||||
//
|
||||
// Created by Stephen Birarda on 4/14/17.
|
||||
// Copyright 2017 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_Baker_h
|
||||
#define hifi_Baker_h
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class Baker : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual void bake() = 0;
|
||||
|
||||
bool hasErrors() const { return !_errorList.isEmpty(); }
|
||||
QStringList getErrors() const { return _errorList; }
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
|
||||
protected:
|
||||
void handleError(const QString& error);
|
||||
|
||||
QStringList _errorList;
|
||||
};
|
||||
|
||||
#endif // hifi_Baker_h
|
|
@ -50,12 +50,6 @@ QString FBXBaker::pathToCopyOfOriginal() const {
|
|||
return _uniqueOutputPath + ORIGINAL_OUTPUT_SUBFOLDER + _fbxURL.fileName();
|
||||
}
|
||||
|
||||
void FBXBaker::handleError(const QString& error) {
|
||||
qCCritical(model_baking).noquote() << error;
|
||||
_errorList.append(error);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void FBXBaker::bake() {
|
||||
qCDebug(model_baking) << "Baking" << _fbxURL;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <QtCore/QUrl>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
#include "Baker.h"
|
||||
|
||||
namespace fbxsdk {
|
||||
class FbxManager;
|
||||
class FbxProperty;
|
||||
|
@ -47,16 +49,13 @@ class TextureBaker;
|
|||
|
||||
static const QString BAKED_FBX_EXTENSION = ".baked.fbx";
|
||||
|
||||
class FBXBaker : public QObject {
|
||||
class FBXBaker : public Baker {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FBXBaker(const QUrl& fbxURL, const QString& baseOutputPath, bool copyOriginals = true);
|
||||
~FBXBaker();
|
||||
|
||||
Q_INVOKABLE void bake();
|
||||
|
||||
bool hasErrors() const { return !_errorList.isEmpty(); }
|
||||
QStringList getErrors() const { return _errorList; }
|
||||
Q_INVOKABLE virtual void bake() override;
|
||||
|
||||
QUrl getFBXUrl() const { return _fbxURL; }
|
||||
QString getBakedFBXRelativePath() const { return _bakedFBXRelativePath; }
|
||||
|
@ -92,8 +91,6 @@ private:
|
|||
|
||||
QString pathToCopyOfOriginal() const;
|
||||
|
||||
void handleError(const QString& error);
|
||||
|
||||
QUrl _fbxURL;
|
||||
QString _fbxName;
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
class TextureBaker : public QObject {
|
||||
#include "Baker.h"
|
||||
|
||||
class TextureBaker : public Baker {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -17,16 +17,17 @@
|
|||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QThread>
|
||||
|
||||
#include <Baker.h>
|
||||
#include <FBXBaker.h>
|
||||
|
||||
class DomainBaker : public QObject {
|
||||
class DomainBaker : public Baker {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DomainBaker(const QUrl& localEntitiesFileURL, const QString& domainName,
|
||||
const QString& baseOutputPath, const QUrl& destinationPath);
|
||||
|
||||
public:
|
||||
void bake();
|
||||
virtual void bake() override;
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "../Oven.h"
|
||||
#include "OvenMainWindow.h"
|
||||
|
||||
#include "DomainBakeWidget.h"
|
||||
|
||||
static const QString DOMAIN_NAME_SETTING_KEY = "domain_name";
|
||||
|
@ -205,15 +208,44 @@ void DomainBakeWidget::bakeButtonClicked() {
|
|||
if (!_entitiesFileLineEdit->text().isEmpty()) {
|
||||
// everything seems to be in place, kick off a bake for this entities file now
|
||||
auto fileToBakeURL = QUrl::fromLocalFile(_entitiesFileLineEdit->text());
|
||||
_baker = std::unique_ptr<DomainBaker> {
|
||||
auto domainBaker = std::unique_ptr<DomainBaker> {
|
||||
new DomainBaker(fileToBakeURL, _domainNameLineEdit->text(),
|
||||
outputDirectory.absolutePath(), _destinationPathLineEdit->text())
|
||||
};
|
||||
|
||||
// run the baker in our thread pool
|
||||
QtConcurrent::run(_baker.get(), &DomainBaker::bake);
|
||||
// make sure we hear from the baker when it is done
|
||||
connect(domainBaker.get(), &DomainBaker::finished, this, &DomainBakeWidget::handleFinishedBaker);
|
||||
|
||||
return;
|
||||
// run the baker in our thread pool
|
||||
QtConcurrent::run(domainBaker.get(), &DomainBaker::bake);
|
||||
|
||||
// add a pending row to the results window to show that this bake is in process
|
||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
||||
auto resultsRowName = _domainNameLineEdit->text().isEmpty() ? fileToBakeURL.fileName() : _domainNameLineEdit->text();
|
||||
auto resultsRow = resultsWindow->addPendingResultRow(resultsRowName);
|
||||
|
||||
// keep the unique ptr to the domain baker and the index to the row representing it in the results table
|
||||
_bakers.emplace_back(std::move(domainBaker), resultsRow);
|
||||
}
|
||||
}
|
||||
|
||||
void DomainBakeWidget::handleFinishedBaker() {
|
||||
if (auto baker = qobject_cast<DomainBaker*>(sender())) {
|
||||
// add the results of this bake to the results window
|
||||
auto it = std::remove_if(_bakers.begin(), _bakers.end(), [baker](const BakerRowPair& value) {
|
||||
return value.first.get() == baker;
|
||||
});
|
||||
|
||||
if (it != _bakers.end()) {
|
||||
auto resultRow = it->second;
|
||||
auto resultsWindow = qApp->getMainWindow()->showResultsWindow();
|
||||
|
||||
if (baker->hasErrors()) {
|
||||
resultsWindow->changeStatusForRow(resultRow, baker->getErrors().join("\n"));
|
||||
} else {
|
||||
resultsWindow->changeStatusForRow(resultRow, "Success");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,14 @@ private slots:
|
|||
|
||||
void outputDirectoryChanged(const QString& newDirectory);
|
||||
|
||||
void handleFinishedBaker();
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
std::unique_ptr<DomainBaker> _baker;
|
||||
using BakerRowPair = std::pair<std::unique_ptr<DomainBaker>, int>;
|
||||
using BakerRowPairList = std::list<BakerRowPair>;
|
||||
BakerRowPairList _bakers;
|
||||
|
||||
QLineEdit* _domainNameLineEdit;
|
||||
QLineEdit* _entitiesFileLineEdit;
|
||||
|
|
Loading…
Reference in a new issue