-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Point Cloud Editor: fix select2D after switch to QOpenGLWidget #5685
Point Cloud Editor: fix select2D after switch to QOpenGLWidget #5685
Conversation
In commit PointCloudLibrary@38cbd62 the CloudEditorWidget was switched from QGLWidget to QOpenGLWidget to be compatible with Qt6. The select2D tool needs the viewport and the projection matrix, which are loaded with `glGetIntegerv(GL_VIEWPORT,viewport)` and `glGetFloatv(GL_PROJECTION_MATRIX, project)` (they are set in `CloudEditorWidget::resizeGL`). However, since the switch to QOpenGLWidget, the received projection matrix is just the identity matrix, and the viewport does not look correct either. It seems that QOpenGLWidget overwrites them. These changes introduce variables in CloudEditorWidget to safely store the viewport and projection matrix, and passes a function to the select2D tool to ask for them when needed.
I tried this branch without building from scratch and found no difference. Now with a clean build, I am unable to configure, for some reason. Possibly unrelated:
|
indeed, same on master. i guess my system is messed up again. but at least the non-clean build did not fix the problem. |
@themightyoarfish Please try again with a clean build. In my tests these changes did fix the problem. |
I managed a clean build, but unfortunately the problem persists. |
Maybe this is a new macos m1 problem of some sort or dependency-related. |
@themightyoarfish Can you put the following in |
@themightyoarfish Did you have a chance for further tests? @larshg tested this PR on Windows and found that it works. We would like to solve this problem within the next few days if possible, so that the fix can be included in the upcoming 1.13.1 release. |
It prints
|
If i try random selections a bunch of times
strangely, there is one occurrence with |
@themightyoarfish Thanks, the projection matrix and viewport look very plausible. Next, can you put this after the other output: |
I added the code and used the provided point cloud.
When I repeatedly select, I sometimes get some point selection, but it does not really correspond to the selected area. |
@themightyoarfish Do you use a high-resolution/"retina" display? I just remembered this issue and this pull request |
I was wondering that as well. The linked issue was on another machine, but my display is 3456 × 2234, so I suppose that qualifies as hidpi. |
@themightyoarfish I guess then the straightforward solution would be to use const auto ratio = this->devicePixelRatio();
viewport_ = {0, 0, static_cast<GLint>(width*ratio), static_cast<GLint>(height*ratio)}; in |
Unfortunately does not help. The symptoms are very different than the scaling issue, so I'm not surprised. |
actually i switched on my brain for a second and this diff solves it
|
I am wondering though why it was working in earlier versions even though the display scaling issue was not touched since. |
In commit 38cbd62 the CloudEditorWidget was switched from QGLWidget to QOpenGLWidget to be compatible with Qt6. The select2D tool needs the viewport and the projection matrix, which are loaded with
glGetIntegerv(GL_VIEWPORT,viewport)
andglGetFloatv(GL_PROJECTION_MATRIX, project)
(they are set inCloudEditorWidget::resizeGL
). However, since the switch to QOpenGLWidget, the received projection matrix is just the identity matrix, and the viewport does not look correct either. It seems that QOpenGLWidget overwrites them. These changes introduce variables in CloudEditorWidget to safely store the viewport and projection matrix, and passes a function to the select2D tool to ask for them when needed.