RavEngine
Loading...
Searching...
No Matches
PxD6Joint.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_D6_JOINT_H
30#define PX_D6_JOINT_H
35#include "extensions/PxJoint.h"
36#include "extensions/PxJointLimit.h"
37#include "foundation/PxFlags.h"
38
39#if !PX_DOXYGEN
40namespace physx
41{
42#endif
43
44class PxD6Joint;
45
57PxD6Joint* PxD6JointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
58
65{
66 enum Enum
67 {
68 eX = 0,
69 eY = 1,
70 eZ = 2,
71 eTWIST = 3,
72 eSWING1 = 4,
73 eSWING2 = 5,
74 eCOUNT = 6
75 };
76};
77
78
85{
92};
93
94
111{
112 enum Enum
113 {
114 eX = 0,
115 eY = 1,
116 eZ = 2,
117 eSWING = 3,
118 eTWIST = 4,
119 eSLERP = 5,
120 eCOUNT = 6
121 };
122};
123
130{
131 enum Enum
132 {
133 eACCELERATION = 1
134 };
135};
136typedef PxFlags<PxD6JointDriveFlag::Enum, PxU32> PxD6JointDriveFlags;
137PX_FLAGS_OPERATORS(PxD6JointDriveFlag::Enum, PxU32)
138
139
145{
146//= ATTENTION! =====================================================================================
147// Changing the data layout of this class breaks the binary serialization format. See comments for
148// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
149// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
150// accordingly.
151//==================================================================================================
152
153public:
154 PxReal forceLimit;
156
160 PxD6JointDrive(): PxSpring(0,0), forceLimit(PX_MAX_F32), flags(0) {}
161
170 PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration = false)
171 : PxSpring(driveStiffness, driveDamping)
172 , forceLimit(driveForceLimit)
173 , flags(isAcceleration?PxU32(PxD6JointDriveFlag::eACCELERATION) : 0)
174 {}
175
179 bool isValid() const
180 {
181 return PxIsFinite(stiffness) && stiffness>=0 &&
182 PxIsFinite(damping) && damping >=0 &&
183 PxIsFinite(forceLimit) && forceLimit >=0;
184 }
185};
186
187
223class PxD6Joint : public PxJoint
224{
225public:
226
240 virtual void setMotion(PxD6Axis::Enum axis, PxD6Motion::Enum type) = 0;
241
251
255 virtual PxReal getTwistAngle() const = 0;
256
263
267 virtual PxReal getSwingYAngle() const = 0;
268
272 virtual PxReal getSwingZAngle() const = 0;
273
285 virtual void setDistanceLimit(const PxJointLinearLimit& limit) = 0;
286
295
300
305
321 virtual void setLinearLimit(PxD6Axis::Enum axis, const PxJointLinearLimitPair& limit) = 0;
322
333
345 virtual void setTwistLimit(const PxJointAngularLimitPair& limit) = 0;
346
355
367 virtual void setSwingLimit(const PxJointLimitCone& limit) = 0;
368
376 virtual PxJointLimitCone getSwingLimit() const = 0;
377
391 virtual void setPyramidSwingLimit(const PxJointLimitPyramid& limit) = 0;
392
401
412 virtual void setDrive(PxD6Drive::Enum index, const PxD6JointDrive& drive) = 0;
413
421 virtual PxD6JointDrive getDrive(PxD6Drive::Enum index) const = 0;
422
436 virtual void setDrivePosition(const PxTransform& pose, bool autowake = true) = 0;
437
443 virtual PxTransform getDrivePosition() const = 0;
444
457 virtual void setDriveVelocity(const PxVec3& linear, const PxVec3& angular, bool autowake = true) = 0;
458
467 virtual void getDriveVelocity(PxVec3& linear, PxVec3& angular) const = 0;
468
489 PX_DEPRECATED virtual void setProjectionLinearTolerance(PxReal tolerance) = 0;
490
500 PX_DEPRECATED virtual PxReal getProjectionLinearTolerance() const = 0;
501
525 PX_DEPRECATED virtual void setProjectionAngularTolerance(PxReal tolerance) = 0;
526
537
541 virtual const char* getConcreteTypeName() const { return "PxD6Joint"; }
542
543protected:
544
545 //serialization
546
550 PX_INLINE PxD6Joint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
551
555 PX_INLINE PxD6Joint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
556
560 virtual bool isKindOf(const char* name) const { return !::strcmp("PxD6Joint", name) || PxJoint::isKindOf(name); }
561
562 //~serialization
563};
564
565#if !PX_DOXYGEN
566} // namespace physx
567#endif
568
570#endif
parameters for configuring the drive model of a PxD6Joint
Definition PxD6Joint.h:145
PxReal forceLimit
the force limit of the drive - may be an impulse or a force depending on PxConstraintFlag::eDRIVE_LIM...
Definition PxD6Joint.h:154
PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration=false)
constructor a PxD6JointDrive.
Definition PxD6Joint.h:170
PxD6JointDriveFlags flags
the joint drive flags
Definition PxD6Joint.h:155
bool isValid() const
returns true if the drive is valid
Definition PxD6Joint.h:179
PxD6JointDrive()
default constructor for PxD6JointDrive.
Definition PxD6Joint.h:160
A D6 joint is a general constraint between two actors.
Definition PxD6Joint.h:224
virtual PxD6Motion::Enum getMotion(PxD6Axis::Enum axis) const =0
Get the motion type around the specified axis.
virtual void setTwistLimit(const PxJointAngularLimitPair &limit)=0
Set the twist limit for the joint.
virtual PxJointLinearLimitPair getLinearLimit(PxD6Axis::Enum axis) const =0
Get the linear limit for a given linear axis.
virtual PxTransform getDrivePosition() const =0
Get the drive goal pose.
virtual void setSwingLimit(const PxJointLimitCone &limit)=0
Set the swing cone limit for the joint.
virtual PxReal getSwingYAngle() const =0
get the swing angle of the joint from the Y axis
virtual PX_DEPRECATED PxReal getProjectionLinearTolerance() const =0
Get the linear tolerance threshold for projection.
virtual PX_DEPRECATED void setProjectionAngularTolerance(PxReal tolerance)=0
Set the angular tolerance threshold for projection. Projection is enabled if PxConstraintFlag::ePROJE...
PX_DEPRECATED PX_FORCE_INLINE void setLinearLimit(const PxJointLinearLimit &limit)
Definition PxD6Joint.h:299
virtual PxJointLinearLimit getDistanceLimit() const =0
Get the distance limit for the joint.
virtual PxD6JointDrive getDrive(PxD6Drive::Enum index) const =0
Get the drive parameters for the specified drive type.
virtual void setPyramidSwingLimit(const PxJointLimitPyramid &limit)=0
Set a pyramidal swing limit for the joint.
virtual void setMotion(PxD6Axis::Enum axis, PxD6Motion::Enum type)=0
Set the motion type around the specified axis.
PX_INLINE PxD6Joint(PxBaseFlags baseFlags)
Deserialization constructor.
Definition PxD6Joint.h:555
virtual void setDrive(PxD6Drive::Enum index, const PxD6JointDrive &drive)=0
Set the drive parameters for the specified drive type.
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxD6Joint.h:560
virtual void setLinearLimit(PxD6Axis::Enum axis, const PxJointLinearLimitPair &limit)=0
Set the linear limit for a given linear axis.
virtual void setDriveVelocity(const PxVec3 &linear, const PxVec3 &angular, bool autowake=true)=0
Set the target goal velocity for drive.
virtual PxReal getSwingZAngle() const =0
get the swing angle of the joint from the Z axis
virtual PX_DEPRECATED PxReal getProjectionAngularTolerance() const =0
Get the angular tolerance threshold for projection.
virtual void setDistanceLimit(const PxJointLinearLimit &limit)=0
Set the distance limit for the joint.
virtual PxJointAngularLimitPair getTwistLimit() const =0
Get the twist limit for the joint.
virtual PxReal getTwistAngle() const =0
get the twist angle of the joint, in the range (-2*Pi, 2*Pi]
virtual void setDrivePosition(const PxTransform &pose, bool autowake=true)=0
Set the drive goal pose.
PX_INLINE PxD6Joint(PxType concreteType, PxBaseFlags baseFlags)
Constructor.
Definition PxD6Joint.h:550
PX_DEPRECATED PX_FORCE_INLINE PxReal getTwist() const
get the twist angle of the joint
Definition PxD6Joint.h:262
virtual PxJointLimitPyramid getPyramidSwingLimit() const =0
Get the pyramidal swing limit for the joint.
virtual PxJointLimitCone getSwingLimit() const =0
Get the cone limit for the joint.
virtual PX_DEPRECATED void setProjectionLinearTolerance(PxReal tolerance)=0
Set the linear tolerance threshold for projection. Projection is enabled if PxConstraintFlag::ePROJEC...
virtual const char * getConcreteTypeName() const
Returns string name of PxD6Joint, used for serialization.
Definition PxD6Joint.h:541
PX_DEPRECATED PX_FORCE_INLINE PxJointLinearLimit getLinearLimit() const
Definition PxD6Joint.h:304
virtual void getDriveVelocity(PxVec3 &linear, PxVec3 &angular) const =0
Get the target goal velocity for joint drive.
Definition PxJointLimit.h:297
Describes an elliptical conical joint limit. Note that very small or highly elliptical limit cones ma...
Definition PxJointLimit.h:371
Describes a pyramidal joint limit.
Definition PxJointLimit.h:450
Describes a two-sided limit.
Definition PxJointLimit.h:230
Describes a one-sided linear limit.
Definition PxJointLimit.h:167
a base interface providing common functionality for PhysX joints
Definition PxJoint.h:105
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxJoint.h:379
Definition PxJoint.h:385
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
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:326
PxD6Joint * PxD6JointCreate(PxPhysics &physics, PxRigidActor *actor0, const PxTransform &localFrame0, PxRigidActor *actor1, const PxTransform &localFrame1)
Create a D6 joint.
Definition ExtD6Joint.cpp:1137
Used to specify one of the degrees of freedom of a D6 joint.
Definition PxD6Joint.h:65
Enum
Definition PxD6Joint.h:67
@ eX
motion along the X axis
Definition PxD6Joint.h:68
@ eSWING2
motion around the Z axis
Definition PxD6Joint.h:73
@ eTWIST
motion around the X axis
Definition PxD6Joint.h:71
@ eY
motion along the Y axis
Definition PxD6Joint.h:69
@ eZ
motion along the Z axis
Definition PxD6Joint.h:70
@ eSWING1
motion around the Y axis
Definition PxD6Joint.h:72
Used to specify which axes of a D6 joint are driven.
Definition PxD6Joint.h:111
Enum
Definition PxD6Joint.h:113
@ eX
drive along the X-axis
Definition PxD6Joint.h:114
@ eY
drive along the Y-axis
Definition PxD6Joint.h:115
@ eTWIST
drive of the displacement around the X-axis
Definition PxD6Joint.h:118
@ eSLERP
drive of all three angular degrees along a SLERP-path
Definition PxD6Joint.h:119
@ eZ
drive along the Z-axis
Definition PxD6Joint.h:116
@ eSWING
drive of displacement from the X-axis
Definition PxD6Joint.h:117
flags for configuring the drive model of a PxD6Joint
Definition PxD6Joint.h:130
Enum
Definition PxD6Joint.h:132
@ eACCELERATION
drive spring is for the acceleration at the joint (rather than the force)
Definition PxD6Joint.h:133
Used to specify the range of motions allowed for a degree of freedom in a D6 joint.
Definition PxD6Joint.h:85
Enum
Definition PxD6Joint.h:87
@ eLOCKED
The DOF is locked, it does not allow relative motion.
Definition PxD6Joint.h:88
@ eLIMITED
The DOF is limited, it only allows motion within a specific range.
Definition PxD6Joint.h:89
@ eFREE
The DOF is free and has its full range of motion.
Definition PxD6Joint.h:90