Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qabstractphysicsnode_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 ABSTRACTPHYSICSNODE_H
6#define ABSTRACTPHYSICSNODE_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 <QtQuick3D/private/qquick3dnode_p.h>
21#include <QtQml/QQmlEngine>
22#include <QtQml/QQmlListProperty>
23#include <QtQuick3DPhysics/private/qabstractcollisionshape_p.h>
24
25namespace physx {
26class PxTransform;
27class PxShape;
28}
29
31
33class QPhysicsJoint;
34
35class Q_QUICK3DPHYSICS_EXPORT QAbstractPhysicsNode : public QQuick3DNode
36{
39 QQmlListProperty<QAbstractCollisionShape> collisionShapes READ collisionShapes CONSTANT)
40 Q_PROPERTY(bool sendContactReports READ sendContactReports WRITE setSendContactReports NOTIFY
41 sendContactReportsChanged)
42 Q_PROPERTY(bool receiveContactReports READ receiveContactReports WRITE setReceiveContactReports
43 NOTIFY receiveContactReportsChanged)
44 Q_PROPERTY(bool sendTriggerReports READ sendTriggerReports WRITE setSendTriggerReports NOTIFY
45 sendTriggerReportsChanged REVISION(6, 5))
46 Q_PROPERTY(bool receiveTriggerReports READ receiveTriggerReports WRITE setReceiveTriggerReports
47 NOTIFY receiveTriggerReportsChanged REVISION(6, 5))
48 Q_PROPERTY(int filterGroup READ filterGroup WRITE setfilterGroup NOTIFY filterGroupChanged
49 REVISION(6, 7))
50 Q_PROPERTY(int filterIgnoreGroups READ filterIgnoreGroups WRITE setFilterIgnoreGroups NOTIFY
51 filterIgnoreGroupsChanged REVISION(6, 7));
52
53 QML_NAMED_ELEMENT(PhysicsNode)
54 QML_UNCREATABLE("abstract interface")
55public:
56 QAbstractPhysicsNode();
57 ~QAbstractPhysicsNode() override;
58
59 QQmlListProperty<QAbstractCollisionShape> collisionShapes();
60 const QVector<QAbstractCollisionShape *> &getCollisionShapesList() const;
61
62 void updateFromPhysicsTransform(const physx::PxTransform &transform);
63
64 void registerContact(QAbstractPhysicsNode *body, const QVector<QVector3D> &positions,
65 const QVector<QVector3D> &impulses, const QVector<QVector3D> &normals);
66
67 bool sendContactReports() const;
68 void setSendContactReports(bool sendContactReports);
69
70 bool receiveContactReports() const;
71 void setReceiveContactReports(bool receiveContactReports);
72
73 Q_REVISION(6, 5) bool sendTriggerReports() const;
74 Q_REVISION(6, 5) void setSendTriggerReports(bool sendTriggerReports);
76 Q_REVISION(6, 5) bool receiveTriggerReports() const;
77 Q_REVISION(6, 5) void setReceiveTriggerReports(bool receiveTriggerReports);
79 bool hasStaticShapes() const { return m_hasStaticShapes; }
81 virtual QAbstractPhysXNode *createPhysXBackend() = 0;
82
83 Q_REVISION(6, 7) int filterGroup() const;
84 Q_REVISION(6, 7) void setfilterGroup(int newfilterGroup);
85
86 Q_REVISION(6, 7) int filterIgnoreGroups() const;
87 Q_REVISION(6, 7) void setFilterIgnoreGroups(int newFilterIgnoreGroups);
89private Q_SLOTS:
90 void onShapeDestroyed(QObject *object);
91 void onShapeNeedsRebuild(QObject *object);
94 void bodyContact(QAbstractPhysicsNode *body, const QVector<QVector3D> &positions,
95 const QVector<QVector3D> &impulses, const QVector<QVector3D> &normals);
96 void sendContactReportsChanged(float sendContactReports);
97 void receiveContactReportsChanged(float receiveContactReports);
98 Q_REVISION(6, 5) void sendTriggerReportsChanged(float sendTriggerReports);
99 Q_REVISION(6, 5) void receiveTriggerReportsChanged(float receiveTriggerReports);
100 Q_REVISION(6, 5) void enteredTriggerBody(QAbstractPhysicsNode *body);
101 Q_REVISION(6, 5) void exitedTriggerBody(QAbstractPhysicsNode *body);
102 Q_REVISION(6, 7) void filterGroupChanged();
103 Q_REVISION(6, 7) void filterIgnoreGroupsChanged();
104
105private:
106 static void qmlAppendShape(QQmlListProperty<QAbstractCollisionShape> *list,
107 QAbstractCollisionShape *shape);
108 static QAbstractCollisionShape *qmlShapeAt(QQmlListProperty<QAbstractCollisionShape> *list,
109 qsizetype index);
110 static qsizetype qmlShapeCount(QQmlListProperty<QAbstractCollisionShape> *list);
111 static void qmlClearShapes(QQmlListProperty<QAbstractCollisionShape> *list);
112
113 QVector<QAbstractCollisionShape *> m_collisionShapes;
114 bool m_shapesDirty = false;
115 bool m_sendContactReports = false;
116 bool m_receiveContactReports = false;
117 bool m_sendTriggerReports = false;
118 bool m_receiveTriggerReports = false;
119 bool m_hasStaticShapes = false;
120 int m_filterGroup = 0;
121 int m_filterIgnoreGroups = 0;
122 bool m_filtersDirty = false;
123
124 friend class QPhysicsJoint;
125 friend class QAbstractPhysXNode;
126 friend class QPhysicsWorld; // for register/deregister TODO: cleaner mechanism
127 friend class SimulationEventCallback;
128 QAbstractPhysXNode *m_backendObject = nullptr;
129};
130
132
133#endif // ABSTRACTPHYSICSNODE_H
virtual void updateDefaultDensity(float density)
virtual void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache)=0
QAbstractPhysicsNode * frontendNode
QVector< physx::PxShape * > shapes
virtual void cleanup(QPhysXWorld *)
physx::PxMaterial * material
static physx::PxMaterial * sDefaultMaterial
virtual void rebuildDirtyShapes(QPhysicsWorld *, QPhysXWorld *)
void setShapesDirty(bool dirty)
virtual bool debugGeometryCapability()
virtual void updateFilters()
void createMaterialFromQtMaterial(QPhysXWorld *physX, QPhysicsMaterial *qtMaterial)
virtual physx::PxTransform getGlobalPose()
virtual void init(QPhysicsWorld *world, QPhysXWorld *physX)=0
virtual void markDirtyShapes()
virtual DebugDrawBodyType getDebugDrawBodyType()
void setFiltersDirty(bool dirty)
virtual void createMaterial(QPhysXWorld *physX)
bool cleanupIfRemoved(QPhysXWorld *physX)
virtual bool useTriggerFlag()
Definition qlist.h:81
void markDirtyShapes() override
void buildShapes(QPhysXWorld *physX)
void rebuildDirtyShapes(QPhysicsWorld *world, QPhysXWorld *physX) override
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
bool debugGeometryCapability() override
void cleanup(QPhysXWorld *physX) override
physx::PxRigidActor * actor
virtual void createActor(QPhysXWorld *physX)
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
void updateFilters() override
physx::PxTransform getGlobalPose() override
Combined button and popup list for selecting options.
DebugDrawBodyType
#define QML_UNCREATABLE(REASON)
#define QML_PRIVATE_NAMESPACE
#define QML_NAMED_ELEMENT(NAME)
void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds=nullptr)
Definition qqml.h:939
#define QML_FOREIGN(FOREIGN_TYPE)
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
#define QT_ANNOTATE_FUNCTION(x)
#define QT_ANNOTATE_CLASS2(type, a1, a2)
#define Q_PROPERTY(...)
#define Q_GADGET_EXPORT(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_CLASSINFO(name, value)
#define QT_ANNOTATE_CLASS(type,...)
#define Q_OBJECT_NO_ATTRIBUTES_WARNING
#define QT_META_OBJECT_VARS
#define Q_INTERFACES(x)
#define QT_TR_FUNCTIONS
#define QT_ANNOTATE_ACCESS_SPECIFIER(x)
#define QT_OBJECT_GADGET_COMMON
#define Q_SLOTS
#define Q_OBJECT_NO_OVERRIDE_WARNING
#define signals
#define Q_SIGNALS
#define Q_ENUM_IMPL(ENUM)
#define Q_ENUM_NS_IMPL(ENUM)
#define emit
#define Q_NAMESPACE_EXPORT(...)