Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59567

QObjectPicker support for multiple Surface/Viewport is broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9
    • 5.8.0
    • Qt3D
    • None

    Description

      I was reading the picking code in Qt3DRender when I saw something that I wasn't sure about but looked buggy.
      After a (somehow) small test it turns out that it is buggy.

      The code:

      bool PickBoundingVolumeJob::runHelper()
      {
          //...
          PickingUtils::ViewportCameraAreaGatherer vcaGatherer;
          const QVector<PickingUtils::ViewportCameraAreaTriplet> vcaTriplets = vcaGatherer.gather(m_frameGraphRoot);
          //...
          for (const QMouseEvent &event : mouseEvents) {
              for (const PickingUtils::ViewportCameraAreaTriplet &vca : vcaTriplets) {
                  QRay3D ray = rayForViewportAndCamera(vca.area, event.pos(), vca.viewport, vca.cameraId);
                  // use ray for picking
      
                // QUESTIONS:
                // 1 - Is event from the current surface ?
                // 2 - Is event.pos() within the current viewport ?
                // 3 - Is this area of the viewport not hidden by another viewport ? (turns out we can't have a viewport on top of another, like a minimap in a game, viewports entities collide if you try to do it, which look like another bug [but i may have miss something in the frame graph]...)
      
              }
          }
      }
      

      The app

      The following application shows how you can have picking hits in the wrong viewport and outside a viewport.
      The scene has 4 cubes. On hover cubes turn red. On click a log is written.
      There are 2 windows, 3 viewports and 3 cameras.
      As the input aspect works with only one source, the user need the give the focus to the window for the mouse tracking to take place.

      1 - Picking in wrong window


      The mouse is over 'Window 2' but a cube turns red like if the mouse was over 'Window 1'.

      2 - Picking outside the viewport


      The mouse is over the orange viewport but a cube turns red like if the yellow viewport was larger.

      As a bonus bug_3.png shows both situations occuring at the same time.

      Attachments

        1. bug_1.png
          bug_1.png
          55 kB
        2. bug_2.png
          bug_2.png
          50 kB
        3. bug_3.png
          bug_3.png
          49 kB
        4. test_picking_cpp.zip
          5 kB
        5. windows.png
          windows.png
          51 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mkrus Mike Krus
              gvallat guilhem vallat
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes