From cc447bf122487fe2d9d259492c79d1219d88869e Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Mon, 12 Jun 2023 11:11:36 +0800 Subject: [PATCH] FIX: render the opaque shell to the transparent shell alpha channel is not need to update in shell Change-Id: I4ad3caa7d40f69ec799f1076cf617805ba1a240b (cherry picked from commit 315605926764121f6d0ccedf0e88a1ffc3aa0b46) --- src/slic3r/GUI/3DScene.cpp | 10 ++++++++-- src/slic3r/GUI/3DScene.hpp | 2 +- src/slic3r/GUI/GCodeViewer.cpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index e4e435414..0a906c4ec 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -1533,7 +1533,7 @@ void GLVolumeCollection::reset_outside_state() } } -void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* config) +void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig *config, bool is_update_alpha) { static const float inv_255 = 1.0f / 255.0f; @@ -1603,7 +1603,13 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con const Color& color = colors[extruder_id]; if (!color.text.empty()) { for (int i = 0; i < 4; ++i) { - volume->color[i] = (float)color.rgba[i] * inv_255; + if (is_update_alpha == false) { + if (i < 3) { + volume->color[i] = (float) color.rgba[i] * inv_255; + } + continue; + } + volume->color[i] = (float) color.rgba[i] * inv_255; } } } diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 4547b5ca5..dcabb5994 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -702,7 +702,7 @@ public: bool check_outside_state(const Slic3r::BuildVolume& build_volume, ModelInstanceEPrintVolumeState* out_state) const; void reset_outside_state(); - void update_colors_by_extruder(const DynamicPrintConfig* config); + void update_colors_by_extruder(const DynamicPrintConfig *config, bool is_update_alpha = true); // Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection std::vector get_current_print_zs(bool active_only) const; diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index c8a0b6ecd..f3f7fdd8b 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1217,7 +1217,7 @@ void GCodeViewer::refresh_render_paths() void GCodeViewer::update_shells_color_by_extruder(const DynamicPrintConfig* config) { if (config != nullptr) - m_shells.volumes.update_colors_by_extruder(config); + m_shells.volumes.update_colors_by_extruder(config,false); } //BBS: always load shell at preview