Browse Source

Fixed rendering of selection rectangle with perspective camera

Enrico Turri 5 years ago
parent
commit
2f806dedc7
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/slic3r/GUI/GLSelectionRectangle.cpp

+ 7 - 1
src/slic3r/GUI/GLSelectionRectangle.cpp

@@ -68,7 +68,8 @@ namespace GUI {
         if (!is_dragging())
             return;
 
-        float zoom = (float)canvas.get_camera().get_zoom();
+        const Camera& camera = canvas.get_camera();
+        float zoom = (float)camera.get_zoom();
         float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
 
         Size cnv_size = canvas.get_canvas_size();
@@ -96,6 +97,11 @@ namespace GUI {
 
         glsafe(::glPushMatrix());
         glsafe(::glLoadIdentity());
+        // ensure that the rectangle is renderered inside the frustrum
+        glsafe(::glTranslated(0.0, 0.0, -(camera.get_near_z() + 0.5)));
+        // ensure that the overlay fits the frustrum near z plane
+        double gui_scale = camera.get_gui_scale();
+        glsafe(::glScaled(gui_scale, gui_scale, 1.0));
 
         glsafe(::glPushAttrib(GL_ENABLE_BIT));
         glsafe(::glLineStipple(4, 0xAAAA));