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
qflexiblejoint.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
"qflexiblejoint_p.h"
5
6
#
include
<
extensions
/
PxJoint
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\qmltype FlexibleJoint
12
\inqmlmodule QtQuick3D.Physics
13
\since 6.13
14
\inherits PhysicsJoint
15
\brief Base type for flexible joints with configurable spring stiffness and damping.
16
17
This is the abstract base type for all joints that support customizable spring stiffness
18
and damping factors for soft constraints and joint limits.
19
20
Whether a joint limit is hard or soft, and how it behaves when soft, depends on the
21
combination of \l stiffness and \l damping, as seen in the following table:
22
23
\table
24
\header
25
\li \l stiffness
26
\li \l damping
27
\li Behavior
28
\row
29
\li \c 0.0
30
\li \c 0.0
31
\li Hard constraint: the limit cannot be penetrated (the default).
32
\row
33
\li greater than \c 0.0
34
\li \c 0.0
35
\li Soft spring, undamped: the body bounces against the limit indefinitely.
36
\row
37
\li greater than \c 0.0
38
\li greater than \c 0.0
39
\li Soft spring, damped: the body bounces against the limit and settles.
40
\row
41
\li \c 0.0
42
\li greater than \c 0.0
43
\li Soft, viscous drag only: motion is resisted, but no positional restoring force is
44
applied.
45
\endtable
46
47
\note At least one of the connected bodies needs to be dynamic.
48
49
\sa {FixedJoint}
50
\sa {DistanceJoint}
51
\sa {PrismaticJoint}
52
\sa {RevoluteJoint}
53
\sa {SphericalJoint}
54
\sa {D6Joint}
55
*/
56
57
/*!
58
\qmlproperty real FlexibleJoint::stiffness
59
\since 6.13
60
\default 0.0
61
62
This property holds the spring stiffness for joint limits. See the table above for how it
63
combines with \l damping to determine whether the limit is hard or soft.
64
65
When greater than \c 0.0, the higher the value, the stronger the restorative force pulling
66
the body back once it crosses the limit boundary, and the less penetration is allowed before
67
the body is pushed back. The right value depends on the mass and geometry of the connected
68
bodies. A value that feels stiff for a light body with a short lever arm may feel soft for a
69
heavier body or a longer lever arm, so start from a small value and increase it until the
70
limit feels sufficiently rigid for your scene.
71
72
Range: \c{[0, \inf)}
73
74
\sa damping, PhysicsWorld::typicalLength, PhysicsWorld::defaultDensity
75
*/
76
77
/*!
78
\qmlproperty real FlexibleJoint::damping
79
\since 6.13
80
\default 0.0
81
82
This property holds the energy dissipation (damping factor) for soft joint limits. See the
83
table above for how it combines with \l stiffness to determine whether the limit is hard or
84
soft.
85
86
When \l stiffness is greater than \c 0.0, this property controls how quickly oscillations
87
around the limit boundary settle: with \c 0.0 (the default), no energy is lost and the body
88
bounces indefinitely; increasing the value suppresses the bounce, though too little leaves
89
the body oscillating before it settles, while too much makes the motion near the limit feel
90
heavy or sluggish.
91
92
When \l stiffness is \c 0.0, this property instead applies a resistive (viscous) force with
93
no positional restoring effect.
94
95
Range: \c{[0, \inf)}
96
97
\sa stiffness, PhysicsWorld::typicalLength, PhysicsWorld::defaultDensity
98
*/
99
100
float
QFlexibleJoint::stiffness()
const
101
{
102
return
m_stiffness;
103
}
104
105
void
QFlexibleJoint::setStiffness(
float
stiffness)
106
{
107
stiffness = qMax(0.f, stiffness);
108
if
(qFuzzyCompare(m_stiffness, stiffness))
109
return
;
110
m_stiffness = stiffness;
111
m_dirtyProperties =
true
;
112
emit
stiffnessChanged();
113
}
114
115
float
QFlexibleJoint::damping()
const
116
{
117
return
m_damping;
118
}
119
120
void
QFlexibleJoint::setDamping(
float
damping)
121
{
122
damping = qMax(0.f, damping);
123
if
(qFuzzyCompare(m_damping, damping))
124
return
;
125
m_damping = damping;
126
m_dirtyProperties =
true
;
127
emit
dampingChanged();
128
}
129
130
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
emit
#define emit
Definition
qtmetamacros.h:53
qtquick3dphysics
src
quick3dphysics
joints
qflexiblejoint.cpp
Generated on
for Qt by
1.18.0