From 90daffccf2b5fa0a5ab21cec8581e8bf1e92e72f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 2 Jul 2019 15:49:18 +0200 Subject: [PATCH] View dependent order of rendering for layers editing visual hints to keep the correct transparency --- src/slic3r/GUI/Plater.cpp | 5 +++++ src/slic3r/GUI/Plater.hpp | 2 ++ src/slic3r/GUI/Selection.cpp | 30 +++++++++++++++++------------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 98b7c1303..0a154034f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4273,6 +4273,11 @@ void Plater::msw_rescale() GetParent()->Layout(); } +const Camera& Plater::get_camera() const +{ + return p->camera; +} + bool Plater::can_delete() const { return p->can_delete(); } bool Plater::can_delete_all() const { return p->can_delete_all(); } bool Plater::can_increase_instances() const { return p->can_increase_instances(); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index c3f8927c0..34fd7984e 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -220,6 +220,8 @@ public: void msw_rescale(); + const Camera& get_camera() const; + private: struct priv; std::unique_ptr p; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 9939c291e..bea94e2e6 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -6,7 +6,8 @@ #include "GUI_ObjectManipulation.hpp" #include "GUI_ObjectList.hpp" #include "Gizmos/GLGizmoBase.hpp" -#include "slic3r/GUI/3DScene.hpp" +#include "3DScene.hpp" +#include "Camera.hpp" #include @@ -1761,33 +1762,36 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co const float min_y = box.min(1) - Margin; const float max_y = box.max(1) + Margin; + // view dependend order of rendering to keep correct transparency + bool camera_on_top = wxGetApp().plater()->get_camera().get_theta() <= 90.0f; + float z1 = camera_on_top ? min_z : max_z; + float z2 = camera_on_top ? max_z : min_z; + glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_CULL_FACE)); glsafe(::glEnable(GL_BLEND)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); - // Draw the min_z plane ::glBegin(GL_QUADS); - if (type == 1) + if ((camera_on_top && (type == 1)) || (!camera_on_top && (type == 2))) ::glColor4f(1.0f, 0.38f, 0.0f, 1.0f); else ::glColor4f(0.8f, 0.8f, 0.8f, 0.5f); - ::glVertex3f(min_x, min_y, min_z); - ::glVertex3f(max_x, min_y, min_z); - ::glVertex3f(max_x, max_y, min_z); - ::glVertex3f(min_x, max_y, min_z); + ::glVertex3f(min_x, min_y, z1); + ::glVertex3f(max_x, min_y, z1); + ::glVertex3f(max_x, max_y, z1); + ::glVertex3f(min_x, max_y, z1); glsafe(::glEnd()); - // Draw the max_z plane ::glBegin(GL_QUADS); - if (type == 2) + if ((camera_on_top && (type == 2)) || (!camera_on_top && (type == 1))) ::glColor4f(1.0f, 0.38f, 0.0f, 1.0f); else ::glColor4f(0.8f, 0.8f, 0.8f, 0.5f); - ::glVertex3f(min_x, min_y, max_z); - ::glVertex3f(max_x, min_y, max_z); - ::glVertex3f(max_x, max_y, max_z); - ::glVertex3f(min_x, max_y, max_z); + ::glVertex3f(min_x, min_y, z2); + ::glVertex3f(max_x, min_y, z2); + ::glVertex3f(max_x, max_y, z2); + ::glVertex3f(min_x, max_y, z2); glsafe(::glEnd()); glsafe(::glEnable(GL_CULL_FACE));