forked from qt-creator/qt-creator
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 <thomas.hartmann@qt.io>
This commit is contained in:
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user