From 101040c395e37816e8ab007a58d24cab035e1b60 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Thu, 3 Oct 2024 22:00:22 +0530 Subject: [PATCH] [Sketcher] Apply tangent autoconstraint only when `Dir` given This relates to `seekAutoConstraint` and `seekAndRenderAutoConstraint`. Fixes #16321. --- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index a8383e8a90..93f2074858 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -511,9 +511,12 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested constr.Type = Sketcher::Tangent; } - if (constr.Type == Sketcher::Tangent && Dir.Length() > 1e-8 - && hitShapeDir.Length() - > 1e-8) { // We are hitting a line and have hitting vector information + if (constr.Type == Sketcher::Tangent) { + if (Dir.Length() < 1e-8 || hitShapeDir.Length() < 1e-8) { + // Direction not set so return; + return suggestedConstraints.size(); + } + // We are hitting a line and have hitting vector information Base::Vector3d dir3d = Base::Vector3d(Dir.x, Dir.y, 0); double cosangle = dir3d.Normalize() * hitShapeDir.Normalize();