mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01: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);
|
||||
}
|
||||
|
||||
if (_mappingURL.isEmpty()) {
|
||||
outputUnbakedFST();
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBaker::handleModelNetworkReply() {
|
||||
|
@ -313,6 +317,37 @@ void ModelBaker::handleFinishedMaterialBaker() {
|
|||
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() {
|
||||
// Output FST file, copying over input mappings if available
|
||||
QString outputFSTFilename = !_mappingURL.isEmpty() ? _mappingURL.fileName() : _modelURL.fileName();
|
||||
|
@ -327,6 +362,7 @@ void ModelBaker::outputBakedFST() {
|
|||
outputMapping[FST_VERSION_FIELD] = FST_VERSION;
|
||||
outputMapping[FILENAME_FIELD] = _bakedModelURL.fileName();
|
||||
outputMapping.remove(TEXDIR_FIELD);
|
||||
outputMapping.remove(COMMENT_FIELD);
|
||||
hifi::ByteArray fstOut = FSTReader::writeMapping(outputMapping);
|
||||
|
||||
QFile fstOutputFile { outputFSTURL };
|
||||
|
|
|
@ -82,6 +82,7 @@ protected slots:
|
|||
void handleFinishedMaterialBaker();
|
||||
|
||||
private:
|
||||
void outputUnbakedFST();
|
||||
void outputBakedFST();
|
||||
|
||||
bool _hasBeenBaked { false };
|
||||
|
|
|
@ -33,6 +33,7 @@ static const QString BLENDSHAPE_FIELD = "bs";
|
|||
static const QString SCRIPT_FIELD = "script";
|
||||
static const QString JOINT_NAME_MAPPING_FIELD = "jointMap";
|
||||
static const QString MATERIAL_MAPPING_FIELD = "materialMap";
|
||||
static const QString COMMENT_FIELD = "comment";
|
||||
|
||||
class FSTReader {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue