From f7d363f5f5b4e939318d2bb7c473cb2827e87dd3 Mon Sep 17 00:00:00 2001 From: Sakaria Pouke Date: Wed, 6 Aug 2025 10:43:29 +0300 Subject: [PATCH] Surface: recalculate bounds in updateModel, always set gradient uniforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-138923 Fixes: QTBUG-138924 Pick-to: 6.10 6.9 6.8 Change-Id: I619fd5382e078b225356fd3d6822164ff7db1512 Reviewed-by: Tomi Korpipää --- src/graphs3d/qml/qquickgraphssurface.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/graphs3d/qml/qquickgraphssurface.cpp b/src/graphs3d/qml/qquickgraphssurface.cpp index 7bf0f6e8..d0b7998f 100644 --- a/src/graphs3d/qml/qquickgraphssurface.cpp +++ b/src/graphs3d/qml/qquickgraphssurface.cpp @@ -1449,8 +1449,8 @@ void QQuickGraphsSurface::updateModel(SurfaceModel *model) bool flatShading = model->series->shading() == QSurface3DSeries::Shading::Flat; - QVector3D boundsMin = model->boundsMin; - QVector3D boundsMax = model->boundsMax; + QVector3D boundsMin = QVector3D(); + QVector3D boundsMax = QVector3D(); QVector heights; heights.reserve(totalSize); @@ -1535,8 +1535,14 @@ void QQuickGraphsSurface::updateModel(SurfaceModel *model) } } } - model->boundsMin = boundsMin; - model->boundsMax = boundsMax; + + if (model->boundsMin != boundsMin || model->boundsMax != boundsMax) { + model->boundsMin = boundsMin; + model->boundsMax = boundsMax; + float range = boundsMax.y() - boundsMin.y(); + material->setProperty("gradientMin", -(boundsMin.y() / range)); + material->setProperty("gradientHeight", 1.0f / range); + } QByteArray heightData = QByteArray(reinterpret_cast(heights.data()), heights.size() * sizeof(QVector4D)); @@ -1985,15 +1991,9 @@ void QQuickGraphsSurface::updateMaterial(SurfaceModel *model) material->setProperty("textured", textured); if (isSeriesVisualsDirty()) { - float minY = model->boundsMin.y(); - float maxY = model->boundsMax.y(); - float range = maxY - minY; - switch (model->series->colorStyle()) { case (QGraphsTheme::ColorStyle::ObjectGradient): material->setProperty("colorStyle", 0); - material->setProperty("gradientMin", -(minY / range)); - material->setProperty("gradientHeight", 1.0f / range); break; case (QGraphsTheme::ColorStyle::RangeGradient): material->setProperty("colorStyle", 1); @@ -2053,7 +2053,8 @@ void QQuickGraphsSurface::updateMaterial(SurfaceModel *model) texInput->texture()->setSource(QUrl()); } } - material->setProperty("rootScale", rootNode()->scale().y()); + material->setProperty("rootScale", rootNode()->scale().y() * scaleWithBackground().y()); + bool colorHasTransparency = false; if (model->series->colorStyle() == QGraphsTheme::ColorStyle::Uniform) colorHasTransparency = model->series->baseColor().alphaF() < 1.0;