diff --git a/src/graphs3d/engine/shaders/surface.frag b/src/graphs3d/engine/shaders/surface.frag index 9d1ae18e..36929d1c 100644 --- a/src/graphs3d/engine/shaders/surface.frag +++ b/src/graphs3d/engine/shaders/surface.frag @@ -7,7 +7,7 @@ in layout(location = 9) flat vec3 nF; void MAIN() { - if (any(greaterThan(UV, vec2(1.01)))) + if (any(greaterThan(UV, vec2(1.01))) || abs(VAR_WORLD_POSITION.y) > graphHeight) discard; vec3 color; vec2 gradientUV; diff --git a/src/graphs3d/engine/shaders/surfaceGrid.frag b/src/graphs3d/engine/shaders/surfaceGrid.frag index 62c9bf2e..da4b5ca4 100644 --- a/src/graphs3d/engine/shaders/surfaceGrid.frag +++ b/src/graphs3d/engine/shaders/surfaceGrid.frag @@ -1,4 +1,6 @@ void MAIN() { + if (abs(VAR_WORLD_POSITION.y) > graphHeight) + discard; BASE_COLOR = gridColor; } diff --git a/src/graphs3d/qml/qquickgraphssurface.cpp b/src/graphs3d/qml/qquickgraphssurface.cpp index 8c42dc30..185ccd20 100644 --- a/src/graphs3d/qml/qquickgraphssurface.cpp +++ b/src/graphs3d/qml/qquickgraphssurface.cpp @@ -1158,6 +1158,7 @@ void QQuickGraphsSurface::updateModel(SurfaceModel *model) material->setProperty("rangeMin", QVector2D(columnStart, rowStart)); material->setProperty("range", QVector2D(sampleSpace.width(), sampleSpace.height())); material->setProperty("vertices", QVector2D(columnCount, rowCount)); + material->setProperty("graphHeight", scaleWithBackground().y()); model->vertices.clear(); model->vertices.reserve(totalSize); @@ -1242,6 +1243,7 @@ void QQuickGraphsSurface::updateModel(SurfaceModel *model) gridMaterial->setProperty("gridColor", gridColor); gridMaterial->setProperty("range", QVector2D(sampleSpace.width(), sampleSpace.height())); gridMaterial->setProperty("vertices", QVector2D(columnCount, rowCount)); + gridMaterial->setProperty("graphHeight", scaleWithBackground().y()); m_proxyDirty = true; } @@ -1832,7 +1834,8 @@ bool QQuickGraphsSurface::doPicking(const QPointF &position) if (!pickResult.isEmpty()) { for (auto picked : pickResult) { - if (picked.objectHit() + bool inBounds = qAbs(picked.position().y()) < scaleWithBackground().y(); + if (inBounds && picked.objectHit() && picked.objectHit()->objectName().contains(QStringLiteral("ProxyModel"))) { pickedPos = picked.position(); pickedModel = qobject_cast(picked.objectHit()->parentItem()); diff --git a/src/graphs3d/qml/resources/GridSurfaceMaterial.qml b/src/graphs3d/qml/resources/GridSurfaceMaterial.qml index 210ca149..96515319 100644 --- a/src/graphs3d/qml/resources/GridSurfaceMaterial.qml +++ b/src/graphs3d/qml/resources/GridSurfaceMaterial.qml @@ -10,6 +10,7 @@ CustomMaterial { property vector2d vertices property vector2d range + property real graphHeight vertexShader: "qrc:/shaders/surfaceGridvert" fragmentShader: "qrc:/shaders/surfaceGridfrag" diff --git a/src/graphs3d/qml/resources/SurfaceMaterial.qml b/src/graphs3d/qml/resources/SurfaceMaterial.qml index 3443f2c9..979b7b87 100644 --- a/src/graphs3d/qml/resources/SurfaceMaterial.qml +++ b/src/graphs3d/qml/resources/SurfaceMaterial.qml @@ -14,6 +14,7 @@ CustomMaterial { property vector2d rangeMin property vector2d range property vector2d vertices + property real graphHeight property real gradientMin property real gradientHeight