Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dphysicsqueryhit.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
9
10#include <PxQueryReport.h>
11#include <PxRigidActor.h>
12
14
15/*!
16 \qmlvaluetype queryHit
17 \inqmlmodule QtQuick3D.Physics
18 \since 6.13
19 \brief Represents the result of a spatial physics query hit (raycast, sweep, or overlap).
20
21 The \c queryHit struct provides hit information returned by spatial
22 queries in the physics world.
23
24 \sa PhysicsNode, CollisionShape
25*/
26
27/*!
28 \qmlproperty PhysicsNode queryHit::body
29 \readonly
30 \since 6.13
31
32 Holds the physical body (\c PhysicsNode) intersected by the spatial query.
33*/
34
35/*!
36 \qmlproperty CollisionShape queryHit::shape
37 \readonly
38 \since 6.13
39
40 Holds the specific collision shape (\c CollisionShape) intersected by the spatial query.
41 Returns \c null if the underlying PhysX shape has no associated Qt collision shape.
42
43 \note When a query intersects a \l CharacterController, the \c body property
44 is populated, but the \c shape property will be \c null because character
45 controllers do not assign individual shape metadata.
46*/
47
48QQuick3DPhysicsQueryHit::QQuick3DPhysicsQueryHit() = default;
49
50QQuick3DPhysicsQueryHit::QQuick3DPhysicsQueryHit(const physx::PxQueryHit &/*hit*/,
51 const physx::PxActorShape &actorShape)
52 : m_body(actorShape.actor ? static_cast<QAbstractPhysicsNode *>(actorShape.actor->userData) : nullptr),
53 m_shape(actorShape.shape ? static_cast<QAbstractCollisionShape *>(actorShape.shape->userData) : nullptr)
54{
55}
56
57QAbstractPhysicsNode *QQuick3DPhysicsQueryHit::body() const
58{
59 return m_body.data();
60}
61
62QAbstractCollisionShape *QQuick3DPhysicsQueryHit::shape() const
63{
64 return m_shape.data();
65}
66
67QT_END_NAMESPACE
Combined button and popup list for selecting options.