diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index a3fdcfa8f8..2be7dd9afc 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -492,11 +492,10 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj } } while (0); - if (color_volume) { - glsafe(::glMultMatrixd(world_matrix().data())); + if (color_volume && !picking) { for (int idx = 0; idx < mmuseg_models.size(); idx++) { GUI::GLModel &m = mmuseg_models[idx]; - if (m.is_empty()) + if (!m.is_initialized()) continue; if (idx == 0) { @@ -570,17 +569,17 @@ void GLWipeTowerVolume::render() if (this->is_left_handed()) glFrontFace(GL_CW); glsafe(::glCullFace(GL_BACK)); - glsafe(::glPushMatrix()); - glsafe(::glMultMatrixd(world_matrix().data())); - GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); for (int i = 0; i < m_colors.size(); i++) { - ColorRGBA new_color = adjust_color_for_rendering(m_colors[i]); - this->model_per_colors[i].set_color(new_color); + if (!picking) { + ColorRGBA new_color = adjust_color_for_rendering(m_colors[i]); + this->model_per_colors[i].set_color(new_color); + } else { + this->model_per_colors[i].set_color(model.get_color()); + } this->model_per_colors[i].render(); } - glsafe(::glPopMatrix()); if (this->is_left_handed()) glFrontFace(GL_CCW); } diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index aefa250b52..18a8ec279d 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -194,6 +194,8 @@ public: bool force_neutral_color : 1; // Whether or not to force rendering of sinking contours bool force_sinking_contours : 1; + // Is render for picking + bool picking : 1; }; // Is mouse or rectangle selection over this object to select/deselect it ? @@ -315,7 +317,7 @@ public: virtual void render(); //BBS: add outline related logic and add virtual specifier - void render_with_outline(const Transform3d &view_model_matrix); + virtual void render_with_outline(const Transform3d &view_model_matrix); //BBS: add simple render function for thumbnail void simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector& extruder_colors); @@ -348,6 +350,7 @@ class GLWipeTowerVolume : public GLVolume { public: GLWipeTowerVolume(const std::vector& colors); void render() override; + void render_with_outline(const Transform3d &view_model_matrix) override { render(); } std::vector model_per_colors; bool IsTransparent(); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index e959229228..32b828e6fa 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -7203,7 +7203,9 @@ void GLCanvas3D::_render_volumes_for_picking() const const Camera& camera = wxGetApp().plater()->get_camera(); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * volume.first->world_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); + volume.first->picking = true; volume.first->render(); + volume.first->picking = false; shader->stop_using(); } }