mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-12 21:41:13 +00:00
fix: crash in Measure tool when a plain edge is the first selection (#14538)
* fix: crash in Measure tool when a plain edge is the first selection The SPHERE_2 gripper raycaster called get_feature_offset() on .first.feature instead of .second.feature (copy-pasted from the SPHERE_1 block). Plain planar-border edges store no extra point, so the Edge branch dereferenced an empty optional behind a release-stripped assert, aborting on Flatpak and undefined behavior elsewhere. Point the SPHERE_2 raycaster at .second.feature and fall the Edge branch back to the edge midpoint. Fixes #14018
This commit is contained in:
@@ -91,9 +91,14 @@ Vec3d GLGizmoMeasure::get_feature_offset(const Measure::SurfaceFeature &feature)
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Edge:
|
||||
{
|
||||
std::optional<Vec3d> p = feature.get_extra_point();
|
||||
assert(p.has_value());
|
||||
ret = *p;
|
||||
// Only polygon edges store an extra point (the polygon centre); plain edges have none.
|
||||
const std::optional<Vec3d> extra = feature.get_extra_point();
|
||||
if (extra.has_value())
|
||||
ret = *extra;
|
||||
else {
|
||||
const auto [pt1, pt2] = feature.get_edge();
|
||||
ret = 0.5 * (pt1 + pt2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Point:
|
||||
@@ -1065,7 +1070,7 @@ void GLGizmoMeasure::on_render()
|
||||
|
||||
if (requires_raycaster_update) {
|
||||
if (m_gripper_id_raycast_map.find(GripperType::SPHERE_2) != m_gripper_id_raycast_map.end()) {
|
||||
m_gripper_id_raycast_map[GripperType::SPHERE_2]->set_transform(Geometry::translation_transform(get_feature_offset(*m_selected_features.first.feature)) *
|
||||
m_gripper_id_raycast_map[GripperType::SPHERE_2]->set_transform(Geometry::translation_transform(get_feature_offset(*m_selected_features.second.feature)) *
|
||||
Geometry::scale_transform(inv_zoom));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user