From 403f6d45f90e7ecdf81e6582122a779bcf4930b5 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 17 Jan 2022 08:24:46 +0100 Subject: [PATCH] Refactoring - Removed member variable GLVolume::force_transparent --- src/slic3r/GUI/3DScene.cpp | 9 ++------- src/slic3r/GUI/3DScene.hpp | 6 ++---- src/slic3r/GUI/GCodeViewer.cpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 7 +------ src/slic3r/GUI/Selection.cpp | 7 +------ 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 120d66781..95077d192 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -377,7 +377,6 @@ GLVolume::GLVolume(float r, float g, float b, float a) , is_modifier(false) , is_wipe_tower(false) , is_extrusion_path(false) - , force_transparent(false) , force_native_color(false) , force_neutral_color(false) , force_sinking_contours(false) @@ -388,7 +387,7 @@ GLVolume::GLVolume(float r, float g, float b, float a) set_render_color(color); } -void GLVolume::set_render_color() +void GLVolume::set_render_color(bool force_transparent) { bool outside = is_outside || is_below_printbed(); @@ -812,11 +811,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab glsafe(::glDisable(GL_CULL_FACE)); for (GLVolumeWithIdAndZ& volume : to_render) { - if (type == ERenderType::Transparent) - volume.first->force_transparent = true; - volume.first->set_render_color(); - if (type == ERenderType::Transparent) - volume.first->force_transparent = false; + volume.first->set_render_color(true); // render sinking contours of non-hovered volumes if (m_show_sinking_contours) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 7ad12c354..c603f3956 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -358,9 +358,7 @@ public: bool is_wipe_tower : 1; // Wheter or not this volume has been generated from an extrusion path bool is_extrusion_path : 1; - // Wheter or not to always render this volume using its own alpha - bool force_transparent : 1; - // Whether or not always use the volume's own color (not using SELECTED/HOVER/DISABLED/OUTSIDE) + // Whether or not always use the volume's own color (not using SELECTED/HOVER/DISABLED/OUTSIDE) bool force_native_color : 1; // Whether or not render this volume in neutral bool force_neutral_color : 1; @@ -397,7 +395,7 @@ public: void set_color(const ColorRGBA& rgba) { color = rgba; } void set_render_color(const ColorRGBA& rgba) { render_color = rgba; } // Sets render color in dependence of current state - void set_render_color(); + void set_render_color(bool force_transparent); // set color according to model volume void set_color_from_model_volume(const ModelVolume& model_volume); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 5edc321f7..d17f184bb 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -2155,7 +2155,7 @@ void GCodeViewer::load_shells(const Print& print, bool initialized) volume->zoom_to_volumes = false; volume->color.a(0.25f); volume->force_native_color = true; - volume->set_render_color(); + volume->set_render_color(true); } } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index fbb5ba694..9e83fb2a4 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1845,12 +1845,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re volume->is_modifier = !mvs->model_volume->is_model_part(); volume->set_color(color_from_model_volume(*mvs->model_volume)); // force update of render_color alpha channel - bool transparent = volume->color.is_transparent(); - if (transparent) - volume->force_transparent = true; - volume->set_render_color(); - if (transparent) - volume->force_transparent = false; + volume->set_render_color(volume->color.is_transparent()); // updates volumes transformations volume->set_instance_transformation(mvs->model_volume->get_object()->instances[mvs->composite_id.instance_id]->get_transformation()); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 5aa2cb4d0..c4b7d2c3d 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -452,12 +452,7 @@ void Selection::clear() for (unsigned int i : m_list) { GLVolume& volume = *(*m_volumes)[i]; volume.selected = false; - bool is_transparent = volume.color.is_transparent(); - if (is_transparent) - volume.force_transparent = true; - volume.set_render_color(); - if (is_transparent) - volume.force_transparent = false; + volume.set_render_color(volume.color.is_transparent()); } m_list.clear();