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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef ABSTRACTPHYSXNODE_H
#define ABSTRACTPHYSXNODE_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 "foundation/PxTransform.h"
#include "qtconfigmacros.h"
#include <QVector>
namespace physx {
class PxMaterial;
class PxShape;
}
QT_BEGIN_NAMESPACE
class QAbstractPhysicsNode;
class QMatrix4x4;
class QQuick3DNode;
class QPhysicsWorld;
class QPhysicsMaterial;
class QPhysXWorld;
// Used for debug drawing
enum class DebugDrawBodyType {
Static = 0,
DynamicAwake = 1,
DynamicSleeping = 2,
Trigger = 3,
Character = 4,
Unknown = 5
};
/*
NOTE
The inheritance hierarchy is not ideal, since both controller and rigid body have materials,
but trigger doesn't. AND both trigger and rigid body have actors, but controller doesn't.
TODO: defaultMaterial isn't used for rigid bodies, since they always create their own
QPhysicsMaterial with default values. We should only have a qt material when set explicitly.
*/
class QAbstractPhysXNode
{
public:
QAbstractPhysXNode(QAbstractPhysicsNode *node);
virtual ~QAbstractPhysXNode();
bool cleanupIfRemoved(QPhysXWorld *physX); // TODO rename??
virtual void init(QPhysicsWorld *world, QPhysXWorld *physX) = 0;
virtual void updateDefaultDensity(float density);
virtual void createMaterial(QPhysXWorld *physX);
void createMaterialFromQtMaterial(QPhysXWorld *physX, QPhysicsMaterial *qtMaterial);
virtual void markDirtyShapes();
virtual void rebuildDirtyShapes(QPhysicsWorld *, QPhysXWorld *);
virtual void updateFilters();
virtual void sync(float deltaTime, QHash<QQuick3DNode *, QMatrix4x4> &transformCache) = 0;
virtual void cleanup(QPhysXWorld *);
virtual bool debugGeometryCapability();
virtual physx::PxTransform getGlobalPose();
virtual bool useTriggerFlag();
virtual DebugDrawBodyType getDebugDrawBodyType();
bool shapesDirty() const;
void setShapesDirty(bool dirty);
bool filtersDirty() const;
void setFiltersDirty(bool dirty);
QVector<physx::PxShape *> shapes;
physx::PxMaterial *material = nullptr;
QAbstractPhysicsNode *frontendNode = nullptr;
bool isRemoved = false;
static physx::PxMaterial *sDefaultMaterial;
};
QT_END_NAMESPACE
#endif
|