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
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
4
#
include
"qrevolutejoint_p.h"
5
6
#
include
"physxnode/qphysxactorbody_p.h"
7
#
include
"qabstractphysicsnode_p.h"
8
#
include
"qstaticphysxobjects_p.h"
9
10
#
include
<
extensions
/
PxRevoluteJoint
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
/*!
15
\qmltype RevoluteJoint
16
\inqmlmodule QtQuick3D.Physics
17
\since 6.12
18
\inherits FlexibleJoint
19
\brief A revolute joint.
20
21
A revolute joint, commonly referred to as a a hinge keeps the origins and x-axes
22
of the frames together, and allows free rotation around this common axis.
23
24
\sa {DistanceJoint}
25
\sa {FixedJoint}
26
\sa {PrismaticJoint}
27
\sa {SphericalJoint}
28
\sa {D6Joint}
29
*/
30
31
/*!
32
\qmlproperty real RevoluteJoint::angularLimitLower
33
\since 6.12
34
\default -pi/2
35
36
The lower angular limit (in radians) of the joint constraint.
37
38
Range: \c{[-2*pi, 2*pi]}
39
40
\sa angularLimitUpper
41
*/
42
43
/*!
44
\qmlproperty real RevoluteJoint::angularLimitUpper
45
\since 6.12
46
\default pi/2
47
48
The Upper angular limit (in radians) of the joint constraint.
49
50
Range: \c{[-2*pi, 2*pi]}
51
52
\sa angularLimitLower
53
*/
54
55
/*!
56
\qmlproperty bool RevoluteJoint::enableAngularLimit
57
\since 6.12
58
\default false
59
60
Enable the angular limit constraint for the joint.
61
*/
62
63
float
QRevoluteJoint::angularLimitLower()
const
64
{
65
return
m_angularLimitLower;
66
}
67
68
void
QRevoluteJoint::setAngularLimitLower(
float
newAngularLimitLower)
69
{
70
newAngularLimitLower = qBound(-2.0f * physx::PxPi, newAngularLimitLower, 2.0f * physx::PxPi);
71
if
(qFuzzyCompare(m_angularLimitLower, newAngularLimitLower))
72
return
;
73
m_angularLimitLower = newAngularLimitLower;
74
m_dirtyProperties =
true
;
75
emit
angularLimitLowerChanged();
76
}
77
78
float
QRevoluteJoint::angularLimitUpper()
const
79
{
80
return
m_angularLimitUpper;
81
}
82
83
void
QRevoluteJoint::setAngularLimitUpper(
float
newAngularLimitUpper)
84
{
85
newAngularLimitUpper = qBound(-2.0f * physx::PxPi, newAngularLimitUpper, 2.0f * physx::PxPi);
86
if
(qFuzzyCompare(m_angularLimitUpper, newAngularLimitUpper))
87
return
;
88
m_angularLimitUpper = newAngularLimitUpper;
89
m_dirtyProperties =
true
;
90
emit
angularLimitUpperChanged();
91
}
92
93
bool
QRevoluteJoint::enableAngularLimit()
const
94
{
95
return
m_enableAngularLimit;
96
}
97
98
void
QRevoluteJoint::setEnableAngularLimit(
bool
newEnableAngularLimit)
99
{
100
if
(m_enableAngularLimit == newEnableAngularLimit)
101
return
;
102
m_enableAngularLimit = newEnableAngularLimit;
103
m_dirtyProperties =
true
;
104
emit
enableAngularLimitChanged();
105
}
106
107
physx::PxJoint *QRevoluteJoint::createPhysxJoint(physx::PxRigidActor *actorA,
108
physx::PxRigidActor *actorB,
109
const
physx::PxTransform &trfA,
110
const
physx::PxTransform &trfB)
111
{
112
return
physx::PxRevoluteJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
113
actorB, trfB);
114
}
115
116
void
QRevoluteJoint::setJointProperties()
117
{
118
physx::PxRevoluteJoint *joint =
static_cast
<physx::PxRevoluteJoint *>(m_joint);
119
const
float
lower = qMin(m_angularLimitLower, m_angularLimitUpper);
120
const
float
upper = qMax(m_angularLimitLower, m_angularLimitUpper);
121
122
physx::PxJointAngularLimitPair limit(lower, upper);
123
limit.stiffness = m_stiffness;
124
limit.damping = m_damping;
125
126
joint->setLimit(limit);
127
joint->setRevoluteJointFlag(physx::PxRevoluteJointFlag::eLIMIT_ENABLED, m_enableAngularLimit);
128
}
129
130
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
qrevolutejoint.cpp
Generated on
for Qt by
1.18.0