blob: 33ae0e099f278c501ec3aafbb05439ac79ab7ca6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qtriggerbody_p.h"
#include "physxnode/qphysxtriggerbody_p.h"
QT_BEGIN_NAMESPACE
/*!
\qmltype TriggerBody
\inherits PhysicsNode
\inqmlmodule QtQuick3D.Physics
\since 6.4
\brief Reports when objects enter a given volume.
This type defines a trigger body. A trigger body is a body that does not interact
physically but is used to detect when objects intersect with its volume.
*/
/*!
\qmlproperty int TriggerBody::collisionCount
This property returns the number of bodies currently colliding with the trigger body.
*/
/*!
\qmlsignal TriggerBody::bodyEntered(PhysicsNode *body)
This signal is emitted when the trigger body is penetrated by the specified \a body.
*/
/*!
\qmlsignal TriggerBody::bodyExited(PhysicsNode *body)
This signal is emitted when the trigger body is no longer penetrated by the specified \a body.
*/
QTriggerBody::QTriggerBody() = default;
void QTriggerBody::registerCollision(QAbstractPhysicsNode *collision)
{
int size = m_collisions.size();
m_collisions.insert(collision);
if (size != m_collisions.size()) {
emit bodyEntered(collision);
emit collisionCountChanged();
}
}
void QTriggerBody::deregisterCollision(QAbstractPhysicsNode *collision)
{
int size = m_collisions.size();
m_collisions.remove(collision);
if (size != m_collisions.size()) {
emit bodyExited(collision);
emit collisionCountChanged();
}
}
int QTriggerBody::collisionCount() const
{
return m_collisions.count();
}
QAbstractPhysXNode *QTriggerBody::createPhysXBackend()
{
return new QPhysXTriggerBody(this);
}
QT_END_NAMESPACE
|