diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index f16aa7cfa..e0c92a71c 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -225,8 +225,7 @@ void SLAPrint::Steps::slice_model(SLAPrintObject &po) if(po.m_config.supports_enable.getBool() || po.m_config.pad_enable.getBool()) { - po.m_supportdata.reset( - new SLAPrintObject::SupportData(po.transformed_mesh()) ); + po.m_supportdata.reset(new SLAPrintObject::SupportData(mesh)); } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index f8f2e125f..75a21057a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -112,10 +112,21 @@ void GLGizmoHollow::on_render() const glsafe(::glEnable(GL_DEPTH_TEST)); if (m_c->m_volume_with_cavity) { + m_c->m_volume_with_cavity->set_sla_shift_z(m_z_shift); m_parent.get_shader().start_using(); - m_c->m_volume_with_cavity->render(); + + GLint current_program_id; + glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_id)); + GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1; + GLint print_box_detection_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_detection") : -1; + GLint print_box_worldmatrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_world_matrix") : -1; + glcheck(); + m_c->m_volume_with_cavity->set_render_color(); + m_c->m_volume_with_cavity->render(color_id, print_box_detection_id, print_box_worldmatrix_id); m_parent.get_shader().stop_using(); } + // Show/hide the original object + m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance); m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); @@ -602,22 +613,22 @@ void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr &&mesh) hole_mesh.transform(m.cast()); hole_mesh.translate(hole.pos); holes_mesh.merge(hole_mesh); - //MeshBoolean::minus(*m_c->m_cavity_mesh.get(), hole_mesh); + holes_mesh.repair(); } MeshBoolean::minus(*m_c->m_cavity_mesh.get(), holes_mesh); } - // create a new GLVolume that only has the cavity inside Geometry::Transformation volume_trafo = m_c->m_model_object->volumes.front()->get_transformation(); volume_trafo.set_offset(volume_trafo.get_offset() + Vec3d(0., 0., m_z_shift)); - m_c->m_volume_with_cavity.reset(new GLVolume(1.f, 0.f, 0.f, 0.5f)); + m_c->m_volume_with_cavity.reset(new GLVolume(GLVolume::MODEL_COLOR[2])); m_c->m_volume_with_cavity->indexed_vertex_array.load_mesh(*m_c->m_cavity_mesh.get()); m_c->m_volume_with_cavity->finalize_geometry(true); m_c->m_volume_with_cavity->set_volume_transformation(volume_trafo); m_c->m_volume_with_cavity->set_instance_transformation(m_c->m_model_object->instances[size_t(m_c->m_active_instance)]->get_transformation()); + m_c->m_volume_with_cavity->force_transparent = false; } - m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance); + if (m_clipping_plane_distance == 0.f) { m_clipping_plane_distance = 0.5f; update_clipping_plane(); @@ -672,7 +683,7 @@ RENDER_AGAIN: const float approx_height = m_imgui->scaled(20.0f); y = std::min(y, bottom_limit - approx_height); m_imgui->set_next_window_pos(x, y, ImGuiCond_Always); - m_imgui->set_next_window_bg_alpha(0.5f); + m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); // First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that: @@ -756,7 +767,8 @@ RENDER_AGAIN: bool remove_selected = false; bool remove_all = false; - m_imgui->text(" "); // vertical gap + // m_imgui->text(" "); // vertical gap + ImGui::Separator(); float diameter_upper_cap = 20.f; //static_cast(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value; if (m_new_hole_radius > diameter_upper_cap) @@ -824,7 +836,8 @@ RENDER_AGAIN: m_imgui->disabled_end(); // Following is rendered in both editing and non-editing mode: - m_imgui->text(""); + // m_imgui->text(""); + ImGui::Separator(); if (m_clipping_plane_distance == 0.f) m_imgui->text(m_desc.at("clipping_of_view")); else { @@ -940,9 +953,9 @@ void GLGizmoHollow::on_set_state() // Release clippers and the AABB raycaster. m_c->m_object_clipper.reset(); m_c->m_supports_clipper.reset(); - m_c->m_mesh_raycaster.reset(); - m_c->m_cavity_mesh.reset(); - m_c->m_volume_with_cavity.reset(); + //m_c->m_mesh_raycaster.reset(); + //m_c->m_cavity_mesh.reset(); + //m_c->m_volume_with_cavity.reset(); } m_old_state = m_state; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 85d57a211..ddde79c52 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -121,6 +121,23 @@ void GLGizmoSlaSupports::on_render() const glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_DEPTH_TEST)); + if (m_c->m_volume_with_cavity) { + m_c->m_volume_with_cavity->set_sla_shift_z(m_z_shift); + m_parent.get_shader().start_using(); + + GLint current_program_id; + glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_id)); + GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1; + GLint print_box_detection_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_detection") : -1; + GLint print_box_worldmatrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_world_matrix") : -1; + glcheck(); + m_c->m_volume_with_cavity->set_render_color(); + m_c->m_volume_with_cavity->render(color_id, print_box_detection_id, print_box_worldmatrix_id); + m_parent.get_shader().stop_using(); + } + // Show/hide the original object + m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance); + m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); if (m_quadric != nullptr && selection.is_from_single_instance()) @@ -328,41 +345,41 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) } // Now render the drain holes: - render_color[0] = 0.7f; - render_color[1] = 0.7f; - render_color[2] = 0.7f; - render_color[3] = 0.7f; - glsafe(::glColor4fv(render_color)); - for (const sla::DrainHole& drain_hole : m_c->m_model_object->sla_drain_holes) { - // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. - glsafe(::glPushMatrix()); - glsafe(::glTranslatef(drain_hole.pos(0), drain_hole.pos(1), drain_hole.pos(2))); - glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); +// render_color[0] = 0.7f; +// render_color[1] = 0.7f; +// render_color[2] = 0.7f; +// render_color[3] = 0.7f; +// glsafe(::glColor4fv(render_color)); +// for (const sla::DrainHole& drain_hole : m_c->m_model_object->sla_drain_holes) { +// // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. +// glsafe(::glPushMatrix()); +// glsafe(::glTranslatef(drain_hole.pos(0), drain_hole.pos(1), drain_hole.pos(2))); +// glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); - if (vol->is_left_handed()) - glFrontFace(GL_CW); +// if (vol->is_left_handed()) +// glFrontFace(GL_CW); - // Matrices set, we can render the point mark now. +// // Matrices set, we can render the point mark now. - Eigen::Quaterniond q; - q.setFromTwoVectors(Vec3d{0., 0., 1.}, instance_scaling_matrix_inverse * (-drain_hole.normal).cast()); - Eigen::AngleAxisd aa(q); - glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2))); - glsafe(::glPushMatrix()); - glsafe(::glTranslated(0., 0., -drain_hole.height)); - ::gluCylinder(m_quadric, drain_hole.radius, drain_hole.radius, drain_hole.height, 24, 1); - glsafe(::glTranslated(0., 0., drain_hole.height)); - ::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1); - glsafe(::glTranslated(0., 0., -drain_hole.height)); - glsafe(::glRotatef(180.f, 1.f, 0.f, 0.f)); - ::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1); - glsafe(::glPopMatrix()); +// Eigen::Quaterniond q; +// q.setFromTwoVectors(Vec3d{0., 0., 1.}, instance_scaling_matrix_inverse * (-drain_hole.normal).cast()); +// Eigen::AngleAxisd aa(q); +// glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2))); +// glsafe(::glPushMatrix()); +// glsafe(::glTranslated(0., 0., -drain_hole.height)); +// ::gluCylinder(m_quadric, drain_hole.radius, drain_hole.radius, drain_hole.height, 24, 1); +// glsafe(::glTranslated(0., 0., drain_hole.height)); +// ::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1); +// glsafe(::glTranslated(0., 0., -drain_hole.height)); +// glsafe(::glRotatef(180.f, 1.f, 0.f, 0.f)); +// ::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1); +// glsafe(::glPopMatrix()); - if (vol->is_left_handed()) - glFrontFace(GL_CCW); - glsafe(::glPopMatrix()); +// if (vol->is_left_handed()) +// glFrontFace(GL_CCW); +// glsafe(::glPopMatrix()); - } +// } if (!picking) glsafe(::glDisable(GL_LIGHTING));