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.cpp
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
#
include
"qtriggerbody_p.h"
6
#
include
"physxnode/qphysxtriggerbody_p.h"
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\qmltype TriggerBody
12
\inherits PhysicsNode
13
\inqmlmodule QtQuick3D.Physics
14
\since 6.4
15
\brief Reports when objects enter a given volume.
16
17
This type defines a trigger body. A trigger body is a body that does not interact
18
physically but is used to detect when objects intersect with its volume.
19
20
\note Only bodies with \l {PhysicsNode::sendTriggerReports}{sendTriggerReports}
21
set to \c true are reported.
22
23
\sa GravityField
24
*/
25
26
/*!
27
\qmlproperty int TriggerBody::collisionCount
28
This property returns the number of bodies currently colliding with the trigger body.
29
30
A body counts once, however many of its collision shapes are inside the trigger body.
31
32
Only a body that had \l {PhysicsNode::sendTriggerReports}{sendTriggerReports} set when it
33
entered is counted, and it goes on counting for as long as it is inside, whatever it sets
34
that property to in the meantime.
35
*/
36
37
/*!
38
\qmlsignal TriggerBody::bodyEntered(PhysicsNode *body)
39
This signal is emitted when the trigger body is penetrated by the specified \a body.
40
41
Emitted once per body, however many of its collision shapes penetrate the trigger body.
42
*/
43
44
/*!
45
\qmlsignal TriggerBody::bodyExited(PhysicsNode *body)
46
This signal is emitted when the trigger body is no longer penetrated by the specified \a body.
47
48
\note This signal is not emitted for a body that is deleted while it is still inside the
49
trigger body, since there is no longer a body to report. \l collisionCount does count such a
50
body out, so a list kept by hand from these signals has to be cleared of deleted bodies
51
another way.
52
*/
53
54
QTriggerBody::QTriggerBody() =
default
;
55
56
void
QTriggerBody::bodyDidEnter(QAbstractPhysicsNode *body)
57
{
58
emit bodyEntered(body);
59
}
60
61
void
QTriggerBody::bodyDidExit(QAbstractPhysicsNode *body)
62
{
63
emit bodyExited(body);
64
}
65
66
bool
QTriggerBody::reportsToBodies()
const
67
{
68
return
true
;
69
}
70
71
QAbstractPhysXNode *QTriggerBody::createPhysXBackend()
72
{
73
return
new
QPhysXTriggerBody(
this
);
74
}
75
76
QT_END_NAMESPACE
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.cpp
Generated on
for Qt by
1.18.0