mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
output domain bake to a unique folder with timestamp
This commit is contained in:
parent
177d4d0e07
commit
a773b0de04
6 changed files with 51 additions and 7 deletions
|
@ -22,7 +22,7 @@
|
||||||
#include "FBXBaker.h"
|
#include "FBXBaker.h"
|
||||||
|
|
||||||
|
|
||||||
FBXBaker::FBXBaker(QUrl fbxURL, QString baseOutputPath, bool copyOriginals) :
|
FBXBaker::FBXBaker(const QUrl& fbxURL, const QString& baseOutputPath, bool copyOriginals) :
|
||||||
_fbxURL(fbxURL),
|
_fbxURL(fbxURL),
|
||||||
_baseOutputPath(baseOutputPath),
|
_baseOutputPath(baseOutputPath),
|
||||||
_copyOriginals(copyOriginals)
|
_copyOriginals(copyOriginals)
|
||||||
|
|
|
@ -47,7 +47,7 @@ class TextureBaker;
|
||||||
class FBXBaker : public QObject {
|
class FBXBaker : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FBXBaker(QUrl fbxURL, QString baseOutputPath, bool copyOriginals = true);
|
FBXBaker(const QUrl& fbxURL, const QString& baseOutputPath, bool copyOriginals = true);
|
||||||
~FBXBaker();
|
~FBXBaker();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
|
@ -20,18 +20,45 @@
|
||||||
|
|
||||||
#include "DomainBaker.h"
|
#include "DomainBaker.h"
|
||||||
|
|
||||||
DomainBaker::DomainBaker(const QUrl& localModelFileURL, QString baseOutputPath) :
|
DomainBaker::DomainBaker(const QUrl& localModelFileURL, const QString& domainName, const QString& baseOutputPath) :
|
||||||
_localEntitiesFileURL(localModelFileURL),
|
_localEntitiesFileURL(localModelFileURL),
|
||||||
|
_domainName(domainName),
|
||||||
_baseOutputPath(baseOutputPath)
|
_baseOutputPath(baseOutputPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainBaker::start() {
|
void DomainBaker::start() {
|
||||||
|
setupOutputFolder();
|
||||||
loadLocalFile();
|
loadLocalFile();
|
||||||
enumerateEntities();
|
enumerateEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainBaker::setupOutputFolder() {
|
||||||
|
// in order to avoid overwriting previous bakes, we create a special output folder with the domain name and timestamp
|
||||||
|
|
||||||
|
// first, construct the directory name
|
||||||
|
auto domainPrefix = !_domainName.isEmpty() ? _domainName + "-" : "";
|
||||||
|
auto timeNow = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
static const QString FOLDER_TIMESTAMP_FORMAT = "yyyyMMdd-hhmmss";
|
||||||
|
QString outputDirectoryName = domainPrefix + timeNow.toString(FOLDER_TIMESTAMP_FORMAT);
|
||||||
|
|
||||||
|
// make sure we can create that directory
|
||||||
|
QDir baseDir { _baseOutputPath };
|
||||||
|
|
||||||
|
if (!baseDir.mkpath(outputDirectoryName)) {
|
||||||
|
|
||||||
|
// add an error to specify that the output directory could not be created
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// store the unique output path so we can re-use it when saving baked models
|
||||||
|
baseDir.cd(outputDirectoryName);
|
||||||
|
_uniqueOutputPath = baseDir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
void DomainBaker::loadLocalFile() {
|
void DomainBaker::loadLocalFile() {
|
||||||
// load up the local entities file
|
// load up the local entities file
|
||||||
QFile modelsFile { _localEntitiesFileURL.toLocalFile() };
|
QFile modelsFile { _localEntitiesFileURL.toLocalFile() };
|
||||||
|
@ -96,7 +123,7 @@ void DomainBaker::enumerateEntities() {
|
||||||
|
|
||||||
// setup an FBXBaker for this URL, as long as we don't already have one
|
// setup an FBXBaker for this URL, as long as we don't already have one
|
||||||
if (!_bakers.contains(modelURL)) {
|
if (!_bakers.contains(modelURL)) {
|
||||||
QSharedPointer<FBXBaker> baker { new FBXBaker(modelURL, _baseOutputPath) };
|
QSharedPointer<FBXBaker> baker { new FBXBaker(modelURL, _uniqueOutputPath) };
|
||||||
|
|
||||||
// start the baker
|
// start the baker
|
||||||
baker->start();
|
baker->start();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
class DomainBaker : public QObject {
|
class DomainBaker : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DomainBaker(const QUrl& localEntitiesFileURL, QString baseOutputPath);
|
DomainBaker(const QUrl& localEntitiesFileURL, const QString& domainName, const QString& baseOutputPath);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
|
@ -30,13 +30,16 @@ signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupOutputFolder();
|
||||||
void loadLocalFile();
|
void loadLocalFile();
|
||||||
void enumerateEntities();
|
void enumerateEntities();
|
||||||
|
|
||||||
QUrl _localEntitiesFileURL;
|
QUrl _localEntitiesFileURL;
|
||||||
|
QString _domainName;
|
||||||
QString _baseOutputPath;
|
QString _baseOutputPath;
|
||||||
QJsonArray _entities;
|
QString _uniqueOutputPath;
|
||||||
|
|
||||||
|
QJsonArray _entities;
|
||||||
|
|
||||||
QHash<QUrl, QSharedPointer<FBXBaker>> _bakers;
|
QHash<QUrl, QSharedPointer<FBXBaker>> _bakers;
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,17 @@ void DomainBakeWidget::setupUI() {
|
||||||
|
|
||||||
int rowIndex = 0;
|
int rowIndex = 0;
|
||||||
|
|
||||||
|
// setup a section to enter the name of the domain being baked
|
||||||
|
QLabel* domainNameLabel = new QLabel("Domain Name");
|
||||||
|
|
||||||
|
_domainNameLineEdit = new QLineEdit;
|
||||||
|
_domainNameLineEdit->setPlaceholderText("welcome");
|
||||||
|
|
||||||
|
gridLayout->addWidget(domainNameLabel);
|
||||||
|
gridLayout->addWidget(_domainNameLineEdit, rowIndex, 1, 1, -1);
|
||||||
|
|
||||||
|
++rowIndex;
|
||||||
|
|
||||||
// setup a section to choose the file being baked
|
// setup a section to choose the file being baked
|
||||||
QLabel* entitiesFileLabel = new QLabel("Entities File");
|
QLabel* entitiesFileLabel = new QLabel("Entities File");
|
||||||
|
|
||||||
|
@ -160,7 +171,9 @@ void DomainBakeWidget::bakeButtonClicked() {
|
||||||
if (!_entitiesFileLineEdit->text().isEmpty()) {
|
if (!_entitiesFileLineEdit->text().isEmpty()) {
|
||||||
// everything seems to be in place, kick off a bake for this entities file now
|
// everything seems to be in place, kick off a bake for this entities file now
|
||||||
auto fileToBakeURL = QUrl::fromLocalFile(_entitiesFileLineEdit->text());
|
auto fileToBakeURL = QUrl::fromLocalFile(_entitiesFileLineEdit->text());
|
||||||
_baker = std::unique_ptr<DomainBaker> { new DomainBaker(fileToBakeURL, outputDirectory.absolutePath()) };
|
_baker = std::unique_ptr<DomainBaker> {
|
||||||
|
new DomainBaker(fileToBakeURL, _domainNameLineEdit->text(), outputDirectory.absolutePath())
|
||||||
|
};
|
||||||
_baker->start();
|
_baker->start();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<DomainBaker> _baker;
|
std::unique_ptr<DomainBaker> _baker;
|
||||||
|
|
||||||
|
QLineEdit* _domainNameLineEdit;
|
||||||
QLineEdit* _entitiesFileLineEdit;
|
QLineEdit* _entitiesFileLineEdit;
|
||||||
QLineEdit* _outputDirLineEdit;
|
QLineEdit* _outputDirLineEdit;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue