RavEngine
Loading...
Searching...
No Matches
ExtD6Joint.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 EXT_D6_JOINT_H
30#define EXT_D6_JOINT_H
31
32#include "extensions/PxD6Joint.h"
33
34#include "ExtJoint.h"
35
36namespace physx
37{
39namespace Ext
40{
41 struct D6JointData : public JointData
42 {
43 //= ATTENTION! =====================================================================================
44 // Changing the data layout of this class breaks the binary serialization format. See comments for
45 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
46 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
47 // accordingly.
48 //==================================================================================================
49
50 PxD6Motion::Enum motion[6];
51 PxJointLinearLimit distanceLimit;
52 PxJointLinearLimitPair linearLimitX;
53 PxJointLinearLimitPair linearLimitY;
54 PxJointLinearLimitPair linearLimitZ;
55 PxJointAngularLimitPair twistLimit;
56 PxJointLimitCone swingLimit;
57 PxJointLimitPyramid pyramidSwingLimit;
58
59 PxD6JointDrive drive[PxD6Drive::eCOUNT];
60
61 PxTransform drivePosition;
62 PxVec3 driveLinearVelocity;
63 PxVec3 driveAngularVelocity;
64
65 // derived quantities
66
67 PxU32 locked; // bitmap of locked DOFs
68 PxU32 limited; // bitmap of limited DOFs
69 PxU32 driving; // bitmap of active drives (implies driven DOFs not locked)
70
71 PxReal distanceMinDist; // distance limit minimum distance to get a good direction
72
73 // projection quantities
74 PxReal projectionLinearTolerance;
75 PxReal projectionAngularTolerance;
76
77 // PT: the PxD6Motion values are now shared for both kind of linear limits, so we need
78 // an extra bool to know which one(s) should be actually used.
79 bool mUseDistanceLimit;
80 bool mUseNewLinearLimits;
81
82 // PT: the swing limits can now be a cone or a pyramid, so we need
83 // an extra bool to know which one(s) should be actually used.
84 bool mUseConeLimit;
85 bool mUsePyramidLimits;
86
87 private:
88 D6JointData(const PxJointLinearLimit& distance,
89 const PxJointLinearLimitPair& linearX,
90 const PxJointLinearLimitPair& linearY,
91 const PxJointLinearLimitPair& linearZ,
92 const PxJointAngularLimitPair& twist,
93 const PxJointLimitCone& swing,
94 const PxJointLimitPyramid& pyramid) :
95 distanceLimit (distance),
96 linearLimitX (linearX),
97 linearLimitY (linearY),
98 linearLimitZ (linearZ),
99 twistLimit (twist),
100 swingLimit (swing),
101 pyramidSwingLimit (pyramid),
102 mUseDistanceLimit (false),
103 mUseNewLinearLimits (false),
104 mUseConeLimit (false),
105 mUsePyramidLimits (false)
106 {}
107 };
108
110
111 class D6Joint : public D6JointT
112 {
113 public:
114// PX_SERIALIZATION
115 D6Joint(PxBaseFlags baseFlags) : D6JointT(baseFlags) {}
116 void resolveReferences(PxDeserializationContext& context);
117 static D6Joint* createObject(PxU8*& address, PxDeserializationContext& context) { return createJointObject<D6Joint>(address, context); }
118 static void getBinaryMetaData(PxOutputStream& stream);
119//~PX_SERIALIZATION
120 D6Joint(const PxTolerancesScale& scale, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1);
121 // PxD6Joint
122 virtual void setMotion(PxD6Axis::Enum index, PxD6Motion::Enum t) PX_OVERRIDE;
123 virtual PxD6Motion::Enum getMotion(PxD6Axis::Enum index) const PX_OVERRIDE;
124 virtual PxReal getTwistAngle() const PX_OVERRIDE;
125 virtual PxReal getSwingYAngle() const PX_OVERRIDE;
126 virtual PxReal getSwingZAngle() const PX_OVERRIDE;
127 virtual void setDistanceLimit(const PxJointLinearLimit& l) PX_OVERRIDE;
128 virtual PxJointLinearLimit getDistanceLimit() const PX_OVERRIDE;
129 virtual void setLinearLimit(PxD6Axis::Enum axis, const PxJointLinearLimitPair& limit) PX_OVERRIDE;
130 virtual PxJointLinearLimitPair getLinearLimit(PxD6Axis::Enum axis) const PX_OVERRIDE;
131 virtual void setTwistLimit(const PxJointAngularLimitPair& l) PX_OVERRIDE;
132 virtual PxJointAngularLimitPair getTwistLimit() const PX_OVERRIDE;
133 virtual void setSwingLimit(const PxJointLimitCone& l) PX_OVERRIDE;
134 virtual PxJointLimitCone getSwingLimit() const PX_OVERRIDE;
135 virtual void setPyramidSwingLimit(const PxJointLimitPyramid& limit) PX_OVERRIDE;
136 virtual PxJointLimitPyramid getPyramidSwingLimit() const PX_OVERRIDE;
137 virtual void setDrive(PxD6Drive::Enum index, const PxD6JointDrive& d) PX_OVERRIDE;
138 virtual PxD6JointDrive getDrive(PxD6Drive::Enum index) const PX_OVERRIDE;
139 virtual void setDrivePosition(const PxTransform& pose, bool autowake = true) PX_OVERRIDE;
140 virtual PxTransform getDrivePosition() const PX_OVERRIDE;
141 virtual void setDriveVelocity(const PxVec3& linear, const PxVec3& angular, bool autowake = true) PX_OVERRIDE;
142 virtual void getDriveVelocity(PxVec3& linear, PxVec3& angular) const PX_OVERRIDE;
143 virtual void setProjectionLinearTolerance(PxReal tolerance) PX_OVERRIDE;
144 virtual PxReal getProjectionLinearTolerance() const PX_OVERRIDE;
145 virtual void setProjectionAngularTolerance(PxReal tolerance) PX_OVERRIDE;
146 virtual PxReal getProjectionAngularTolerance() const PX_OVERRIDE;
147 //~PxD6Joint
148
149 // PxConstraintConnector
151 virtual void* prepareData() PX_OVERRIDE;
152#if PX_SUPPORT_OMNI_PVD
153 virtual void updateOmniPvdProperties() const PX_OVERRIDE;
154#endif
155 //~PxConstraintConnector
156
157 private:
158 bool active(const PxD6Drive::Enum index) const
159 {
160 const PxD6JointDrive& d = data().drive[index];
161 return d.stiffness!=0 || d.damping != 0;
162 }
163
164 bool mRecomputeMotion;
165 bool mPadding[3]; // PT: padding from prev bool
166 };
167
168} // namespace Ext
169
170} // namespace physx
171
172#endif
Definition base.h:1940
Definition ExtD6Joint.h:112
virtual PxConstraintSolverPrep getPrep() const PX_OVERRIDE
Obtain the shader function pointer used to prep rows for this constraint.
Definition ExtD6Joint.cpp:1135
virtual void * prepareData() PX_OVERRIDE
Pre-simulation data preparation when the constraint is marked dirty, this function is called at the s...
Definition ExtD6Joint.cpp:363
Definition ExtJoint.h:105
virtual void updateOmniPvdProperties() const PX_OVERRIDE
this function is called by the SDK to update OmniPVD's view of it
Definition ExtJoint.h:183
parameters for configuring the drive model of a PxD6Joint
Definition PxD6Joint.h:145
Binary deserialization context class.
Definition PxSerialFramework.h:174
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
Output stream class for I/O.
Definition PxIO.h:114
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
PxReal stiffness
the spring strength of the drive: that is, the force proportional to the position error
Definition PxJoint.h:394
PxReal damping
the damping strength of the drive: that is, the force proportional to the velocity error
Definition PxJoint.h:395
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition PxTolerancesScale.h:53
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_OVERRIDE
Definition PxPreprocessor.h:375
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxU32(* PxConstraintSolverPrep)(Px1DConstraint *constraints, PxVec3p &bodyAWorldOffset, PxU32 maxConstraints, PxConstraintInvMassScale &invMassScale, const void *constantBlock, const PxTransform &bodyAToWorld, const PxTransform &bodyBToWorld, bool useExtendedLimits, PxVec3p &cAtW, PxVec3p &cBtW)
Solver constraint generation shader.
Definition PxConstraintDesc.h:223
Definition PxExtensionAutoGeneratedMetaDataObjects.h:293
Definition ExtD6Joint.h:42
Definition ExtJointData.h:39
Enum
Definition PxD6Joint.h:67
Enum
Definition PxD6Joint.h:113
Enum
Definition PxD6Joint.h:87