From 9bdaf0bae2ba857204e3ed95c7683ab9baa4df8b Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 22 Nov 2022 12:36:51 +0100 Subject: [PATCH] Gizmo measure - Fixed incorrect point on feature detection --- src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 139584799..1e4ba61c7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -666,7 +666,7 @@ void GLGizmoMeasure::on_render() return trafo * p.cast(); } } - return Vec3d::Zero(); + return Vec3d(DBL_MAX, DBL_MAX, DBL_MAX); }; if (m_curr_feature.has_value()) { @@ -683,8 +683,11 @@ void GLGizmoMeasure::on_render() const std::optional extra = m_curr_feature->get_extra_point(); if (extra.has_value() && m_hover_id == POINT_ID) m_curr_point_on_feature_position = *extra; - else - m_curr_point_on_feature_position = position_on_feature(EDGE_ID, camera, [](const Vec3f& v) { return Vec3f(0.0f, 0.0f, v.z()); }); + else { + const Vec3d pos = position_on_feature(EDGE_ID, camera, [](const Vec3f& v) { return Vec3f(0.0f, 0.0f, v.z()); }); + if (!pos.isApprox(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))) + m_curr_point_on_feature_position = pos; + } break; } case Measure::SurfaceFeatureType::Plane: @@ -715,6 +718,7 @@ void GLGizmoMeasure::on_render() } } else { + m_curr_point_on_feature_position.reset(); if (m_curr_feature.has_value() && m_curr_feature->get_type() == Measure::SurfaceFeatureType::Circle) { if (update_circle()) { m_parent.remove_raycasters_for_picking(SceneRaycaster::EType::Gizmo, CIRCLE_ID);