|
@@ -37,28 +37,18 @@ ChainShape *luax_checkchainshape(lua_State *L, int idx)
|
|
|
int w_ChainShape_setNextVertex(lua_State *L)
|
|
|
{
|
|
|
ChainShape *c = luax_checkchainshape(L, 1);
|
|
|
- if (lua_isnoneornil(L, 2))
|
|
|
- c->setNextVertex();
|
|
|
- else
|
|
|
- {
|
|
|
- float x = (float)luaL_checknumber(L, 2);
|
|
|
- float y = (float)luaL_checknumber(L, 3);
|
|
|
- luax_catchexcept(L, [&](){ c->setNextVertex(x, y); });
|
|
|
- }
|
|
|
+ float x = (float)luaL_checknumber(L, 2);
|
|
|
+ float y = (float)luaL_checknumber(L, 3);
|
|
|
+ luax_catchexcept(L, [&](){ c->setNextVertex(x, y); });
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int w_ChainShape_setPreviousVertex(lua_State *L)
|
|
|
{
|
|
|
ChainShape *c = luax_checkchainshape(L, 1);
|
|
|
- if (lua_isnoneornil(L, 2))
|
|
|
- c->setPreviousVertex();
|
|
|
- else
|
|
|
- {
|
|
|
- float x = (float)luaL_checknumber(L, 2);
|
|
|
- float y = (float)luaL_checknumber(L, 3);
|
|
|
- luax_catchexcept(L, [&](){ c->setPreviousVertex(x, y); });
|
|
|
- }
|
|
|
+ float x = (float)luaL_checknumber(L, 2);
|
|
|
+ float y = (float)luaL_checknumber(L, 3);
|
|
|
+ luax_catchexcept(L, [&](){ c->setPreviousVertex(x, y); });
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -95,27 +85,19 @@ int w_ChainShape_getPoint(lua_State *L)
|
|
|
int w_ChainShape_getNextVertex(lua_State *L)
|
|
|
{
|
|
|
ChainShape *c = luax_checkchainshape(L, 1);
|
|
|
- float x, y;
|
|
|
- if (c->getNextVertex(x, y))
|
|
|
- {
|
|
|
- lua_pushnumber(L, x);
|
|
|
- lua_pushnumber(L, y);
|
|
|
- return 2;
|
|
|
- }
|
|
|
- return 0;
|
|
|
+ b2Vec2 v = c->getNextVertex();
|
|
|
+ lua_pushnumber(L, v.x);
|
|
|
+ lua_pushnumber(L, v.y);
|
|
|
+ return 2;
|
|
|
}
|
|
|
|
|
|
int w_ChainShape_getPreviousVertex(lua_State *L)
|
|
|
{
|
|
|
ChainShape *c = luax_checkchainshape(L, 1);
|
|
|
- float x, y;
|
|
|
- if (c->getPreviousVertex(x, y))
|
|
|
- {
|
|
|
- lua_pushnumber(L, x);
|
|
|
- lua_pushnumber(L, y);
|
|
|
- return 2;
|
|
|
- }
|
|
|
- return 0;
|
|
|
+ b2Vec2 v = c->getPreviousVertex();
|
|
|
+ lua_pushnumber(L, v.x);
|
|
|
+ lua_pushnumber(L, v.y);
|
|
|
+ return 2;
|
|
|
}
|
|
|
|
|
|
int w_ChainShape_getPoints(lua_State *L)
|