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
qtriggerbody_p.h
Go to the documentation of this file.
1
// Copyright (C) 2021 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
TRIGGERBODY_H
6
#
define
TRIGGERBODY_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
class
Q_QUICK3DPHYSICS_EXPORT
QTriggerBody
:
public
QAbstractPhysicsNode
28
{
29
Q_OBJECT
30
Q_PROPERTY(
int
collisionCount READ collisionCount NOTIFY collisionCountChanged)
31
QML_NAMED_ELEMENT(TriggerBody)
32
public
:
33
QTriggerBody();
34
35
// One shape of the trigger together with one shape of a body, which is what
36
// the simulation reports an overlap for. The same shape listed twice on one
37
// node builds two PhysX shapes that name the same pair, which is the same
38
// answer: they are built from the same geometry at the same pose, so they
39
// start and stop overlapping in the same step.
40
using
ShapePair = QPair<QAbstractCollisionShape *, QAbstractCollisionShape *>;
41
42
void
registerCollision(QAbstractPhysicsNode *collision, ShapePair shapes);
43
void
deregisterCollision(QAbstractPhysicsNode *collision, ShapePair shapes);
44
void
invalidateOverlaps(QAbstractPhysicsNode *node);
45
void
dropUnreportedOverlaps();
46
47
int
collisionCount()
const
;
48
QAbstractPhysXNode *createPhysXBackend() final;
49
50
Q_SIGNALS:
51
void
bodyEntered(QAbstractPhysicsNode *body);
52
void
bodyExited(QAbstractPhysicsNode *body);
53
void
collisionCountChanged();
54
55
private
:
56
void
dropDestroyedBody(QObject *body);
57
58
// What is currently reported as overlapping for one body: the shape pairs it
59
// is reported for, and those of them that are waiting to be reported again
60
// because the shapes on one side of them have been replaced.
61
struct
Overlaps
62
{
63
QSet<ShapePair> pairs;
64
QSet<ShapePair> unreported;
65
// What the body asked for when it entered, so that the reports on the
66
// way out are the ones that were made on the way in even if it changes
67
// its mind while inside.
68
bool
sends =
false
;
69
bool
receives =
false
;
70
};
71
72
void
reportEntered(QAbstractPhysicsNode *body,
bool
sends,
bool
receives);
73
void
reportExited(QAbstractPhysicsNode *body,
bool
sends,
bool
receives);
74
75
// Keyed by body, so that one pair no longer overlapping does not report the
76
// whole body as having left. The shapes in the pairs are only ever compared,
77
// never dereferenced, since a shape can be gone before its pairs are.
78
QHash<QAbstractPhysicsNode *, Overlaps> m_collisions;
79
// How many of those asked to be counted and reported, kept as they come and
80
// go rather than counted on demand: a body that only asked to be told
81
// itself is held here too but is not one of these, and a trigger around a
82
// whole scene has an entry per body in it while this is read from bindings
83
// on every change.
84
int
m_reportedCount = 0;
85
};
86
87
QT_END_NAMESPACE
88
89
#
endif
// TRIGGERBODY_H
QPhysXActorBody
Definition
qphysxactorbody_p.h:29
QPhysXTriggerBody
Definition
qphysxtriggerbody_p.h:27
QPhysXTriggerBody::QPhysXTriggerBody
QPhysXTriggerBody(QTriggerBody *frontEnd)
Definition
qphysxtriggerbody.cpp:14
QPhysXTriggerBody::getDebugDrawBodyType
DebugDrawBodyType getDebugDrawBodyType() override
Definition
qphysxtriggerbody.cpp:16
QPhysXTriggerBody::sync
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
Definition
qphysxtriggerbody.cpp:21
QPhysXTriggerBody::useTriggerFlag
bool useTriggerFlag() override
Definition
qphysxtriggerbody_p.h:32
QTriggerBody
Definition
qtriggerbody_p.h:28
physx
Definition
qphysxactorbody_p.h:22
physx::PxTransform
PxTransformT< float > PxTransform
Definition
qabstractphysicsnode_p.h:28
DebugDrawBodyType
DebugDrawBodyType
Definition
qabstractphysxnode_p.h:42
DebugDrawBodyType::Trigger
@ Trigger
Definition
qabstractphysxnode_p.h:46
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
Definition
qtconfigmacros.h:161
QT_END_NAMESPACE
#define QT_END_NAMESPACE
Definition
qtconfigmacros.h:162
qtquick3dphysics
src
quick3dphysics
qtriggerbody_p.h
Generated on
for Qt by
1.18.0