aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2024-02-25 11:20:26 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-12 13:27:01 +0000
commit90cf6c08b6765109f4e8358178608c448f544ef4 (patch)
tree659148620e49c59147a5279c8b32a2d478e4432e
parent921f682bfff4ee672918db04987c63468246831d (diff)
Fix input processing for 2D Items in 3D scenes (internalPick)
Previously we would filter input events by using the childrenRect of the Item2D and testing to see if the input event was inside of this rect. This works fine for simple cases, but breaks down when the actual contained items have any transforms applied to them, or the item uses custom masking. There is already a system in place in Qt Quick to for this so this patch uses that. So first, the UV cordinate gives a pixel coordinate in the coordinate space of the container item of the Item2D, so it's important to map that pixel coordinate to the same coordinate space of the items inside of the Item2D. Then by using the "contains" method of the QQuickItem under test, this will work for the standard case (boundingRect) as well as the masked case where the user creates a custom contains method themselves. Pick-to: 6.5 Change-Id: I80fda5dea668d25e96560bee6f65d7238ae087fd Reviewed-by: Christian Strømme <christian.stromme@qt.io> (cherry picked from commit d63f1393b3e463c8b705609dc8fa659c529364ee) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick3d/qquick3dviewport.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/quick3d/qquick3dviewport.cpp b/src/quick3d/qquick3dviewport.cpp
index cdf3cfad..968003c0 100644
--- a/src/quick3d/qquick3dviewport.cpp
+++ b/src/quick3d/qquick3dviewport.cpp
@@ -1290,12 +1290,12 @@ void QQuick3DViewport::processPickedObject(const QSSGRenderGraphObject *backendO
if (!subsceneRootItem || subsceneRootItem->childItems().isEmpty())
return; // ignore empty 2D subscenes
- // In this case the "UV" coordinates are in pixels in the subscene root item, so we can just use them.
+ // In this case the "UV" coordinates are in pixels in the subscene root item's coordinate system.
subscenePosition = pickResult.m_localUVCoords.toPointF();
- // Even though an Item2D is an "infinite plane" for rendering purposes,
- // avoid delivering events outside the rectangular area that is occupied by child items,
- // so that events can "fall through" to other interactive content in the scene or behind it.
- if (!subsceneRootItem->childrenRect().contains(subscenePosition))
+
+ // The following code will account for custom input masking, as well any
+ // transformations that might have been applied to the Item
+ if (!subsceneRootItem->childAt(subscenePosition.x(), subscenePosition.y()))
return;
} else if (frontendObjectPrivate->type == QQuick3DObjectPrivate::Type::Model) {
// Model