From b441988b5844301d913fdef8262a4e4de61b5faf Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 14 May 2020 17:29:31 +0300 Subject: [PATCH] QmlDesigner: Add fade control handle to point light gizmo Also changed the point light mesh to just a single camera plane ring based on discussions with UX. Change-Id: If9e847440570bbe87483194c0b417cf09c7084a2 Fixes: QDS-2041 Reviewed-by: Thomas Hartmann --- .../qml/qmlpuppet/mockfiles/FadeHandle.qml | 3 +- .../qml/qmlpuppet/mockfiles/LightGizmo.qml | 53 ++++++++++++------- .../qml2puppet/editor3d/lightgeometry.cpp | 12 +---- .../qml2puppet/editor3d/lightgeometry.h | 3 +- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/FadeHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/FadeHandle.qml index 76e52272c27..6c0d86a9e48 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/FadeHandle.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/FadeHandle.qml @@ -33,6 +33,7 @@ DirectionalDraggable { property point currentMousePos property real fadeScale property real baseScale: 5 + property real dragScale: 1 scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale)) length: 3 @@ -98,7 +99,7 @@ DirectionalDraggable { } onPressed: { - _startScale = autoScaler.relativeScale * baseScale * 2; + _startScale = autoScaler.relativeScale * baseScale * dragScale; _startFadeScale = fadeScale; _l = targetNode.linearFade; _c = targetNode.constantFade; diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml index a2c8667370a..ee1c5017eff 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml @@ -61,7 +61,7 @@ Node { || spotLightFadeHandle.dragging || areaHeightHandle.dragging || areaWidthHandle.dragging - + || pointLightFadeHandle.dragging property point currentMousePos property string currentLabel @@ -79,18 +79,41 @@ 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) + Node { + id: pointLightParts rotation: lightGizmo.view3D.camera.rotation + visible: lightGizmo.targetNode instanceof PointLight + + LightModel { + id: pointModel + geometryName: "Edit 3D PointLight" + geometryType: LightGeometry.Point + material: lightMaterial + scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale) + } + + FadeHandle { + id: pointLightFadeHandle + view3D: lightGizmo.view3D + color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color + position: lightGizmo.targetNode instanceof PointLight ? Qt.vector3d(-pointModel.scale.x, 0, 0) + : Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, -90) + targetNode: lightGizmo.targetNode instanceof PointLight ? lightGizmo.targetNode : null + active: lightGizmo.targetNode instanceof PointLight + dragHelper: lightGizmo.dragHelper + fadeScale: lightGizmo.fadeScale + + onCurrentMousePosChanged: { + lightGizmo.currentMousePos = currentMousePos; + lightGizmo.currentLabel = currentLabel; + } + onValueChange: lightGizmo.propertyValueChange(propName) + onValueCommit: lightGizmo.propertyValueCommit(propName) + } } + Node { rotation: !lightGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) : lightGizmo.targetNode.sceneRotation @@ -193,6 +216,7 @@ Node { active: lightGizmo.targetNode instanceof SpotLight dragHelper: lightGizmo.dragHelper fadeScale: lightGizmo.fadeScale + dragScale: 2 onCurrentMousePosChanged: { lightGizmo.currentMousePos = currentMousePos; @@ -272,15 +296,6 @@ Node { scale: autoScaler.getScale(Qt.vector3d(50, 50, 50)) } - LightModel { - id: pointModel - geometryName: "Edit 3D PointLight" - geometryType: LightGeometry.Point - material: lightMaterial - visible: lightGizmo.targetNode instanceof PointLight - scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale) - } - AdjustableArrow { id: primaryArrow eulerRotation: Qt.vector3d(-90, 0, 0) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp index f6cf51d2cc7..cebf3232f13 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp @@ -108,14 +108,10 @@ void LightGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData // Directional light model is a circle with perpendicular lines on circumference vertices vertexSize = int(sizeof(float)) * 3 * (segments + dirLines); indexSize = int(sizeof(quint16)) * (segments + dirLines) * 2; - } else if (m_lightType == LightType::Point) { - // Point light model is a set of three perpendicular circles - vertexSize = int(sizeof(float)) * 3 * segments * 3; - indexSize = int(sizeof(quint16)) * segments * 2 * 3; } 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) { + } else if (m_lightType == LightType::Point) { vertexSize = int(sizeof(float)) * 3 * segments; indexSize = int(sizeof(quint16)) * segments * 2; } @@ -160,10 +156,6 @@ void LightGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData *indexPtr++ = i * arc; *indexPtr++ = i + segments; } - } else if (m_lightType == LightType::Point) { - createCircle(0, 0.f, 0, 1, 2); - createCircle(segments, 0.f, 2, 0, 1); - createCircle(segments * 2, 0.f, 1, 2, 0); } else if (m_lightType == LightType::Spot) { createCircle(0, -1.f, 0, 1, 2); @@ -176,7 +168,7 @@ void LightGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData *indexPtr++ = tipIndex; *indexPtr++ = i * arc; } - } else if (m_lightType == LightType::Circle) { + } else if (m_lightType == LightType::Point) { createCircle(0, 0.f, 0, 1, 2); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h index 5ddd2be34c9..cac375d675e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h @@ -43,8 +43,7 @@ public: Spot, Area, Directional, - Point, - Circle // Not a light type, but an auxiliary mesh for point light + Point }; Q_ENUM(LightType)