Setting ModelBaker.cpp back to main.

This commit is contained in:
Kalila R 2019-11-11 20:28:16 -05:00
parent 5f7486fe7e
commit 7c1b9e79ae

View file

@ -45,6 +45,7 @@
#include <QJsonArray>
ModelBaker::ModelBaker(const QUrl& inputModelURL, const QString& bakedOutputDirectory, const QString& originalOutputDirectory, bool hasBeenBaked) :
_originalInputModelURL(inputModelURL),
_modelURL(inputModelURL),
_bakedOutputDir(bakedOutputDirectory),
_originalOutputDir(originalOutputDirectory),
@ -245,6 +246,12 @@ void ModelBaker::bakeSourceCopy() {
// Begin hfm baking
baker.run();
const auto& errors = baker.getDracoErrors();
if (std::find(errors.cbegin(), errors.cend(), true) != errors.cend()) {
handleError("Failed to finalize the baking of a draco Geometry node from model " + _modelURL.toString());
return;
}
_hfmModel = baker.getHFMModel();
_materialMapping = baker.getMaterialMapping();
dracoMeshes = baker.getDracoMeshes();
@ -389,37 +396,6 @@ void ModelBaker::outputUnbakedFST() {
}
}
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();
@ -467,8 +443,7 @@ void ModelBaker::abort() {
bool ModelBaker::buildDracoMeshNode(FBXNode& dracoMeshNode, const QByteArray& dracoMeshBytes, const std::vector<hifi::ByteArray>& dracoMaterialList) {
if (dracoMeshBytes.isEmpty()) {
handleError("Failed to finalize the baking of a draco Geometry node");
return false;
handleWarning("Empty mesh detected in model: '" + _modelURL.toString() + "'. It will be included in the baked output.");
}
FBXNode dracoNode;