RavEngine
Loading...
Searching...
No Matches
ScArticulationJointCore.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 SC_ARTICULATION_JOINT_CORE_H
30#define SC_ARTICULATION_JOINT_CORE_H
31
32#include "foundation/PxTransform.h"
33#include "common/PxMetaData.h"
34#include "foundation/PxUserAllocated.h"
35#include "DyVArticulation.h"
36
37namespace physx
38{
39namespace Sc
40{
41 class BodyCore;
42 class ArticulationJointSim;
43 class ArticulationCore;
44
46 {
47 public:
48 BodyCore* parent;
49 BodyCore* child;
50 PxTransform parentPose;
51 PxTransform childPose;
52 };
53
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 //==================================================================================================
62
63 public:
64// PX_SERIALIZATION
65 ArticulationJointCore(const PxEMPTY) : mCore(PxEmpty), mSim(NULL) {}
66 void preExportDataReset() { mCore.jointDirtyFlag = Dy::ArticulationJointCoreDirtyFlag::eALL; }
67 static void getBinaryMetaData(PxOutputStream& stream);
68//~PX_SERIALIZATION
69 ArticulationJointCore(const PxTransform& parentFrame, const PxTransform& childFrame);
71
72 //Those methods are not allowed while the articulation are in the scene
73 PX_FORCE_INLINE const PxTransform& getParentPose() const { return mCore.parentPose; }
74 void setParentPose(const PxTransform&);
75
76 PX_FORCE_INLINE const PxTransform& getChildPose() const { return mCore.childPose; }
77 void setChildPose(const PxTransform&);
78
79 //Those functions doesn't change the articulation configuration so the application is allowed to change those value in run-time
80 PX_FORCE_INLINE PxArticulationLimit getLimit(PxArticulationAxis::Enum axis) const { return mCore.limits[axis]; }
81 void setLimit(PxArticulationAxis::Enum axis, const PxArticulationLimit& limit);
82
83 PX_FORCE_INLINE PxArticulationDrive getDrive(PxArticulationAxis::Enum axis) const { return mCore.drives[axis]; }
84 void setDrive(PxArticulationAxis::Enum axis, const PxArticulationDrive& drive);
85
86 void setTargetP(PxArticulationAxis::Enum axis, PxReal targetP);
87 PX_FORCE_INLINE PxReal getTargetP(PxArticulationAxis::Enum axis) const { return mCore.targetP[axis]; }
88
89 void setTargetV(PxArticulationAxis::Enum axis, PxReal targetV);
90 PX_FORCE_INLINE PxReal getTargetV(PxArticulationAxis::Enum axis) const { return mCore.targetV[axis]; }
91
92 void setArmature(PxArticulationAxis::Enum axis, PxReal armature);
93 PX_FORCE_INLINE PxReal getArmature(PxArticulationAxis::Enum axis) const { return mCore.armature[axis]; }
94
95 void setJointPosition(PxArticulationAxis::Enum axis, const PxReal jointPos);
96 PxReal getJointPosition(PxArticulationAxis::Enum axis) const;
97
98 void setJointVelocity(PxArticulationAxis::Enum axis, const PxReal jointVel);
99 PxReal getJointVelocity(PxArticulationAxis::Enum axis) const;
100
101 // PT: TODO: don't we need to set ArticulationJointCoreDirtyFlag::eMOTION here?
102 PX_FORCE_INLINE void setMotion(PxArticulationAxis::Enum axis, PxArticulationMotion::Enum motion) { mCore.motion[axis] = PxU8(motion); }
103 PX_FORCE_INLINE PxArticulationMotion::Enum getMotion(PxArticulationAxis::Enum axis) const { return PxArticulationMotion::Enum(mCore.motion[axis]); }
104
105 PX_FORCE_INLINE void setJointType(PxArticulationJointType::Enum type) { mCore.initJointType(type); }
106 PX_FORCE_INLINE PxArticulationJointType::Enum getJointType() const { return PxArticulationJointType::Enum(mCore.jointType); }
107
108 PX_FORCE_INLINE void setFrictionCoefficient(const PxReal coefficient) { mCore.initFrictionCoefficient(coefficient); }
109 PX_FORCE_INLINE PxReal getFrictionCoefficient() const { return mCore.frictionCoefficient; }
110
111 PX_FORCE_INLINE void setMaxJointVelocity(const PxReal maxJointV) { mCore.initMaxJointVelocity(maxJointV); }
112 PX_FORCE_INLINE PxReal getMaxJointVelocity() const { return mCore.maxJointVelocity; }
113
114 PX_FORCE_INLINE ArticulationJointSim* getSim() const { return mSim; }
115 PX_FORCE_INLINE void setSim(ArticulationJointSim* sim)
116 {
117 PX_ASSERT((sim==0) ^ (mSim == 0));
118 mSim = sim;
119 }
120
121 PX_FORCE_INLINE Dy::ArticulationJointCore& getCore() { return mCore; }
122
123 PX_FORCE_INLINE void setArticulation(ArticulationCore* articulation) { mArticulation = articulation; }
124 PX_FORCE_INLINE const ArticulationCore* getArticulation() const { return mArticulation; }
125
126 PX_FORCE_INLINE void setRoot(PxArticulationJointReducedCoordinate* base) { mRootType = base; }
127 PX_FORCE_INLINE PxArticulationJointReducedCoordinate* getRoot() const { return mRootType; }
128
129 PX_FORCE_INLINE void setLLIndex(const PxU32 llLinkIndex) { mLLLinkIndex = llLinkIndex; }
130 private:
131 void setSimDirty();
132 PX_FORCE_INLINE void setDirty(Dy::ArticulationJointCoreDirtyFlag::Enum dirtyFlag)
133 {
134 mCore.jointDirtyFlag |= dirtyFlag;
135 setSimDirty();
136 }
137
140 ArticulationCore* mArticulation;
142 PxU32 mLLLinkIndex;
143#if PX_P64_FAMILY
144 PxU32 pad;
145#endif
146 };
147
148} // namespace Sc
149
150}
151
152#endif
A joint between two links in an articulation.
Definition PxArticulationJointReducedCoordinate.h:49
Output stream class for I/O.
Definition PxIO.h:114
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
Definition PxUserAllocated.h:43
Definition ScArticulationCore.h:52
Definition ScArticulationJointCore.h:55
Definition ScArticulationJointCore.h:46
Definition ScArticulationJointSim.h:42
Definition ScBodyCore.h:49
#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
Definition DyArticulationJointCore.h:44
Enum
Definition PxSolverDefs.h:252
Data structure for articulation joint drive configuration.
Definition PxSolverDefs.h:359
Enum
Definition PxSolverDefs.h:281
Data structure to set articulation joint limits.
Definition PxSolverDefs.h:327
Enum
Definition PxSolverDefs.h:268