1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30#ifndef PX_SPHERICALJOINT_H
31#define PX_SPHERICALJOINT_H
32/** \addtogroup extensions
33 @{
34*/
35
36#include "extensions/PxJoint.h"
37#include "extensions/PxJointLimit.h"
38
39#if !PX_DOXYGEN
40namespace physx
41{
42#endif
43
44class PxSphericalJoint;
45
46/**
47\brief Create a spherical joint.
48
49 \param[in] physics The physics SDK
50 \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
51 \param[in] localFrame0 The position and orientation of the joint relative to actor0
52 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame
53 \param[in] localFrame1 The position and orientation of the joint relative to actor1
54
55@see PxSphericalJoint
56*/
57PxSphericalJoint* PxSphericalJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
58
59
60/**
61\brief Flags specific to the spherical joint.
62
63@see PxSphericalJoint
64*/
65struct PxSphericalJointFlag
66{
67 enum Enum
68 {
69 eLIMIT_ENABLED = 1<<1 //!< the cone limit for the spherical joint is enabled
70 };
71};
72typedef PxFlags<PxSphericalJointFlag::Enum, PxU16> PxSphericalJointFlags;
73PX_FLAGS_OPERATORS(PxSphericalJointFlag::Enum, PxU16)
74
75/**
76\brief A joint which behaves in a similar way to a ball and socket.
77
78 A spherical joint removes all linear degrees of freedom from two objects.
79
80 The position of the joint on each actor is specified by the origin of the body's joint frame.
81
82 A spherical joint may have a cone limit, to restrict the motion to within a certain range. In
83 addition, the bodies may be projected together if the distance between them exceeds a given threshold.
84
85 Projection, drive and limits are activated by setting the appropriate flags on the joint.
86
87 @see PxRevoluteJointCreate() PxJoint
88*/
89class PxSphericalJoint : public PxJoint
90{
91public:
92
93 /**
94 \brief Set the limit cone.
95
96 If enabled, the limit cone will constrain the angular movement of the joint to lie
97 within an elliptical cone.
98
99 \return the limit cone
100
101 @see PxJointLimitCone setLimit()
102 */
103 virtual PxJointLimitCone getLimitCone() const = 0;
104
105 /**
106 \brief Get the limit cone.
107
108 \param[in] limit the limit cone
109
110 @see PxJointLimitCone getLimit()
111 */
112 virtual void setLimitCone(const PxJointLimitCone& limit) = 0;
113
114 /**
115 \brief get the swing angle of the joint from the Y axis
116 */
117 virtual PxReal getSwingYAngle() const = 0;
118
119 /**
120 \brief get the swing angle of the joint from the Z axis
121 */
122 virtual PxReal getSwingZAngle() const = 0;
123
124 /**
125 \brief Set the flags specific to the Spherical Joint.
126
127 <b>Default</b> PxSphericalJointFlags(0)
128
129 \param[in] flags The joint flags.
130
131 @see PxSphericalJointFlag setFlag() getFlags()
132 */
133 virtual void setSphericalJointFlags(PxSphericalJointFlags flags) = 0;
134
135 /**
136 \brief Set a single flag specific to a Spherical Joint to true or false.
137
138 \param[in] flag The flag to set or clear.
139 \param[in] value the value to which to set the flag
140
141 @see PxSphericalJointFlag, getFlags() setFlags()
142 */
143 virtual void setSphericalJointFlag(PxSphericalJointFlag::Enum flag, bool value) = 0;
144
145 /**
146 \brief Get the flags specific to the Spherical Joint.
147
148 \return the joint flags
149
150 @see PxSphericalJoint::flags, PxSphericalJointFlag setFlag() setFlags()
151 */
152 virtual PxSphericalJointFlags getSphericalJointFlags() const = 0;
153
154 /**
155 \brief Set the linear tolerance threshold for projection. Projection is enabled if PxConstraintFlag::ePROJECTION
156 is set for the joint.
157
158 If the joint separates by more than this distance along its locked degrees of freedom, the solver
159 will move the bodies to close the distance.
160
161 Setting a very small tolerance may result in simulation jitter or other artifacts.
162
163 Sometimes it is not possible to project (for example when the joints form a cycle).
164
165 <b>Range:</b> [0, PX_MAX_F32)<br>
166 <b>Default:</b> 1e10f
167
168 \param[in] tolerance the linear tolerance threshold
169
170 @see getProjectionLinearTolerance() PxJoint::setConstraintFlags() PxConstraintFlag::ePROJECTION
171 */
172 virtual void setProjectionLinearTolerance(PxReal tolerance) = 0;
173
174 /**
175 \brief Get the linear tolerance threshold for projection.
176
177 \return the linear tolerance threshold
178
179 @see setProjectionLinearTolerance()
180 */
181 virtual PxReal getProjectionLinearTolerance() const = 0;
182
183 /**
184 \brief Returns string name of PxSphericalJoint, used for serialization
185 */
186 virtual const char* getConcreteTypeName() const { return "PxSphericalJoint"; }
187
188protected:
189
190 //serialization
191
192 /**
193 \brief Constructor
194 */
195 PX_INLINE PxSphericalJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
196
197 /**
198 \brief Deserialization constructor
199 */
200 PX_INLINE PxSphericalJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
201
202 /**
203 \brief Returns whether a given type name matches with the type of this instance
204 */
205 virtual bool isKindOf(const char* name) const { return !::strcmp(s1: "PxSphericalJoint", s2: name) || PxJoint::isKindOf(name); }
206
207 //~serialization
208};
209
210#if !PX_DOXYGEN
211} // namespace physx
212#endif
213
214/** @} */
215#endif
216

source code of qtquick3dphysics/src/3rdparty/PhysX/include/extensions/PxSphericalJoint.h