RavEngine
Loading...
Searching...
No Matches
NpArticulationTendon.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 NP_ARTICULATION_TENDON_H
30#define NP_ARTICULATION_TENDON_H
31
32#include "foundation/PxInlineArray.h"
33#include "PxArticulationTendon.h"
34#include "ScArticulationTendonCore.h"
35#include "ScArticulationAttachmentCore.h"
36#include "ScArticulationTendonJointCore.h"
37#include "NpBase.h"
38
39
40namespace physx
41{
42
43typedef PxU32 ArticulationAttachmentHandle;
44typedef PxU32 ArticulationTendonHandle;
45
46class NpArticulationReducedCoordinate;
47
48class NpArticulationAttachment;
49class NpArticulationSpatialTendon;
50
51class NpArticulationTendonJoint;
52class NpArticulationFixedTendon;
53
54class NpArticulationAttachmentArray : public PxInlineArray<NpArticulationAttachment*, 4>
55{
56 //= ATTENTION! =====================================================================================
57 // Changing the data layout of this class breaks the binary serialization format. See comments for
58 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
59 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
60 // accordingly.
61 //==================================================================================================
62public:
63 // PX_SERIALIZATION
65 static void getBinaryMetaData(PxOutputStream& stream);
66 //~PX_SERIALIZATION
68};
69
70class NpArticulationTendonJointArray : public PxInlineArray<NpArticulationTendonJoint*, 4>
71{
72 //= ATTENTION! =====================================================================================
73 // Changing the data layout of this class breaks the binary serialization format. See comments for
74 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
75 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
76 // accordingly.
77 //==================================================================================================
78public:
79 // PX_SERIALIZATION
81 static void getBinaryMetaData(PxOutputStream& stream);
82 //~PX_SERIALIZATION
84};
85
87{
88
89public:
90
91// PX_SERIALIZATION
93 : PxArticulationAttachment(baseFlags), NpBase(PxEmpty), mHandle(PxEmpty), mChildren(PxEmpty), mCore(PxEmpty) {}
94 void preExportDataReset() { mCore.preExportDataReset(); }
95 virtual void exportExtraData(PxSerializationContext& );
96 void importExtraData(PxDeserializationContext& );
97 void resolveReferences(PxDeserializationContext& );
98 virtual void requiresObjects(PxProcessPxBaseCallback&);
99 virtual bool isSubordinate() const { return true; }
100 static NpArticulationAttachment* createObject(PxU8*& address, PxDeserializationContext& context);
101 static void getBinaryMetaData(PxOutputStream& stream);
102//~PX_SERIALIZATION
103
104
105 NpArticulationAttachment(PxArticulationAttachment* parent, const PxReal coefficient, const PxVec3 relativeOffset, PxArticulationLink* link);
106
108
109
110 virtual void setRestLength(const PxReal restLength);
111 virtual PxReal getRestLength() const;
112
113 virtual void setLimitParameters(const PxArticulationTendonLimit& paramters);
115
116 virtual void setRelativeOffset(const PxVec3& offset);
117 virtual PxVec3 getRelativeOffset() const;
118
119 virtual void setCoefficient(const PxReal coefficient);
120 virtual PxReal getCoefficient() const;
121
122 virtual PxArticulationLink* getLink() const { return mLink; }
123 virtual PxArticulationAttachment* getParent() const { return mParent; }
124 virtual PxArticulationSpatialTendon* getTendon() const;
125
126 virtual bool isLeaf() const { return mChildren.empty(); }
127
128 virtual void release();
129
130 PX_FORCE_INLINE NpArticulationAttachment** getChildren() { return mChildren.begin(); }
131 PX_FORCE_INLINE PxU32 getNumChildren() { return mChildren.size(); }
132
133 PX_FORCE_INLINE void setTendon(NpArticulationSpatialTendon* tendon) { mTendon = tendon; }
134 PX_FORCE_INLINE NpArticulationSpatialTendon& getTendon() { return *mTendon; }
135
136 PX_FORCE_INLINE Sc::ArticulationAttachmentCore& getCore() { return mCore; }
137
138 void removeChild(NpArticulationAttachment* child);
139
140 PxArticulationLink* mLink; //the link this attachment attach to
141 PxArticulationAttachment* mParent;
142 ArticulationAttachmentHandle mHandle;
143 NpArticulationAttachmentArray mChildren;
144 NpArticulationSpatialTendon* mTendon;
145 Sc::ArticulationAttachmentCore mCore;
146};
147
148
150{
151public:
152
153// PX_SERIALIZATION
155 : PxArticulationSpatialTendon(baseFlags), NpBase(PxEmpty), mAttachments(PxEmpty), mCore(PxEmpty) {}
156 void preExportDataReset() { mCore.preExportDataReset(); }
157 virtual void exportExtraData(PxSerializationContext& );
158 void importExtraData(PxDeserializationContext& );
159 void resolveReferences(PxDeserializationContext& );
160 virtual void requiresObjects(PxProcessPxBaseCallback&);
161 virtual bool isSubordinate() const { return true; }
162 static NpArticulationSpatialTendon* createObject(PxU8*& address, PxDeserializationContext& context);
163 static void getBinaryMetaData(PxOutputStream& stream);
164//~PX_SERIALIZATION
165
167
169
170 virtual PxArticulationAttachment* createAttachment(PxArticulationAttachment* parent, const PxReal coefficient, const PxVec3 relativeOffset, PxArticulationLink* link);
171
172 NpArticulationAttachment* getAttachment(const PxU32 index);
173 virtual PxU32 getAttachments(PxArticulationAttachment** userBuffer, PxU32 bufferSize, PxU32 startIndex) const;
174 PxU32 getNbAttachments() const;
175
176 virtual void setStiffness(const PxReal stiffness);
177 virtual PxReal getStiffness() const;
178
179 virtual void setDamping(const PxReal damping);
180 virtual PxReal getDamping() const;
181
182 virtual void setLimitStiffness(const PxReal stiffness);
183 virtual PxReal getLimitStiffness() const;
184
185 virtual void setOffset(const PxReal offset, bool autowake = true);
186 virtual PxReal getOffset() const;
187
189
190 virtual void release();
191
192 PX_FORCE_INLINE Sc::ArticulationSpatialTendonCore& getTendonCore() { return mCore; }
193
194 PX_FORCE_INLINE ArticulationTendonHandle getHandle() { return mHandle; }
195 PX_FORCE_INLINE void setHandle(ArticulationTendonHandle handle) { mHandle = handle; }
196
197 PX_FORCE_INLINE NpArticulationAttachmentArray& getAttachments() { return mAttachments; }
198
199private:
201 NpArticulationReducedCoordinate* mArticulation;
202 PxU32 mLLIndex;
204 ArticulationTendonHandle mHandle;
205};
206
208{
209public:
210 // PX_SERIALIZATION
211 NpArticulationTendonJoint(PxBaseFlags baseFlags) : PxArticulationTendonJoint(baseFlags), NpBase(PxEmpty), mChildren(PxEmpty), mCore(PxEmpty), mHandle(PxEmpty) {}
212 void preExportDataReset() { mCore.preExportDataReset(); }
213 virtual void exportExtraData(PxSerializationContext& );
214 void importExtraData(PxDeserializationContext& );
215 void resolveReferences(PxDeserializationContext& );
216 virtual void requiresObjects(PxProcessPxBaseCallback&);
217 virtual bool isSubordinate() const { return true; }
218 static NpArticulationTendonJoint* createObject(PxU8*& address, PxDeserializationContext& context);
219 static void getBinaryMetaData(PxOutputStream& stream);
220 //~PX_SERIALIZATION
221
222 NpArticulationTendonJoint(PxArticulationTendonJoint* parent, PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient, PxArticulationLink* link);
223
225
226 virtual PxArticulationLink* getLink() const { return mLink; }
227
228 virtual PxArticulationTendonJoint* getParent() const { return mParent; }
229
230 virtual PxArticulationFixedTendon* getTendon() const;
231
232 virtual void setCoefficient(const PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient);
233 virtual void getCoefficient(PxArticulationAxis::Enum& axis, PxReal& coefficient, PxReal& recipCoefficient) const;
234
235
236 virtual void release();
237
238 PX_FORCE_INLINE NpArticulationTendonJoint** getChildren() { return mChildren.begin(); }
239 PX_FORCE_INLINE PxU32 getNumChildren() { return mChildren.size(); }
240
241 PX_FORCE_INLINE void setTendon(NpArticulationFixedTendon* tendon) { mTendon = tendon; }
242 PX_FORCE_INLINE NpArticulationFixedTendon& getTendon() { return *mTendon; }
243
244 PX_FORCE_INLINE Sc::ArticulationTendonJointCore& getCore() { return mCore; }
245
246 void removeChild(NpArticulationTendonJoint* child);
247
248 PxArticulationLink* mLink; //the link this joint associated with
249 PxArticulationTendonJoint* mParent;
250 NpArticulationTendonJointArray mChildren;
251 NpArticulationFixedTendon* mTendon;
252 Sc::ArticulationTendonJointCore mCore;
253 PxU32 mHandle;
254
255};
256
258{
259public:
260 // PX_SERIALIZATION
261 NpArticulationFixedTendon(PxBaseFlags baseFlags): PxArticulationFixedTendon(baseFlags), NpBase(PxEmpty), mTendonJoints(PxEmpty), mCore(PxEmpty), mHandle(PxEmpty) {}
262 void preExportDataReset() {}
263 virtual void exportExtraData(PxSerializationContext& );
264 void importExtraData(PxDeserializationContext& );
265 void resolveReferences(PxDeserializationContext& );
266 virtual void requiresObjects(PxProcessPxBaseCallback&);
267 virtual bool isSubordinate() const { return true; }
268 static NpArticulationFixedTendon* createObject(PxU8*& address, PxDeserializationContext& context);
269 static void getBinaryMetaData(PxOutputStream& stream);
270 //~PX_SERIALIZATION
271
273
275
276 virtual PxArticulationTendonJoint* createTendonJoint(PxArticulationTendonJoint* parent, PxArticulationAxis::Enum axis, const PxReal scale, const PxReal recipScale, PxArticulationLink* link);
277
278 NpArticulationTendonJoint* getTendonJoint(const PxU32 index);
279 virtual PxU32 getTendonJoints(PxArticulationTendonJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex) const;
280 virtual PxU32 getNbTendonJoints(void) const;
281
282 virtual void setStiffness(const PxReal stiffness);
283 virtual PxReal getStiffness() const;
284
285 virtual void setDamping(const PxReal damping);
286 virtual PxReal getDamping() const;
287
288 virtual void setLimitStiffness(const PxReal damping);
289 virtual PxReal getLimitStiffness() const;
290
291 virtual void setRestLength(const PxReal restLength);
292 virtual PxReal getRestLength() const;
293
294 virtual void setLimitParameters(const PxArticulationTendonLimit& paramters);
296
297 virtual void setOffset(const PxReal offset, bool autowake = true);
298 virtual PxReal getOffset() const;
299
301
302 virtual void release();
303
304 PX_FORCE_INLINE ArticulationTendonHandle getHandle() { return mHandle; }
305 PX_FORCE_INLINE void setHandle(ArticulationTendonHandle handle) { mHandle = handle; }
306
307 PX_FORCE_INLINE Sc::ArticulationFixedTendonCore& getTendonCore() { return mCore; }
308
309 PX_FORCE_INLINE NpArticulationTendonJointArray& getTendonJoints() { return mTendonJoints; }
310
311private:
312 NpArticulationTendonJointArray mTendonJoints;
313 NpArticulationReducedCoordinate* mArticulation;
314 PxU32 mLLIndex;
316 ArticulationTendonHandle mHandle;
317};
318
319}
320
321#endif
Definition base.h:1940
!!AL TODO: check if default of 4 elements makes sense
Definition NpArticulationTendon.h:55
Definition NpArticulationTendon.h:87
virtual void setRelativeOffset(const PxVec3 &offset)
Sets the attachment's relative offset in the link actor frame.
Definition NpArticulationTendon.cpp:140
virtual void setCoefficient(const PxReal coefficient)
Sets the attachment coefficient.
Definition NpArticulationTendon.cpp:153
virtual PxVec3 getRelativeOffset() const
Gets the attachment's relative offset in the link actor frame.
Definition NpArticulationTendon.cpp:148
virtual PxArticulationAttachment * getParent() const
Gets the parent attachment.
Definition NpArticulationTendon.h:123
virtual PxReal getCoefficient() const
Gets the attachment coefficient.
Definition NpArticulationTendon.cpp:163
virtual PxReal getRestLength() const
Gets the spring rest length for the sub-tendon from the root to this leaf attachment.
Definition NpArticulationTendon.cpp:114
virtual void release()
Releases the attachment.
Definition NpArticulationTendon.cpp:173
virtual void setRestLength(const PxReal restLength)
Sets the spring rest length for the sub-tendon from the root to this leaf attachment.
Definition NpArticulationTendon.cpp:104
virtual PxArticulationSpatialTendon * getTendon() const
Gets the spatial tendon that the attachment is a part of.
Definition NpArticulationTendon.cpp:168
virtual PxArticulationLink * getLink() const
Gets the articulation link.
Definition NpArticulationTendon.h:122
virtual PxArticulationTendonLimit getLimitParameters() const
Gets the low and high limit on the length of the sub-tendon from the root to this leaf attachment.
Definition NpArticulationTendon.cpp:131
virtual void setLimitParameters(const PxArticulationTendonLimit &paramters)
Sets the low and high limit on the length of the sub-tendon from the root to this leaf attachment.
Definition NpArticulationTendon.cpp:119
virtual bool isLeaf() const
Indicates that this attachment is a leaf, and thus defines a sub-tendon from the root to this attachm...
Definition NpArticulationTendon.h:126
Definition NpArticulationTendon.h:258
virtual PxArticulationTendonJoint * createTendonJoint(PxArticulationTendonJoint *parent, PxArticulationAxis::Enum axis, const PxReal scale, const PxReal recipScale, PxArticulationLink *link)
Creates an articulation tendon joint and adds it to the list of children in the parent tendon joint.
Definition NpArticulationTendon.cpp:636
virtual void setStiffness(const PxReal stiffness)
Sets the spring stiffness term acting on the tendon length.
Definition NpArticulationTendon.cpp:687
virtual PxReal getDamping() const
Gets the damping term acting both on the tendon length and tendon-length limits.
Definition NpArticulationTendon.cpp:712
virtual void setDamping(const PxReal damping)
Sets the damping term acting both on the tendon length and tendon-length limits.
Definition NpArticulationTendon.cpp:703
virtual PxArticulationTendonLimit getLimitParameters() const
Gets the low and high limit on the length of the tendon.
Definition NpArticulationTendon.cpp:760
virtual PxU32 getNbTendonJoints(void) const
Returns the number of tendon joints in the tendon.
Definition NpArticulationTendon.cpp:774
virtual PxReal getRestLength() const
Gets the spring rest length of the tendon.
Definition NpArticulationTendon.cpp:744
virtual PxReal getOffset() const
Gets the length offset term for the tendon.
Definition NpArticulationTendon.cpp:792
virtual void setOffset(const PxReal offset, bool autowake=true)
Sets the length offset term for the tendon.
Definition NpArticulationTendon.cpp:779
virtual PxReal getLimitStiffness() const
Gets the limit stiffness term acting on the tendon's length limits.
Definition NpArticulationTendon.cpp:728
virtual void setLimitStiffness(const PxReal damping)
Sets the limit stiffness term acting on the tendon's length limits.
Definition NpArticulationTendon.cpp:719
virtual PxReal getStiffness() const
Gets the spring stiffness of the tendon.
Definition NpArticulationTendon.cpp:696
virtual PxArticulationReducedCoordinate * getArticulation() const
Gets the articulation that the tendon is a part of.
Definition NpArticulationTendon.cpp:799
virtual PxU32 getTendonJoints(PxArticulationTendonJoint **userBuffer, PxU32 bufferSize, PxU32 startIndex) const
Fills a user-provided buffer of tendon-joint pointers with the set of tendon joints.
Definition NpArticulationTendon.cpp:680
virtual void setRestLength(const PxReal restLength)
Sets the spring rest length of the tendon.
Definition NpArticulationTendon.cpp:735
virtual void release()
Releases a tendon to remove it from the articulation and free its associated memory.
Definition NpArticulationTendon.cpp:618
virtual void setLimitParameters(const PxArticulationTendonLimit &paramters)
Sets the low and high limit on the length of the tendon.
Definition NpArticulationTendon.cpp:751
Definition NpArticulationReducedCoordinate.h:56
Definition NpArticulationTendon.h:150
virtual void setStiffness(const PxReal stiffness)
Sets the spring stiffness term acting on the tendon length.
Definition NpArticulationTendon.cpp:331
virtual PxU32 getAttachments(PxArticulationAttachment **userBuffer, PxU32 bufferSize, PxU32 startIndex) const
Fills a user-provided buffer of attachment pointers with the set of attachments.
Definition NpArticulationTendon.cpp:324
virtual void setOffset(const PxReal offset, bool autowake=true)
Sets the length offset term for the tendon.
Definition NpArticulationTendon.cpp:383
virtual PxArticulationAttachment * createAttachment(PxArticulationAttachment *parent, const PxReal coefficient, const PxVec3 relativeOffset, PxArticulationLink *link)
Creates an articulation attachment and adds it to the list of children in the parent attachment.
Definition NpArticulationTendon.cpp:280
virtual void release()
Releases a tendon to remove it from the articulation and free its associated memory.
Definition NpArticulationTendon.cpp:408
virtual void setDamping(const PxReal damping)
Sets the damping term acting both on the tendon length and tendon-length limits.
Definition NpArticulationTendon.cpp:351
virtual PxReal getDamping() const
Gets the damping term acting both on the tendon length and tendon-length limits.
Definition NpArticulationTendon.cpp:360
virtual PxReal getStiffness() const
Gets the spring stiffness of the tendon.
Definition NpArticulationTendon.cpp:344
virtual PxArticulationReducedCoordinate * getArticulation() const
Gets the articulation that the tendon is a part of.
Definition NpArticulationTendon.cpp:403
virtual PxReal getOffset() const
Gets the length offset term for the tendon.
Definition NpArticulationTendon.cpp:396
virtual void setLimitStiffness(const PxReal stiffness)
Sets the limit stiffness term acting on the tendon's length limits.
Definition NpArticulationTendon.cpp:367
virtual PxReal getLimitStiffness() const
Gets the limit stiffness term acting on the tendon's length limits.
Definition NpArticulationTendon.cpp:376
PxU32 getNbAttachments() const
Returns the number of attachments in the tendon.
Definition NpArticulationTendon.cpp:432
!!AL TODO: check if default of 4 elements makes sense
Definition NpArticulationTendon.h:71
Definition NpArticulationTendon.h:208
virtual PxArticulationFixedTendon * getTendon() const
Gets the tendon that the joint is a part of.
Definition NpArticulationTendon.cpp:505
virtual void release()
Releases a tendon joint.
Definition NpArticulationTendon.cpp:529
virtual PxArticulationTendonJoint * getParent() const
Gets the parent tendon joint.
Definition NpArticulationTendon.h:228
virtual PxArticulationLink * getLink() const
Gets the articulation link.
Definition NpArticulationTendon.h:226
virtual void getCoefficient(PxArticulationAxis::Enum &axis, PxReal &coefficient, PxReal &recipCoefficient) const
Gets the tendon joint coefficient.
Definition NpArticulationTendon.cpp:524
virtual void setCoefficient(const PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient)
Sets the tendon joint coefficient.
Definition NpArticulationTendon.cpp:510
Definition NpBase.h:167
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
PX_FORCE_INLINE ConstIterator begin() const
Definition PxArray.h:176
PX_FORCE_INLINE bool empty() const
Definition PxArray.h:261
Defines a spatial tendon attachment point on a link.
Definition PxArticulationTendon.h:60
A fixed tendon that can be used to link multiple degrees of freedom of multiple articulation joints v...
Definition PxArticulationTendon.h:478
A tree structure of bodies connected by joints that is treated as a unit by the dynamics solver....
Definition PxArticulationReducedCoordinate.h:448
A spatial tendon that attaches to an articulation.
Definition PxArticulationTendon.h:413
Defines a fixed-tendon joint on an articulation joint degree of freedom.
Definition PxArticulationTendon.h:203
Defines the low/high limits of the length of a tendon.
Definition PxArticulationTendon.h:50
Binary deserialization context class.
Definition PxSerialFramework.h:174
Definition PxInlineArray.h:43
Output stream class for I/O.
Definition PxIO.h:114
Callback class used to process PxBase objects.
Definition PxSerialFramework.h:81
Binary serialization context class.
Definition PxSerialFramework.h:99
3 Element vector class.
Definition PxVec3.h:50
Definition ScArticulationTendonCore.h:101
Definition ScArticulationTendonCore.h:63
#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
PxEMPTY
Definition Px.h:87
Enum
Definition PxSolverDefs.h:252