Box2D  2.2.0
A 2D Physics Engine for Games
b2WeldJoint.h
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_WELD_JOINT_H
00020 #define B2_WELD_JOINT_H
00021 
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023 
00027 struct b2WeldJointDef : public b2JointDef
00028 {
00029         b2WeldJointDef()
00030         {
00031                 type = e_weldJoint;
00032                 localAnchorA.Set(0.0f, 0.0f);
00033                 localAnchorB.Set(0.0f, 0.0f);
00034                 referenceAngle = 0.0f;
00035         }
00036 
00039         void Initialize(b2Body* body1, b2Body* body2, const b2Vec2& anchor);
00040 
00042         b2Vec2 localAnchorA;
00043 
00045         b2Vec2 localAnchorB;
00046 
00048         float32 referenceAngle;
00049 };
00050 
00053 class b2WeldJoint : public b2Joint
00054 {
00055 public:
00056         b2Vec2 GetAnchorA() const;
00057         b2Vec2 GetAnchorB() const;
00058 
00059         b2Vec2 GetReactionForce(float32 inv_dt) const;
00060         float32 GetReactionTorque(float32 inv_dt) const;
00061 
00062 protected:
00063 
00064         friend class b2Joint;
00065 
00066         b2WeldJoint(const b2WeldJointDef* def);
00067 
00068         void InitVelocityConstraints(const b2SolverData& data);
00069         void SolveVelocityConstraints(const b2SolverData& data);
00070         bool SolvePositionConstraints(const b2SolverData& data);
00071 
00072         // Solver shared
00073         b2Vec2 m_localAnchorA;
00074         b2Vec2 m_localAnchorB;
00075         float32 m_referenceAngle;
00076         b2Vec3 m_impulse;
00077 
00078         // Solver temp
00079         int32 m_indexA;
00080         int32 m_indexB;
00081         b2Vec2 m_rA;
00082         b2Vec2 m_rB;
00083         b2Vec2 m_localCenterA;
00084         b2Vec2 m_localCenterB;
00085         float32 m_invMassA;
00086         float32 m_invMassB;
00087         float32 m_invIA;
00088         float32 m_invIB;
00089         b2Mat33 m_mass;
00090 };
00091 
00092 #endif
 All Classes Files Functions Variables Enumerations Enumerator Defines