RavEngine
Loading...
Searching...
No Matches
DyArticulationTendon.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
30#ifndef PXD_ARTICULATION_TENDON_H
31#define PXD_ARTICULATION_TENDON_H
32
33#include "foundation/PxVec3.h"
34#include "foundation/PxQuat.h"
35#include "foundation/PxTransform.h"
36#include "foundation/PxVecMath.h"
37#include "foundation/PxUtilities.h"
38#include "CmUtils.h"
39#include "CmIDPool.h"
40#include "solver/PxSolverDefs.h"
41
42namespace physx
43{
44namespace Dy
45{
46
47 typedef PxU64 ArticulationAttachmentBitField;
48
49#define DY_ARTICULATION_ATTACHMENT_NONE 0xffffffff
50
52 {
53 PxVec3 relativeOffset; //relative offset to the link
54 PxReal lowLimit;
55 PxReal highLimit;
56 PxReal restLength;
57
58 PxReal coefficient;
59 PxU32 parent; //parent index
60 PxU32 myInd;
61 PxU32 mConstraintInd;
62 PxU16 linkInd;
63 PxU16 childCount;
64
65 ArticulationAttachmentBitField children;
66 };
67
69 {
70 public:
71
72 ArticulationTendon() : mStiffness(0.f), mDamping(0.f), mOffset(0.f), mLimitStiffness(0.f)
73 {
74 }
75 PxReal mStiffness;
76 PxReal mDamping;
77 PxReal mOffset;
78 PxReal mLimitStiffness;
79 };
80
82 {
83 public:
84
86 {
87 mAttachments.reserve(64);
88 mAttachments.forceSize_Unsafe(64);
89
90 }
91
92 PX_FORCE_INLINE ArticulationAttachment* getAttachments() { return mAttachments.begin(); }
93
94 PX_FORCE_INLINE ArticulationAttachment& getAttachment(const PxU32 index) { return mAttachments[index]; }
95
96 PX_FORCE_INLINE PxU32 getNumAttachments() { return mIDPool.getNumUsedID(); }
97
98 PX_FORCE_INLINE PxU32 getNewID()
99 {
100 const PxU32 index = mIDPool.getNewID();
101 if (mAttachments.capacity() <= index)
102 {
103 mAttachments.resize(index * 2 + 1);
104 }
105 return index;
106 }
107
108 PX_FORCE_INLINE void freeID(const PxU32 index)
109 {
110 mIDPool.freeID(index);
111 }
112
113 PX_FORCE_INLINE PxU32 getTendonIndex() { return mIndex; }
114
115 PX_FORCE_INLINE void setTendonIndex(const PxU32 index) { mIndex = index; }
116
117 private:
118
120 Cm::IDPool mIDPool;
121 PxU32 mIndex;
122 };
123
125 {
126 public:
127 PxU16 axis;
128 PxU16 startJointOffset;
129 PxReal coefficient;
130 PxReal recipCoefficient;
131 PxU32 mConstraintInd;
132 PxU32 parent; //parent index
133 PxU16 linkInd;
134 PxU16 childCount;
135 ArticulationAttachmentBitField children;
136 };
137
139 {
140 public:
141
142 ArticulationFixedTendon() :mLowLimit(PX_MAX_F32), mHighLimit(-PX_MAX_F32), mRestLength(0.f)
143 {
144 mTendonJoints.reserve(64);
145 mTendonJoints.forceSize_Unsafe(64);
146
147 }
148
149
150 PX_FORCE_INLINE ArticulationTendonJoint* getTendonJoints() { return mTendonJoints.begin(); }
151
152 PX_FORCE_INLINE ArticulationTendonJoint& getTendonJoint(const PxU32 index) { return mTendonJoints[index]; }
153
154 PX_FORCE_INLINE PxU32 getNumJoints() { return mIDPool.getNumUsedID(); }
155
156 PX_FORCE_INLINE PxU32 getNewID()
157 {
158 const PxU32 index = mIDPool.getNewID();
159 if (mTendonJoints.capacity() <= index)
160 {
161 mTendonJoints.resize(index * 2 + 1);
162 }
163 return index;
164 }
165
166 PX_FORCE_INLINE void freeID(const PxU32 index)
167 {
168 mIDPool.freeID(index);
169 }
170
171 PX_FORCE_INLINE PxU32 getTendonIndex() { return mIndex; }
172
173 PX_FORCE_INLINE void setTendonIndex(const PxU32 index) { mIndex = index; }
174
175 PxReal mLowLimit;
176 PxReal mHighLimit;
177 PxReal mRestLength;
178
179 PxReal mError;
180
181 private:
183
184 Cm::IDPool mIDPool;
185 PxU32 mIndex;
186 };
187
188
189}//namespace Dy
190}//namespace physx
191
192#endif
Definition CmIDPool.h:177
Definition DyArticulationTendon.h:139
Definition DyArticulationTendon.h:82
Definition DyArticulationTendon.h:125
Definition DyArticulationTendon.h:69
Definition PxArray.h:53
3 Element vector class.
Definition PxVec3.h:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition DyArticulationTendon.h:52