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
qabstractphysxnode.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
10
11#include "PxPhysics.h"
12#include "PxMaterial.h"
13#include "PxShape.h"
14
15#define PHYSX_RELEASE(x)
16 if (x != nullptr) {
17 x->release();
18 x = nullptr;
19 }
20
22
23physx::PxMaterial *QAbstractPhysXNode::sDefaultMaterial = nullptr;
24
25QAbstractPhysXNode::QAbstractPhysXNode(QAbstractPhysicsNode *node) : frontendNode(node)
26{
27 Q_ASSERT(node->m_backendObject == nullptr);
28 node->m_backendObject = this;
29}
30
32 if (!frontendNode) {
33 Q_ASSERT(isRemoved);
34 return;
35 }
36
37 Q_ASSERT(frontendNode->m_backendObject == this);
38 frontendNode->m_backendObject = nullptr;
39}
40
42{
43 if (isRemoved) {
44 cleanup(physX);
45 delete this;
46 return true;
47 }
48 return false;
49}
50
52
57
58void QAbstractPhysXNode::createMaterialFromQtMaterial(QPhysXWorld *, QPhysicsMaterial *qtMaterial)
59{
61
62 if (qtMaterial) {
63 material = s_physx.physics->createMaterial(qtMaterial->staticFriction(),
64 qtMaterial->dynamicFriction(),
65 qtMaterial->restitution());
66 } else {
67 if (!sDefaultMaterial) {
68 sDefaultMaterial = s_physx.physics->createMaterial(
69 QPhysicsMaterial::defaultStaticFriction,
70 QPhysicsMaterial::defaultDynamicFriction, QPhysicsMaterial::defaultRestitution);
71 }
73 }
74}
75
77
79
81
83{
84 for (auto *shape : shapes)
85 PHYSX_RELEASE(shape);
88}
89
91{
92 return false;
93}
94
96{
97 return {};
98}
99
101{
102 return false;
103}
104
109
111{
112 return frontendNode && frontendNode->m_shapesDirty;
113}
114
116{
117 frontendNode->m_shapesDirty = dirty;
118}
119
121{
122 return frontendNode && frontendNode->m_filtersDirty;
123}
124
126{
127 Q_ASSERT(frontendNode);
128 frontendNode->m_filtersDirty = dirty;
129}
130
virtual void updateDefaultDensity(float density)
QAbstractPhysicsNode * frontendNode
virtual void cleanup(QPhysXWorld *)
physx::PxMaterial * material
static physx::PxMaterial * sDefaultMaterial
QAbstractPhysXNode(QAbstractPhysicsNode *node)
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 markDirtyShapes()
virtual DebugDrawBodyType getDebugDrawBodyType()
void setFiltersDirty(bool dirty)
virtual void createMaterial(QPhysXWorld *physX)
bool cleanupIfRemoved(QPhysXWorld *physX)
virtual bool useTriggerFlag()
#define PHYSX_RELEASE(x)
DebugDrawBodyType
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
static StaticPhysXObjects & getReference()