mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
Stop Body:getWorldPoints from overflowing the lua stack
This commit is contained in:
@@ -316,9 +316,14 @@ namespace box2d
|
|||||||
|
|
||||||
for (int i = 0;i<vcount;i++)
|
for (int i = 0;i<vcount;i++)
|
||||||
{
|
{
|
||||||
float x = (float)lua_tonumber(L, i*2+1);
|
float x = (float)lua_tonumber(L, 1);
|
||||||
float y = (float)lua_tonumber(L, i*2+2);
|
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))));
|
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.x);
|
||||||
lua_pushnumber(L, point.y);
|
lua_pushnumber(L, point.y);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user