RavEngine
Loading...
Searching...
No Matches
PulleyJoint.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 PULLEY_JOINT_H
30#define PULLEY_JOINT_H
31
32#include "PxPhysicsAPI.h"
33
34// a pulley joint constrains two actors such that the sum of their distances from their respective anchor points at their attachment points
35// is a fixed value (the parameter 'distance'). Only dynamic actors are supported.
36//
37// The constraint equation is as follows:
38//
39// |anchor0 - attachment0| + |anchor1 - attachment1| * ratio = distance
40//
41// where 'ratio' provides mechanical advantage.
42//
43// The above equation results in a singularity when the anchor point is coincident with the attachment point; for simplicity
44// the constraint does not attempt to handle this case robustly.
45
47{
48public:
49
50 static const physx::PxU32 TYPE_ID = physx::PxConcreteType::eFIRST_USER_EXTENSION;
51
53 physx::PxRigidBody& body0, const physx::PxTransform& localFrame0, const physx::PxVec3& attachment0,
54 physx::PxRigidBody& body1, const physx::PxTransform& localFrame1, const physx::PxVec3& attachment1);
55
56 void release();
57
58 // attribute accessor and mutators
59
60 void setAttachment0(const physx::PxVec3& pos);
61 physx::PxVec3 getAttachment0() const;
62
63 void setAttachment1(const physx::PxVec3& pos);
64 physx::PxVec3 getAttachment1() const;
65
66 void setDistance(physx::PxReal totalDistance);
67 physx::PxReal getDistance() const;
68
69 void setRatio(physx::PxReal ratio);
70 physx::PxReal getRatio() const;
71
72 // PxConstraintConnector boilerplate
73
74 void* prepareData();
76 void onComShift(physx::PxU32 actor);
77 void onOriginShift(const physx::PxVec3& shift);
78 void* getExternalReference(physx::PxU32& typeID);
79
83 void updateOmniPvdProperties() const { }
84 physx::PxBase* getSerializable() { return NULL; }
85
87
88 virtual const void* getConstantBlock() const { return &mData; }
89
91 {
92 physx::PxTransform c2b[2];
93
94 physx::PxVec3 attachment0;
95 physx::PxVec3 attachment1;
96
97 physx::PxReal distance;
98 physx::PxReal ratio;
99 physx::PxReal tolerance;
100 };
101
102 physx::PxRigidBody* mBody[2];
103 physx::PxTransform mLocalPose[2];
104
105 physx::PxConstraint* mConstraint;
106 PulleyJointData mData;
107
108 ~PulleyJoint() {}
109};
110
111#endif
Definition PulleyJoint.h:47
bool updatePvdProperties(physx::pvdsdk::PvdDataStream &, const physx::PxConstraint *, physx::PxPvdUpdateType::Enum) const
this function is called by the SDK to update PVD's view of it
Definition PulleyJoint.h:80
void onComShift(physx::PxU32 actor)
Center-of-mass shift callback.
Definition PulleyJoint.cpp:208
void updateOmniPvdProperties() const
this function is called by the SDK to update OmniPVD's view of it
Definition PulleyJoint.h:83
virtual physx::PxConstraintSolverPrep getPrep() const
Obtain the shader function pointer used to prep rows for this constraint.
Definition PulleyJoint.cpp:122
void * prepareData()
Pre-simulation data preparation when the constraint is marked dirty, this function is called at the s...
Definition PulleyJoint.cpp:198
void onOriginShift(const physx::PxVec3 &shift)
Origin shift callback.
Definition PulleyJoint.cpp:214
virtual const void * getConstantBlock() const
Obtain the pointer to the constraint's constant data.
Definition PulleyJoint.h:88
void * getExternalReference(physx::PxU32 &typeID)
Fetches external data for a constraint.
Definition PulleyJoint.cpp:220
void onConstraintRelease()
Constraint release callback.
Definition PulleyJoint.cpp:203
physx::PxBase * getSerializable()
Obtain a reference to a PxBase interface if the constraint has one.
Definition PulleyJoint.h:84
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
This class connects a custom constraint to the SDK.
Definition PxConstraintDesc.h:354
A plugin class for implementing constraints.
Definition PxConstraint.h:100
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition PxPhysics.h:91
PxRigidBody is a base class shared between dynamic rigid body objects.
Definition PxRigidBody.h:199
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
Definition PxPvdDataStream.h:241
PxU32(* PxConstraintSolverPrep)(Px1DConstraint *constraints, PxVec3p &bodyAWorldOffset, PxU32 maxConstraints, PxConstraintInvMassScale &invMassScale, const void *constantBlock, const PxTransform &bodyAToWorld, const PxTransform &bodyBToWorld, bool useExtendedLimits, PxVec3p &cAtW, PxVec3p &cBtW)
Solver constraint generation shader.
Definition PxConstraintDesc.h:223
Definition PulleyJoint.h:91
Enum
Definition PxConstraintDesc.h:337