123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #ifndef B2_WELD_JOINT_H
- #define B2_WELD_JOINT_H
- #include <Box2D/Dynamics/Joints/b2Joint.h>
- struct b2WeldJointDef : public b2JointDef
- {
- b2WeldJointDef()
- {
- type = e_weldJoint;
- localAnchorA.Set(0.0f, 0.0f);
- localAnchorB.Set(0.0f, 0.0f);
- referenceAngle = 0.0f;
- frequencyHz = 0.0f;
- dampingRatio = 0.0f;
- }
-
-
- void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
-
- b2Vec2 localAnchorA;
-
- b2Vec2 localAnchorB;
-
- float32 referenceAngle;
-
-
-
- float32 frequencyHz;
-
- float32 dampingRatio;
- };
- class b2WeldJoint : 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; }
-
- float32 GetReferenceAngle() const { return m_referenceAngle; }
-
- void SetFrequency(float32 hz) { m_frequencyHz = hz; }
- float32 GetFrequency() const { return m_frequencyHz; }
-
- void SetDampingRatio(float32 ratio) { m_dampingRatio = ratio; }
- float32 GetDampingRatio() const { return m_dampingRatio; }
-
- void Dump();
- protected:
- friend class b2Joint;
- b2WeldJoint(const b2WeldJointDef* def);
- void InitVelocityConstraints(const b2SolverData& data);
- void SolveVelocityConstraints(const b2SolverData& data);
- bool SolvePositionConstraints(const b2SolverData& data);
- float32 m_frequencyHz;
- float32 m_dampingRatio;
- float32 m_bias;
-
- b2Vec2 m_localAnchorA;
- b2Vec2 m_localAnchorB;
- float32 m_referenceAngle;
- float32 m_gamma;
- b2Vec3 m_impulse;
-
- 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;
- b2Mat33 m_mass;
- };
- #endif
|