don't save copy of originals for one-off bake

This commit is contained in:
Stephen Birarda 2017-04-07 15:40:40 -07:00
parent 1fc678a929
commit d9efd4adef
3 changed files with 18 additions and 10 deletions

View file

@ -22,9 +22,10 @@
#include "FBXBaker.h"
FBXBaker::FBXBaker(QUrl fbxURL, QString baseOutputPath) :
FBXBaker::FBXBaker(QUrl fbxURL, QString baseOutputPath, bool copyOriginals) :
_fbxURL(fbxURL),
_baseOutputPath(baseOutputPath)
_baseOutputPath(baseOutputPath),
_copyOriginals(copyOriginals)
{
// create an FBX SDK manager
_sdkManager = FbxManager::Create();
@ -152,8 +153,8 @@ void FBXBaker::bake() {
rewriteAndBakeSceneTextures();
exportScene();
removeEmbeddedMediaFolder();
possiblyCleanupOriginals();
}
bool FBXBaker::importScene() {
@ -466,11 +467,15 @@ bool FBXBaker::exportScene() {
}
bool FBXBaker::removeEmbeddedMediaFolder() {
void FBXBaker::removeEmbeddedMediaFolder() {
// now that the bake is complete, remove the embedded media folder produced by the FBX SDK when it imports an FBX
auto embeddedMediaFolderName = _fbxURL.fileName().replace(".fbx", ".fbm");
QDir(_uniqueOutputPath + ORIGINAL_OUTPUT_SUBFOLDER + embeddedMediaFolderName).removeRecursively();
// we always return true because a failure to delete the embedded media folder is not a failure of the bake
return true;
}
void FBXBaker::possiblyCleanupOriginals() {
if (!_copyOriginals) {
// caller did not ask us to keep the original around, so delete the original output folder now
QDir(_uniqueOutputPath + ORIGINAL_OUTPUT_SUBFOLDER).removeRecursively();
}
}

View file

@ -47,7 +47,7 @@ class TextureBaker;
class FBXBaker : public QObject {
Q_OBJECT
public:
FBXBaker(QUrl fbxURL, QString baseOutputPath);
FBXBaker(QUrl fbxURL, QString baseOutputPath, bool copyOriginals = true);
~FBXBaker();
void start();
@ -66,7 +66,8 @@ private:
bool importScene();
bool rewriteAndBakeSceneTextures();
bool exportScene();
bool removeEmbeddedMediaFolder();
void removeEmbeddedMediaFolder();
void possiblyCleanupOriginals();
QString createBakedTextureFileName(const QFileInfo& textureFileInfo);
QUrl getTextureURL(const QFileInfo& textureFileInfo, fbxsdk::FbxFileTexture* fileTexture);
@ -91,6 +92,8 @@ private:
QHash<uint64_t, TextureType> _textureTypes;
std::list<std::unique_ptr<TextureBaker>> _bakingTextures;
bool _copyOriginals { true };
};
#endif // hifi_FBXBaker_h

View file

@ -157,6 +157,6 @@ void ModelBakeWidget::bakeButtonClicked() {
}
// everything seems to be in place, kick off a bake now
_baker.reset(new FBXBaker(modelToBakeURL, outputDirectory.absolutePath()));
_baker.reset(new FBXBaker(modelToBakeURL, outputDirectory.absolutePath(), false));
_baker->start();
}