123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef B2_FRICTION_JOINT_H
- #define B2_FRICTION_JOINT_H
- #include <Box2D/Dynamics/Joints/b2Joint.h>
- struct b2FrictionJointDef : public b2JointDef
- {
- b2FrictionJointDef()
- {
- type = e_frictionJoint;
- localAnchorA.SetZero();
- localAnchorB.SetZero();
- maxForce = 0.0f;
- maxTorque = 0.0f;
- }
-
-
- void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
-
- b2Vec2 localAnchorA;
-
- b2Vec2 localAnchorB;
-
- float32 maxForce;
-
- float32 maxTorque;
- };
- class b2FrictionJoint : public b2Joint
- {
- public:
- b2Vec2 GetAnchorA() const;
- b2Vec2 GetAnchorB() const;
- b2Vec2 GetReactionForce(float32 inv_dt) const;
- float32 GetReactionTorque(float32 inv_dt) const;
-
- const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
-
- const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
-
- void SetMaxForce(float32 force);
-
- float32 GetMaxForce() const;
-
- void SetMaxTorque(float32 torque);
-
- float32 GetMaxTorque() const;
-
- void Dump();
- protected:
- friend class b2Joint;
- b2FrictionJoint(const b2FrictionJointDef* def);
- void InitVelocityConstraints(const b2SolverData& data);
- void SolveVelocityConstraints(const b2SolverData& data);
- bool SolvePositionConstraints(const b2SolverData& data);
- b2Vec2 m_localAnchorA;
- b2Vec2 m_localAnchorB;
-
- b2Vec2 m_linearImpulse;
- float32 m_angularImpulse;
- float32 m_maxForce;
- float32 m_maxTorque;
-
- int32 m_indexA;
- int32 m_indexB;
- b2Vec2 m_rA;
- b2Vec2 m_rB;
- b2Vec2 m_localCenterA;
- b2Vec2 m_localCenterB;
- float32 m_invMassA;
- float32 m_invMassB;
- float32 m_invIA;
- float32 m_invIB;
- b2Mat22 m_linearMass;
- float32 m_angularMass;
- };
- #endif
|