Fix the picking

This commit is contained in:
Laurent Rineau 2022-05-16 17:12:00 +02:00
parent 213da3115f
commit b32619fedd
2 changed files with 3 additions and 4 deletions

View File

@ -475,7 +475,7 @@ inline void read_pixel(const QPoint &pixel, QOpenGLFunctions *p,
GLvoid *pixel_data) { GLvoid *pixel_data) {
const auto pixel_ratio = camera->devicePixelRatio(); const auto pixel_ratio = camera->devicePixelRatio();
p->glReadPixels(pixel.x() * pixel_ratio, p->glReadPixels(pixel.x() * pixel_ratio,
(camera->screenHeight() - 1 - pixel.y()) * pixel_ratio, 1, 1, (camera->screenHeight() - pixel.y()) * pixel_ratio - 1, 1, 1,
format, type, pixel_data); format, type, pixel_data);
} }

View File

@ -563,9 +563,8 @@ void Scene::renderScene(const QList<Scene_interface::Item_id> &items,
if(with_names) { if(with_names) {
// read depth buffer at pick location; // read depth buffer at pick location;
float depth = 1.0; float depth = read_depth_under_pixel(picked_pixel, viewer, viewer->camera());
depth = read_depth_under_pixel(picked_pixel, viewer, viewer->camera()); if (depth < 2.0)
if (depth != 1.0)
{ {
//add object to list of picked objects; //add object to list of picked objects;
picked_item_IDs[depth] = index; picked_item_IDs[depth] = index;