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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef ABSTRACTPHYSICSNODE_H
#define ABSTRACTPHYSICSNODE_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtQuick3DPhysics/qtquick3dphysicsglobal.h>
#include <QtQuick3D/private/qquick3dnode_p.h>
#include <QtQml/QQmlEngine>
#include <QtQml/QQmlListProperty>
#include <QtQuick3DPhysics/private/qabstractcollisionshape_p.h>
namespace physx {
class PxTransform;
class PxShape;
}
QT_BEGIN_NAMESPACE
class QAbstractPhysXNode;
class Q_QUICK3DPHYSICS_EXPORT QAbstractPhysicsNode : public QQuick3DNode
{
Q_OBJECT
Q_PROPERTY(
QQmlListProperty<QAbstractCollisionShape> collisionShapes READ collisionShapes CONSTANT)
Q_PROPERTY(bool sendContactReports READ sendContactReports WRITE setSendContactReports NOTIFY
sendContactReportsChanged)
Q_PROPERTY(bool receiveContactReports READ receiveContactReports WRITE setReceiveContactReports
NOTIFY receiveContactReportsChanged)
Q_PROPERTY(bool sendTriggerReports READ sendTriggerReports WRITE setSendTriggerReports NOTIFY
sendTriggerReportsChanged REVISION(6, 5))
Q_PROPERTY(bool receiveTriggerReports READ receiveTriggerReports WRITE setReceiveTriggerReports
NOTIFY receiveTriggerReportsChanged REVISION(6, 5))
Q_PROPERTY(int filterGroup READ filterGroup WRITE setfilterGroup NOTIFY filterGroupChanged
REVISION(6, 7))
Q_PROPERTY(int filterIgnoreGroups READ filterIgnoreGroups WRITE setFilterIgnoreGroups NOTIFY
filterIgnoreGroupsChanged REVISION(6, 7));
QML_NAMED_ELEMENT(PhysicsNode)
QML_UNCREATABLE("abstract interface")
public:
QAbstractPhysicsNode();
~QAbstractPhysicsNode() override;
QQmlListProperty<QAbstractCollisionShape> collisionShapes();
const QVector<QAbstractCollisionShape *> &getCollisionShapesList() const;
void updateFromPhysicsTransform(const physx::PxTransform &transform);
void registerContact(QAbstractPhysicsNode *body, const QVector<QVector3D> &positions,
const QVector<QVector3D> &impulses, const QVector<QVector3D> &normals);
bool sendContactReports() const;
void setSendContactReports(bool sendContactReports);
bool receiveContactReports() const;
void setReceiveContactReports(bool receiveContactReports);
Q_REVISION(6, 5) bool sendTriggerReports() const;
Q_REVISION(6, 5) void setSendTriggerReports(bool sendTriggerReports);
Q_REVISION(6, 5) bool receiveTriggerReports() const;
Q_REVISION(6, 5) void setReceiveTriggerReports(bool receiveTriggerReports);
bool hasStaticShapes() const { return m_hasStaticShapes; }
virtual QAbstractPhysXNode *createPhysXBackend() = 0;
Q_REVISION(6, 7) int filterGroup() const;
Q_REVISION(6, 7) void setfilterGroup(int newfilterGroup);
Q_REVISION(6, 7) int filterIgnoreGroups() const;
Q_REVISION(6, 7) void setFilterIgnoreGroups(int newFilterIgnoreGroups);
private Q_SLOTS:
void onShapeDestroyed(QObject *object);
void onShapeNeedsRebuild(QObject *object);
Q_SIGNALS:
void bodyContact(QAbstractPhysicsNode *body, const QVector<QVector3D> &positions,
const QVector<QVector3D> &impulses, const QVector<QVector3D> &normals);
void sendContactReportsChanged(float sendContactReports);
void receiveContactReportsChanged(float receiveContactReports);
Q_REVISION(6, 5) void sendTriggerReportsChanged(float sendTriggerReports);
Q_REVISION(6, 5) void receiveTriggerReportsChanged(float receiveTriggerReports);
Q_REVISION(6, 5) void enteredTriggerBody(QAbstractPhysicsNode *body);
Q_REVISION(6, 5) void exitedTriggerBody(QAbstractPhysicsNode *body);
Q_REVISION(6, 7) void filterGroupChanged();
Q_REVISION(6, 7) void filterIgnoreGroupsChanged();
private:
static void qmlAppendShape(QQmlListProperty<QAbstractCollisionShape> *list,
QAbstractCollisionShape *shape);
static QAbstractCollisionShape *qmlShapeAt(QQmlListProperty<QAbstractCollisionShape> *list,
qsizetype index);
static qsizetype qmlShapeCount(QQmlListProperty<QAbstractCollisionShape> *list);
static void qmlClearShapes(QQmlListProperty<QAbstractCollisionShape> *list);
QVector<QAbstractCollisionShape *> m_collisionShapes;
bool m_shapesDirty = false;
bool m_sendContactReports = false;
bool m_receiveContactReports = false;
bool m_sendTriggerReports = false;
bool m_receiveTriggerReports = false;
bool m_hasStaticShapes = false;
int m_filterGroup = 0;
int m_filterIgnoreGroups = 0;
bool m_filtersDirty = false;
friend class QAbstractPhysXNode;
friend class QPhysicsWorld; // for register/deregister TODO: cleaner mechanism
friend class SimulationEventCallback;
QAbstractPhysXNode *m_backendObject = nullptr;
};
QT_END_NAMESPACE
#endif // ABSTRACTPHYSICSNODE_H
|