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
Issue Links
- is duplicated by
-
QTBUG-59554 Pick events are emitted from cameras rendering offscreen
- Closed
- is required for
-
QTBUG-59125 Provide normalized coordinates in Qt3D QMouseEvents
- Open