From afa4a696ab06dca87d775ab6d01a2e3674954151 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Mon, 26 Feb 2024 15:56:01 +0100 Subject: [PATCH] Assembly: Fix Object disappears when dragging with slider #12449 --- src/Gui/View3DInventorViewer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 671e6ee5b7..9d64f2f240 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2732,7 +2732,17 @@ SbVec3f View3DInventorViewer::getPointOnLine(const SbVec2s& pnt, const SbVec3f& SbVec3f pt, ptOnFocalPlaneAndOnLine, ptOnFocalPlane; SbPlane focalPlane = vol.getPlane(focalDist); vol.projectPointToLine(pnt2d, line); - focalPlane.intersect(line, ptOnFocalPlane); + + if (!focalPlane.intersect(line, ptOnFocalPlane)) { + return {}; // No intersection found + } + + // Check if line is orthogonal to the focal plane + SbVec3f focalPlaneNormal = focalPlane.getNormal(); + float dotProduct = fabs(axis.dot(focalPlaneNormal)); + if (dotProduct > 1.0 - 1e-6) { + return {}; + } SbLine projectedLine = projectLineOntoPlane(axisCenter, axisCenter + axis, focalPlane); ptOnFocalPlaneAndOnLine = projectedLine.getClosestPoint(ptOnFocalPlane);