Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qabstracttriggerregion_p.h
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
5
#
ifndef
ABSTRACTTRIGGERREGION_H
6
#
define
ABSTRACTTRIGGERREGION_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtQuick3DPhysics
/
qtquick3dphysicsglobal
.
h
>
20
#
include
"qabstractphysicsnode_p.h"
21
#
include
<
QtCore
/
QHash
>
22
#
include
<
QtCore
/
QSet
>
23
#
include
<
QtQml
/
QQmlEngine
>
24
25
QT_BEGIN_NAMESPACE
26
27
// What a node whose shapes are PhysX triggers keeps track of: the bodies
28
// overlapping it. TriggerBody reports them, and GravityField acts on them.
29
class
Q_QUICK3DPHYSICS_EXPORT
QAbstractTriggerRegion
:
public
QAbstractPhysicsNode
30
{
31
Q_OBJECT
32
QML_ANONYMOUS
33
public
:
34
QAbstractTriggerRegion();
35
36
// One shape of the region together with one shape of a body, which is what
37
// the simulation reports an overlap for. The same shape listed twice on one
38
// node builds two PhysX shapes that name the same pair, which is the same
39
// answer: they are built from the same geometry at the same pose, so they
40
// start and stop overlapping in the same step.
41
using
ShapePair = QPair<QAbstractCollisionShape *, QAbstractCollisionShape *>;
42
43
void
registerCollision(QAbstractPhysicsNode *collision, ShapePair shapes);
44
void
deregisterCollision(QAbstractPhysicsNode *collision, ShapePair shapes);
45
void
invalidateOverlaps(QAbstractPhysicsNode *node);
46
void
dropUnreportedOverlaps();
47
48
// Whether `body` is counted by collisionCount and passed to bodyDidEnter()
49
// and bodyDidExit(). By default, whether it asked for that with
50
// PhysicsNode::sendTriggerReports.
51
virtual
bool
countsBody(
const
QAbstractPhysicsNode *body)
const
;
52
53
// Whether bodies that set PhysicsNode::receiveTriggerReports are told about
54
// this region through PhysicsNode::enteredTriggerBody and exitedTriggerBody.
55
// Those signals name a TriggerBody, so by default they are not.
56
virtual
bool
reportsToBodies()
const
;
57
58
// The number of bodies inside the region that countsBody() accepted.
59
int
collisionCount()
const
;
60
61
Q_SIGNALS:
62
void
collisionCountChanged();
63
64
protected
:
65
// Called when a node actually enters or leaves, i.e. not for repeated
66
// reports about a node that is already tracked.
67
virtual
void
bodyDidEnter(QAbstractPhysicsNode *body);
68
virtual
void
bodyDidExit(QAbstractPhysicsNode *body);
69
70
// What is currently reported as overlapping for one body: the shape pairs it
71
// is reported for, and those of them that are waiting to be reported again
72
// because the shapes on one side of them have been replaced.
73
struct
Overlaps
74
{
75
QSet<ShapePair> pairs;
76
QSet<ShapePair> unreported;
77
// countsBody() and what the body asked for, as of when it entered, so
78
// that the reports on the way out are the ones made on the way in.
79
bool
reports =
false
;
80
bool
receives =
false
;
81
};
82
83
// Every body overlapping the region, counted or not. The shapes in the
84
// pairs are only ever compared, never dereferenced, since a shape can be
85
// gone before its pairs are.
86
const
QHash<QAbstractPhysicsNode *, Overlaps> &collisions()
const
{
return
m_collisions; }
87
88
private
:
89
void
dropDestroyedBody(QObject *body);
90
void
reportEntered(QAbstractPhysicsNode *body,
bool
reports,
bool
receives);
91
void
reportExited(QAbstractPhysicsNode *body,
bool
reports,
bool
receives);
92
93
QHash<QAbstractPhysicsNode *, Overlaps> m_collisions;
94
// How many of those are counted, kept as they come and go rather than
95
// counted on every read.
96
int
m_reportedCount = 0;
97
};
98
99
QT_END_NAMESPACE
100
101
#
endif
// ABSTRACTTRIGGERREGION_H
QAbstractPhysXNode::backendOf
static QAbstractPhysXNode * backendOf(const QAbstractPhysicsNode *node)
Definition
qabstractphysxnode.cpp:173
QAbstractTriggerRegion
Definition
qabstracttriggerregion_p.h:30
QGravityField
Definition
qgravityfield_p.h:35
QPhysXActorBody
Definition
qphysxactorbody_p.h:29
QPhysXActorBody::init
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
Definition
qphysxactorbody.cpp:65
QPhysXGravityField
Definition
qphysxgravityfield_p.h:33
QPhysXGravityField::wakesOnRemoval
QList< QPointer< QAbstractPhysicsNode > > wakesOnRemoval
Definition
qphysxgravityfield_p.h:63
QPhysXGravityField::applyGravity
std::optional< SceneGravity > applyGravity(QList< QFilterData > &staleFilters)
Definition
qphysxgravityfield.cpp:39
QPhysXGravityField::QPhysXGravityField
QPhysXGravityField(QGravityField *frontEnd)
Definition
qphysxgravityfield.cpp:18
QPhysXGravityField::getDebugDrawBodyType
DebugDrawBodyType getDebugDrawBodyType() override
Definition
qphysxgravityfield.cpp:28
QPhysXGravityField::init
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
Definition
qphysxgravityfield.cpp:20
QPhysXGravityField::useTriggerFlag
bool useTriggerFlag() override
Definition
qphysxgravityfield_p.h:38
QPhysXGravityField::staleFilterOnRemoval
std::optional< QFilterData > staleFilterOnRemoval
Definition
qphysxgravityfield_p.h:64
QPhysXGravityField::sync
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
Definition
qphysxgravityfield.cpp:106
QPhysXGravityField::fieldDestroyed
static void fieldDestroyed(QGravityField *field)
Definition
qphysxgravityfield.cpp:94
QPhysXWorld
Definition
qphysxworld_p.h:33
QPhysXGravity
Definition
qphysxgravity_p.h:28
QPhysXGravity::apply
void apply(const QPhysicsGravity &gravity, QPhysicsGravity::Target target, QAbstractPhysicsNode *node, QAbstractPhysXNode *backend, bool wake)
Definition
qphysxgravity.cpp:41
QPhysicsUtils
Definition
qphysicsutils_p.h:33
QPhysicsUtils::fuzzyEquals
Q_ALWAYS_INLINE bool fuzzyEquals(const physx::PxTransform &a, const physx::PxTransform &b)
Definition
qphysicsutils_p.h:67
physx
Definition
qphysxactorbody_p.h:22
physx::PxTransform
PxTransformT< float > PxTransform
Definition
qabstractphysicsnode_p.h:29
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
DebugDrawBodyType
DebugDrawBodyType
Definition
qabstractphysxnode_p.h:42
DebugDrawBodyType::Trigger
@ Trigger
Definition
qabstractphysxnode_p.h:46
operator!=
static bool operator!=(const QFilterData &a, const QFilterData &b)
Definition
qphysxgravityfield.cpp:33
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
Definition
qtconfigmacros.h:161
QT_END_NAMESPACE
#define QT_END_NAMESPACE
Definition
qtconfigmacros.h:162
QFilterData
Definition
qfilterdata_p.h:30
QPhysXGravityField::SceneGravity
Definition
qphysxgravityfield_p.h:44
QPhysXGravityField::SceneGravity::wake
bool wake
Definition
qphysxgravityfield_p.h:48
QPhysXGravityField::SceneGravity::gravity
QPhysicsGravity gravity
Definition
qphysxgravityfield_p.h:45
QPhysXGravityField::SceneGravity::filterData
QFilterData filterData
Definition
qphysxgravityfield_p.h:46
QPhysicsGravity
Definition
qphysicsgravity_p.h:33
qtquick3dphysics
src
quick3dphysics
qabstracttriggerregion_p.h
Generated on
for Qt by
1.18.0