Add Body:getFilterList

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-09-24 17:12:45 -04:00
parent 15d2b7c63d
commit 221d9699f6
4 changed files with 31 additions and 0 deletions
+15
View File
@@ -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)
{
+7
View File
@@ -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:
/**
+8
View File
@@ -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 }
};
+1
View File
@@ -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);