From 94877a0ec0d0575b4bd2c8389c3111ec2257b5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 3 Jun 2021 08:00:46 +0200 Subject: [PATCH] Fixed the wrong transformation matrix for "Clipping of view" when is used a printer with multiple extruders. --- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 4ba9eaf05..ec3a7c4d9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -132,6 +132,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const glsafe(::glEnable(GL_CLIP_PLANE0)); } + auto *shader = wxGetApp().get_shader("gouraud"); int mesh_id = -1; for (const ModelVolume* mv : mo->volumes) { if (! mv->is_model_part()) @@ -150,6 +151,16 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const glsafe(::glPushMatrix()); glsafe(::glMultMatrixd(trafo_matrix.data())); + // For printers with multiple extruders, it is necessary to pass trafo_matrix + // to the shader input variable print_box.volume_world_matrix before + // rendering the painted triangles. When this matrix is not set, the + // wrong transformation matrix is used for "Clipping of view". + if (shader) { + shader->start_using(); + shader->set_uniform("print_box.volume_world_matrix", trafo_matrix); + shader->stop_using(); + } + m_triangle_selectors[mesh_id]->render(m_imgui); glsafe(::glPopMatrix());