PxD6Joint.h
Go to the documentation of this file.
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_D6JOINT_H
31 #define PX_D6JOINT_H
32 
36 #include "extensions/PxJoint.h"
38 #include "foundation/PxFlags.h"
39 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
45 class PxD6Joint;
46 
58 PxD6Joint* PxD6JointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
59 
65 struct PxD6Axis
66 {
67  enum Enum
68  {
69  eX = 0,
70  eY = 1,
71  eZ = 2,
72  eTWIST = 3,
73  eSWING1 = 4,
74  eSWING2 = 5,
75  eCOUNT = 6
76  };
77 };
78 
79 
85 struct PxD6Motion
86 {
87  enum Enum
88  {
91  eFREE
92  };
93 };
94 
95 
111 struct PxD6Drive
112 {
113  enum Enum
114  {
115  eX = 0,
116  eY = 1,
117  eZ = 2,
118  eSWING = 3,
119  eTWIST = 4,
120  eSLERP = 5,
121  eCOUNT = 6
122  };
123 };
124 
131 {
132  enum Enum
133  {
134  eACCELERATION = 1
135  };
136 };
138 PX_FLAGS_OPERATORS(PxD6JointDriveFlag::Enum, PxU32)
139 
140 
145 class PxD6JointDrive : public PxSpring
146 {
147 //= ATTENTION! =====================================================================================
148 // Changing the data layout of this class breaks the binary serialization format. See comments for
149 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
150 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
151 // accordingly.
152 //==================================================================================================
153 
154 public:
157 
161  PxD6JointDrive(): PxSpring(0,0), forceLimit(PX_MAX_F32), flags(0) {}
162 
171  PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration = false)
172  : PxSpring(driveStiffness, driveDamping)
173  , forceLimit(driveForceLimit)
174  , flags(isAcceleration?PxU32(PxD6JointDriveFlag::eACCELERATION) : 0)
175  {}
176 
180  bool isValid() const
181  {
182  return PxIsFinite(stiffness) && stiffness>=0 &&
183  PxIsFinite(damping) && damping >=0 &&
184  PxIsFinite(forceLimit) && forceLimit >=0;
185  }
186 };
187 
188 
224 class PxD6Joint : public PxJoint
225 {
226 public:
227 
241  virtual void setMotion(PxD6Axis::Enum axis, PxD6Motion::Enum type) = 0;
242 
251  virtual PxD6Motion::Enum getMotion(PxD6Axis::Enum axis) const = 0;
252 
256  virtual PxReal getTwistAngle() const = 0;
257 
263  PX_DEPRECATED PX_FORCE_INLINE PxReal getTwist() const { return getTwistAngle(); }
264 
268  virtual PxReal getSwingYAngle() const = 0;
269 
273  virtual PxReal getSwingZAngle() const = 0;
274 
286  virtual void setDistanceLimit(const PxJointLinearLimit& limit) = 0;
287 
295  virtual PxJointLinearLimit getDistanceLimit() const = 0;
296 
300  PX_DEPRECATED PX_FORCE_INLINE void setLinearLimit(const PxJointLinearLimit& limit) { setDistanceLimit(limit); }
301 
305  PX_DEPRECATED PX_FORCE_INLINE PxJointLinearLimit getLinearLimit() const { return getDistanceLimit(); }
306 
322  virtual void setLinearLimit(PxD6Axis::Enum axis, const PxJointLinearLimitPair& limit) = 0;
323 
333  virtual PxJointLinearLimitPair getLinearLimit(PxD6Axis::Enum axis) const = 0;
334 
346  virtual void setTwistLimit(const PxJointAngularLimitPair& limit) = 0;
347 
355  virtual PxJointAngularLimitPair getTwistLimit() const = 0;
356 
368  virtual void setSwingLimit(const PxJointLimitCone& limit) = 0;
369 
377  virtual PxJointLimitCone getSwingLimit() const = 0;
378 
392  virtual void setPyramidSwingLimit(const PxJointLimitPyramid& limit) = 0;
393 
401  virtual PxJointLimitPyramid getPyramidSwingLimit() const = 0;
402 
413  virtual void setDrive(PxD6Drive::Enum index, const PxD6JointDrive& drive) = 0;
414 
422  virtual PxD6JointDrive getDrive(PxD6Drive::Enum index) const = 0;
423 
436  virtual void setDrivePosition(const PxTransform& pose, bool autowake = true) = 0;
437 
443  virtual PxTransform getDrivePosition() const = 0;
444 
456  virtual void setDriveVelocity(const PxVec3& linear, const PxVec3& angular, bool autowake = true) = 0;
457 
466  virtual void getDriveVelocity(PxVec3& linear, PxVec3& angular) const = 0;
467 
486  virtual void setProjectionLinearTolerance(PxReal tolerance) = 0;
487 
495  virtual PxReal getProjectionLinearTolerance() const = 0;
496 
518  virtual void setProjectionAngularTolerance(PxReal tolerance) = 0;
519 
527  virtual PxReal getProjectionAngularTolerance() const = 0;
528 
532  virtual const char* getConcreteTypeName() const { return "PxD6Joint"; }
533 
534 protected:
535 
536  //serialization
537 
541  PX_INLINE PxD6Joint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
542 
546  PX_INLINE PxD6Joint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
547 
551  virtual bool isKindOf(const char* name) const { return !::strcmp("PxD6Joint", name) || PxJoint::isKindOf(name); }
552 
553  //~serialization
554 };
555 
556 #if !PX_DOXYGEN
557 } // namespace physx
558 #endif
559 
561 #endif
Definition: GuContactBuffer.h:37
PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration=false)
constructor a PxD6JointDrive.
Definition: PxD6Joint.h:171
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition: PxD6Joint.h:551
PX_DEPRECATED PX_FORCE_INLINE void setLinearLimit(const PxJointLinearLimit &limit)
Definition: PxD6Joint.h:300
Enum
Definition: PxD6Joint.h:87
PxD6Joint * PxD6JointCreate(PxPhysics &physics, PxRigidActor *actor0, const PxTransform &localFrame0, PxRigidActor *actor1, const PxTransform &localFrame1)
Create a D6 joint.
flags for configuring the drive model of a PxD6Joint
Definition: PxD6Joint.h:130
Enum
Definition: PxD6Joint.h:113
parameters for configuring the drive model of a PxD6Joint
Definition: PxD6Joint.h:145
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:351
float PxReal
Definition: PxSimpleTypes.h:78
The DOF is limited, it only allows motion within a specific range.
Definition: PxD6Joint.h:90
Enum
Definition: PxD6Joint.h:67
Describes a one-sided linear limit.
Definition: PxJointLimit.h:165
Used to specify which axes of a D6 joint are driven.
Definition: PxD6Joint.h:111
PxU16 PxType
Definition: PxBase.h:49
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
PxReal stiffness
spring parameter, for spring constraints
Definition: PxConstraintDesc.h:99
PX_DEPRECATED PX_FORCE_INLINE PxJointLinearLimit getLinearLimit() const
Definition: PxD6Joint.h:305
a base interface providing common functionality for PhysX joints
Definition: PxJoint.h:101
#define PX_DEPRECATED
Definition: PxPreprocessor.h:424
PxVec3 angular
Definition: PxArticulationReducedCoordinate.h:134
Definition: PxJointLimit.h:295
PxReal forceLimit
the force limit of the drive - may be an impulse or a force depending on PxConstraintFlag::eDRIVE_LIM...
Definition: PxD6Joint.h:155
The DOF is locked, it does not allow relative motion.
Definition: PxD6Joint.h:89
Enum
Definition: PxD6Joint.h:132
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition: PxJoint.h:376
Describes a pyramidal joint limit.
Definition: PxJointLimit.h:448
Describes a two-sided limit.
Definition: PxJointLimit.h:228
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
Definition: PxJoint.h:381
#define PX_MAX_F32
Definition: PxSimpleTypes.h:86
PxFlags< PxD6JointDriveFlag::Enum, PxU32 > PxD6JointDriveFlags
Definition: PxD6Joint.h:137
PxReal damping
damping parameter, for spring constraints
Definition: PxConstraintDesc.h:100
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PxD6JointDriveFlags flags
the joint drive flags
Definition: PxD6Joint.h:156
Used to specify the range of motions allowed for a degree of freedom in a D6 joint.
Definition: PxD6Joint.h:85
Used to specify one of the degrees of freedom of a D6 joint.
Definition: PxD6Joint.h:65
virtual const char * getConcreteTypeName() const
Returns string name of PxD6Joint, used for serialization.
Definition: PxD6Joint.h:532
PxVec3 linear
Definition: PxArticulationReducedCoordinate.h:132
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxIsFinite(float f)
returns true if the passed number is a finite floating point number as opposed to INF...
Definition: PxMath.h:292
PX_INLINE PxD6Joint(PxBaseFlags baseFlags)
Deserialization constructor.
Definition: PxD6Joint.h:546
Describes an elliptical conical joint limit. Note that very small or highly elliptical limit cones ma...
Definition: PxJointLimit.h:369
PX_INLINE PxD6Joint(PxType concreteType, PxBaseFlags baseFlags)
Constructor.
Definition: PxD6Joint.h:541
PX_DEPRECATED PX_FORCE_INLINE PxReal getTwist() const
get the twist angle of the joint
Definition: PxD6Joint.h:263
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition: PxPhysics.h:71
PxD6JointDrive()
default constructor for PxD6JointDrive.
Definition: PxD6Joint.h:161
uint32_t PxU32
Definition: Px.h:48
bool isValid() const
returns true if the drive is valid
Definition: PxD6Joint.h:180
#define PX_INLINE
Definition: PxPreprocessor.h:336
3 Element vector class.
Definition: PxVec3.h:49
A D6 joint is a general constraint between two actors.
Definition: PxD6Joint.h:224