View dependent order of rendering for layers editing visual hints to keep the correct transparency

This commit is contained in:
Enrico Turri 2019-07-02 15:49:18 +02:00
parent 0bcad2a5c5
commit 90daffccf2
3 changed files with 24 additions and 13 deletions

View File

@ -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(); }

View File

@ -220,6 +220,8 @@ public:
void msw_rescale();
const Camera& get_camera() const;
private:
struct priv;
std::unique_ptr<priv> p;

View File

@ -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 <GL/glew.h>
@ -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));