mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 16:23:17 +02:00
Merge pull request #12580 from elisa-lj11/RC65-blocks-image-bug
Fixed blocks importer textures being interpreted as image entities
This commit is contained in:
commit
260715d616
4 changed files with 29 additions and 14 deletions
|
@ -6607,17 +6607,17 @@ void Application::addAssetToWorld(QString path, QString zipFile, bool isZip, boo
|
||||||
|
|
||||||
addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server.");
|
addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server.");
|
||||||
|
|
||||||
addAssetToWorldWithNewMapping(path, mapping, 0);
|
addAssetToWorldWithNewMapping(path, mapping, 0, isZip, isBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy) {
|
void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isZip, bool isBlocks) {
|
||||||
auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
|
auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
|
||||||
|
|
||||||
QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
|
QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
|
||||||
const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard.
|
const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard.
|
||||||
auto result = request->getError();
|
auto result = request->getError();
|
||||||
if (result == GetMappingRequest::NotFound) {
|
if (result == GetMappingRequest::NotFound) {
|
||||||
addAssetToWorldUpload(filePath, mapping);
|
addAssetToWorldUpload(filePath, mapping, isZip, isBlocks);
|
||||||
} else if (result != GetMappingRequest::NoError) {
|
} else if (result != GetMappingRequest::NoError) {
|
||||||
QString errorInfo = "Could not map asset name: "
|
QString errorInfo = "Could not map asset name: "
|
||||||
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
||||||
|
@ -6629,7 +6629,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin
|
||||||
}
|
}
|
||||||
copy++;
|
copy++;
|
||||||
mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
|
mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
|
||||||
addAssetToWorldWithNewMapping(filePath, mapping, copy);
|
addAssetToWorldWithNewMapping(filePath, mapping, copy, isZip, isBlocks);
|
||||||
} else {
|
} else {
|
||||||
QString errorInfo = "Too many copies of asset name: "
|
QString errorInfo = "Too many copies of asset name: "
|
||||||
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
||||||
|
@ -6642,7 +6642,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin
|
||||||
request->start();
|
request->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldUpload(QString filePath, QString mapping) {
|
void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool isZip, bool isBlocks) {
|
||||||
qInfo(interfaceapp) << "Uploading" << filePath << "to Asset Server as" << mapping;
|
qInfo(interfaceapp) << "Uploading" << filePath << "to Asset Server as" << mapping;
|
||||||
auto upload = DependencyManager::get<AssetClient>()->createUpload(filePath);
|
auto upload = DependencyManager::get<AssetClient>()->createUpload(filePath);
|
||||||
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
|
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;
|
qWarning(interfaceapp) << "Error downloading model: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
} else {
|
} else {
|
||||||
addAssetToWorldSetMapping(filePath, mapping, hash);
|
addAssetToWorldSetMapping(filePath, mapping, hash, isZip, isBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove temporary directory created by Clara.io market place download.
|
// Remove temporary directory created by Clara.io market place download.
|
||||||
|
@ -6668,7 +6668,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping) {
|
||||||
upload->start();
|
upload->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash) {
|
void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isZip, bool isBlocks) {
|
||||||
auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash);
|
auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash);
|
||||||
connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable {
|
connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable {
|
||||||
if (request->getError() != SetMappingRequest::NoError) {
|
if (request->getError() != SetMappingRequest::NoError) {
|
||||||
|
@ -6676,9 +6676,10 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q
|
||||||
qWarning(interfaceapp) << "Error downloading model: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading model: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
} else {
|
} else {
|
||||||
// to prevent files that aren't models from being loaded into world automatically
|
// to prevent files that aren't models or texture files from being loaded into world automatically
|
||||||
if (filePath.endsWith(OBJ_EXTENSION) || filePath.endsWith(FBX_EXTENSION) ||
|
if ((filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION)) ||
|
||||||
filePath.endsWith(JPG_EXTENSION) || filePath.endsWith(PNG_EXTENSION)) {
|
((filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION)) &&
|
||||||
|
((!isBlocks) && (!isZip)))) {
|
||||||
addAssetToWorldAddEntity(filePath, mapping);
|
addAssetToWorldAddEntity(filePath, mapping);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(interfaceapp) << "Zipped contents are not supported entity files";
|
qCDebug(interfaceapp) << "Zipped contents are not supported entity files";
|
||||||
|
|
|
@ -320,11 +320,11 @@ public slots:
|
||||||
// FIXME: Move addAssetToWorld* methods to own class?
|
// FIXME: Move addAssetToWorld* methods to own class?
|
||||||
void addAssetToWorldFromURL(QString url);
|
void addAssetToWorldFromURL(QString url);
|
||||||
void addAssetToWorldFromURLRequestFinished();
|
void addAssetToWorldFromURLRequestFinished();
|
||||||
void addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks);
|
void addAssetToWorld(QString filePath, QString zipFile, bool isZip = false, bool isBlocks = false);
|
||||||
void addAssetToWorldUnzipFailure(QString filePath);
|
void addAssetToWorldUnzipFailure(QString filePath);
|
||||||
void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy);
|
void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isZip = false, bool isBlocks = false);
|
||||||
void addAssetToWorldUpload(QString filePath, QString mapping);
|
void addAssetToWorldUpload(QString filePath, QString mapping, bool isZip = false, bool isBlocks = false);
|
||||||
void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash);
|
void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isZip = false, bool isBlocks = false);
|
||||||
void addAssetToWorldAddEntity(QString filePath, QString mapping);
|
void addAssetToWorldAddEntity(QString filePath, QString mapping);
|
||||||
|
|
||||||
void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isZip, bool isBlocks);
|
void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isZip, bool isBlocks);
|
||||||
|
|
|
@ -68,6 +68,10 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool
|
||||||
if (path.contains("vr.google.com/downloads")) {
|
if (path.contains("vr.google.com/downloads")) {
|
||||||
isZip = true;
|
isZip = true;
|
||||||
}
|
}
|
||||||
|
if (!hasModel(fileList)) {
|
||||||
|
isZip = false;
|
||||||
|
}
|
||||||
|
|
||||||
emit unzipResult(path, fileList, autoAdd, isZip, isBlocks);
|
emit unzipResult(path, fileList, autoAdd, isZip, isBlocks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,6 +111,15 @@ bool FileScriptingInterface::isTempDir(QString tempDir) {
|
||||||
return (testContainer == tempContainer);
|
return (testContainer == tempContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileScriptingInterface::hasModel(QStringList fileList) {
|
||||||
|
for (int i = 0; i < fileList.size(); i++) {
|
||||||
|
if (fileList.at(i).toLower().contains(".fbx") || fileList.at(i).toLower().contains(".obj")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString FileScriptingInterface::getTempDir() {
|
QString FileScriptingInterface::getTempDir() {
|
||||||
QTemporaryDir dir;
|
QTemporaryDir dir;
|
||||||
dir.setAutoRemove(false);
|
dir.setAutoRemove(false);
|
||||||
|
|
|
@ -32,6 +32,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isTempDir(QString tempDir);
|
bool isTempDir(QString tempDir);
|
||||||
|
bool hasModel(QStringList fileList);
|
||||||
QStringList unzipFile(QString path, QString tempDir);
|
QStringList unzipFile(QString path, QString tempDir);
|
||||||
void recursiveFileScan(QFileInfo file, QString* dirName);
|
void recursiveFileScan(QFileInfo file, QString* dirName);
|
||||||
void downloadZip(QString path, const QString link);
|
void downloadZip(QString path, const QString link);
|
||||||
|
|
Loading…
Reference in a new issue