summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-01-29 19:53:46 +0000
committerMike Krus <mike.krus@kdab.com>2020-01-30 07:02:28 +0000
commita72d8c086ff7c87bce04cbeaa637caf016699d89 (patch)
tree86efe2ee035485929a0b40643e814cd473e19214
parentef7f6e5cc41c1a2bf99fb3ab898e52d9e5262878 (diff)
Remove support for binary json gltf
Binary JSON was deprecated in 5.15. It was never an official gltf format anyway. Could be replaced by CBOR but API is different. Change-Id: If4ac6301addde8aa875fde246055dc8f1c6bcf9d Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/animation/backend/gltfimporter.cpp4
-rw-r--r--src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp4
-rw-r--r--src/plugins/sceneparsers/gltf/gltfimporter.cpp8
-rw-r--r--src/plugins/sceneparsers/gltfexport/gltfexporter.cpp38
-rw-r--r--src/plugins/sceneparsers/gltfexport/gltfexporter.h1
-rw-r--r--src/render/geometry/gltfskeletonloader.cpp4
-rw-r--r--tests/auto/render/gltfplugins/tst_gltfplugins.cpp9
-rw-r--r--tools/qgltf/qgltf.cpp25
8 files changed, 23 insertions, 70 deletions
diff --git a/src/animation/backend/gltfimporter.cpp b/src/animation/backend/gltfimporter.cpp
index a2630fc5e..ff42507f2 100644
--- a/src/animation/backend/gltfimporter.cpp
+++ b/src/animation/backend/gltfimporter.cpp
@@ -435,9 +435,7 @@ GLTFImporter::GLTFImporter()
bool GLTFImporter::load(QIODevice *ioDev)
{
QByteArray jsonData = ioDev->readAll();
- QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData);
- if (sceneDocument.isNull())
- sceneDocument = QJsonDocument::fromJson(jsonData);
+ QJsonDocument sceneDocument = QJsonDocument::fromJson(jsonData);
if (Q_UNLIKELY(!setJSON(sceneDocument))) {
qWarning("not a JSON document");
diff --git a/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp b/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp
index ddb950f86..583b0ec58 100644
--- a/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp
+++ b/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp
@@ -103,9 +103,7 @@ bool GLTFGeometryLoader::load(QIODevice *ioDev, const QString &subMesh)
Q_UNUSED(subMesh);
QByteArray jsonData = ioDev->readAll();
- QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData);
- if (sceneDocument.isNull())
- sceneDocument = QJsonDocument::fromJson(jsonData);
+ QJsonDocument sceneDocument = QJsonDocument::fromJson(jsonData);
if (Q_UNLIKELY(!setJSON(sceneDocument))) {
qCWarning(GLTFGeometryLoaderLog, "not a JSON document");
diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
index a10a83cca..1a33973da 100644
--- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp
@@ -411,9 +411,7 @@ void GLTFImporter::setSource(const QUrl &source)
f.open(QIODevice::ReadOnly);
QByteArray jsonData = f.readAll();
- QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData);
- if (sceneDocument.isNull())
- sceneDocument = QJsonDocument::fromJson(jsonData);
+ QJsonDocument sceneDocument = QJsonDocument::fromJson(jsonData);
if (Q_UNLIKELY(!setJSON(sceneDocument))) {
qCWarning(GLTFImporterLog, "not a JSON document");
@@ -430,9 +428,7 @@ void GLTFImporter::setSource(const QUrl &source)
*/
void GLTFImporter::setData(const QByteArray& data, const QString &basePath)
{
- QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(data);
- if (sceneDocument.isNull())
- sceneDocument = QJsonDocument::fromJson(data);
+ QJsonDocument sceneDocument = QJsonDocument::fromJson(data);
if (Q_UNLIKELY(!setJSON(sceneDocument))) {
qCWarning(GLTFImporterLog, "not a JSON document");
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
index b4b87ef76..0f9a3bef9 100644
--- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
+++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
@@ -284,9 +284,7 @@ GLTFExporter::~GLTFExporter()
// options : Export options.
//
// Supported options are:
-// "binaryJson" (bool): Generates a binary JSON file, which is more efficient to parse.
// "compactJson" (bool): Removes unnecessary whitespace from the generated JSON file.
-// Ignored if "binaryJson" option is true.
/*!
Exports the scene to the GLTF format
@@ -322,8 +320,6 @@ bool GLTFExporter::exportScene(QEntity *sceneRoot, const QString &outDir,
m_renderPassCount = 0;
m_effectCount = 0;
- m_gltfOpts.binaryJson = options.value(QStringLiteral("binaryJson"),
- QVariant(false)).toBool();
m_gltfOpts.compactJson = options.value(QStringLiteral("compactJson"),
QVariant(false)).toBool();
@@ -1582,32 +1578,18 @@ bool GLTFExporter::saveScene()
QString gltfName = m_exportDir + m_exportName + QStringLiteral(".qgltf");
f.setFileName(gltfName);
- qCDebug(GLTFExporterLog, " Writing %sJSON file: '%ls'",
- m_gltfOpts.binaryJson ? "binary " : "", qUtf16PrintableImpl(gltfName));
+ qCDebug(GLTFExporterLog, " Writing JSON file: '%ls'", qUtf16PrintableImpl(gltfName));
- if (m_gltfOpts.binaryJson) {
- if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- m_exportedFiles.insert(QFileInfo(f.fileName()).fileName());
- QByteArray json = m_doc.toBinaryData();
- f.write(json);
- f.close();
- } else {
- qCWarning(GLTFExporterLog, " Writing binary JSON file '%ls' failed!",
- qUtf16PrintableImpl(gltfName));
- return false;
- }
+ if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
+ m_exportedFiles.insert(QFileInfo(f.fileName()).fileName());
+ QByteArray json = m_doc.toJson(m_gltfOpts.compactJson ? QJsonDocument::Compact
+ : QJsonDocument::Indented);
+ f.write(json);
+ f.close();
} else {
- if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
- m_exportedFiles.insert(QFileInfo(f.fileName()).fileName());
- QByteArray json = m_doc.toJson(m_gltfOpts.compactJson ? QJsonDocument::Compact
- : QJsonDocument::Indented);
- f.write(json);
- f.close();
- } else {
- qCWarning(GLTFExporterLog, " Writing JSON file '%ls' failed!",
- qUtf16PrintableImpl(gltfName));
- return false;
- }
+ qCWarning(GLTFExporterLog, " Writing JSON file '%ls' failed!",
+ qUtf16PrintableImpl(gltfName));
+ return false;
}
QString qrcName = m_exportDir + m_exportName + QStringLiteral(".qrc");
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.h b/src/plugins/sceneparsers/gltfexport/gltfexporter.h
index fe6977a6e..e135ea8eb 100644
--- a/src/plugins/sceneparsers/gltfexport/gltfexporter.h
+++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.h
@@ -94,7 +94,6 @@ public:
const QString &exportName, const QVariantHash &options) final;
struct GltfOptions {
- bool binaryJson;
bool compactJson;
};
diff --git a/src/render/geometry/gltfskeletonloader.cpp b/src/render/geometry/gltfskeletonloader.cpp
index 56144747c..7827bce02 100644
--- a/src/render/geometry/gltfskeletonloader.cpp
+++ b/src/render/geometry/gltfskeletonloader.cpp
@@ -317,9 +317,7 @@ GLTFSkeletonLoader::GLTFSkeletonLoader()
bool GLTFSkeletonLoader::load(QIODevice *ioDev)
{
QByteArray jsonData = ioDev->readAll();
- QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData);
- if (sceneDocument.isNull())
- sceneDocument = QJsonDocument::fromJson(jsonData);
+ QJsonDocument sceneDocument = QJsonDocument::fromJson(jsonData);
if (Q_UNLIKELY(!setJSON(sceneDocument))) {
qCWarning(Jobs, "not a JSON document");
diff --git a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp
index 0de94a931..7f40fffcc 100644
--- a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp
+++ b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp
@@ -1131,20 +1131,16 @@ Qt3DCore::QEntity *tst_gltfPlugins::findCameraChild(Qt3DCore::QEntity *entity,
void tst_gltfPlugins::exportAndImport_data()
{
- QTest::addColumn<bool>("binaryJson");
QTest::addColumn<bool>("compactJson");
- QTest::newRow("No options") << false << false;
+ QTest::newRow("No options") << false;
#ifndef VISUAL_CHECK
- QTest::newRow("Binary json") << true << false;
- QTest::newRow("Compact json") << false << true;
- QTest::newRow("Binary/Compact json") << true << true; // Compact is ignored in this case
+ QTest::newRow("Compact json") << true;
#endif
}
void tst_gltfPlugins::exportAndImport()
{
- QFETCH(bool, binaryJson);
QFETCH(bool, compactJson);
createTestScene();
@@ -1164,7 +1160,6 @@ void tst_gltfPlugins::exportAndImport()
Qt3DRender::QSceneExportFactory::create(key, QStringList());
if (exporter != nullptr && key == QStringLiteral("gltfexport")) {
QVariantHash options;
- options.insert(QStringLiteral("binaryJson"), QVariant(binaryJson));
options.insert(QStringLiteral("compactJson"), QVariant(compactJson));
exporter->exportScene(m_sceneRoot1, exportDir, sceneName, options);
break;
diff --git a/tools/qgltf/qgltf.cpp b/tools/qgltf/qgltf.cpp
index 562e50911..814ae7e27 100644
--- a/tools/qgltf/qgltf.cpp
+++ b/tools/qgltf/qgltf.cpp
@@ -216,7 +216,6 @@ static inline QVector<float> ai2qt(const aiMatrix4x4 &matrix)
struct Options {
QString outDir;
- bool genBin;
bool compact;
bool compress;
bool genTangents;
@@ -2451,22 +2450,13 @@ void GltfExporter::save(const QString &inputFilename)
QString gltfName = opts.outDir + basename + QStringLiteral(".qgltf");
f.setFileName(gltfName);
if (opts.showLog)
- qDebug().noquote() << (opts.genBin ? "Writing (binary JSON)" : "Writing") << gltfName;
+ qDebug().noquote() << "Writing" << gltfName;
- if (opts.genBin) {
- if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- m_files.insert(QFileInfo(f.fileName()).fileName());
- QByteArray json = m_doc.toBinaryData();
- f.write(json);
- f.close();
- }
- } else {
- if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
- m_files.insert(QFileInfo(f.fileName()).fileName());
- QByteArray json = m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented);
- f.write(json);
- f.close();
- }
+ if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
+ m_files.insert(QFileInfo(f.fileName()).fileName());
+ QByteArray json = m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented);
+ f.write(json);
+ f.close();
}
QString qrcName = opts.outDir + basename + QStringLiteral(".qrc");
@@ -2509,8 +2499,6 @@ int main(int argc, char **argv)
cmdLine.setApplicationDescription(QString::fromUtf8(description));
QCommandLineOption outDirOpt(QStringLiteral("d"), QStringLiteral("Place all output data into <dir>"), QStringLiteral("dir"));
cmdLine.addOption(outDirOpt);
- QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .qgltf file"));
- cmdLine.addOption(binOpt);
QCommandLineOption compactOpt(QStringLiteral("m"), QStringLiteral("Store compact JSON in the .qgltf file"));
cmdLine.addOption(compactOpt);
QCommandLineOption compOpt(QStringLiteral("c"), QStringLiteral("qCompress() vertex/index data in the .bin file"));
@@ -2533,7 +2521,6 @@ int main(int argc, char **argv)
cmdLine.addOption(silentOpt);
cmdLine.process(app);
opts.outDir = cmdLine.value(outDirOpt);
- opts.genBin = cmdLine.isSet(binOpt);
opts.compact = cmdLine.isSet(compactOpt);
opts.compress = cmdLine.isSet(compOpt);
opts.genTangents = cmdLine.isSet(tangentOpt);