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
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
5
6#include "physxnode/qphysxactorbody_p.h"
9
10#include <extensions/PxSphericalJoint.h>
11
13
14/*!
15 \qmltype SphericalJoint
16 \inqmlmodule QtQuick3D.Physics
17 \since 6.12
18 \brief A spherical joint.
19
20 A spherical joint, also known as a ball-and-socket joint, keeps the origins
21 together, but allows the orientations to vary freely.
22
23 \sa {DistanceJoint}
24 \sa {FixedJoint}
25 \sa {PrismaticJoint}
26 \sa {RevoluteJoint}
27*/
28
29/*!
30 \qmlproperty real SphericalJoint::coneLimitY
31 \since 6.12
32 \default 0.0
33
34 The y limit (in radians) of the joint's cone constraint.
35*/
36
37/*!
38 \qmlproperty real SphericalJoint::coneLimitZ
39 \since 6.12
40 \default 0.0
41
42 The z limit (in radians) of the joint's cone constraint.
43*/
44
45/*!
46 \qmlproperty bool SphericalJoint::enableConeLimit
47 \since 6.12
48 \default false
49
50 Enable the cone limit constraint for the joint.
51*/
52
53float QSphericalJoint::coneLimitY() const
54{
55 return m_coneLimitY;
56}
57
58void QSphericalJoint::setConeLimitY(float newConeLimitY)
59{
60 if (qFuzzyCompare(m_coneLimitY, newConeLimitY))
61 return;
62 m_coneLimitY = newConeLimitY;
63 m_dirtyProperties = true;
64 emit coneLimitYChanged();
65}
66
67float QSphericalJoint::coneLimitZ() const
68{
69 return m_coneLimitZ;
70}
71
72void QSphericalJoint::setConeLimitZ(float newConeLimitZ)
73{
74 if (qFuzzyCompare(m_coneLimitZ, newConeLimitZ))
75 return;
76 m_coneLimitZ = newConeLimitZ;
77 m_dirtyProperties = true;
78 emit coneLimitZChanged();
79}
80
81bool QSphericalJoint::enableConeLimit() const
82{
83 return m_enableConeLimit;
84}
85
86void QSphericalJoint::setEnableConeLimit(bool newEnableConeLimit)
87{
88 if (m_enableConeLimit == newEnableConeLimit)
89 return;
90 m_enableConeLimit = newEnableConeLimit;
91 m_dirtyProperties = true;
92 emit enableConeLimitChanged();
93}
94
95physx::PxJoint *QSphericalJoint::createPhysxJoint(physx::PxRigidActor *actorA,
96 physx::PxRigidActor *actorB,
97 const physx::PxTransform &trfA,
98 const physx::PxTransform &trfB)
99{
100 return physx::PxSphericalJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
101 actorB, trfB);
102}
103
104void QSphericalJoint::setJointProperties()
105{
106 physx::PxSphericalJoint *joint = static_cast<physx::PxSphericalJoint *>(m_joint);
107 joint->setLimitCone(physx::PxJointLimitCone(m_coneLimitY, m_coneLimitZ));
108 joint->setSphericalJointFlag(physx::PxSphericalJointFlag::eLIMIT_ENABLED, m_enableConeLimit);
109}
110
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
#define emit