b2RopeJoint.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
00003 *
00004 * This software is provided 'as-is', without any express or implied
00005 * warranty.  In no event will the authors be held liable for any damages
00006 * arising from the use of this software.
00007 * Permission is granted to anyone to use this software for any purpose,
00008 * including commercial applications, and to alter it and redistribute it
00009 * freely, subject to the following restrictions:
00010 * 1. The origin of this software must not be misrepresented; you must not
00011 * claim that you wrote the original software. If you use this software
00012 * in a product, an acknowledgment in the product documentation would be
00013 * appreciated but is not required.
00014 * 2. Altered source versions must be plainly marked as such, and must not be
00015 * misrepresented as being the original software.
00016 * 3. This notice may not be removed or altered from any source distribution.
00017 */
00018 
00019 #ifndef B2_ROPE_JOINT_H
00020 #define B2_ROPE_JOINT_H
00021 
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023 
00028 struct b2RopeJointDef : public b2JointDef
00029 {
00030         b2RopeJointDef()
00031         {
00032                 type = e_ropeJoint;
00033                 localAnchorA.Set(-1.0f, 0.0f);
00034                 localAnchorB.Set(1.0f, 0.0f);
00035                 maxLength = 0.0f;
00036         }
00037 
00039         b2Vec2 localAnchorA;
00040 
00042         b2Vec2 localAnchorB;
00043 
00047         float32 maxLength;
00048 };
00049 
00058 class b2RopeJoint : public b2Joint
00059 {
00060 public:
00061         b2Vec2 GetAnchorA() const;
00062         b2Vec2 GetAnchorB() const;
00063 
00064         b2Vec2 GetReactionForce(float32 inv_dt) const;
00065         float32 GetReactionTorque(float32 inv_dt) const;
00066 
00068         const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
00069 
00071         const b2Vec2& GetLocalAnchorB() const  { return m_localAnchorB; }
00072 
00074         void SetMaxLength(float32 length) { m_maxLength = length; }
00075         float32 GetMaxLength() const;
00076 
00077         b2LimitState GetLimitState() const;
00078 
00080         void Dump();
00081 
00082 protected:
00083 
00084         friend class b2Joint;
00085         b2RopeJoint(const b2RopeJointDef* data);
00086 
00087         void InitVelocityConstraints(const b2SolverData& data);
00088         void SolveVelocityConstraints(const b2SolverData& data);
00089         bool SolvePositionConstraints(const b2SolverData& data);
00090 
00091         // Solver shared
00092         b2Vec2 m_localAnchorA;
00093         b2Vec2 m_localAnchorB;
00094         float32 m_maxLength;
00095         float32 m_length;
00096         float32 m_impulse;
00097 
00098         // Solver temp
00099         int32 m_indexA;
00100         int32 m_indexB;
00101         b2Vec2 m_u;
00102         b2Vec2 m_rA;
00103         b2Vec2 m_rB;
00104         b2Vec2 m_localCenterA;
00105         b2Vec2 m_localCenterB;
00106         float32 m_invMassA;
00107         float32 m_invMassB;
00108         float32 m_invIA;
00109         float32 m_invIB;
00110         float32 m_mass;
00111         b2LimitState m_state;
00112 };
00113 
00114 #endif


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 22:08:35