RavEngine
Loading...
Searching...
No Matches
NpArticulationLink.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_LINK_H
30#define NP_ARTICULATION_LINK_H
31
32#include "NpRigidBodyTemplate.h"
33#include "PxArticulationLink.h"
34
35#if PX_ENABLE_DEBUG_VISUALIZATION
36 #include "common/PxRenderOutput.h"
37#else
38 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
39#endif
40
41namespace physx
42{
43
44class NpArticulationLink;
45class NpArticulationJointReducedCoordinate;
46class PxConstraintVisualizer;
47
48typedef NpRigidBodyTemplate<PxArticulationLink> NpArticulationLinkT;
49
50class NpArticulationLinkArray : public PxInlineArray<NpArticulationLink*, 4>
51{
52//= ATTENTION! =====================================================================================
53// Changing the data layout of this class breaks the binary serialization format. See comments for
54// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
55// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
56// accordingly.
57//==================================================================================================
58public:
59// PX_SERIALIZATION
61 static void getBinaryMetaData(PxOutputStream& stream);
62//~PX_SERIALIZATION
64};
65
67{
68//= ATTENTION! =====================================================================================
69// Changing the data layout of this class breaks the binary serialization format. See comments for
70// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
71// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
72// accordingly.
73//==================================================================================================
74public:
75// PX_SERIALIZATION
76 NpArticulationLink(PxBaseFlags baseFlags) : NpArticulationLinkT(baseFlags), mChildLinks(PxEmpty) {}
77 void preExportDataReset() { NpArticulationLinkT::preExportDataReset(); }
78 virtual void exportExtraData(PxSerializationContext& context);
79 void importExtraData(PxDeserializationContext& context);
80 void resolveReferences(PxDeserializationContext& context);
81 virtual void requiresObjects(PxProcessPxBaseCallback& c);
82 virtual bool isSubordinate() const { return true; }
83 static NpArticulationLink* createObject(PxU8*& address, PxDeserializationContext& context);
84 static void getBinaryMetaData(PxOutputStream& stream);
85//~PX_SERIALIZATION
86 virtual ~NpArticulationLink();
87
88 //---------------------------------------------------------------------------------
89 // PxArticulationLink implementation
90 //---------------------------------------------------------------------------------
91 virtual void release();
92
93
94 virtual PxActorType::Enum getType() const { return PxActorType::eARTICULATION_LINK; }
95
96 // Pose
97 virtual void setGlobalPose(const PxTransform& /*pose*/, bool /*wake*/) { /*return false; */}
98 virtual PxTransform getGlobalPose() const;
99
100
101 virtual bool attachShape(PxShape& shape);
102 virtual void detachShape(PxShape& shape, bool wakeOnLostTouch = true);
103
104 virtual PxArticulationReducedCoordinate& getArticulation() const;
105 virtual PxArticulationJointReducedCoordinate* getInboundJoint() const;
106 virtual PxU32 getInboundJointDof() const;
107
108 virtual PxU32 getNbChildren() const;
109 virtual PxU32 getChildren(PxArticulationLink** userBuffer, PxU32 bufferSize, PxU32 startIndex) const;
110 virtual PxU32 getLinkIndex() const;
111 virtual void setCMassLocalPose(const PxTransform& pose);
112
113 virtual void addForce(const PxVec3& force, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true);
114 virtual void addTorque(const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true);
115 virtual void setForceAndTorque(const PxVec3& force, const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE);
116 virtual void clearForce(PxForceMode::Enum mode = PxForceMode::eFORCE);
117 virtual void clearTorque(PxForceMode::Enum mode = PxForceMode::eFORCE);
118
119 virtual void setCfmScale(const PxReal cfmScale);
120 virtual PxReal getCfmScale() const;
121 //---------------------------------------------------------------------------------
122 // Miscellaneous
123 //---------------------------------------------------------------------------------
125
126 void releaseInternal();
127
128 PX_INLINE PxArticulationReducedCoordinate& getRoot() { return *mRoot; }
129 PX_INLINE NpArticulationLink* getParent() { return mParent; }
130 PX_INLINE const NpArticulationLink* getParent() const { return mParent; }
131
132 PX_INLINE void setInboundJoint(PxArticulationJointReducedCoordinate& joint) { mInboundJoint = &joint; }
133
134 void setGlobalPoseInternal(const PxTransform& pose, bool autowake);
135 void setLLIndex(const PxU32 index) { mLLIndex = index; }
136 void setInboundJointDof(const PxU32 index) { mInboundJointDof = index; }
137 static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF_RT(NpArticulationLink, mCore); }
138private:
139 PX_INLINE void addToChildList(NpArticulationLink& link) { mChildLinks.pushBack(&link); }
140 PX_INLINE void removeFromChildList(NpArticulationLink& link) { PX_ASSERT(mChildLinks.find(&link) != mChildLinks.end()); mChildLinks.findAndReplaceWithLast(&link); }
141
142public:
143 PX_INLINE NpArticulationLink* const* getChildren() { return mChildLinks.empty() ? NULL : &mChildLinks.front(); }
144 void setKinematicLink(const bool value);
145
146#if PX_ENABLE_DEBUG_VISUALIZATION
147 void visualize(PxRenderOutput& out, NpScene& scene, float scale) const;
148 void visualizeJoint(PxConstraintVisualizer& jointViz) const;
149#else
150 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
151#endif
152
153private:
156 NpArticulationLink* mParent;
157 NpArticulationLinkArray mChildLinks;
158 PxU32 mLLIndex;
159 PxU32 mInboundJointDof;
160};
161
162}
163
164#endif
Definition base.h:1940
!!AL TODO: check if default of 4 elements makes sense
Definition NpArticulationLink.h:51
Definition NpRigidBodyTemplate.h:80
Definition NpScene.h:130
PX_INLINE Iterator find(const T &a)
Definition PxArray.h:272
PX_FORCE_INLINE ConstIterator end() const
Definition PxArray.h:192
PX_FORCE_INLINE const T & front() const
Definition PxArray.h:207
PX_FORCE_INLINE bool empty() const
Definition PxArray.h:261
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
PX_INLINE bool findAndReplaceWithLast(const T &a)
Definition PxArray.h:368
A joint between two links in an articulation.
Definition PxArticulationJointReducedCoordinate.h:49
A tree structure of bodies connected by joints that is treated as a unit by the dynamics solver....
Definition PxArticulationReducedCoordinate.h:448
API used to visualize details about a constraint.
Definition PxConstraintDesc.h:256
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
Definition PxRenderOutput.h:50
Binary serialization context class.
Definition PxSerialFramework.h:99
Abstract class for collision shapes.
Definition PxShape.h:146
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_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
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 PxActor.h:121
@ eARTICULATION_LINK
An articulation link.
Definition PxActor.h:138
Enum
Definition PxForceMode.h:51
@ eFORCE
parameter has unit of mass * length / time^2, i.e., a force
Definition PxForceMode.h:52