6#include "physxnode/qphysxactorbody_p.h"
10#include <extensions/PxRevoluteJoint.h>
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
32
33
34
35
36
37
38
39
40
41
44
45
46
47
48
49
50
51
52
53
56
57
58
59
60
61
63float QRevoluteJoint::angularLimitLower()
const
65 return m_angularLimitLower;
68void QRevoluteJoint::setAngularLimitLower(
float newAngularLimitLower)
70 newAngularLimitLower = qBound(-2.0f * physx::PxPi, newAngularLimitLower, 2.0f * physx::PxPi);
71 if (qFuzzyCompare(m_angularLimitLower, newAngularLimitLower))
73 m_angularLimitLower = newAngularLimitLower;
74 m_dirtyProperties =
true;
75 emit angularLimitLowerChanged();
78float QRevoluteJoint::angularLimitUpper()
const
80 return m_angularLimitUpper;
83void QRevoluteJoint::setAngularLimitUpper(
float newAngularLimitUpper)
85 newAngularLimitUpper = qBound(-2.0f * physx::PxPi, newAngularLimitUpper, 2.0f * physx::PxPi);
86 if (qFuzzyCompare(m_angularLimitUpper, newAngularLimitUpper))
88 m_angularLimitUpper = newAngularLimitUpper;
89 m_dirtyProperties =
true;
90 emit angularLimitUpperChanged();
93bool QRevoluteJoint::enableAngularLimit()
const
95 return m_enableAngularLimit;
98void QRevoluteJoint::setEnableAngularLimit(
bool newEnableAngularLimit)
100 if (m_enableAngularLimit == newEnableAngularLimit)
102 m_enableAngularLimit = newEnableAngularLimit;
103 m_dirtyProperties =
true;
104 emit enableAngularLimitChanged();
107physx::PxJoint *QRevoluteJoint::createPhysxJoint(physx::PxRigidActor *actorA,
108 physx::PxRigidActor *actorB,
109 const physx::PxTransform &trfA,
110 const physx::PxTransform &trfB)
112 return physx::PxRevoluteJointCreate(*StaticPhysXObjects::getReference().physics, actorA, trfA,
116void QRevoluteJoint::setJointProperties()
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);
122 physx::PxJointAngularLimitPair limit(lower, upper);
123 limit.stiffness = m_stiffness;
124 limit.damping = m_damping;
126 joint->setLimit(limit);
127 joint->setRevoluteJointFlag(physx::PxRevoluteJointFlag::eLIMIT_ENABLED, m_enableAngularLimit);
#define QT_BEGIN_NAMESPACE