mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
FDM supports gizmo: fixed a crash when trying to paint on the clipping plane
This commit is contained in:
parent
9c365da828
commit
feb591782f
1 changed files with 101 additions and 98 deletions
|
@ -308,7 +308,7 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
const Transform3d& instance_trafo = mi->get_transformation().get_matrix();
|
const Transform3d& instance_trafo = mi->get_transformation().get_matrix();
|
||||||
|
|
||||||
std::vector<std::vector<std::pair<Vec3f, size_t>>> hit_positions_and_facet_ids;
|
std::vector<std::vector<std::pair<Vec3f, size_t>>> hit_positions_and_facet_ids;
|
||||||
bool some_mesh_was_hit = false;
|
bool clipped_mesh_was_hit = false;
|
||||||
|
|
||||||
Vec3f normal = Vec3f::Zero();
|
Vec3f normal = Vec3f::Zero();
|
||||||
Vec3f hit = Vec3f::Zero();
|
Vec3f hit = Vec3f::Zero();
|
||||||
|
@ -343,7 +343,7 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
{
|
{
|
||||||
// In case this hit is clipped, skip it.
|
// In case this hit is clipped, skip it.
|
||||||
if (is_mesh_point_clipped(hit.cast<double>())) {
|
if (is_mesh_point_clipped(hit.cast<double>())) {
|
||||||
some_mesh_was_hit = true;
|
clipped_mesh_was_hit = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,11 +357,16 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We now know where the ray hit, let's save it and cast another ray
|
|
||||||
if (closest_hit_mesh_id != size_t(-1)) // only if there is at least one hit
|
|
||||||
some_mesh_was_hit = true;
|
|
||||||
|
|
||||||
if (some_mesh_was_hit) {
|
if (closest_hit_mesh_id == -1) {
|
||||||
|
// In case we have no valid hit, we can return. The event will
|
||||||
|
// be stopped in following two cases:
|
||||||
|
// 1. clicking the clipping plane
|
||||||
|
// 2. dragging while painting (to prevent scene rotations and moving the object)
|
||||||
|
return clipped_mesh_was_hit
|
||||||
|
|| (action == SLAGizmoEventType::Dragging && m_button_down != Button::None);
|
||||||
|
}
|
||||||
|
|
||||||
// Now propagate the hits
|
// Now propagate the hits
|
||||||
mesh_id = -1;
|
mesh_id = -1;
|
||||||
const TriangleMesh* mesh = nullptr;
|
const TriangleMesh* mesh = nullptr;
|
||||||
|
@ -463,9 +468,7 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
|
|
||||||
if (m_button_down == Button::None)
|
if (m_button_down == Button::None)
|
||||||
m_button_down = ((action == SLAGizmoEventType::LeftDown) ? Button::Left : Button::Right);
|
m_button_down = ((action == SLAGizmoEventType::LeftDown) ? Button::Left : Button::Right);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (action == SLAGizmoEventType::Dragging && m_button_down != Button::None)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue