mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 20:35:56 +08:00
Cut: Pt connectors to the cut plane
This commit is contained in:
parent
e785a66a01
commit
861187997b
@ -160,6 +160,30 @@ void GLGizmoCut3D::rotate_vec3d_around_center(Vec3d& vec, const Vec3d& angles, c
|
|||||||
vec += center;
|
vec += center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoCut3D::put_connetors_on_cut_plane()
|
||||||
|
{
|
||||||
|
ModelObject* mo = m_c->selection_info()->model_object();
|
||||||
|
if (CutConnectors& connectors = mo->cut_connectors; !connectors.empty()) {
|
||||||
|
const float sla_shift = m_c->selection_info()->get_sla_shift();
|
||||||
|
const Vec3d& instance_offset = mo->instances[m_c->selection_info()->get_active_instance()]->get_offset();
|
||||||
|
|
||||||
|
const ClippingPlane* cp = m_c->object_clipper()->get_clipping_plane();
|
||||||
|
const Vec3d& normal = cp->get_normal();
|
||||||
|
|
||||||
|
for (auto& connector : connectors) {
|
||||||
|
// convert connetor pos to the world coordinates
|
||||||
|
Vec3d pos = connector.pos + instance_offset;
|
||||||
|
pos[Z] += sla_shift;
|
||||||
|
|
||||||
|
// scalar distance from point to plane along the normal
|
||||||
|
double distance = cp->distance(pos);
|
||||||
|
|
||||||
|
// move connector
|
||||||
|
connector.pos += distance * normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoCut3D::update_clipper()
|
void GLGizmoCut3D::update_clipper()
|
||||||
{
|
{
|
||||||
const Vec3d& angles = m_rotation_gizmo.get_rotation();
|
const Vec3d& angles = m_rotation_gizmo.get_rotation();
|
||||||
@ -177,6 +201,8 @@ void GLGizmoCut3D::update_clipper()
|
|||||||
double dist = (m_plane_center - beg).norm();
|
double dist = (m_plane_center - beg).norm();
|
||||||
|
|
||||||
m_c->object_clipper()->set_range_and_pos(beg, end, dist);
|
m_c->object_clipper()->set_range_and_pos(beg, end, dist);
|
||||||
|
|
||||||
|
put_connetors_on_cut_plane();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoCut3D::update_clipper_on_render()
|
void GLGizmoCut3D::update_clipper_on_render()
|
||||||
@ -578,10 +604,6 @@ void GLGizmoCut3D::on_dragging(const UpdateData& data)
|
|||||||
|
|
||||||
// move cut plane center
|
// move cut plane center
|
||||||
set_center(starting_box_center + shift);
|
set_center(starting_box_center + shift);
|
||||||
|
|
||||||
// move connectors
|
|
||||||
for (auto& connector : connectors)
|
|
||||||
connector.pos += shift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (m_hover_id > m_group_id)
|
else if (m_hover_id > m_group_id)
|
||||||
@ -838,6 +860,9 @@ void GLGizmoCut3D::render_connectors(bool picking)
|
|||||||
const CutConnectors& connectors = mo->cut_connectors;
|
const CutConnectors& connectors = mo->cut_connectors;
|
||||||
size_t cache_size = connectors.size();
|
size_t cache_size = connectors.size();
|
||||||
|
|
||||||
|
const Vec3d& instance_offset = mo->instances[m_c->selection_info()->get_active_instance()]->get_offset();
|
||||||
|
const float sla_shift = m_c->selection_info()->get_sla_shift();
|
||||||
|
|
||||||
for (size_t i = 0; i < cache_size; ++i) {
|
for (size_t i = 0; i < cache_size; ++i) {
|
||||||
const CutConnector& connector = connectors[i];
|
const CutConnector& connector = connectors[i];
|
||||||
const bool& point_selected = m_selected[i];
|
const bool& point_selected = m_selected[i];
|
||||||
@ -859,9 +884,8 @@ void GLGizmoCut3D::render_connectors(bool picking)
|
|||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
// recalculate connector position to world position
|
// recalculate connector position to world position
|
||||||
Vec3d pos = connector.pos;
|
Vec3d pos = connector.pos + instance_offset;
|
||||||
pos += mo->instances[m_c->selection_info()->get_active_instance()]->get_offset();
|
pos[Z] += sla_shift;
|
||||||
pos[Z] += m_c->selection_info()->get_sla_shift();
|
|
||||||
|
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(
|
const Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(
|
||||||
@ -918,7 +942,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
|||||||
const GLVolume* first_glvolume = selection.get_volume(*selection.get_volume_idxs().begin());
|
const GLVolume* first_glvolume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
const double object_cut_z = m_plane_center.z() - first_glvolume->get_sla_shift_z();
|
const double object_cut_z = m_plane_center.z() - first_glvolume->get_sla_shift_z();
|
||||||
|
|
||||||
Vec3d instance_offset = wxGetApp().plater()->model().objects[object_idx]->instances[instance_idx]->get_offset();
|
const Vec3d& instance_offset = wxGetApp().plater()->model().objects[object_idx]->instances[instance_idx]->get_offset();
|
||||||
|
|
||||||
Vec3d cut_center_offset = m_plane_center - instance_offset;
|
Vec3d cut_center_offset = m_plane_center - instance_offset;
|
||||||
cut_center_offset[Z] -= first_glvolume->get_sla_shift_z();
|
cut_center_offset[Z] -= first_glvolume->get_sla_shift_z();
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
|
|
||||||
void shift_cut_z(double delta);
|
void shift_cut_z(double delta);
|
||||||
void rotate_vec3d_around_center(Vec3d& vec, const Vec3d& angles, const Vec3d& center);
|
void rotate_vec3d_around_center(Vec3d& vec, const Vec3d& angles, const Vec3d& center);
|
||||||
|
void put_connetors_on_cut_plane();
|
||||||
void update_clipper();
|
void update_clipper();
|
||||||
void update_clipper_on_render();
|
void update_clipper_on_render();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user