summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2018-05-28 12:25:16 +0200
committerAndy Nichols <andy.nichols@qt.io>2018-05-28 10:53:11 +0000
commit9d89536db50d7cf5fe873e94053f61baa9dd293a (patch)
treecea59c2fe75483821240861188d0daa113b1dc14
parent58f54fde6c6a99225cefca183ec29f612177cb31 (diff)
When no part in model mesh with sub-meshes use last instead of first
This resolves an issue with .mesh files generated by older versions of Q3DS that stored revisions in the .mesh file. The models did not explicitly specify a part number for the latest revision, so the oldest revision would be used instead because that was part #1. Now when a mesh source has no part number, we will by default use the last mesh in the mesh list. This will still typically be #1 because non- submesh meshes still will only have 1 part entry. Task-number: QT3DS-1791 Change-Id: I8c9633c545c2f4f1fa325d9b0a28ab5981acd3b6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/runtime/q3dsmeshloader.cpp6
-rw-r--r--src/runtime/q3dsuippresentation.cpp6
-rw-r--r--tests/auto/uipparser/tst_q3dsuipparser.cpp2
3 files changed, 12 insertions, 2 deletions
diff --git a/src/runtime/q3dsmeshloader.cpp b/src/runtime/q3dsmeshloader.cpp
index 4b6f9fc..d01732a 100644
--- a/src/runtime/q3dsmeshloader.cpp
+++ b/src/runtime/q3dsmeshloader.cpp
@@ -775,14 +775,20 @@ MeshList loadMeshDataFromMulti(const QString &path, int id, bool useQt3DAttribut
QMap<quint32, MeshMultiEntry> entries;
quint64 multiOffset = multiHeaderStart - size * sizeof(MeshMultiEntry);
meshFile.seek(multiOffset);
+ quint32 lastEntry = 1;
for (quint32 i = 0; i < size; ++i) {
MeshMultiEntry entry;
meshFileStream >> entry.m_MeshOffset;
meshFileStream >> entry.m_MeshId;
meshFileStream >> entry.m_Padding;
entries.insert(entry.m_MeshId, entry);
+ lastEntry = entry.m_MeshId;
}
+ // QT3DS-1791: If no part is specified, use the last entry (newest revisions)
+ if (id == -1)
+ id = int(lastEntry);
+
// Load mesh data
MeshList meshList;
if (entries.contains(id)) {
diff --git a/src/runtime/q3dsuippresentation.cpp b/src/runtime/q3dsuippresentation.cpp
index 75bef24..66c03bb 100644
--- a/src/runtime/q3dsuippresentation.cpp
+++ b/src/runtime/q3dsuippresentation.cpp
@@ -3910,8 +3910,12 @@ QString Q3DSUipPresentation::assetFileName(const QString &xmlFileNameRef, int *p
*part = idx;
rawName = rawName.left(pos);
} else {
+ // If no part is specified return -1 so the mesh parser can decide which
+ // part is the best. This will usually be 1 but for older versions
+ // of the editor multi-meshes were used for revisions, and we would
+ // need to return the last part in the list, not the first.
if (part)
- *part = 1;
+ *part = -1;
}
rawName.replace('\\', '/');
diff --git a/tests/auto/uipparser/tst_q3dsuipparser.cpp b/tests/auto/uipparser/tst_q3dsuipparser.cpp
index f6a5d5a..e93eb3b 100644
--- a/tests/auto/uipparser/tst_q3dsuipparser.cpp
+++ b/tests/auto/uipparser/tst_q3dsuipparser.cpp
@@ -195,7 +195,7 @@ void tst_Q3DSUipParser::assetRef()
part = -123;
fn = pres->assetFileName("something", &part);
QCOMPARE(fn, QLatin1String(":/data/something"));
- QCOMPARE(part, 1);
+ QCOMPARE(part, -1);
fn = pres->assetFileName("/absolute/blah#32", &part);
QCOMPARE(fn, QLatin1String("/absolute/blah"));