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
31#ifndef DV_ARTICULATION_JOINT_CORE_H
32#define DV_ARTICULATION_JOINT_CORE_H
33
34#include "DyArticulationCore.h"
35#include "PxArticulationJoint.h"
36#include "solver/PxSolverDefs.h"
37#include "PxArticulationJointReducedCoordinate.h"
38
39namespace physx
40{
41 namespace Dy
42 {
43 struct ArticulationJointCoreBase
44 {
45 //= ATTENTION! =====================================================================================
46 // Changing the data layout of this class breaks the binary serialization format. See comments for
47 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
48 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
49 // accordingly.
50 //==================================================================================================
51 public:
52
53 PX_CUDA_CALLABLE bool setJointPose(PxQuat& relativeQuat)
54 {
55 if (dirtyFlag & ArticulationJointCoreDirtyFlag::ePOSE)
56 {
57 relativeQuat = (childPose.q * (parentPose.q.getConjugate())).getNormalized();
58
59 //ML: this way work in GPU
60 PxU8 flag = PxU8(ArticulationJointCoreDirtyFlag::ePOSE);
61 dirtyFlag &= ArticulationJointCoreDirtyFlags(~flag);
62
63 return true;
64 }
65
66 return false;
67 }
68
69 PX_CUDA_CALLABLE PX_FORCE_INLINE void operator=(ArticulationJointCoreBase& other)
70 {
71 parentPose = other.parentPose;
72 childPose = other.childPose;
73
74 dirtyFlag = other.dirtyFlag;
75
76 //KS - temp place to put reduced coordinate limit and drive values
77 for(PxU32 i=0; i<PxArticulationAxis::eCOUNT; i++)
78 {
79 limits[i] = other.limits[i];
80 drives[i] = other.drives[i];
81 targetP[i] = other.targetP[i];
82 targetV[i] = other.targetV[i];
83
84 dofIds[i] = other.dofIds[i];
85 motion[i] = other.motion[i];
86 }
87
88 frictionCoefficient = other.frictionCoefficient;
89 maxJointVelocity = other.maxJointVelocity;
90 //relativeQuat = other.relativeQuat;
91 jointType = other.jointType;
92 jointOffset = other.jointOffset; //this is the dof offset for the joint in the cache
93 }
94
95 // attachment points, don't change the order, otherwise it will break GPU code
96 PxTransform parentPose; //28 28
97 PxTransform childPose; //28 56
98
99 //KS - temp place to put reduced coordinate limit and drive values
100 PxArticulationLimit limits[PxArticulationAxis::eCOUNT]; //48 104
101 PxArticulationDrive drives[PxArticulationAxis::eCOUNT]; //96 200
102 PxReal targetP[PxArticulationAxis::eCOUNT]; //24 224
103 PxReal targetV[PxArticulationAxis::eCOUNT]; //24 248
104
105 // initial parent to child rotation. Could be
106 //PxQuat relativeQuat; //16 264
107 PxReal frictionCoefficient; //4 268
108
109 PxU8 dofIds[PxArticulationAxis::eCOUNT]; //6 274
110 PxU8 motion[PxArticulationAxis::eCOUNT]; //6 280
111
112 PxReal maxJointVelocity; //4 284
113
114 //Currently, jointOffset can't exceed 64*3 so we can use a PxU8 here! This brings mem footprint to exactly a multiple of 16 bytes
115 //this is the dof offset for the joint in the cache.
116 PxU8 jointOffset; //1 285
117 ArticulationJointCoreDirtyFlags dirtyFlag; //1 286
118 PxU8 jointType; //1 287
119 PxU8 pad[1];
120
121 ArticulationJointCoreBase() { maxJointVelocity = 100.f; }
122 // PX_SERIALIZATION
123 ArticulationJointCoreBase(const PxEMPTY&) : dirtyFlag(PxEmpty) { PX_COMPILE_TIME_ASSERT(sizeof(PxArticulationMotions) == sizeof(PxU8)); }
124 //~PX_SERIALIZATION
125 };
126 }
127}
128
129#endif
130

source code of qtquick3dphysics/src/3rdparty/PhysX/source/lowleveldynamics/include/DyArticulationJointCore.h