mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Add EdgeShape:set/getNext/PreviousVertex. ChainShape:setNext/PreviousVertex can now take no arguments to disable ghost vertices.
Resolves issue #1191.
This commit is contained in:
@@ -37,18 +37,28 @@ ChainShape *luax_checkchainshape(lua_State *L, int idx)
|
||||
int w_ChainShape_setNextVertex(lua_State *L)
|
||||
{
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
luax_catchexcept(L, [&](){ c->setNextVertex(x, y); });
|
||||
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); });
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ChainShape_setPreviousVertex(lua_State *L)
|
||||
{
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
luax_catchexcept(L, [&](){ c->setPreviousVertex(x, y); });
|
||||
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); });
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -85,12 +95,11 @@ int w_ChainShape_getPoint(lua_State *L)
|
||||
int w_ChainShape_getNextVertex(lua_State *L)
|
||||
{
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
if (c->hasNextVertex())
|
||||
float x, y;
|
||||
if (c->getNextVertex(x, y))
|
||||
{
|
||||
b2Vec2 v;
|
||||
luax_catchexcept(L, [&](){ v = c->getNextVertex(); });
|
||||
lua_pushnumber(L, v.x);
|
||||
lua_pushnumber(L, v.y);
|
||||
lua_pushnumber(L, x);
|
||||
lua_pushnumber(L, y);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
@@ -99,12 +108,11 @@ int w_ChainShape_getNextVertex(lua_State *L)
|
||||
int w_ChainShape_getPreviousVertex(lua_State *L)
|
||||
{
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
if (c->hasPreviousVertex())
|
||||
float x, y;
|
||||
if (c->getPreviousVertex(x, y))
|
||||
{
|
||||
b2Vec2 v;
|
||||
luax_catchexcept(L, [&](){ v = c->getPreviousVertex(); });
|
||||
lua_pushnumber(L, v.x);
|
||||
lua_pushnumber(L, v.y);
|
||||
lua_pushnumber(L, x);
|
||||
lua_pushnumber(L, y);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user