From 5a4a524f8e242b4669a1a97619d7448d013ff11d Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 29 Jun 2016 15:28:02 +0300 Subject: Don't save camera projection matrix Projection matrix can be calculated from other values, so storing it is unnecessary. Setting it explicitly changes the projection type to custom, which we don't support. Change-Id: Iec7f8b08f52c1693aa9e4dde4c896e994fc8b364 Reviewed-by: Mika Salmela Reviewed-by: Titta Heikkala --- .../GeneratedScene_scene_res/GeneratedScene.qml | 1 - editorlib/src/editorsceneparser.cpp | 19 ++++++++++++++++++- editorlib/src/editorsceneparser.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/creatorplugin/tocreator/qt3dsceneeditor/GeneratedScene_scene_res/GeneratedScene.qml b/creatorplugin/tocreator/qt3dsceneeditor/GeneratedScene_scene_res/GeneratedScene.qml index c01c07f..ff262d9 100644 --- a/creatorplugin/tocreator/qt3dsceneeditor/GeneratedScene_scene_res/GeneratedScene.qml +++ b/creatorplugin/tocreator/qt3dsceneeditor/GeneratedScene_scene_res/GeneratedScene.qml @@ -64,7 +64,6 @@ Scene3D { farPlane: 50 fieldOfView: 45 aspectRatio: 1.7777777910232544 - projectionMatrix: Qt.matrix4x4(1.358,0,0,0,0,2.41421,0,0,0,0,-1.00401,-0.200401,0,0,-1,0) position: Qt.vector3d(4,5,-5) viewCenter: Qt.vector3d(0,0,0) } diff --git a/editorlib/src/editorsceneparser.cpp b/editorlib/src/editorsceneparser.cpp index 06d004a..fa2185b 100644 --- a/editorlib/src/editorsceneparser.cpp +++ b/editorlib/src/editorsceneparser.cpp @@ -730,7 +730,10 @@ void EditorSceneParser::outEntity(Qt3DCore::QEntity *entity) m_idMap.insert(quint64(entity), entityId); outItemId(entityId); - outGenericProperties(type, entity); + if (type == Camera) + outCamera(entity); + else + outGenericProperties(type, entity); // Output components Qt3DCore::QComponentVector componentList = entity->components(); @@ -1071,6 +1074,20 @@ void EditorSceneParser::outSceneLoader(Qt3DCore::QComponent *component) outGenericProperties(SceneLoader, component); } +void EditorSceneParser::outCamera(Qt3DCore::QEntity *entity) +{ + QVector properties = m_propertyMap.value(Camera); + QObject *defaultObject = m_defaultObjectMap.value(Camera); + for (int i = 0; i < properties.size(); i++) { + QString propertyName = properties.at(i).name(); + // Skip storing projection matrix for cameras, as setting it explicitly changes camera + // projectionType to CustomProjection, which we don't support. + // Also, projection matrix will be determined from other values, so storing it is unnecessary. + if (propertyName != QStringLiteral("projectionMatrix")) + outGenericProperty(entity, properties.at(i), defaultObject); + } +} + QString EditorSceneParser::indent() const { return QString(m_spaceArray.constData(), m_indentLevel * 4); diff --git a/editorlib/src/editorsceneparser.h b/editorlib/src/editorsceneparser.h index 4525346..be5e440 100644 --- a/editorlib/src/editorsceneparser.h +++ b/editorlib/src/editorsceneparser.h @@ -124,6 +124,7 @@ private: const QMetaProperty &property, const QObject *defaultComponent); void outHelperFunctions(); void outSceneLoader(Qt3DCore::QComponent *component); + void outCamera(Qt3DCore::QEntity *entity); QString indent() const; EditorItemType itemType(QObject *item) const; -- cgit v1.2.3