mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Add Body:getFilterList
--HG-- branch : box2d-update
This commit is contained in:
@@ -394,6 +394,21 @@ namespace box2d
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
int Body::getFixtureList(lua_State * L) const
|
||||
{
|
||||
lua_newtable(L);
|
||||
b2Fixture * f = body->GetFixtureList();
|
||||
int i = 1;
|
||||
do {
|
||||
if (!f) break;
|
||||
Fixture * fixture = (Fixture *)Memoizer::find(f);
|
||||
if (!fixture) throw love::Exception("A fixture has escaped Memoizer!");
|
||||
luax_newtype(L, "Fixture", PHYSICS_FIXTURE_T, (void*)fixture);
|
||||
lua_rawseti(L, -1, i);
|
||||
} while ((f = f->GetNext()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
b2Vec2 Body::getVector(lua_State * L)
|
||||
{
|
||||
|
||||
@@ -378,6 +378,13 @@ namespace box2d
|
||||
* Get the World this Body resides in.
|
||||
*/
|
||||
World * getWorld() const;
|
||||
|
||||
/**
|
||||
* Get an array of all the Fixtures attached to this Body.
|
||||
* @return An array of Fixtures.
|
||||
**/
|
||||
int getFixtureList(lua_State * L) const;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
||||
@@ -499,6 +499,13 @@ namespace box2d
|
||||
luax_pushboolean(L, b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Body_getFixtureList(lua_State * L)
|
||||
{
|
||||
Body * t = luax_checkbody(L, 1);
|
||||
lua_remove(L, 1);
|
||||
return t->getFixtureList(L);
|
||||
}
|
||||
|
||||
int w_Body_destroy(lua_State * L)
|
||||
{
|
||||
@@ -561,6 +568,7 @@ namespace box2d
|
||||
{ "setAwake", w_Body_setAwake },
|
||||
{ "setFixedRotation", w_Body_setFixedRotation },
|
||||
{ "isFixedRotation", w_Body_isFixedRotation },
|
||||
{ "getFixtureList", w_Body_getFixtureList },
|
||||
{ "destroy", w_Body_destroy },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace box2d
|
||||
int w_Body_setAwake(lua_State * L);
|
||||
int w_Body_setFixedRotation(lua_State * L);
|
||||
int w_Body_isFixedRotation(lua_State * L);
|
||||
int w_Body_getFixtureList(lua_State * L);
|
||||
int w_Body_destroy(lua_State * L);
|
||||
int luaopen_body(lua_State * L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user