Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsphericaljoint.cpp
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
#
include
"qsphericaljoint_p.h"
5
6
#
include
"physxnode/qphysxactorbody_p.h"
7
#
include
"qabstractphysicsnode_p.h"
8
#
include
"qstaticphysxobjects_p.h"
9
10
#
include
<
extensions
/
PxSphericalJoint
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
/*!
15
\qmltype SphericalJoint
16
\inqmlmodule QtQuick3D.Physics
17
\since 6.12
18
\inherits FlexibleJoint
19
\brief A spherical joint.
20
21
A spherical joint, also known as a ball-and-socket joint, keeps the origins
22
together, but allows the orientations to vary freely.
23
24
\sa {DistanceJoint}
25
\sa {FixedJoint}
26
\sa {PrismaticJoint}
27
\sa {RevoluteJoint}
28
\sa {D6Joint}
29
*/
30
31
/*!
32
\qmlproperty real SphericalJoint::coneLimitY
33
\since 6.12
34
\default pi/2
35
36
The y limit (in radians) of the joint's cone constraint.
37
38
Range: \c{(0, pi)}
39
40
\sa coneLimitZ
41
*/
42
43
/*!
44
\qmlproperty real SphericalJoint::coneLimitZ
45
\since 6.12
46
\default pi/2
47
48
The z limit (in radians) of the joint's cone constraint.
49
50
Range: \c{(0, pi)}
51
52
\sa coneLimitY
53
*/
54
55
/*!
56
\qmlproperty bool SphericalJoint::enableConeLimit
57
\since 6.12
58
\default false
59
60
Enable the cone limit constraint for the joint.
61
*/
62
63
float
QSphericalJoint::coneLimitY()
const
64
{
65
return
m_coneLimitY;
66
}
67
68
void
QSphericalJoint::setConeLimitY(
float
newConeLimitY)
69
{
70
// PxJointLimitCone::isValid() requires yAngle strictly within (0, PxPi),
71
// so the margin keeps the clamped value off both boundaries.
72
newConeLimitY = qBound(1e-4f, newConeLimitY, physx::PxPi - 1e-4f);
73
if
(qFuzzyCompare(m_coneLimitY, newConeLimitY))
74
return
;
75
m_coneLimitY = newConeLimitY;
76
m_dirtyProperties =
true
;
77
emit
coneLimitYChanged();
78
}
79
80
float
QSphericalJoint::coneLimitZ()
const
81
{
82
return
m_coneLimitZ;
83
}
84
85
void
QSphericalJoint::setConeLimitZ(
float
newConeLimitZ)
86
{
87
// PxJointLimitCone::isValid() requires zAngle strictly within (0, PxPi),
88
// so the margin keeps the clamped value off both boundaries.
89
newConeLimitZ = qBound(1e-4f, newConeLimitZ, physx::PxPi - 1e-4f);
90
if
(qFuzzyCompare(m_coneLimitZ, newConeLimitZ))
91
return
;
92
m_coneLimitZ = newConeLimitZ;
93
m_dirtyProperties =
true
;
94
emit
coneLimitZChanged();
95
}
96
97
bool
QSphericalJoint::enableConeLimit()
const
98
{
99
return
m_enableConeLimit;
100
}
101
102
void
QSphericalJoint::setEnableConeLimit(
bool
newEnableConeLimit)
103
{
104
if
(m_enableConeLimit == newEnableConeLimit)
105
return
;
106
m_enableConeLimit = newEnableConeLimit;
107
m_dirtyProperties =
true
;
108
emit
enableConeLimitChanged();
109
}
110
111
physx::PxJoint *QSphericalJoint::createPhysxJoint(physx::PxRigidActor *actorA,
112
physx::PxRigidActor *actorB,
113
const
physx::PxTransform &trfA,
114
const
physx::PxTransform &trfB)
115
{
116
return
physx::PxSphericalJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
117
actorB, trfB);
118
}
119
120
void
QSphericalJoint::setJointProperties()
121
{
122
physx::PxSphericalJoint *joint =
static_cast
<physx::PxSphericalJoint *>(m_joint);
123
124
physx::PxJointLimitCone limit(m_coneLimitY, m_coneLimitZ);
125
limit.stiffness = m_stiffness;
126
limit.damping = m_damping;
127
128
joint->setLimitCone(limit);
129
joint->setSphericalJointFlag(physx::PxSphericalJointFlag::eLIMIT_ENABLED, m_enableConeLimit);
130
}
131
132
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
Definition
qtconfigmacros.h:161
QT_END_NAMESPACE
#define QT_END_NAMESPACE
Definition
qtconfigmacros.h:162
emit
#define emit
Definition
qtmetamacros.h:53
qtquick3dphysics
src
quick3dphysics
joints
qsphericaljoint.cpp
Generated on
for Qt by
1.18.0