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