mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-06 16:09:02 +02:00
Fix baked FSTs unable to be rebaked by creating an FST in the original
output folder
This commit is contained in:
parent
bbab0b59b7
commit
d80b40e5a5
3 changed files with 38 additions and 0 deletions
|
@ -167,6 +167,10 @@ void ModelBaker::saveSourceModel() {
|
||||||
|
|
||||||
connect(networkReply, &QNetworkReply::finished, this, &ModelBaker::handleModelNetworkReply);
|
connect(networkReply, &QNetworkReply::finished, this, &ModelBaker::handleModelNetworkReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_mappingURL.isEmpty()) {
|
||||||
|
outputUnbakedFST();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelBaker::handleModelNetworkReply() {
|
void ModelBaker::handleModelNetworkReply() {
|
||||||
|
@ -313,6 +317,37 @@ void ModelBaker::handleFinishedMaterialBaker() {
|
||||||
outputBakedFST();
|
outputBakedFST();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelBaker::outputUnbakedFST() {
|
||||||
|
// Output an unbaked FST file in the original output folder to make it easier for FSTBaker to rebake this model
|
||||||
|
// TODO: Consider a more robust method that does not depend on FSTBaker navigating to a hardcoded relative path
|
||||||
|
QString outputFSTFilename = _modelURL.fileName();
|
||||||
|
auto extensionStart = outputFSTFilename.indexOf(".");
|
||||||
|
if (extensionStart != -1) {
|
||||||
|
outputFSTFilename.resize(extensionStart);
|
||||||
|
}
|
||||||
|
outputFSTFilename += FST_EXTENSION;
|
||||||
|
QString outputFSTURL = _originalOutputDir + "/" + outputFSTFilename;
|
||||||
|
|
||||||
|
hifi::VariantHash outputMapping;
|
||||||
|
outputMapping[FST_VERSION_FIELD] = FST_VERSION;
|
||||||
|
outputMapping[FILENAME_FIELD] = _modelURL.fileName();
|
||||||
|
outputMapping[COMMENT_FIELD] = "This FST file was generated by Oven for use during rebaking. It is not part of the original model. This file's existence is subject to change.";
|
||||||
|
hifi::ByteArray fstOut = FSTReader::writeMapping(outputMapping);
|
||||||
|
|
||||||
|
QFile fstOutputFile { outputFSTURL };
|
||||||
|
if (fstOutputFile.exists()) {
|
||||||
|
handleWarning("The file '" + outputFSTURL + "' already exists. Should that be baked instead of '" + _modelURL.toString() + "'?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!fstOutputFile.open(QIODevice::WriteOnly)) {
|
||||||
|
handleWarning("Failed to open file '" + outputFSTURL + "' for writing. Rebaking may fail on the associated model.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fstOutputFile.write(fstOut) == -1) {
|
||||||
|
handleWarning("Failed to write to file '" + outputFSTURL + "'. Rebaking may fail on the associated model.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModelBaker::outputBakedFST() {
|
void ModelBaker::outputBakedFST() {
|
||||||
// Output FST file, copying over input mappings if available
|
// Output FST file, copying over input mappings if available
|
||||||
QString outputFSTFilename = !_mappingURL.isEmpty() ? _mappingURL.fileName() : _modelURL.fileName();
|
QString outputFSTFilename = !_mappingURL.isEmpty() ? _mappingURL.fileName() : _modelURL.fileName();
|
||||||
|
@ -327,6 +362,7 @@ void ModelBaker::outputBakedFST() {
|
||||||
outputMapping[FST_VERSION_FIELD] = FST_VERSION;
|
outputMapping[FST_VERSION_FIELD] = FST_VERSION;
|
||||||
outputMapping[FILENAME_FIELD] = _bakedModelURL.fileName();
|
outputMapping[FILENAME_FIELD] = _bakedModelURL.fileName();
|
||||||
outputMapping.remove(TEXDIR_FIELD);
|
outputMapping.remove(TEXDIR_FIELD);
|
||||||
|
outputMapping.remove(COMMENT_FIELD);
|
||||||
hifi::ByteArray fstOut = FSTReader::writeMapping(outputMapping);
|
hifi::ByteArray fstOut = FSTReader::writeMapping(outputMapping);
|
||||||
|
|
||||||
QFile fstOutputFile { outputFSTURL };
|
QFile fstOutputFile { outputFSTURL };
|
||||||
|
|
|
@ -82,6 +82,7 @@ protected slots:
|
||||||
void handleFinishedMaterialBaker();
|
void handleFinishedMaterialBaker();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void outputUnbakedFST();
|
||||||
void outputBakedFST();
|
void outputBakedFST();
|
||||||
|
|
||||||
bool _hasBeenBaked { false };
|
bool _hasBeenBaked { false };
|
||||||
|
|
|
@ -33,6 +33,7 @@ static const QString BLENDSHAPE_FIELD = "bs";
|
||||||
static const QString SCRIPT_FIELD = "script";
|
static const QString SCRIPT_FIELD = "script";
|
||||||
static const QString JOINT_NAME_MAPPING_FIELD = "jointMap";
|
static const QString JOINT_NAME_MAPPING_FIELD = "jointMap";
|
||||||
static const QString MATERIAL_MAPPING_FIELD = "materialMap";
|
static const QString MATERIAL_MAPPING_FIELD = "materialMap";
|
||||||
|
static const QString COMMENT_FIELD = "comment";
|
||||||
|
|
||||||
class FSTReader {
|
class FSTReader {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue