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
qd6joint_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QD6JOINT_P_H
5#define QD6JOINT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DPhysics/private/qjoint_p.h>
19#include <QtQml/qqmlregistration.h>
20
21#include <extensions/PxD6Joint.h>
22
24
25class Q_QUICK3DPHYSICS_EXPORT QD6Joint : public QPhysicsJoint
26{
27 Q_OBJECT
28 // Motion states for 6 degrees of freedom
29 Q_PROPERTY(Motion xMotion READ xMotion WRITE setXMotion NOTIFY xMotionChanged
30 FINAL REVISION(6, 13))
31 Q_PROPERTY(Motion yMotion READ yMotion WRITE setYMotion NOTIFY yMotionChanged
32 FINAL REVISION(6, 13))
33 Q_PROPERTY(Motion zMotion READ zMotion WRITE setZMotion NOTIFY zMotionChanged
34 FINAL REVISION(6, 13))
35 Q_PROPERTY(Motion twistMotion READ twistMotion WRITE setTwistMotion NOTIFY twistMotionChanged
36 FINAL REVISION(6, 13))
37 Q_PROPERTY(Motion swingMotionY READ swingMotionY WRITE setSwingMotionY NOTIFY swingMotionYChanged
38 FINAL REVISION(6, 13))
39 Q_PROPERTY(Motion swingMotionZ READ swingMotionZ WRITE setSwingMotionZ NOTIFY swingMotionZChanged
40 FINAL REVISION(6, 13))
42 // Linear limits per axis
43 Q_PROPERTY(float linearLimitXLower READ linearLimitXLower WRITE setLinearLimitXLower NOTIFY linearLimitXLowerChanged
44 FINAL REVISION(6, 13))
45 Q_PROPERTY(float linearLimitXUpper READ linearLimitXUpper WRITE setLinearLimitXUpper NOTIFY linearLimitXUpperChanged
46 FINAL REVISION(6, 13))
47 Q_PROPERTY(float linearLimitYLower READ linearLimitYLower WRITE setLinearLimitYLower NOTIFY linearLimitYLowerChanged
48 FINAL REVISION(6, 13))
49 Q_PROPERTY(float linearLimitYUpper READ linearLimitYUpper WRITE setLinearLimitYUpper NOTIFY linearLimitYUpperChanged
50 FINAL REVISION(6, 13))
51 Q_PROPERTY(float linearLimitZLower READ linearLimitZLower WRITE setLinearLimitZLower NOTIFY linearLimitZLowerChanged
52 FINAL REVISION(6, 13))
53 Q_PROPERTY(float linearLimitZUpper READ linearLimitZUpper WRITE setLinearLimitZUpper NOTIFY linearLimitZUpperChanged
54 FINAL REVISION(6, 13))
55
56 // Angular limits
57 Q_PROPERTY(float twistLimitLower READ twistLimitLower WRITE setTwistLimitLower NOTIFY twistLimitLowerChanged
58 FINAL REVISION(6, 13))
59 Q_PROPERTY(float twistLimitUpper READ twistLimitUpper WRITE setTwistLimitUpper NOTIFY twistLimitUpperChanged
60 FINAL REVISION(6, 13))
61 Q_PROPERTY(float swingLimitAngleY READ swingLimitAngleY WRITE setSwingLimitAngleY NOTIFY swingLimitAngleYChanged
62 FINAL REVISION(6, 13))
63 Q_PROPERTY(float swingLimitAngleZ READ swingLimitAngleZ WRITE setSwingLimitAngleZ NOTIFY swingLimitAngleZChanged
64 FINAL REVISION(6, 13))
65
66 // Spring parameters for soft constraints / flexible behavior
67 Q_PROPERTY(float linearStiffness READ linearStiffness WRITE setLinearStiffness NOTIFY linearStiffnessChanged
68 FINAL REVISION(6, 13))
69 Q_PROPERTY(float linearDamping READ linearDamping WRITE setLinearDamping NOTIFY linearDampingChanged
70 FINAL REVISION(6, 13))
71 Q_PROPERTY(float angularStiffness READ angularStiffness WRITE setAngularStiffness NOTIFY angularStiffnessChanged
72 FINAL REVISION(6, 13))
73 Q_PROPERTY(float angularDamping READ angularDamping WRITE setAngularDamping NOTIFY angularDampingChanged
74 FINAL REVISION(6, 13))
75
76 QML_NAMED_ELEMENT(D6Joint)
77 QML_ADDED_IN_VERSION(6, 13)
78
79public:
80 enum class Motion {
81 Locked,
82 Limited,
83 Free
84 };
85 Q_ENUM(Motion)
86
87 QD6Joint();
88 ~QD6Joint() override = default;
89
90 Motion xMotion() const;
91 void setXMotion(Motion motion);
92
93 Motion yMotion() const;
94 void setYMotion(Motion motion);
95
96 Motion zMotion() const;
97 void setZMotion(Motion motion);
98
99 Motion twistMotion() const;
100 void setTwistMotion(Motion motion);
101
102 float linearLimitXLower() const;
103 void setLinearLimitXLower(float limit);
104
105 float linearLimitXUpper() const;
106 void setLinearLimitXUpper(float limit);
107
108 float linearLimitYLower() const;
109 void setLinearLimitYLower(float limit);
110
111 float linearLimitYUpper() const;
112 void setLinearLimitYUpper(float limit);
113
114 float linearLimitZLower() const;
115 void setLinearLimitZLower(float limit);
116
117 float linearLimitZUpper() const;
118 void setLinearLimitZUpper(float limit);
119
120 float twistLimitLower() const;
121 void setTwistLimitLower(float limit);
122
123 float twistLimitUpper() const;
124 void setTwistLimitUpper(float limit);
125
126 float linearStiffness() const;
127 void setLinearStiffness(float stiffness);
128
129 float linearDamping() const;
130 void setLinearDamping(float damping);
132 float angularStiffness() const;
133 void setAngularStiffness(float stiffness);
135 float angularDamping() const;
136 void setAngularDamping(float damping);
138 Motion swingMotionY() const;
139 void setSwingMotionY(Motion newSwingMotionY);
141 Motion swingMotionZ() const;
142 void setSwingMotionZ(Motion newSwingMotionZ);
144 float swingLimitAngleY() const;
145 void setSwingLimitAngleY(float newSwingLimitAngleY);
147 float swingLimitAngleZ() const;
148 void setSwingLimitAngleZ(float newSwingLimitAngleZ);
150signals:
151 void xMotionChanged();
152 void yMotionChanged();
153 void zMotionChanged();
154 void twistMotionChanged();
155 void linearLimitXLowerChanged();
156 void linearLimitXUpperChanged();
157 void linearLimitYLowerChanged();
158 void linearLimitYUpperChanged();
159 void linearLimitZLowerChanged();
160 void linearLimitZUpperChanged();
161 void twistLimitLowerChanged();
162 void twistLimitUpperChanged();
163 void linearStiffnessChanged();
164 void linearDampingChanged();
165 void angularStiffnessChanged();
166 void angularDampingChanged();
167
168 void swingMotionYChanged();
169 void swingMotionZChanged();
170 void swingLimitAngleYChanged();
171 void swingLimitAngleZChanged();
172
173protected:
174 physx::PxJoint *createPhysxJoint(physx::PxRigidActor *actorA,
175 physx::PxRigidActor *actorB,
176 const physx::PxTransform &trfA,
177 const physx::PxTransform &trfB) override;
178 void setJointProperties() override;
179
180private:
181 Motion m_xMotion = Motion::Locked;
182 Motion m_yMotion = Motion::Locked;
183 Motion m_zMotion = Motion::Locked;
184 Motion m_twistMotion = Motion::Locked;
185 Motion m_swingMotionY = Motion::Locked;
186 Motion m_swingMotionZ = Motion::Locked;
187
188 // Linear limits
189 float m_linearLimitXLower = -1.0f;
190 float m_linearLimitXUpper = 1.0f;
191 float m_linearLimitYLower = -1.0f;
192 float m_linearLimitYUpper = 1.0f;
193 float m_linearLimitZLower = -1.0f;
194 float m_linearLimitZUpper = 1.0f;
195
196 // Angular limits (Twist: [-45 deg, 45 deg], Swing: 45 deg in radians)
197 float m_twistLimitLower = -float(M_PI_4);
198 float m_twistLimitUpper = float(M_PI_4);
199 float m_swingLimitAngleY = float(M_PI_4);
200 float m_swingLimitAngleZ = float(M_PI_4);
201
202 // Spring & Damping (0.0f means hard limits by default)
203 float m_linearStiffness = 0.0f;
204 float m_linearDamping = 0.0f;
205 float m_angularStiffness = 0.0f;
206 float m_angularDamping = 0.0f;
207
208};
209
210QT_END_NAMESPACE
211
212#endif // QD6JOINT_P_H
physx::PxD6Motion::Enum toPxEnum(QD6Joint::Motion val)
Definition qd6joint.cpp:286
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE