Implmented a few 'missing methods' in love.physics.

This commit is contained in:
rude
2010-01-31 14:24:22 +01:00
parent c269430981
commit 67e10b64f9
8 changed files with 75 additions and 1 deletions
+17 -1
View File
@@ -31,11 +31,12 @@ namespace physics
namespace box2d
{
CircleShape::CircleShape(Body * body, b2CircleDef * def)
: Shape(body), radius(def->radius)
: Shape(body)
{
def->localPosition = body->world->scaleDown(def->localPosition);
def->radius = body->world->scaleDown(def->radius);
radius = def->radius;
this->localPosition = def->localPosition;
shape = body->body->CreateShape(def);
shape->SetUserData((void*)data);
}
@@ -49,6 +50,21 @@ namespace box2d
return body->world->scaleUp(radius);
}
void CircleShape::getLocalCenter(float & x, float & y) const
{
x = localPosition.x;
y = localPosition.y;
body->world->scaleUp(x, y);
}
void CircleShape::getWorldCenter(float & x, float & y) const
{
b2Vec2 worldCenter = body->body->GetWorldPoint(localPosition);
worldCenter = body->world->scaleUp(worldCenter);
x = worldCenter.x;
y = worldCenter.y;
}
} // box2d
} // physics
} // love