fixed names of protected members according to naming conventions

This commit is contained in:
utkarshgautamnyu 2017-10-25 17:10:12 -07:00
parent 8d3f11a990
commit 854c190f32
5 changed files with 77 additions and 77 deletions

View file

@ -39,7 +39,7 @@ FBXBaker::FBXBaker(const QUrl& fbxURL, TextureBakerThreadGetter textureThreadGet
{
}
FBXBaker::~FBXBaker() {
if (_tempDir.exists()) {
if (!_tempDir.remove(_originalFBXFilePath)) {
@ -62,7 +62,7 @@ void FBXBaker::abort() {
}
void FBXBaker::bake() {
qDebug() << "FBXBaker" << _modelURL << "bake starting";
qDebug() << "FBXBaker" << modelURL << "bake starting";
auto tempDir = PathUtils::generateTemporaryDir();
@ -73,7 +73,7 @@ void FBXBaker::bake() {
_tempDir = tempDir;
_originalFBXFilePath = _tempDir.filePath(_modelURL.fileName());
_originalFBXFilePath = _tempDir.filePath(modelURL.fileName());
qDebug() << "Made temporary dir " << _tempDir;
qDebug() << "Origin file path: " << _originalFBXFilePath;
@ -124,19 +124,19 @@ void FBXBaker::bakeSourceCopy() {
void FBXBaker::setupOutputFolder() {
// make sure there isn't already an output directory using the same name
if (QDir(_bakedOutputDir).exists()) {
qWarning() << "Output path" << _bakedOutputDir << "already exists. Continuing.";
if (QDir(bakedOutputDir).exists()) {
qWarning() << "Output path" << bakedOutputDir << "already exists. Continuing.";
} else {
qCDebug(model_baking) << "Creating FBX output folder" << _bakedOutputDir;
qCDebug(model_baking) << "Creating FBX output folder" << bakedOutputDir;
// attempt to make the output folder
if (!QDir().mkpath(_bakedOutputDir)) {
handleError("Failed to create FBX output folder " + _bakedOutputDir);
if (!QDir().mkpath(bakedOutputDir)) {
handleError("Failed to create FBX output folder " + bakedOutputDir);
return;
}
// attempt to make the output folder
if (!QDir().mkpath(_originalOutputDir)) {
handleError("Failed to create FBX output folder " + _bakedOutputDir);
if (!QDir().mkpath(originalOutputDir)) {
handleError("Failed to create FBX output folder " + bakedOutputDir);
return;
}
}
@ -144,22 +144,22 @@ void FBXBaker::setupOutputFolder() {
void FBXBaker::loadSourceFBX() {
// check if the FBX is local or first needs to be downloaded
if (_modelURL.isLocalFile()) {
if (modelURL.isLocalFile()) {
// load up the local file
QFile localFBX { _modelURL.toLocalFile() };
QFile localFBX { modelURL.toLocalFile() };
qDebug() << "Local file url: " << _modelURL << _modelURL.toString() << _modelURL.toLocalFile() << ", copying to: " << _originalFBXFilePath;
qDebug() << "Local file url: " << modelURL << modelURL.toString() << modelURL.toLocalFile() << ", copying to: " << _originalFBXFilePath;
if (!localFBX.exists()) {
//QMessageBox::warning(this, "Could not find " + _fbxURL.toString(), "");
handleError("Could not find " + _modelURL.toString());
handleError("Could not find " + modelURL.toString());
return;
}
// make a copy in the output folder
if (!_originalOutputDir.isEmpty()) {
qDebug() << "Copying to: " << _originalOutputDir << "/" << _modelURL.fileName();
localFBX.copy(_originalOutputDir + "/" + _modelURL.fileName());
if (!originalOutputDir.isEmpty()) {
qDebug() << "Copying to: " << originalOutputDir << "/" << modelURL.fileName();
localFBX.copy(originalOutputDir + "/" + modelURL.fileName());
}
localFBX.copy(_originalFBXFilePath);
@ -177,9 +177,9 @@ void FBXBaker::loadSourceFBX() {
networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
networkRequest.setUrl(_modelURL);
networkRequest.setUrl(modelURL);
qCDebug(model_baking) << "Downloading" << _modelURL;
qCDebug(model_baking) << "Downloading" << modelURL;
auto networkReply = networkAccessManager.get(networkRequest);
connect(networkReply, &QNetworkReply::finished, this, &FBXBaker::handleFBXNetworkReply);
@ -190,7 +190,7 @@ void FBXBaker::handleFBXNetworkReply() {
auto requestReply = qobject_cast<QNetworkReply*>(sender());
if (requestReply->error() == QNetworkReply::NoError) {
qCDebug(model_baking) << "Downloaded" << _modelURL;
qCDebug(model_baking) << "Downloaded" << modelURL;
// grab the contents of the reply and make a copy in the output folder
QFile copyOfOriginal(_originalFBXFilePath);
@ -199,26 +199,26 @@ void FBXBaker::handleFBXNetworkReply() {
if (!copyOfOriginal.open(QIODevice::WriteOnly)) {
// add an error to the error list for this FBX stating that a duplicate of the original FBX could not be made
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to open " + _originalFBXFilePath + ")");
handleError("Could not create copy of " + modelURL.toString() + " (Failed to open " + _originalFBXFilePath + ")");
return;
}
if (copyOfOriginal.write(requestReply->readAll()) == -1) {
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to write)");
handleError("Could not create copy of " + modelURL.toString() + " (Failed to write)");
return;
}
// close that file now that we are done writing to it
copyOfOriginal.close();
if (!_originalOutputDir.isEmpty()) {
copyOfOriginal.copy(_originalOutputDir + "/" + _modelURL.fileName());
if (!originalOutputDir.isEmpty()) {
copyOfOriginal.copy(originalOutputDir + "/" + modelURL.fileName());
}
// emit our signal to start the import of the FBX source copy
emit sourceCopyReadyToLoad();
} else {
// add an error to our list stating that the FBX could not be downloaded
handleError("Failed to download " + _modelURL.toString());
handleError("Failed to download " + modelURL.toString());
}
}
@ -233,10 +233,10 @@ void FBXBaker::importScene() {
FBXReader reader;
qCDebug(model_baking) << "Parsing" << _modelURL;
qCDebug(model_baking) << "Parsing" << modelURL;
_rootNode = reader._rootNode = reader.parseFBX(&fbxFile);
_geometry = reader.extractFBXGeometry({}, _modelURL.toString());
_textureContent = reader._textureContent;
_geometry = reader.extractFBXGeometry({}, modelURL.toString());
textureContentMap = reader._textureContent;
}
void FBXBaker::rewriteAndBakeSceneModels() {
@ -398,11 +398,11 @@ void FBXBaker::rewriteAndBakeSceneTextures() {
void FBXBaker::exportScene() {
// save the relative path to this FBX inside our passed output folder
auto fileName = _modelURL.fileName();
auto fileName = modelURL.fileName();
auto baseName = fileName.left(fileName.lastIndexOf('.'));
auto bakedFilename = baseName + BAKED_FBX_EXTENSION;
_bakedFBXFilePath = _bakedOutputDir + "/" + bakedFilename;
_bakedFBXFilePath = bakedOutputDir + "/" + bakedFilename;
auto fbxData = FBXWriter::encodeFBX(_rootNode);
@ -417,5 +417,5 @@ void FBXBaker::exportScene() {
_outputFiles.push_back(_bakedFBXFilePath);
qCDebug(model_baking) << "Exported" << _modelURL << "with re-written paths to" << _bakedFBXFilePath;
qCDebug(model_baking) << "Exported" << modelURL << "with re-written paths to" << _bakedFBXFilePath;
}

View file

@ -37,7 +37,7 @@ public:
const QString& bakedOutputDir, const QString& originalOutputDir = "");
~FBXBaker() override;
QUrl getFBXUrl() const { return _modelURL; }
QUrl getFBXUrl() const { return modelURL; }
QString getBakedFBXFilePath() const { return _bakedFBXFilePath; }
public slots:

View file

@ -31,10 +31,10 @@
ModelBaker::ModelBaker(const QUrl& modelURL, TextureBakerThreadGetter textureThreadGetter,
const QString& bakedOutputDir, const QString& originalOutputDir) :
_modelURL(modelURL),
_textureThreadGetter(textureThreadGetter),
_bakedOutputDir(bakedOutputDir),
_originalOutputDir(originalOutputDir)
modelURL(modelURL),
textureThreadGetter(textureThreadGetter),
bakedOutputDir(bakedOutputDir),
originalOutputDir(originalOutputDir)
{
}
@ -244,7 +244,7 @@ QByteArray* ModelBaker::compressTexture(QString modelTextureFileName, getTexture
// figure out the URL to this texture, embedded or external
if (!modelTextureFileInfo.filePath().isEmpty()) {
textureContent = _textureContent.value(modelTextureFileName.toLocal8Bit());
textureContent = textureContentMap.value(modelTextureFileName.toLocal8Bit());
}
auto urlToTexture = getTextureURL(modelTextureFileInfo, modelTextureFileName, !textureContent.isNull());
@ -263,7 +263,7 @@ QByteArray* ModelBaker::compressTexture(QString modelTextureFileName, getTexture
<< "to" << bakedTextureFileName;
QString bakedTextureFilePath{
_bakedOutputDir + "/" + bakedTextureFileName
bakedOutputDir + "/" + bakedTextureFileName
};
textureChild = bakedTextureFileName.toLocal8Bit();
@ -272,7 +272,7 @@ QByteArray* ModelBaker::compressTexture(QString modelTextureFileName, getTexture
_outputFiles.push_back(bakedTextureFilePath);
// bake this texture asynchronously
bakeTexture(urlToTexture, textureType, _bakedOutputDir, bakedTextureFileName, textureContent);
bakeTexture(urlToTexture, textureType, bakedOutputDir, bakedTextureFileName, textureContent);
}
}
@ -286,7 +286,7 @@ QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativ
auto apparentRelativePath = QFileInfo(relativeFileName.replace("\\", "/"));
if (isEmbedded) {
urlToTexture = _modelURL.toString() + "/" + apparentRelativePath.filePath();
urlToTexture = modelURL.toString() + "/" + apparentRelativePath.filePath();
} else {
if (textureFileInfo.exists() && textureFileInfo.isFile()) {
// set the texture URL to the local texture that we have confirmed exists
@ -296,14 +296,14 @@ QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativ
// this is a relative file path which will require different handling
// depending on the location of the original model
if (_modelURL.isLocalFile() && apparentRelativePath.exists() && apparentRelativePath.isFile()) {
if (modelURL.isLocalFile() && apparentRelativePath.exists() && apparentRelativePath.isFile()) {
// the absolute path we ran into for the texture in the model exists on this machine
// so use that file
urlToTexture = QUrl::fromLocalFile(apparentRelativePath.absoluteFilePath());
} else {
// we didn't find the texture on this machine at the absolute path
// so assume that it is right beside the model to match the behaviour of interface
urlToTexture = _modelURL.resolved(apparentRelativePath.fileName());
urlToTexture = modelURL.resolved(apparentRelativePath.fileName());
}
}
}
@ -328,7 +328,7 @@ void ModelBaker::bakeTexture(const QUrl& textureURL, image::TextureUsage::Type t
_bakingTextures.insert(textureURL, bakingTexture);
// start baking the texture on one of our available worker threads
bakingTexture->moveToThread(_textureThreadGetter());
bakingTexture->moveToThread(textureThreadGetter());
QMetaObject::invokeMethod(bakingTexture.data(), "bake");
}
@ -339,7 +339,7 @@ void ModelBaker::handleBakedTexture() {
if (bakedTexture) {
if (!shouldStop()) {
if (!bakedTexture->hasErrors()) {
if (!_originalOutputDir.isEmpty()) {
if (!originalOutputDir.isEmpty()) {
// we've been asked to make copies of the originals, so we need to make copies of this if it is a linked texture
// use the path to the texture being baked to determine if this was an embedded or a linked texture
@ -347,16 +347,16 @@ void ModelBaker::handleBakedTexture() {
// it is embeddded if the texure being baked was inside a folder with the name of the model
// since that is the fake URL we provide when baking external textures
if (!_modelURL.isParentOf(bakedTexture->getTextureURL())) {
if (!modelURL.isParentOf(bakedTexture->getTextureURL())) {
// for linked textures we want to save a copy of original texture beside the original model
qCDebug(model_baking) << "Saving original texture for" << bakedTexture->getTextureURL();
// check if we have a relative path to use for the texture
auto relativeTexturePath = texturePathRelativeToModel(_modelURL, bakedTexture->getTextureURL());
auto relativeTexturePath = texturePathRelativeToModel(modelURL, bakedTexture->getTextureURL());
QFile originalTextureFile{
_originalOutputDir + "/" + relativeTexturePath + bakedTexture->getTextureURL().fileName()
originalOutputDir + "/" + relativeTexturePath + bakedTexture->getTextureURL().fileName()
};
if (relativeTexturePath.length() > 0) {
@ -365,10 +365,10 @@ void ModelBaker::handleBakedTexture() {
if (originalTextureFile.open(QIODevice::WriteOnly) && originalTextureFile.write(bakedTexture->getOriginalTexture()) != -1) {
qCDebug(model_baking) << "Saved original texture file" << originalTextureFile.fileName()
<< "for" << _modelURL;
<< "for" << modelURL;
} else {
handleError("Could not save original external texture " + originalTextureFile.fileName()
+ " for " + _modelURL.toString());
+ " for " + modelURL.toString());
return;
}
}
@ -435,7 +435,7 @@ void ModelBaker::checkIfTexturesFinished() {
return;
} else {
qCDebug(model_baking) << "Finished baking, emitting finished" << _modelURL;
qCDebug(model_baking) << "Finished baking, emitting finished" << modelURL;
setIsFinished(true);
}
@ -487,7 +487,7 @@ void ModelBaker::setWasAborted(bool wasAborted) {
Baker::setWasAborted(wasAborted);
if (wasAborted) {
qCDebug(model_baking) << "Aborted baking" << _modelURL;
qCDebug(model_baking) << "Aborted baking" << modelURL;
}
}
}

View file

@ -43,11 +43,11 @@ public:
protected:
void checkIfTexturesFinished();
QHash<QByteArray, QByteArray> _textureContent;
QString _bakedOutputDir;
QString _originalOutputDir;
TextureBakerThreadGetter _textureThreadGetter;
QUrl _modelURL;
QHash<QByteArray, QByteArray> textureContentMap;
QString bakedOutputDir;
QString originalOutputDir;
TextureBakerThreadGetter textureThreadGetter;
QUrl modelURL;
public slots:
virtual void bake() override;

View file

@ -53,7 +53,7 @@ OBJBaker::~OBJBaker() {
}
void OBJBaker::bake() {
qDebug() << "OBJBaker" << _modelURL << "bake starting";
qDebug() << "OBJBaker" << modelURL << "bake starting";
auto tempDir = PathUtils::generateTemporaryDir();
@ -64,7 +64,7 @@ void OBJBaker::bake() {
_tempDir = tempDir;
_originalOBJFilePath = _tempDir.filePath(_modelURL.fileName());
_originalOBJFilePath = _tempDir.filePath(modelURL.fileName());
qDebug() << "Made temporary dir " << _tempDir;
qDebug() << "Origin file path: " << _originalOBJFilePath;
@ -77,21 +77,21 @@ void OBJBaker::bake() {
void OBJBaker::loadOBJ() {
// check if the OBJ is local or it needs to be downloaded
if (_modelURL.isLocalFile()) {
if (modelURL.isLocalFile()) {
// loading the local OBJ
QFile localOBJ{ _modelURL.toLocalFile() };
QFile localOBJ{ modelURL.toLocalFile() };
qDebug() << "Local file url: " << _modelURL << _modelURL.toString() << _modelURL.toLocalFile() << ", copying to: " << _originalOBJFilePath;
qDebug() << "Local file url: " << modelURL << modelURL.toString() << modelURL.toLocalFile() << ", copying to: " << _originalOBJFilePath;
if (!localOBJ.exists()) {
handleError("Could not find " + _modelURL.toString());
handleError("Could not find " + modelURL.toString());
return;
}
// make a copy in the output folder
if (!_originalOutputDir.isEmpty()) {
qDebug() << "Copying to: " << _originalOutputDir << "/" << _modelURL.fileName();
localOBJ.copy(_originalOutputDir + "/" + _modelURL.fileName());
if (!originalOutputDir.isEmpty()) {
qDebug() << "Copying to: " << originalOutputDir << "/" << modelURL.fileName();
localOBJ.copy(originalOutputDir + "/" + modelURL.fileName());
}
localOBJ.copy(_originalOBJFilePath);
@ -108,9 +108,9 @@ void OBJBaker::loadOBJ() {
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
networkRequest.setUrl(_modelURL);
networkRequest.setUrl(modelURL);
qCDebug(model_baking) << "Downloading" << _modelURL;
qCDebug(model_baking) << "Downloading" << modelURL;
auto networkReply = networkAccessManager.get(networkRequest);
connect(networkReply, &QNetworkReply::finished, this, &OBJBaker::handleOBJNetworkReply);
@ -121,7 +121,7 @@ void OBJBaker::handleOBJNetworkReply() {
auto requestReply = qobject_cast<QNetworkReply*>(sender());
if (requestReply->error() == QNetworkReply::NoError) {
qCDebug(model_baking) << "Downloaded" << _modelURL;
qCDebug(model_baking) << "Downloaded" << modelURL;
// grab the contents of the reply and make a copy in the output folder
QFile copyOfOriginal(_originalOBJFilePath);
@ -130,26 +130,26 @@ void OBJBaker::handleOBJNetworkReply() {
if (!copyOfOriginal.open(QIODevice::WriteOnly)) {
// add an error to the error list for this obj stating that a duplicate of the original obj could not be made
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to open " + _originalOBJFilePath + ")");
handleError("Could not create copy of " + modelURL.toString() + " (Failed to open " + _originalOBJFilePath + ")");
return;
}
if (copyOfOriginal.write(requestReply->readAll()) == -1) {
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to write)");
handleError("Could not create copy of " + modelURL.toString() + " (Failed to write)");
return;
}
// close that file now that we are done writing to it
copyOfOriginal.close();
if (!_originalOutputDir.isEmpty()) {
copyOfOriginal.copy(_originalOutputDir + "/" + _modelURL.fileName());
if (!originalOutputDir.isEmpty()) {
copyOfOriginal.copy(originalOutputDir + "/" + modelURL.fileName());
}
// remote OBJ is loaded emit signal to trigger its baking
emit OBJLoaded();
} else {
// add an error to our list stating that the OBJ could not be downloaded
handleError("Failed to download " + _modelURL.toString());
handleError("Failed to download " + modelURL.toString());
}
}
@ -166,7 +166,7 @@ void OBJBaker::bakeOBJ() {
bool combineParts = true; // set true so that OBJReader reads material info from material library
OBJReader reader;
FBXGeometry* geometry = reader.readOBJ(objData, QVariantHash(), combineParts, _modelURL);
FBXGeometry* geometry = reader.readOBJ(objData, QVariantHash(), combineParts, modelURL);
// Write OBJ Data as FBX tree nodes
FBXNode rootNode;
@ -176,11 +176,11 @@ void OBJBaker::bakeOBJ() {
auto encodedFBX = FBXWriter::encodeFBX(rootNode);
// Export as baked FBX
auto fileName = _modelURL.fileName();
auto fileName = modelURL.fileName();
auto baseName = fileName.left(fileName.lastIndexOf('.'));
auto bakedFilename = baseName + ".baked.fbx";
_bakedOBJFilePath = _bakedOutputDir + "/" + bakedFilename;
_bakedOBJFilePath = bakedOutputDir + "/" + bakedFilename;
QFile bakedFile;
bakedFile.setFileName(_bakedOBJFilePath);
@ -193,7 +193,7 @@ void OBJBaker::bakeOBJ() {
// Export successful
_outputFiles.push_back(_bakedOBJFilePath);
qCDebug(model_baking) << "Exported" << _modelURL << "to" << _bakedOBJFilePath;
qCDebug(model_baking) << "Exported" << modelURL << "to" << _bakedOBJFilePath;
// Export done emit finished
emit finished();