GillesDebunne / libQGLViewer

libQGLViewer is an open source C++ library based on Qt that eases the creation of OpenGL 3D viewers.
Other
241 stars 94 forks source link

Set Pivot doesn't work since move to QOpenGLWidget #56

Closed bjornpiltz closed 1 year ago

bjornpiltz commented 2 years ago

The problem

Setting the pivot (by default SHIFT+RIGHT CLICK) doesn't set the right pivot anymore. This is a regression introduced with 0e765fbed945fa3dda317d1c8e5e718150721732.

Analysis

The problem seems to be that the call to glReadPixels() in Camera::pointUnderPixel() always sets depth to 0.0.

However, the functions Zoom on pixel (Z+RIGHT CLICK) and selecting (SHIFT+LEFT CLICK) are not affected.

Fix

Adding a call to makeCurrent() here works for me.

  case RAP_FROM_PIXEL:
    makeCurrent();
    if (!camera()->setPivotPointFromPixel(e->pos()))
      camera()->setPivotPoint(sceneCenter());

Platform

Tested on Windows with MSVC 2019 - Qt 5.15.2 and 6.2.0.

GillesDebunne commented 1 year ago

With a one year delay for which I would like to apologise, I finally had a look at this issue.

A problem with high pixel density screens was making it more difficult, but in the end your proposed fix is also needed.

Thanks a lot for this contribution.

Gilles