mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Added backwards compatible frequency/dampingRatio functions. Added new stiffness/damping functions.
This commit is contained in:
@@ -66,9 +66,37 @@ void WeldJoint::init(b2WeldJointDef &def, Body *body1, Body *body2, float xA, fl
|
||||
def.collideConnected = collideConnected;
|
||||
}
|
||||
|
||||
void WeldJoint::setStiffness(float hz)
|
||||
void WeldJoint::setFrequency(float hz)
|
||||
{
|
||||
joint->SetStiffness(hz);
|
||||
float stiffness, damping;
|
||||
b2LinearStiffness(stiffness, damping, hz, getDampingRatio(), joint->GetBodyA(), joint->GetBodyB());
|
||||
joint->SetStiffness(stiffness);
|
||||
}
|
||||
|
||||
float WeldJoint::getFrequency() const
|
||||
{
|
||||
float frequency, ratio;
|
||||
Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB());
|
||||
return frequency;
|
||||
}
|
||||
|
||||
void WeldJoint::setDampingRatio(float ratio)
|
||||
{
|
||||
float stiffness, damping;
|
||||
b2LinearStiffness(stiffness, damping, getFrequency(), ratio, joint->GetBodyA(), joint->GetBodyB());
|
||||
joint->SetDamping(damping);
|
||||
}
|
||||
|
||||
float WeldJoint::getDampingRatio() const
|
||||
{
|
||||
float frequency, ratio;
|
||||
Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB());
|
||||
return ratio;
|
||||
}
|
||||
|
||||
void WeldJoint::setStiffness(float k)
|
||||
{
|
||||
joint->SetStiffness(k);
|
||||
}
|
||||
|
||||
float WeldJoint::getStiffness() const
|
||||
|
||||
Reference in New Issue
Block a user