Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5
9
10#include "PxPhysics.h"
11#include "PxMaterial.h"
12#include "PxShape.h"
13
14#define PHYSX_RELEASE(x) \
15 if (x != nullptr) { \
16 x->release(); \
17 x = nullptr; \
18 }
19
21
22physx::PxMaterial *QAbstractPhysXNode::sDefaultMaterial = nullptr;
23
25{
26 Q_ASSERT(node->m_backendObject == nullptr);
27 node->m_backendObject = this;
28}
29
31 if (!frontendNode) {
33 return;
34 }
35
36 Q_ASSERT(frontendNode->m_backendObject == this);
37 frontendNode->m_backendObject = nullptr;
38}
39
41{
42 if (isRemoved) {
43 cleanup(physX);
44 delete this;
45 return true;
46 }
47 return false;
48}
49
51
56
58{
59 auto &s_physx = StaticPhysXObjects::getReference();
60
61 if (qtMaterial) {
62 material = s_physx.physics->createMaterial(qtMaterial->staticFriction(),
63 qtMaterial->dynamicFriction(),
64 qtMaterial->restitution());
65 } else {
66 if (!sDefaultMaterial) {
67 sDefaultMaterial = s_physx.physics->createMaterial(
70 }
72 }
73}
74
76
78
80
82{
83 for (auto *shape : shapes)
84 PHYSX_RELEASE(shape);
87}
88
90{
91 return false;
92}
93
95{
96 return {};
97}
98
100{
101 return false;
102}
103
108
110{
111 return frontendNode && frontendNode->m_shapesDirty;
112}
113
115{
116 frontendNode->m_shapesDirty = dirty;
117}
118
120{
121 return frontendNode && frontendNode->m_filtersDirty;
122}
123
125{
127 frontendNode->m_filtersDirty = dirty;
128}
129
virtual void updateDefaultDensity(float density)
QAbstractPhysicsNode * frontendNode
QVector< physx::PxShape * > shapes
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()
static constexpr float defaultDynamicFriction
static constexpr float defaultStaticFriction
static constexpr float defaultRestitution
Combined button and popup list for selecting options.
#define PHYSX_RELEASE(x)
DebugDrawBodyType
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static StaticPhysXObjects & getReference()