mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Updated to Box2D 2.2, added new joints, some other updates to match the API changes (still plenty more to go though)
--HG-- branch : box2d-update
This commit is contained in:
Regular → Executable
+30
-25
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -27,7 +27,6 @@
|
||||
/// can violate the constraint slightly. The joint translation is zero
|
||||
/// when the local anchor points coincide in world space. Using local
|
||||
/// anchors and a local axis helps when saving and loading a game.
|
||||
/// @warning at least one body should by dynamic with a non-fixed rotation.
|
||||
struct b2PrismaticJointDef : public b2JointDef
|
||||
{
|
||||
b2PrismaticJointDef()
|
||||
@@ -35,7 +34,7 @@ struct b2PrismaticJointDef : public b2JointDef
|
||||
type = e_prismaticJoint;
|
||||
localAnchorA.SetZero();
|
||||
localAnchorB.SetZero();
|
||||
localAxis1.Set(1.0f, 0.0f);
|
||||
localAxisA.Set(1.0f, 0.0f);
|
||||
referenceAngle = 0.0f;
|
||||
enableLimit = false;
|
||||
lowerTranslation = 0.0f;
|
||||
@@ -56,9 +55,9 @@ struct b2PrismaticJointDef : public b2JointDef
|
||||
b2Vec2 localAnchorB;
|
||||
|
||||
/// The local translation axis in body1.
|
||||
b2Vec2 localAxis1;
|
||||
b2Vec2 localAxisA;
|
||||
|
||||
/// The constrained angle between the bodies: body2_angle - body1_angle.
|
||||
/// The constrained angle between the bodies: bodyB_angle - bodyA_angle.
|
||||
float32 referenceAngle;
|
||||
|
||||
/// Enable/disable the joint limit.
|
||||
@@ -81,7 +80,7 @@ struct b2PrismaticJointDef : public b2JointDef
|
||||
};
|
||||
|
||||
/// A prismatic joint. This joint provides one degree of freedom: translation
|
||||
/// along an axis fixed in body1. Relative rotation is prevented. You can
|
||||
/// along an axis fixed in bodyA. Relative rotation is prevented. You can
|
||||
/// use a joint limit to restrict the range of motion and a joint motor to
|
||||
/// drive the motion or to model joint friction.
|
||||
class b2PrismaticJoint : public b2Joint
|
||||
@@ -129,42 +128,48 @@ public:
|
||||
/// Set the maximum motor force, usually in N.
|
||||
void SetMaxMotorForce(float32 force);
|
||||
|
||||
/// Get the current motor force, usually in N.
|
||||
float32 GetMotorForce() const;
|
||||
/// Get the current motor force given the inverse time step, usually in N.
|
||||
float32 GetMotorForce(float32 inv_dt) const;
|
||||
|
||||
protected:
|
||||
friend class b2Joint;
|
||||
friend class b2GearJoint;
|
||||
b2PrismaticJoint(const b2PrismaticJointDef* def);
|
||||
|
||||
void InitVelocityConstraints(const b2TimeStep& step);
|
||||
void SolveVelocityConstraints(const b2TimeStep& step);
|
||||
bool SolvePositionConstraints(float32 baumgarte);
|
||||
void InitVelocityConstraints(const b2SolverData& data);
|
||||
void SolveVelocityConstraints(const b2SolverData& data);
|
||||
bool SolvePositionConstraints(const b2SolverData& data);
|
||||
|
||||
b2Vec2 m_localAnchor1;
|
||||
b2Vec2 m_localAnchor2;
|
||||
b2Vec2 m_localXAxis1;
|
||||
b2Vec2 m_localYAxis1;
|
||||
// Solver shared
|
||||
b2Vec2 m_localAnchorA;
|
||||
b2Vec2 m_localAnchorB;
|
||||
b2Vec2 m_localXAxisA;
|
||||
b2Vec2 m_localYAxisA;
|
||||
float32 m_refAngle;
|
||||
|
||||
b2Vec2 m_axis, m_perp;
|
||||
float32 m_s1, m_s2;
|
||||
float32 m_a1, m_a2;
|
||||
|
||||
b2Mat33 m_K;
|
||||
b2Vec3 m_impulse;
|
||||
|
||||
float32 m_motorMass; // effective mass for motor/limit translational constraint.
|
||||
float32 m_motorImpulse;
|
||||
|
||||
float32 m_lowerTranslation;
|
||||
float32 m_upperTranslation;
|
||||
float32 m_maxMotorForce;
|
||||
float32 m_motorSpeed;
|
||||
|
||||
bool m_enableLimit;
|
||||
bool m_enableMotor;
|
||||
b2LimitState m_limitState;
|
||||
|
||||
// Solver temp
|
||||
int32 m_indexA;
|
||||
int32 m_indexB;
|
||||
b2Vec2 m_localCenterA;
|
||||
b2Vec2 m_localCenterB;
|
||||
float32 m_invMassA;
|
||||
float32 m_invMassB;
|
||||
float32 m_invIA;
|
||||
float32 m_invIB;
|
||||
b2Vec2 m_axis, m_perp;
|
||||
float32 m_s1, m_s2;
|
||||
float32 m_a1, m_a2;
|
||||
b2Mat33 m_K;
|
||||
float32 m_motorMass;
|
||||
};
|
||||
|
||||
inline float32 b2PrismaticJoint::GetMotorSpeed() const
|
||||
|
||||
Reference in New Issue
Block a user