From 251e4a312736cba17c7e4a51e0f38cd7029dc561 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Tue, 6 Mar 2018 16:35:49 -0800 Subject: [PATCH] Fixed blocks importer textures being interpreted as image entities --- interface/src/Application.cpp | 18 +++++++++--------- interface/src/Application.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index af159263ed..189b4c02bc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6607,17 +6607,17 @@ void Application::addAssetToWorld(QString path, QString zipFile, bool isZip, boo addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server."); - addAssetToWorldWithNewMapping(path, mapping, 0); + addAssetToWorldWithNewMapping(path, mapping, 0, isBlocks); } -void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy) { +void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isBlocks) { auto request = DependencyManager::get()->createGetMappingRequest(mapping); QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable { const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard. auto result = request->getError(); if (result == GetMappingRequest::NotFound) { - addAssetToWorldUpload(filePath, mapping); + addAssetToWorldUpload(filePath, mapping, isBlocks); } else if (result != GetMappingRequest::NoError) { QString errorInfo = "Could not map asset name: " + mapping.left(mapping.length() - QString::number(copy).length() - 1); @@ -6629,7 +6629,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin } copy++; mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy)); - addAssetToWorldWithNewMapping(filePath, mapping, copy); + addAssetToWorldWithNewMapping(filePath, mapping, copy, isBlocks); } else { QString errorInfo = "Too many copies of asset name: " + mapping.left(mapping.length() - QString::number(copy).length() - 1); @@ -6642,7 +6642,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin request->start(); } -void Application::addAssetToWorldUpload(QString filePath, QString mapping) { +void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool isBlocks) { qInfo(interfaceapp) << "Uploading" << filePath << "to Asset Server as" << mapping; auto upload = DependencyManager::get()->createUpload(filePath); QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { @@ -6651,7 +6651,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping) { qWarning(interfaceapp) << "Error downloading model: " + errorInfo; addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { - addAssetToWorldSetMapping(filePath, mapping, hash); + addAssetToWorldSetMapping(filePath, mapping, hash, isBlocks); } // Remove temporary directory created by Clara.io market place download. @@ -6668,7 +6668,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping) { upload->start(); } -void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash) { +void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isBlocks) { auto request = DependencyManager::get()->createSetMappingRequest(mapping, hash); connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable { if (request->getError() != SetMappingRequest::NoError) { @@ -6677,8 +6677,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { // to prevent files that aren't models from being loaded into world automatically - if (filePath.endsWith(OBJ_EXTENSION) || filePath.endsWith(FBX_EXTENSION) || - filePath.endsWith(JPG_EXTENSION) || filePath.endsWith(PNG_EXTENSION)) { + if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || + filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && (!isBlocks)) { addAssetToWorldAddEntity(filePath, mapping); } else { qCDebug(interfaceapp) << "Zipped contents are not supported entity files"; diff --git a/interface/src/Application.h b/interface/src/Application.h index ad12a4dc67..8b8e76d584 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -322,9 +322,9 @@ public slots: void addAssetToWorldFromURLRequestFinished(); void addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks); void addAssetToWorldUnzipFailure(QString filePath); - void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy); - void addAssetToWorldUpload(QString filePath, QString mapping); - void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash); + void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isBlocks); + void addAssetToWorldUpload(QString filePath, QString mapping, bool isBlocks); + void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isBlocks); void addAssetToWorldAddEntity(QString filePath, QString mapping); void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isZip, bool isBlocks);