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
qdistancejoint.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/PxDistanceJoint.h>
11
13
14/*!
15 \qmltype DistanceJoint
16 \inqmlmodule QtQuick3D.Physics
17 \since 6.12
18 \brief A distance joint.
19
20 A distance joint that will keep the origins of the joint within the
21 distance range specified by \l{DistanceJoint::}{minDistance} and
22 \l{DistanceJoint::}{maxDistance}.
23
24 \sa {FixedJoint}
25 \sa {PrismaticJoint}
26 \sa {RevoluteJoint}
27 \sa {SphericalJoint}
28*/
29
30/*!
31 \qmlproperty real DistanceJoint::minDistance
32 \since 6.12
33 \default 0.0
34
35 The minimum distance of the joint constraint.
36*/
37
38/*!
39 \qmlproperty real DistanceJoint::maxDistance
40 \since 6.12
41 \default 0.0
42
43 The maximum distance of the joint constraint.
44*/
45
46float QDistanceJoint::minDistance() const
47{
48 return m_minDistance;
49}
50
51void QDistanceJoint::setMinDistance(float newMinDistance)
52{
53 if (qFuzzyCompare(m_minDistance, newMinDistance))
54 return;
55 m_minDistance = newMinDistance;
56 m_dirtyProperties = true;
57 emit minDistanceChanged();
58}
59
60float QDistanceJoint::maxDistance() const
61{
62 return m_maxDistance;
63}
64
65void QDistanceJoint::setMaxDistance(float newMaxDistance)
66{
67 if (qFuzzyCompare(m_maxDistance, newMaxDistance))
68 return;
69 m_maxDistance = newMaxDistance;
70 m_dirtyProperties = true;
71 emit maxDistanceChanged();
72}
73
74physx::PxJoint *QDistanceJoint::createPhysxJoint(physx::PxRigidActor *actorA,
75 physx::PxRigidActor *actorB,
76 const physx::PxTransform &trfA,
77 const physx::PxTransform &trfB)
78{
79 return physx::PxDistanceJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
80 actorB, trfB);
81}
82
83void QDistanceJoint::setJointProperties()
84{
85 physx::PxDistanceJoint *joint = static_cast<physx::PxDistanceJoint *>(m_joint);
86 joint->setMinDistance(m_minDistance);
87 joint->setMaxDistance(m_maxDistance);
88}
89
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
#define emit