mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Fix a lot of scaling issues
--HG-- branch : box2d-update
This commit is contained in:
@@ -176,22 +176,24 @@ namespace box2d
|
||||
|
||||
void Body::applyAngularImpulse(float impulse)
|
||||
{
|
||||
body->ApplyAngularImpulse(Physics::scaleDown(impulse));
|
||||
// Angular impulse is in kg*m^2/s, meaning it needs to be scaled twice
|
||||
body->ApplyAngularImpulse(Physics::scaleDown(Physics::scaleDown(impulse)));
|
||||
}
|
||||
|
||||
void Body::applyTorque(float t)
|
||||
{
|
||||
body->ApplyTorque(t);
|
||||
// Torque is in N*m, or kg*m^2/s^2, meaning it also needs to be scaled twice
|
||||
body->ApplyTorque(Physics::scaleDown(Physics::scaleDown(t)));
|
||||
}
|
||||
|
||||
void Body::applyForce(float fx, float fy, float rx, float ry)
|
||||
{
|
||||
body->ApplyForce(b2Vec2(fx, fy), Physics::scaleDown(b2Vec2(rx, ry)));
|
||||
body->ApplyForce(Physics::scaleDown(b2Vec2(fx, fy)), Physics::scaleDown(b2Vec2(rx, ry)));
|
||||
}
|
||||
|
||||
void Body::applyForce(float fx, float fy)
|
||||
{
|
||||
body->ApplyForce(b2Vec2(fx, fy), body->GetWorldCenter());
|
||||
body->ApplyForce(Physics::scaleDown(b2Vec2(fx, fy)), body->GetWorldCenter());
|
||||
}
|
||||
|
||||
void Body::setX(float x)
|
||||
|
||||
@@ -50,22 +50,22 @@ namespace box2d
|
||||
|
||||
void FrictionJoint::setMaxForce(float force)
|
||||
{
|
||||
joint->SetMaxForce(force);
|
||||
joint->SetMaxForce(Physics::scaleDown(force));
|
||||
}
|
||||
|
||||
float FrictionJoint::getMaxForce() const
|
||||
{
|
||||
return joint->GetMaxForce();
|
||||
return Physics::scaleUp(joint->GetMaxForce());
|
||||
}
|
||||
|
||||
void FrictionJoint::setMaxTorque(float torque)
|
||||
{
|
||||
joint->SetMaxTorque(torque);
|
||||
joint->SetMaxTorque(Physics::scaleDown(Physics::scaleDown(torque)));
|
||||
}
|
||||
|
||||
float FrictionJoint::getMaxTorque() const
|
||||
{
|
||||
return joint->GetMaxTorque();
|
||||
return Physics::scaleUp(Physics::scaleUp(joint->GetMaxTorque()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace box2d
|
||||
int Joint::getReactionForce(lua_State * L)
|
||||
{
|
||||
float dt = (float)luaL_checknumber(L, 2);
|
||||
b2Vec2 v = joint->GetReactionForce(dt);
|
||||
b2Vec2 v = Physics::scaleUp(joint->GetReactionForce(dt));
|
||||
lua_pushnumber(L, v.x);
|
||||
lua_pushnumber(L, v.y);
|
||||
return 2;
|
||||
@@ -106,7 +106,7 @@ namespace box2d
|
||||
|
||||
float Joint::getReactionTorque(float dt)
|
||||
{
|
||||
return joint->GetReactionTorque(dt);
|
||||
return Physics::scaleUp(Physics::scaleUp(joint->GetReactionTorque(dt)));
|
||||
}
|
||||
|
||||
b2Joint * Joint::createJoint(b2JointDef * def)
|
||||
|
||||
@@ -63,12 +63,12 @@ namespace box2d
|
||||
|
||||
void MouseJoint::setMaxForce(float force)
|
||||
{
|
||||
joint->SetMaxForce(force);
|
||||
joint->SetMaxForce(Physics::scaleDown(force));
|
||||
}
|
||||
|
||||
float MouseJoint::getMaxForce() const
|
||||
{
|
||||
return joint->GetMaxForce();
|
||||
return Physics::scaleUp(joint->GetMaxForce());
|
||||
}
|
||||
|
||||
void MouseJoint::setFrequency(float hz)
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace box2d
|
||||
|
||||
void RevoluteJoint::setMaxMotorTorque(float torque)
|
||||
{
|
||||
joint->SetMaxMotorTorque(torque);
|
||||
joint->SetMaxMotorTorque(Physics::scaleDown(Physics::scaleDown(torque)));
|
||||
}
|
||||
|
||||
void RevoluteJoint::setMotorSpeed(float speed)
|
||||
@@ -85,7 +85,7 @@ namespace box2d
|
||||
|
||||
float RevoluteJoint::getMotorTorque(float inv_dt) const
|
||||
{
|
||||
return joint->GetMotorTorque(inv_dt);
|
||||
return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(inv_dt)));
|
||||
}
|
||||
|
||||
void RevoluteJoint::enableLimit(bool limit)
|
||||
|
||||
@@ -76,12 +76,12 @@ namespace box2d
|
||||
void setMaxMotorTorque(float torque);
|
||||
|
||||
/**
|
||||
* Sets the motor speed in degrees per second.
|
||||
* Sets the motor speed in radians per second.
|
||||
**/
|
||||
void setMotorSpeed(float speed);
|
||||
|
||||
/**
|
||||
* Gets the motor speed in degrees per second.
|
||||
* Gets the motor speed in radians per second.
|
||||
**/
|
||||
float getMotorSpeed() const;
|
||||
|
||||
|
||||
@@ -70,47 +70,47 @@ namespace box2d
|
||||
|
||||
void WheelJoint::setMotorSpeed(float speed)
|
||||
{
|
||||
joint->SetMotorSpeed(Physics::scaleDown(speed));
|
||||
joint->SetMotorSpeed(speed);
|
||||
}
|
||||
|
||||
float WheelJoint::getMotorSpeed() const
|
||||
{
|
||||
return Physics::scaleUp(joint->GetMotorSpeed());
|
||||
return joint->GetMotorSpeed();
|
||||
}
|
||||
|
||||
void WheelJoint::setMaxMotorTorque(float torque)
|
||||
{
|
||||
joint->SetMaxMotorTorque(Physics::scaleDown(torque));
|
||||
joint->SetMaxMotorTorque(Physics::scaleDown(Physics::scaleDown(torque)));
|
||||
}
|
||||
|
||||
float WheelJoint::getMaxMotorTorque() const
|
||||
{
|
||||
return Physics::scaleUp(joint->GetMaxMotorTorque());
|
||||
return Physics::scaleUp(Physics::scaleUp(joint->GetMaxMotorTorque()));
|
||||
}
|
||||
|
||||
float WheelJoint::getMotorTorque(float inv_dt) const
|
||||
{
|
||||
return Physics::scaleUp(joint->GetMotorTorque(inv_dt));
|
||||
return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(inv_dt)));
|
||||
}
|
||||
|
||||
void WheelJoint::setSpringFrequencyHz(float hz)
|
||||
{
|
||||
joint->SetSpringFrequencyHz(Physics::scaleDown(hz));
|
||||
joint->SetSpringFrequencyHz(hz);
|
||||
}
|
||||
|
||||
float WheelJoint::getSpringFrequencyHz() const
|
||||
{
|
||||
return Physics::scaleUp(joint->GetSpringFrequencyHz());
|
||||
return joint->GetSpringFrequencyHz();
|
||||
}
|
||||
|
||||
void WheelJoint::setSpringDampingRatio(float ratio)
|
||||
{
|
||||
joint->SetSpringDampingRatio(Physics::scaleDown(ratio));
|
||||
joint->SetSpringDampingRatio(ratio);
|
||||
}
|
||||
|
||||
float WheelJoint::getSpringDampingRatio() const
|
||||
{
|
||||
return Physics::scaleUp(joint->GetSpringDampingRatio());
|
||||
return joint->GetSpringDampingRatio();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user