mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Restore 'Re-bake originals' checkbox to domain bake window
This commit is contained in:
parent
a93825c2f9
commit
7f77e163ac
6 changed files with 26 additions and 5 deletions
|
@ -38,6 +38,13 @@ QUrl getBakeableModelURL(const QUrl& url) {
|
||||||
return QUrl();
|
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) {
|
std::unique_ptr<ModelBaker> getModelBaker(const QUrl& bakeableModelURL, TextureBakerThreadGetter inputTextureThreadGetter, const QString& contentOutputPath) {
|
||||||
auto filename = bakeableModelURL.fileName();
|
auto filename = bakeableModelURL.fileName();
|
||||||
|
|
||||||
|
@ -59,6 +66,7 @@ std::unique_ptr<ModelBaker> getModelBakerWithOutputDirectories(const QUrl& bakea
|
||||||
auto filename = bakeableModelURL.fileName();
|
auto filename = bakeableModelURL.fileName();
|
||||||
|
|
||||||
std::unique_ptr<ModelBaker> baker;
|
std::unique_ptr<ModelBaker> baker;
|
||||||
|
|
||||||
if (filename.endsWith(FST_EXTENSION, Qt::CaseInsensitive)) {
|
if (filename.endsWith(FST_EXTENSION, Qt::CaseInsensitive)) {
|
||||||
baker = std::make_unique<FSTBaker>(bakeableModelURL, inputTextureThreadGetter, bakedOutputDirectory, originalOutputDirectory, filename.endsWith(BAKED_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)) {
|
} else if (filename.endsWith(FBX_EXTENSION, Qt::CaseInsensitive)) {
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
// Returns either the given model URL if valid, or an empty URL
|
// Returns either the given model URL if valid, or an empty URL
|
||||||
QUrl getBakeableModelURL(const QUrl& 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
|
// 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
|
// Returns an empty pointer if a baker could not be created
|
||||||
std::unique_ptr<ModelBaker> getModelBaker(const QUrl& bakeableModelURL, TextureBakerThreadGetter inputTextureThreadGetter, const QString& contentOutputPath);
|
std::unique_ptr<ModelBaker> getModelBaker(const QUrl& bakeableModelURL, TextureBakerThreadGetter inputTextureThreadGetter, const QString& contentOutputPath);
|
||||||
|
|
|
@ -23,10 +23,12 @@
|
||||||
#include "baking/BakerLibrary.h"
|
#include "baking/BakerLibrary.h"
|
||||||
|
|
||||||
DomainBaker::DomainBaker(const QUrl& localModelFileURL, const QString& domainName,
|
DomainBaker::DomainBaker(const QUrl& localModelFileURL, const QString& domainName,
|
||||||
const QString& baseOutputPath, const QUrl& destinationPath) :
|
const QString& baseOutputPath, const QUrl& destinationPath,
|
||||||
|
bool shouldRebakeOriginals) :
|
||||||
_localEntitiesFileURL(localModelFileURL),
|
_localEntitiesFileURL(localModelFileURL),
|
||||||
_domainName(domainName),
|
_domainName(domainName),
|
||||||
_baseOutputPath(baseOutputPath)
|
_baseOutputPath(baseOutputPath),
|
||||||
|
_shouldRebakeOriginals(shouldRebakeOriginals)
|
||||||
{
|
{
|
||||||
// make sure the destination path has a trailing slash
|
// make sure the destination path has a trailing slash
|
||||||
if (!destinationPath.toString().endsWith('/')) {
|
if (!destinationPath.toString().endsWith('/')) {
|
||||||
|
@ -146,7 +148,7 @@ void DomainBaker::loadLocalFile() {
|
||||||
void DomainBaker::addModelBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef) {
|
void DomainBaker::addModelBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef) {
|
||||||
// grab a QUrl for the model URL
|
// grab a QUrl for the model URL
|
||||||
QUrl bakeableModelURL = getBakeableModelURL(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
|
// setup a ModelBaker for this URL, as long as we don't already have one
|
||||||
if (!_modelBakers.contains(bakeableModelURL)) {
|
if (!_modelBakers.contains(bakeableModelURL)) {
|
||||||
auto getWorkerThreadCallback = []() -> QThread* {
|
auto getWorkerThreadCallback = []() -> QThread* {
|
||||||
|
|
|
@ -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.
|
// 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.
|
// That means you must pass a usable running QThread when constructing a domain baker.
|
||||||
DomainBaker(const QUrl& localEntitiesFileURL, const QString& domainName,
|
DomainBaker(const QUrl& localEntitiesFileURL, const QString& domainName,
|
||||||
const QString& baseOutputPath, const QUrl& destinationPath);
|
const QString& baseOutputPath, const QUrl& destinationPath,
|
||||||
|
bool shouldRebakeOriginals);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void allModelsFinished();
|
void allModelsFinished();
|
||||||
|
@ -70,6 +71,8 @@ private:
|
||||||
int _totalNumberOfSubBakes { 0 };
|
int _totalNumberOfSubBakes { 0 };
|
||||||
int _completedSubBakes { 0 };
|
int _completedSubBakes { 0 };
|
||||||
|
|
||||||
|
bool _shouldRebakeOriginals { false };
|
||||||
|
|
||||||
void addModelBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef);
|
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 addTextureBaker(const QString& property, const QString& url, image::TextureUsage::Type type, QJsonValueRef& jsonRef);
|
||||||
void addScriptBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef);
|
void addScriptBaker(const QString& property, const QString& url, QJsonValueRef& jsonRef);
|
||||||
|
|
|
@ -126,6 +126,10 @@ void DomainBakeWidget::setupUI() {
|
||||||
// start a new row for the next component
|
// start a new row for the next component
|
||||||
++rowIndex;
|
++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
|
// add a button that will kickoff the bake
|
||||||
QPushButton* bakeButton = new QPushButton("Bake");
|
QPushButton* bakeButton = new QPushButton("Bake");
|
||||||
connect(bakeButton, &QPushButton::clicked, this, &DomainBakeWidget::bakeButtonClicked);
|
connect(bakeButton, &QPushButton::clicked, this, &DomainBakeWidget::bakeButtonClicked);
|
||||||
|
@ -207,7 +211,8 @@ void DomainBakeWidget::bakeButtonClicked() {
|
||||||
auto fileToBakeURL = QUrl::fromLocalFile(_entitiesFileLineEdit->text());
|
auto fileToBakeURL = QUrl::fromLocalFile(_entitiesFileLineEdit->text());
|
||||||
auto domainBaker = std::unique_ptr<DomainBaker> {
|
auto domainBaker = std::unique_ptr<DomainBaker> {
|
||||||
new DomainBaker(fileToBakeURL, _domainNameLineEdit->text(),
|
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
|
// make sure we hear from the baker when it is done
|
||||||
|
|
|
@ -45,6 +45,7 @@ private:
|
||||||
QLineEdit* _entitiesFileLineEdit;
|
QLineEdit* _entitiesFileLineEdit;
|
||||||
QLineEdit* _outputDirLineEdit;
|
QLineEdit* _outputDirLineEdit;
|
||||||
QLineEdit* _destinationPathLineEdit;
|
QLineEdit* _destinationPathLineEdit;
|
||||||
|
QCheckBox* _rebakeOriginalsCheckBox;
|
||||||
|
|
||||||
Setting::Handle<QString> _domainNameSetting;
|
Setting::Handle<QString> _domainNameSetting;
|
||||||
Setting::Handle<QString> _exportDirectory;
|
Setting::Handle<QString> _exportDirectory;
|
||||||
|
|
Loading…
Reference in a new issue