diff options
author | Andy Nichols <andy.nichols@theqtcompany.com> | 2015-08-05 11:34:00 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@theqtcompany.com> | 2015-08-08 12:55:39 +0000 |
commit | a3fc4b556c6cac9a7e048493f5136a4ee75e1459 (patch) | |
tree | 77662fc9f5ac9d2e60341a86e8c236698a6c0cc8 | |
parent | 473bd13ed373c4cc24bdd3211ee90a070a466ce2 (diff) |
glTF Parser: Support loading binary json scene data
We support generating gltf files using binary json rather than plain text
with our qgltf tool. This reduces metadata file sizes and load times.
Change-Id: I99a4c270aa4b0b828cddfbdcce02dce206606708
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/plugins/sceneparsers/gltf/gltfparser.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp index a4a0602c2..ba39e74ba 100644 --- a/src/plugins/sceneparsers/gltf/gltfparser.cpp +++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp @@ -189,7 +189,12 @@ void GLTFParser::setSource(const QUrl &source) QFile f(path); f.open(QIODevice::ReadOnly); - if (!setJSON(QJsonDocument::fromJson(f.readAll()))) { + QByteArray jsonData = f.readAll(); + QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData); + if (sceneDocument.isNull()) + sceneDocument = QJsonDocument::fromJson(jsonData); + + if (!setJSON(sceneDocument)) { qCWarning(GLTFParserLog) << "not a JSON document"; return; } |