mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 18:02:23 +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"
|
||||
|
||||
|
||||
FBXBaker::FBXBaker(QUrl fbxURL, QString baseOutputPath, bool copyOriginals) :
|
||||
FBXBaker::FBXBaker(const QUrl& fbxURL, const QString& baseOutputPath, bool copyOriginals) :
|
||||
_fbxURL(fbxURL),
|
||||
_baseOutputPath(baseOutputPath),
|
||||
_copyOriginals(copyOriginals)
|
||||
|
|
|
@ -47,7 +47,7 @@ class TextureBaker;
|
|||
class FBXBaker : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FBXBaker(QUrl fbxURL, QString baseOutputPath, bool copyOriginals = true);
|
||||
FBXBaker(const QUrl& fbxURL, const QString& baseOutputPath, bool copyOriginals = true);
|
||||
~FBXBaker();
|
||||
|
||||
void start();
|
||||
|
|
|
@ -20,18 +20,45 @@
|
|||
|
||||
#include "DomainBaker.h"
|
||||
|
||||
DomainBaker::DomainBaker(const QUrl& localModelFileURL, QString baseOutputPath) :
|
||||
DomainBaker::DomainBaker(const QUrl& localModelFileURL, const QString& domainName, const QString& baseOutputPath) :
|
||||
_localEntitiesFileURL(localModelFileURL),
|
||||
_domainName(domainName),
|
||||
_baseOutputPath(baseOutputPath)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DomainBaker::start() {
|
||||
setupOutputFolder();
|
||||
loadLocalFile();
|
||||
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() {
|
||||
// load up the local entities file
|
||||
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
|
||||
if (!_bakers.contains(modelURL)) {
|
||||
QSharedPointer<FBXBaker> baker { new FBXBaker(modelURL, _baseOutputPath) };
|
||||
QSharedPointer<FBXBaker> baker { new FBXBaker(modelURL, _uniqueOutputPath) };
|
||||
|
||||
// start the baker
|
||||
baker->start();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
class DomainBaker : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DomainBaker(const QUrl& localEntitiesFileURL, QString baseOutputPath);
|
||||
DomainBaker(const QUrl& localEntitiesFileURL, const QString& domainName, const QString& baseOutputPath);
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
|
@ -30,13 +30,16 @@ signals:
|
|||
void finished();
|
||||
|
||||
private:
|
||||
void setupOutputFolder();
|
||||
void loadLocalFile();
|
||||
void enumerateEntities();
|
||||
|
||||
QUrl _localEntitiesFileURL;
|
||||
QString _domainName;
|
||||
QString _baseOutputPath;
|
||||
QJsonArray _entities;
|
||||
QString _uniqueOutputPath;
|
||||
|
||||
QJsonArray _entities;
|
||||
|
||||
QHash<QUrl, QSharedPointer<FBXBaker>> _bakers;
|
||||
};
|
||||
|
|
|
@ -38,6 +38,17 @@ void DomainBakeWidget::setupUI() {
|
|||
|
||||
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
|
||||
QLabel* entitiesFileLabel = new QLabel("Entities File");
|
||||
|
||||
|
@ -160,7 +171,9 @@ 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> { new DomainBaker(fileToBakeURL, outputDirectory.absolutePath()) };
|
||||
_baker = std::unique_ptr<DomainBaker> {
|
||||
new DomainBaker(fileToBakeURL, _domainNameLineEdit->text(), outputDirectory.absolutePath())
|
||||
};
|
||||
_baker->start();
|
||||
|
||||
return;
|
||||
|
|
|
@ -39,6 +39,7 @@ private:
|
|||
|
||||
std::unique_ptr<DomainBaker> _baker;
|
||||
|
||||
QLineEdit* _domainNameLineEdit;
|
||||
QLineEdit* _entitiesFileLineEdit;
|
||||
QLineEdit* _outputDirLineEdit;
|
||||
|
||||
|
|
Loading…
Reference in a new issue