bounds check ChainShape:getPoint, and make functions that take indices 1-indexed on the Lua end of things

This commit is contained in:
Bill Meltsner
2012-02-04 19:38:11 -05:00
parent 83f7002f67
commit ddb1492c1f
4 changed files with 11 additions and 7 deletions
+2 -2
View File
@@ -268,7 +268,7 @@ namespace box2d
float p2x = Physics::scaleDown((float)luaL_checknumber(L, 3));
float p2y = Physics::scaleDown((float)luaL_checknumber(L, 4));
float maxFraction = (float)luaL_checknumber(L, 5);
int childIndex = (int)luaL_optint(L, 6, 0);
int childIndex = (int)luaL_optint(L, 6, 1) - 1; // Convert from 1-based index
b2RayCastInput input;
input.p1.Set(p1x, p1y);
input.p2.Set(p2x, p2y);
@@ -284,7 +284,7 @@ namespace box2d
int Fixture::getBoundingBox(lua_State * L) const
{
int childIndex = (int)luaL_optint(L, 1, 0);
int childIndex = (int)luaL_optint(L, 1, 1) - 1; // Convert from 1-based index
b2AABB box = fixture->GetAABB(childIndex);
box = Physics::scaleUp(box);
lua_pushnumber(L, box.lowerBound.x);