From 7c1b9e79aec03b06557880698ebd32efc8fdc34c Mon Sep 17 00:00:00 2001 From: Kalila R Date: Mon, 11 Nov 2019 20:28:16 -0500 Subject: [PATCH] Setting ModelBaker.cpp back to main. --- libraries/baking/src/ModelBaker.cpp | 41 ++++++----------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/libraries/baking/src/ModelBaker.cpp b/libraries/baking/src/ModelBaker.cpp index cdd07fccf8..70290fe283 100644 --- a/libraries/baking/src/ModelBaker.cpp +++ b/libraries/baking/src/ModelBaker.cpp @@ -45,6 +45,7 @@ #include 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& 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;