From 387657b83a5cb1db2a7ee3c3abb2d83dc4c99e18 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 11 May 2020 13:01:32 +0300 Subject: [PATCH] QmlDesigner: Add missing camera plane ring to point light model Task-number: QDS-2037 Change-Id: Ica5a7ec2983da251d2ab75565120423288de27a2 Reviewed-by: Thomas Hartmann --- .../qml/qmlpuppet/mockfiles/LightGizmo.qml | 22 +++++++++++++++---- .../qml/qmlpuppet/mockfiles/LightModel.qml | 11 ++-------- .../qml2puppet/editor3d/lightgeometry.cpp | 5 +++++ .../qml2puppet/editor3d/lightgeometry.h | 3 ++- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml index a82d5116752..36c7c2cb38c 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml @@ -73,6 +73,18 @@ Node { view3D: lightGizmo.view3D } + // Camera plane circle for point light mesh + LightModel { + id: pointRing + geometryName: "Edit 3D Circle" + geometryType: LightGeometry.Circle + material: lightMaterial + + visible: lightGizmo.targetNode instanceof PointLight + scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale) + rotation: lightGizmo.view3D.camera.rotation + } + Node { rotation: !lightGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) : lightGizmo.targetNode.sceneRotation @@ -86,7 +98,7 @@ Node { geometryName: "Edit 3D SpotLight" geometryType: LightGeometry.Spot - color: lightGizmo.color + material: lightMaterial visible: lightGizmo.targetNode instanceof SpotLight scale: Qt.vector3d(coneScale, coneScale, lightGizmo.fadeScale) } @@ -122,26 +134,28 @@ Node { id: areaModel geometryName: "Edit 3D AreaLight" geometryType: LightGeometry.Area - color: lightGizmo.color + material: lightMaterial visible: lightGizmo.targetNode instanceof AreaLight scale: visible ? Qt.vector3d(lightGizmo.targetNode.width / 2, lightGizmo.targetNode.height / 2, 1) .times(lightGizmo.targetNode.scale) : Qt.vector3d(1, 1, 1) } + LightModel { id: directionalModel geometryName: "Edit 3D DirLight" geometryType: LightGeometry.Directional - color: lightGizmo.color + material: lightMaterial visible: lightGizmo.targetNode instanceof DirectionalLight scale: autoScale.getScale(Qt.vector3d(50, 50, 50)) } + LightModel { id: pointModel geometryName: "Edit 3D PointLight" geometryType: LightGeometry.Point - color: lightGizmo.color + material: lightMaterial visible: lightGizmo.targetNode instanceof PointLight scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale) } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml index 16f14f090d2..9ccb3c49ae1 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml @@ -32,7 +32,7 @@ Model { property alias geometryName: lightGeometry.name // Name must be unique for each geometry property alias geometryType: lightGeometry.lightType - property color color + property Material material function updateGeometry() { @@ -42,14 +42,7 @@ Model { scale: Qt.vector3d(50, 50, 50) geometry: lightGeometry - materials: [ - DefaultMaterial { - id: defaultMaterial - emissiveColor: lightModel.color - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] + materials: [ material ] LightGeometry { id: lightGeometry diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp index 7b9d898b17c..f6cf51d2cc7 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp @@ -115,6 +115,9 @@ void LightGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData } else if (m_lightType == LightType::Spot) { vertexSize = int(sizeof(float)) * 3 * (segments + 1); indexSize = int(sizeof(quint16)) * (segments + dirLines) * 2; + } else if (m_lightType == LightType::Circle) { + vertexSize = int(sizeof(float)) * 3 * segments; + indexSize = int(sizeof(quint16)) * segments * 2; } vertexData.resize(vertexSize); indexData.resize(indexSize); @@ -173,6 +176,8 @@ void LightGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData *indexPtr++ = tipIndex; *indexPtr++ = i * arc; } + } else if (m_lightType == LightType::Circle) { + createCircle(0, 0.f, 0, 1, 2); } static const float floatMin = std::numeric_limits::lowest(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h index cac375d675e..5ddd2be34c9 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h @@ -43,7 +43,8 @@ public: Spot, Area, Directional, - Point + Point, + Circle // Not a light type, but an auxiliary mesh for point light }; Q_ENUM(LightType)