| 1 | // | 
| 2 | // Redistribution and use in source and binary forms, with or without | 
| 3 | // modification, are permitted provided that the following conditions | 
| 4 | // are met: | 
| 5 | //  * Redistributions of source code must retain the above copyright | 
| 6 | //    notice, this list of conditions and the following disclaimer. | 
| 7 | //  * Redistributions in binary form must reproduce the above copyright | 
| 8 | //    notice, this list of conditions and the following disclaimer in the | 
| 9 | //    documentation and/or other materials provided with the distribution. | 
| 10 | //  * Neither the name of NVIDIA CORPORATION nor the names of its | 
| 11 | //    contributors may be used to endorse or promote products derived | 
| 12 | //    from this software without specific prior written permission. | 
| 13 | // | 
| 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY | 
| 15 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
| 17 | // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 
| 18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 
| 19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 
| 20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 
| 21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 
| 22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 25 | // | 
| 26 | // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. | 
| 27 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. | 
| 28 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.   | 
| 29 |  | 
| 30 | #ifndef PX_CONTACTJOINT_H | 
| 31 | #define PX_CONTACTJOINT_H | 
| 32 |  | 
| 33 | #include "extensions/PxJoint.h" | 
| 34 |  | 
| 35 | #if !PX_DOXYGEN | 
| 36 | namespace physx | 
| 37 | { | 
| 38 | #endif | 
| 39 |  | 
| 40 | 	class PxContactJoint; | 
| 41 |  | 
| 42 | 	/** | 
| 43 | 	\brief Create a distance Joint. | 
| 44 |  | 
| 45 | 	\param[in] physics		The physics SDK | 
| 46 | 	\param[in] actor0		An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame | 
| 47 | 	\param[in] localFrame0	The position and orientation of the joint relative to actor0 | 
| 48 | 	\param[in] actor1		An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame | 
| 49 | 	\param[in] localFrame1	The position and orientation of the joint relative to actor1 | 
| 50 |  | 
| 51 | 	@see PxContactJoint | 
| 52 | 	*/ | 
| 53 | 	PxContactJoint*	PxContactJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); | 
| 54 |  | 
| 55 | 	/** | 
| 56 | 	\brief a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects | 
| 57 |  | 
| 58 | 	@see PxContactJointCreate PxJoint | 
| 59 | 	*/ | 
| 60 |  | 
| 61 | 	struct PxJacobianRow | 
| 62 | 	{ | 
| 63 | 		PxVec3 linear0; | 
| 64 | 		PxVec3 linear1; | 
| 65 | 		PxVec3 angular0; | 
| 66 | 		PxVec3 angular1; | 
| 67 | 		 | 
| 68 | 		PxJacobianRow(){} | 
| 69 | 		 | 
| 70 | 		PxJacobianRow(const PxVec3& lin0, const PxVec3& lin1, const PxVec3& ang0, const PxVec3& ang1) :  | 
| 71 | 		linear0(lin0), linear1(lin1), angular0(ang0), angular1(ang1) | 
| 72 | 		{ | 
| 73 | 			 | 
| 74 | 		} | 
| 75 |  | 
| 76 | 		void operator *= (const PxReal scale) | 
| 77 | 		{ | 
| 78 | 			linear0 *= scale; | 
| 79 | 			linear1 *= scale; | 
| 80 | 			angular0 *= scale; | 
| 81 | 			angular1 *= scale; | 
| 82 | 		} | 
| 83 |  | 
| 84 | 		PxJacobianRow operator * (const PxReal scale) const | 
| 85 | 		{ | 
| 86 | 			return PxJacobianRow(linear0*scale, linear1*scale, angular0*scale, angular1*scale); | 
| 87 | 		} | 
| 88 | 	}; | 
| 89 |  | 
| 90 | 	/** | 
| 91 | 	\brief a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects | 
| 92 |  | 
| 93 | 	@see PxContactJointCreate PxJoint | 
| 94 | 	*/ | 
| 95 | 	class PxContactJoint : public PxJoint | 
| 96 | 	{ | 
| 97 | 	public: | 
| 98 |  | 
| 99 | 		/** | 
| 100 | 		\brief Set the current contact of the joint | 
| 101 | 		*/ | 
| 102 | 		virtual void					setContact(const PxVec3& contact)	= 0; | 
| 103 |  | 
| 104 | 		/** | 
| 105 | 		\brief Set the current contact normal of the joint | 
| 106 | 		*/ | 
| 107 | 		virtual	void					setContactNormal(const PxVec3& contactNormal) = 0; | 
| 108 |  | 
| 109 | 		/** | 
| 110 | 		\brief Set the current penetration of the joint | 
| 111 | 		*/ | 
| 112 | 		virtual	void					setPenetration(const PxReal penetration) = 0; | 
| 113 | 		 | 
| 114 | 		/** | 
| 115 | 		\brief Return the current contact of the joint | 
| 116 | 		*/ | 
| 117 | 		virtual PxVec3					getContact()	const = 0; | 
| 118 |  | 
| 119 | 		/** | 
| 120 | 		\brief Return the current contact normal of the joint | 
| 121 | 		*/ | 
| 122 | 		virtual PxVec3					getContactNormal() const = 0; | 
| 123 |  | 
| 124 | 		/** | 
| 125 | 		\brief Return the current penetration value of the joint | 
| 126 | 		*/ | 
| 127 | 		virtual PxReal					getPenetration() const = 0; | 
| 128 |  | 
| 129 | 		virtual	PxReal					getResititution()	const = 0; | 
| 130 | 		virtual	void					setResititution(const PxReal resititution) = 0; | 
| 131 | 		virtual PxReal					getBounceThreshold() const = 0; | 
| 132 | 		virtual void					setBounceThreshold(const PxReal bounceThreshold) = 0; | 
| 133 |  | 
| 134 | 		/** | 
| 135 | 		\brief Returns string name of PxContactJoint, used for serialization | 
| 136 | 		*/ | 
| 137 | 		virtual	const char*				getConcreteTypeName() const { return "PxContactJoint" ; } | 
| 138 | 	 | 
| 139 | 		virtual void computeJacobians(PxJacobianRow* jacobian) const = 0; | 
| 140 | 		virtual PxU32 getNbJacobianRows() const = 0; | 
| 141 |  | 
| 142 | 	protected: | 
| 143 | 		//serialization | 
| 144 |  | 
| 145 | 		/** | 
| 146 | 		\brief Constructor | 
| 147 | 		*/ | 
| 148 | 		PX_INLINE						PxContactJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} | 
| 149 |  | 
| 150 | 		/** | 
| 151 | 		\brief Deserialization constructor | 
| 152 | 		*/ | 
| 153 | 		PX_INLINE						PxContactJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} | 
| 154 |  | 
| 155 | 		/** | 
| 156 | 		\brief Returns whether a given type name matches with the type of this instance | 
| 157 | 		*/ | 
| 158 | 		virtual	bool					isKindOf(const char* name)	const { return !::strcmp(s1: "PxContactJoint" , s2: name) || PxJoint::isKindOf(name); } | 
| 159 |  | 
| 160 | 		//~serialization | 
| 161 | 	}; | 
| 162 |  | 
| 163 | #if !PX_DOXYGEN | 
| 164 | } | 
| 165 | #endif | 
| 166 |  | 
| 167 |  | 
| 168 | #endif | 
| 169 |  |