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
qprismaticjoint.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
"qprismaticjoint_p.h"
5
6
#
include
"physxnode/qphysxactorbody_p.h"
7
#
include
"qabstractphysicsnode_p.h"
8
#
include
"qstaticphysxobjects_p.h"
9
10
#
include
<
extensions
/
PxPrismaticJoint
.
h
>
11
12
#
include
<
PxPhysics
.
h
>
13
14
#
include
<
foundation
/
PxSimpleTypes
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
/*!
19
\qmltype PrismaticJoint
20
\inqmlmodule QtQuick3D.Physics
21
\since 6.12
22
\inherits FlexibleJoint
23
\brief A prismatic joint.
24
25
A prismatic joint permits relative translational movement between two bodies along an axis, but
26
no relative rotational movement. the axis on each body is defined as the line containing the
27
origin of the joint frame and extending along the x-axis of that frame
28
29
\sa {DistanceJoint}
30
\sa {FixedJoint}
31
\sa {RevoluteJoint}
32
\sa {SphericalJoint}
33
\sa {D6Joint}
34
*/
35
36
/*!
37
\qmlproperty real PrismaticJoint::lowerLimit
38
\since 6.12
39
\default -1000000
40
41
The lower limit of the constraint, i.e. how far along the negative x-axis the joint can extend.
42
43
Range: \c{[-inf, inf]}
44
45
\sa upperLimit
46
*/
47
48
/*!
49
\qmlproperty real PrismaticJoint::upperLimit
50
\since 6.12
51
\default 1000000
52
53
The upper limit of the constraint, i.e. how far along the positive x-axis the joint can extend.
54
55
Range: \c{[-inf, inf]}
56
57
\sa lowerLimit
58
*/
59
60
physx::PxJoint *QPrismaticJoint::createPhysxJoint(physx::PxRigidActor *actorA,
61
physx::PxRigidActor *actorB,
62
const
physx::PxTransform &trfA,
63
const
physx::PxTransform &trfB)
64
{
65
return
physx::PxPrismaticJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
66
actorB, trfB);
67
}
68
69
void
QPrismaticJoint::setJointProperties()
70
{
71
physx::PxPrismaticJoint *joint =
static_cast
<physx::PxPrismaticJoint *>(m_joint);
72
const
physx::PxTolerancesScale scale =
73
StaticPhysXObjects::getReference().physics->getTolerancesScale();
74
const
float
lowerLimit = qMin(m_lowerLimit, m_upperLimit);
75
const
float
upperLimit = qMax(m_lowerLimit, m_upperLimit);
76
77
physx::PxJointLinearLimitPair limit(scale, lowerLimit, upperLimit);
78
limit.stiffness = m_stiffness;
79
limit.damping = m_damping;
80
81
joint->setLimit(limit);
82
joint->setPrismaticJointFlag(physx::PxPrismaticJointFlag::eLIMIT_ENABLED,
true
);
83
}
84
85
float
QPrismaticJoint::lowerLimit()
const
86
{
87
return
m_lowerLimit;
88
}
89
90
void
QPrismaticJoint::setLowerLimit(
float
newLowerLimit)
91
{
92
newLowerLimit = qBound(-PX_MAX_F32, newLowerLimit, PX_MAX_F32);
93
if
(qFuzzyCompare(m_lowerLimit, newLowerLimit))
94
return
;
95
m_lowerLimit = newLowerLimit;
96
m_dirtyProperties =
true
;
97
emit
lowerLimitChanged();
98
}
99
100
float
QPrismaticJoint::upperLimit()
const
101
{
102
return
m_upperLimit;
103
}
104
105
void
QPrismaticJoint::setUpperLimit(
float
newUpperLimit)
106
{
107
newUpperLimit = qBound(-PX_MAX_F32, newUpperLimit, PX_MAX_F32);
108
if
(qFuzzyCompare(m_upperLimit, newUpperLimit))
109
return
;
110
m_upperLimit = newUpperLimit;
111
m_dirtyProperties =
true
;
112
emit
upperLimitChanged();
113
}
114
115
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
qprismaticjoint.cpp
Generated on
for Qt by
1.18.0