summaryrefslogtreecommitdiffstats
path: root/src/plugins/sceneparsers
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2018-01-17 11:49:32 +0000
committerSean Harmer <sean.harmer@kdab.com>2018-01-17 11:49:32 +0000
commitb420edb0b5e914b83c35a071b371d0759eba4d3d (patch)
treee84852a8c44a18fe6aeadf29cba5dcdefe8e9e58 /src/plugins/sceneparsers
parent24b2599b91c51ae4b7f2c161cf46696bbde67624 (diff)
parente9594f27ccad5667ebc27451f87184296c5cd297 (diff)
Merge branch '5.10' into dev
Conflicts: .qmake.conf Change-Id: I248aa369ba98659a61e563fd29cc811c76ea1e2d
Diffstat (limited to 'src/plugins/sceneparsers')
-rw-r--r--src/plugins/sceneparsers/assimp/assimpimporter.cpp2
-rw-r--r--src/plugins/sceneparsers/gltf/gltfimporter.cpp5
-rw-r--r--src/plugins/sceneparsers/gltfexport/gltfexporter.cpp52
3 files changed, 36 insertions, 23 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.cpp b/src/plugins/sceneparsers/assimp/assimpimporter.cpp
index 3a06c7807..66446ced5 100644
--- a/src/plugins/sceneparsers/assimp/assimpimporter.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpimporter.cpp
@@ -380,7 +380,7 @@ AssimpImporter::~AssimpImporter()
*/
bool AssimpImporter::areAssimpExtensions(const QStringList &extensions)
{
- for (const auto ext : qAsConst(extensions))
+ for (const auto &ext : qAsConst(extensions))
if (AssimpImporter::assimpSupportedFormatsList.contains(ext.toLower()))
return true;
return false;
diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
index 4419bd708..9b8057334 100644
--- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
@@ -1107,7 +1107,7 @@ void GLTFImporter::cleanup()
m_shaderPaths.clear();
delete_if_without_parent(m_programs);
m_programs.clear();
- for (auto params : qAsConst(m_techniqueParameters))
+ for (const auto &params : qAsConst(m_techniqueParameters))
delete_if_without_parent(params);
m_techniqueParameters.clear();
delete_if_without_parent(m_techniques);
@@ -1581,7 +1581,8 @@ void GLTFImporter::processJSONExtensions(const QString &id, const QJsonObject &j
// level GLTF item.
if (id == KEY_COMMON_MAT) {
const auto lights = jsonObject.value(KEY_LIGHTS).toObject();
- for (const auto &lightKey : lights.keys()) {
+ const auto keys = lights.keys();
+ for (const auto &lightKey : keys) {
const auto light = lights.value(lightKey).toObject();
auto lightType = light.value(KEY_TYPE).toString();
const auto lightValues = light.value(lightType).toObject();
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
index ba100e095..56c94a19c 100644
--- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
+++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
@@ -394,7 +394,7 @@ bool GLTFExporter::exportScene(QEntity *sceneRoot, const QString &outDir,
QFile::Permissions targetPermissions = gltfFile.permissions();
// Copy exported scene to actual export directory
- for (const auto &sourceFileStr : m_exportedFiles) {
+ for (const auto &sourceFileStr : qAsConst(m_exportedFiles)) {
QFileInfo fiSource(m_exportDir + sourceFileStr);
QFileInfo fiDestination(finalExportDir + sourceFileStr);
if (fiDestination.exists()) {
@@ -548,7 +548,7 @@ void GLTFExporter::copyTextures()
void GLTFExporter::createShaders()
{
qCDebug(GLTFExporterLog, "Creating shaders...");
- for (const auto &si : m_shaderInfo) {
+ for (const auto &si : qAsConst(m_shaderInfo)) {
const QString fileName = m_exportDir + si.uri;
QFile f(fileName);
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
@@ -571,7 +571,8 @@ void GLTFExporter::parseEntities(const QEntity *entity, Node *parentNode)
node->uniqueName = newNodeName();
int irrelevantComponents = 0;
- for (auto component : entity->components()) {
+ const auto components = entity->components();
+ for (auto component : components) {
if (auto mesh = qobject_cast<QGeometryRenderer *>(component))
m_meshMap.insert(node, mesh);
else if (auto material = qobject_cast<QMaterial *>(component))
@@ -812,7 +813,8 @@ void GLTFExporter::parseMeshes()
uint stride(0);
- for (QAttribute *att : meshGeometry->attributes()) {
+ const auto attributes = meshGeometry->attributes();
+ for (QAttribute *att : attributes) {
if (att->attributeType() == QAttribute::IndexAttribute) {
indexAttrib = att;
indexPtr = reinterpret_cast<const quint16 *>(att->buffer()->data().constData());
@@ -969,11 +971,12 @@ void GLTFExporter::parseMeshes()
qCDebug(GLTFExporterLog, " Vertex buffer size (bytes): %i", vertexBuf.size());
qCDebug(GLTFExporterLog, " Index buffer size (bytes): %i", indexBuf.size());
QStringList sl;
- for (const auto &bv : meshInfo.views)
+ const auto views = meshInfo.views;
+ for (const auto &bv : views)
sl << bv.name;
qCDebug(GLTFExporterLog) << " buffer views:" << sl;
sl.clear();
- for (const auto &acc : meshInfo.accessors)
+ for (const auto &acc : qAsConst(meshInfo.accessors))
sl << acc.name;
qCDebug(GLTFExporterLog) << " accessors:" << sl;
qCDebug(GLTFExporterLog, " material: '%ls'",
@@ -1091,7 +1094,8 @@ void GLTFExporter::parseTechniques(QMaterial *material)
int techniqueCount = 0;
qCDebug(GLTFExporterLog, " Parsing material techniques...");
- for (auto technique : material->effect()->techniques()) {
+ const auto techniques = material->effect()->techniques();
+ for (auto technique : techniques) {
QString techName;
if (m_techniqueIdMap.contains(technique)) {
techName = m_techniqueIdMap.value(technique);
@@ -1116,7 +1120,8 @@ void GLTFExporter::parseRenderPasses(QTechnique *technique)
int passCount = 0;
qCDebug(GLTFExporterLog, " Parsing render passes for technique...");
- for (auto pass : technique->renderPasses()) {
+ const auto renderPasses = technique->renderPasses();
+ for (auto pass : renderPasses) {
QString name;
if (m_renderPassIdMap.contains(pass)) {
name = m_renderPassIdMap.value(pass);
@@ -1158,7 +1163,7 @@ QString GLTFExporter::addShaderInfo(QShaderProgram::ShaderType type, QByteArray
if (code.isEmpty())
return QString();
- for (const auto &si : m_shaderInfo) {
+ for (const auto &si : qAsConst(m_shaderInfo)) {
if (si.type == QShaderProgram::Vertex && code == si.code)
return si.name;
}
@@ -1223,7 +1228,7 @@ bool GLTFExporter::saveScene()
m_obj["buffers"] = buffers;
QJsonObject bufferViews;
- for (const auto &bv : bvList) {
+ for (const auto &bv : qAsConst(bvList)) {
QJsonObject bufferView;
bufferView["buffer"] = QStringLiteral("buf");
bufferView["byteLength"] = int(bv.length);
@@ -1236,7 +1241,7 @@ bool GLTFExporter::saveScene()
m_obj["bufferViews"] = bufferViews;
QJsonObject accessors;
- for (const auto &acc : accList) {
+ for (const auto &acc : qAsConst(accList)) {
QJsonObject accessor;
accessor["bufferView"] = acc.bufferView;
accessor["byteOffset"] = int(acc.offset);
@@ -1265,7 +1270,8 @@ bool GLTFExporter::saveScene()
QJsonObject prim;
prim["mode"] = 4; // triangles
QJsonObject attrs;
- for (const auto &acc : meshInfo.accessors) {
+ const auto meshAccessors = meshInfo.accessors;
+ for (const auto &acc : meshAccessors) {
if (acc.usage != QStringLiteral("INDEX"))
attrs[acc.usage] = acc.name;
else
@@ -1282,7 +1288,7 @@ bool GLTFExporter::saveScene()
m_obj["meshes"] = meshes;
QJsonObject cameras;
- for (auto camInfo : qAsConst(m_cameraInfo)) {
+ for (const auto &camInfo : qAsConst(m_cameraInfo)) {
QJsonObject camera;
QJsonObject proj;
proj["znear"] = camInfo.znear;
@@ -1394,14 +1400,16 @@ bool GLTFExporter::saveScene()
QJsonObject effectObj;
QJsonObject paramObj;
- for (QParameter *param : effect->parameters())
+ const auto effectParameters = effect->parameters();
+ for (QParameter *param : effectParameters)
exportParameter(paramObj, param->name(), param->value());
if (!effect->objectName().isEmpty())
effectObj["name"] = effect->objectName();
if (!paramObj.isEmpty())
effectObj["parameters"] = paramObj;
QJsonArray techs;
- for (auto tech : effect->techniques())
+ const auto effectTechniques = effect->techniques();
+ for (auto tech : effectTechniques)
techs << m_techniqueIdMap.value(tech);
effectObj["techniques"] = techs;
effects[effectName] = effectObj;
@@ -1419,13 +1427,16 @@ bool GLTFExporter::saveScene()
QJsonObject paramObj;
QJsonArray renderPassArr;
- for (QFilterKey *filterKey : technique->filterKeys())
+ const auto techniqueFilterKeys = technique->filterKeys();
+ for (QFilterKey *filterKey : techniqueFilterKeys)
setVarToJSonObject(filterKeyObj, filterKey->name(), filterKey->value());
- for (QRenderPass *pass : technique->renderPasses())
+ const auto techniqueRenderPasses = technique->renderPasses();
+ for (QRenderPass *pass : techniqueRenderPasses)
renderPassArr << m_renderPassIdMap.value(pass);
- for (QParameter *param : technique->parameters())
+ const auto techniqueParameters = technique->parameters();
+ for (QParameter *param : techniqueParameters)
exportParameter(paramObj, param->name(), param->value());
const QGraphicsApiFilter *gFilter = technique->graphicsApiFilter();
@@ -1517,7 +1528,7 @@ bool GLTFExporter::saveScene()
// Save shaders for custom materials
QJsonObject shaders;
- for (const auto &si : m_shaderInfo) {
+ for (const auto &si : qAsConst(m_shaderInfo)) {
QJsonObject shaderObj;
shaderObj["uri"] = si.uri;
shaders[si.name] = shaderObj;
@@ -1885,7 +1896,8 @@ void GLTFExporter::exportRenderStates(QJsonObject &jsonObj, const QRenderPass *p
{
QJsonArray enableStates;
QJsonObject funcObj;
- for (QRenderState *state : pass->renderStates()) {
+ const auto renderStates = pass->renderStates();
+ for (QRenderState *state : renderStates) {
QJsonArray arr;
if (qobject_cast<QAlphaCoverage *>(state)) {
enableStates << GL_SAMPLE_ALPHA_TO_COVERAGE;