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#include <PxQueryReport.h>
7#include <PxRigidActor.h>
8
10
11/*!
12 \qmlvaluetype queryHit
13 \inqmlmodule QtQuick3D.Physics
14 \since 6.13
15 \brief Represents the result of a spatial physics query hit (raycast, sweep, or overlap).
16
17 The \c queryHit struct provides hit information returned by spatial
18 queries in the physics world.
19
20 \sa PhysicsNode, CollisionShape
21*/
22
23/*!
24 \qmlproperty PhysicsNode queryHit::body
25 \readonly
26 \since 6.13
27
28 Holds the physical body (\c PhysicsNode) intersected by the spatial query.
29*/
30
31/*!
32 \qmlproperty CollisionShape queryHit::shape
33 \readonly
34 \since 6.13
35
36 Holds the specific collision shape (\c CollisionShape) intersected by the spatial query.
37 Returns \c null if the underlying PhysX shape has no associated Qt collision shape.
38
39 \note When a query intersects a \l CharacterController, the \c body property
40 is populated, but the \c shape property will be \c null because character
41 controllers do not assign individual shape metadata.
42*/
43
44QQuick3DPhysicsQueryHit::QQuick3DPhysicsQueryHit() = default;
45
46QQuick3DPhysicsQueryHit::QQuick3DPhysicsQueryHit(const physx::PxQueryHit &/*hit*/,
47 const physx::PxActorShape &actorShape)
48 : m_body(actorShape.actor ? static_cast<QAbstractPhysicsNode *>(actorShape.actor->userData) : nullptr),
49 m_shape(actorShape.shape ? static_cast<QAbstractCollisionShape *>(actorShape.shape->userData) : nullptr)
50{
51}
52
53QAbstractPhysicsNode *QQuick3DPhysicsQueryHit::body() const
54{
55 return m_body;
56}
57
58QAbstractCollisionShape *QQuick3DPhysicsQueryHit::shape() const
59{
60 return m_shape;
61}
62
63QT_END_NAMESPACE
Combined button and popup list for selecting options.