mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Implmented a few 'missing methods' in love.physics.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user