Stop Body:getWorldPoints from overflowing the lua stack

This commit is contained in:
Bart van Strien
2012-01-15 11:09:38 +01:00
parent e57e9efe0e
commit f6e9f4cac7
+7 -2
View File
@@ -316,9 +316,14 @@ namespace box2d
for (int i = 0;i<vcount;i++)
{
float x = (float)lua_tonumber(L, i*2+1);
float y = (float)lua_tonumber(L, i*2+2);
float x = (float)lua_tonumber(L, 1);
float y = (float)lua_tonumber(L, 2);
// Remove them, so we don't run out of stack space
lua_remove(L, 1);
lua_remove(L, 1);
// Time for scaling
b2Vec2 point = Physics::scaleUp(body->GetWorldPoint(Physics::scaleDown(b2Vec2(x, y))));
// And then we push the result
lua_pushnumber(L, point.x);
lua_pushnumber(L, point.y);
}