mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer
This commit is contained in:
commit
34759f9a70
5 changed files with 126 additions and 95 deletions
|
@ -3758,6 +3758,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
m_mouse.dragging = true;
|
m_mouse.dragging = true;
|
||||||
|
|
||||||
|
// Translation of objects is forbidden when SLA supports/hollowing/fdm
|
||||||
|
// supports gizmo is active.
|
||||||
|
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports
|
||||||
|
|| m_gizmos.get_current_type() == GLGizmosManager::FdmSupports
|
||||||
|
|| m_gizmos.get_current_type() == GLGizmosManager::Hollow)
|
||||||
|
return;
|
||||||
|
|
||||||
Vec3d cur_pos = m_mouse.drag.start_position_3D;
|
Vec3d cur_pos = m_mouse.drag.start_position_3D;
|
||||||
// we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
|
// we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
|
||||||
if (m_selection.contains_volume(get_first_hover_volume_idx()))
|
if (m_selection.contains_volume(get_first_hover_volume_idx()))
|
||||||
|
|
|
@ -314,6 +314,30 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
const ModelInstance* mi = mo->instances[selection.get_instance_idx()];
|
const ModelInstance* mi = mo->instances[selection.get_instance_idx()];
|
||||||
const Transform3d& instance_trafo = mi->get_transformation().get_matrix();
|
const Transform3d& instance_trafo = mi->get_transformation().get_matrix();
|
||||||
|
|
||||||
|
// List of mouse positions that will be used as seeds for painting.
|
||||||
|
std::vector<Vec2d> mouse_positions{mouse_position};
|
||||||
|
|
||||||
|
// In case current mouse position is far from the last one,
|
||||||
|
// add several positions from between into the list, so there
|
||||||
|
// are no gaps in the painted region.
|
||||||
|
{
|
||||||
|
if (m_last_mouse_position == Vec2d::Zero())
|
||||||
|
m_last_mouse_position = mouse_position;
|
||||||
|
// resolution describes minimal distance limit using circle radius
|
||||||
|
// as a unit (e.g., 2 would mean the patches will be touching).
|
||||||
|
double resolution = 0.7;
|
||||||
|
double diameter_px = resolution * m_cursor_radius * camera.get_zoom();
|
||||||
|
int patches_in_between = int(((mouse_position - m_last_mouse_position).norm() - diameter_px) / diameter_px);
|
||||||
|
if (patches_in_between > 0) {
|
||||||
|
Vec2d diff = (mouse_position - m_last_mouse_position)/(patches_in_between+1);
|
||||||
|
for (int i=1; i<=patches_in_between; ++i)
|
||||||
|
mouse_positions.emplace_back(m_last_mouse_position + i*diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_last_mouse_position = Vec2d::Zero(); // only actual hits should be saved
|
||||||
|
|
||||||
|
// Now "click" into all the prepared points and spill paint around them.
|
||||||
|
for (const Vec2d& mp : mouse_positions) {
|
||||||
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 clipped_mesh_was_hit = false;
|
bool clipped_mesh_was_hit = false;
|
||||||
|
|
||||||
|
@ -340,7 +364,7 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
hit_positions_and_facet_ids.push_back(std::vector<std::pair<Vec3f, size_t>>());
|
hit_positions_and_facet_ids.push_back(std::vector<std::pair<Vec3f, size_t>>());
|
||||||
|
|
||||||
if (m_c->raycaster()->raycasters()[mesh_id]->unproject_on_mesh(
|
if (m_c->raycaster()->raycasters()[mesh_id]->unproject_on_mesh(
|
||||||
mouse_position,
|
mp,
|
||||||
trafo_matrices[mesh_id],
|
trafo_matrices[mesh_id],
|
||||||
camera,
|
camera,
|
||||||
hit,
|
hit,
|
||||||
|
@ -385,18 +409,14 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find respective mesh id.
|
// Find respective mesh id.
|
||||||
// FIXME We need a separate TriangleSelector for each volume mesh.
|
|
||||||
mesh_id = -1;
|
mesh_id = -1;
|
||||||
//const TriangleMesh* mesh = nullptr;
|
|
||||||
for (const ModelVolume* mv : mo->volumes) {
|
for (const ModelVolume* mv : mo->volumes) {
|
||||||
if (! mv->is_model_part())
|
if (! mv->is_model_part())
|
||||||
continue;
|
continue;
|
||||||
++mesh_id;
|
++mesh_id;
|
||||||
if (mesh_id == closest_hit_mesh_id) {
|
if (mesh_id == closest_hit_mesh_id)
|
||||||
//mesh = &mv->mesh();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const Transform3d& trafo_matrix = trafo_matrices[mesh_id];
|
const Transform3d& trafo_matrix = trafo_matrices[mesh_id];
|
||||||
|
|
||||||
|
@ -413,6 +433,8 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
assert(mesh_id < int(m_triangle_selectors.size()));
|
assert(mesh_id < int(m_triangle_selectors.size()));
|
||||||
m_triangle_selectors[mesh_id]->select_patch(closest_hit, closest_facet, camera_pos,
|
m_triangle_selectors[mesh_id]->select_patch(closest_hit, closest_facet, camera_pos,
|
||||||
dir, limit, new_state);
|
dir, limit, new_state);
|
||||||
|
m_last_mouse_position = mouse_position;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -430,6 +452,7 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
update_model_object();
|
update_model_object();
|
||||||
|
|
||||||
m_button_down = Button::None;
|
m_button_down = Button::None;
|
||||||
|
m_last_mouse_position = Vec2d::Zero();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ private:
|
||||||
bool m_setting_angle = false;
|
bool m_setting_angle = false;
|
||||||
bool m_internal_stack_active = false;
|
bool m_internal_stack_active = false;
|
||||||
bool m_schedule_update = false;
|
bool m_schedule_update = false;
|
||||||
|
Vec2d m_last_mouse_position = Vec2d::Zero();
|
||||||
|
|
||||||
// This map holds all translated description texts, so they can be easily referenced during layout calculations
|
// This map holds all translated description texts, so they can be easily referenced during layout calculations
|
||||||
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
|
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue