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
qrevolutejoint.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/PxRevoluteJoint.h>
11
13
14/*!
15 \qmltype RevoluteJoint
16 \inqmlmodule QtQuick3D.Physics
17 \since 6.12
18 \brief A revolute joint.
19
20 A revolute joint, commonly referred to as a a hinge keeps the origins and x-axes
21 of the frames together, and allows free rotation around this common axis.
22
23 \sa {DistanceJoint}
24 \sa {FixedJoint}
25 \sa {PrismaticJoint}
26 \sa {SphericalJoint}
27*/
28
29/*!
30 \qmlproperty real RevoluteJoint::angularLimitLower
31 \since 6.12
32 \default 0.0
33
34 The lower angular limit (in radians) of the joint constraint.
35*/
36
37/*!
38 \qmlproperty real RevoluteJoint::angularLimitUpper
39 \since 6.12
40 \default 0.0
41
42 The Upper angular limit (in radians) of the joint constraint.
43*/
44
45/*!
46 \qmlproperty bool RevoluteJoint::enableAngularLimit
47 \since 6.12
48 \default false
49
50 Enable the angular limit constraint for the joint.
51*/
52
53float QRevoluteJoint::angularLimitLower() const
54{
55 return m_angularLimitLower;
56}
57
58void QRevoluteJoint::setAngularLimitLower(float newAngularLimitLower)
59{
60 if (qFuzzyCompare(m_angularLimitLower, newAngularLimitLower))
61 return;
62 m_angularLimitLower = newAngularLimitLower;
63 m_dirtyProperties = true;
64 emit angularLimitLowerChanged();
65}
66
67float QRevoluteJoint::angularLimitUpper() const
68{
69 return m_angularLimitUpper;
70}
71
72void QRevoluteJoint::setAngularLimitUpper(float newAngularLimitUpper)
73{
74 if (qFuzzyCompare(m_angularLimitUpper, newAngularLimitUpper))
75 return;
76 m_angularLimitUpper = newAngularLimitUpper;
77 m_dirtyProperties = true;
78 emit angularLimitUpperChanged();
79}
80
81bool QRevoluteJoint::enableAngularLimit() const
82{
83 return m_enableAngularLimit;
84}
85
86void QRevoluteJoint::setEnableAngularLimit(bool newEnableAngularLimit)
87{
88 if (m_enableAngularLimit == newEnableAngularLimit)
89 return;
90 m_enableAngularLimit = newEnableAngularLimit;
91 m_dirtyProperties = true;
92 emit enableAngularLimitChanged();
93}
94
95physx::PxJoint *QRevoluteJoint::createPhysxJoint(physx::PxRigidActor *actorA,
96 physx::PxRigidActor *actorB,
97 const physx::PxTransform &trfA,
98 const physx::PxTransform &trfB)
99{
100 return physx::PxRevoluteJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
101 actorB, trfB);
102}
103
104void QRevoluteJoint::setJointProperties()
105{
106 physx::PxRevoluteJoint *joint = static_cast<physx::PxRevoluteJoint *>(m_joint);
107 joint->setLimit(physx::PxJointAngularLimitPair(m_angularLimitLower, m_angularLimitUpper));
108 joint->setRevoluteJointFlag(physx::PxRevoluteJointFlag::eLIMIT_ENABLED, m_enableAngularLimit);
109}
110
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
#define emit