Restore 'Re-bake originals' checkbox to domain bake window

This commit is contained in:
sabrina-shanman 2019-03-12 18:17:11 -07:00
parent a93825c2f9
commit 7f77e163ac
6 changed files with 26 additions and 5 deletions

View file

@ -38,6 +38,13 @@ QUrl getBakeableModelURL(const QUrl& url) {
return QUrl();
}
bool isModelBaked(const QUrl& bakeableModelURL) {
auto modelString = bakeableModelURL.toString();
auto beforeModelExtension = modelString;
beforeModelExtension.resize(modelString.lastIndexOf('.'));
return beforeModelExtension.endsWith(".baked");
}
std::unique_ptr<ModelBaker> getModelBaker(const QUrl& bakeableModelURL, TextureBakerThreadGetter inputTextureThreadGetter, const QString& contentOutputPath) {
auto filename = bakeableModelURL.fileName();
@ -59,6 +66,7 @@ std::unique_ptr<ModelBaker> getModelBakerWithOutputDirectories(const QUrl& bakea
auto filename = bakeableModelURL.fileName();
std::unique_ptr<ModelBaker> baker;
if (filename.endsWith(FST_EXTENSION, Qt::CaseInsensitive)) {
baker = std::make_unique<FSTBaker>(bakeableModelURL, inputTextureThreadGetter, bakedOutputDirectory, originalOutputDirectory, filename.endsWith(BAKED_FST_EXTENSION, Qt::CaseInsensitive));
} else if (filename.endsWith(FBX_EXTENSION, Qt::CaseInsensitive)) {

View file

@ -19,6 +19,8 @@
// Returns either the given model URL if valid, or an empty URL
QUrl getBakeableModelURL(const QUrl& url);
bool isModelBaked(const QUrl& bakeableModelURL);
// Assuming the URL is valid, gets the appropriate baker for the given URL, and creates the base directory where the baker's output will later be stored
// Returns an empty pointer if a baker could not be created
std::unique_ptr<ModelBaker> getModelBaker(const QUrl& bakeableModelURL, TextureBakerThreadGetter inputTextureThreadGetter, const QString& contentOutputPath);

View file

@ -23,10 +23,12 @@
#include "baking/BakerLibrary.h"
DomainBaker::DomainBaker(const QUrl& localModelFileURL, const QString& domainName,
const QString& baseOutputPath, const QUrl& destinationPath) :
const QString& baseOutputPath, const QUrl& destinationPath,
bool shouldRebakeOriginals) :
_localEntitiesFileURL(localModelFileURL),
_domainName(domainName),
_baseOutputPath(baseOutputPath)
_baseOutputPath(baseOutputPath),
_shouldRebakeOriginals(shouldRebakeOriginals)
{
// make sure the destination path has a trailing slash
if (!destinationPath.toString().endsWith('/')) {
@ -146,7 +148,7 @@ void DomainBaker::loadLocalFile() {
void DomainBaker::addModelBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef) {
// grab a QUrl for the model URL
QUrl bakeableModelURL = getBakeableModelURL(url);
if (!bakeableModelURL.isEmpty()) {
if (!bakeableModelURL.isEmpty() && (_shouldRebakeOriginals || !isModelBaked(bakeableModelURL))) {
// setup a ModelBaker for this URL, as long as we don't already have one
if (!_modelBakers.contains(bakeableModelURL)) {
auto getWorkerThreadCallback = []() -> QThread* {

View file

@ -29,7 +29,8 @@ public:
// This means that we need to put all of the FBX importing/exporting from the same process on the same thread.
// That means you must pass a usable running QThread when constructing a domain baker.
DomainBaker(const QUrl& localEntitiesFileURL, const QString& domainName,
const QString& baseOutputPath, const QUrl& destinationPath);
const QString& baseOutputPath, const QUrl& destinationPath,
bool shouldRebakeOriginals);
signals:
void allModelsFinished();
@ -70,6 +71,8 @@ private:
int _totalNumberOfSubBakes { 0 };
int _completedSubBakes { 0 };
bool _shouldRebakeOriginals { false };
void addModelBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef);
void addTextureBaker(const QString& property, const QString& url, image::TextureUsage::Type type, QJsonValueRef& jsonRef);
void addScriptBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef);

View file

@ -126,6 +126,10 @@ void DomainBakeWidget::setupUI() {
// start a new row for the next component
++rowIndex;
// setup a checkbox to allow re-baking of original assets
_rebakeOriginalsCheckBox = new QCheckBox("Re-bake originals");
gridLayout->addWidget(_rebakeOriginalsCheckBox, rowIndex, 0);
// add a button that will kickoff the bake
QPushButton* bakeButton = new QPushButton("Bake");
connect(bakeButton, &QPushButton::clicked, this, &DomainBakeWidget::bakeButtonClicked);
@ -207,7 +211,8 @@ void DomainBakeWidget::bakeButtonClicked() {
auto fileToBakeURL = QUrl::fromLocalFile(_entitiesFileLineEdit->text());
auto domainBaker = std::unique_ptr<DomainBaker> {
new DomainBaker(fileToBakeURL, _domainNameLineEdit->text(),
outputDirectory.absolutePath(), _destinationPathLineEdit->text())
outputDirectory.absolutePath(), _destinationPathLineEdit->text(),
_rebakeOriginalsCheckBox->isChecked())
};
// make sure we hear from the baker when it is done

View file

@ -45,6 +45,7 @@ private:
QLineEdit* _entitiesFileLineEdit;
QLineEdit* _outputDirLineEdit;
QLineEdit* _destinationPathLineEdit;
QCheckBox* _rebakeOriginalsCheckBox;
Setting::Handle<QString> _domainNameSetting;
Setting::Handle<QString> _exportDirectory;