Browse Source

Catch possible Box2D exception in Fixture:getBoundingBox() (fixes #1196)

Bart van Strien 9 years ago
parent
commit
0ce44e465d
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/modules/physics/box2d/Fixture.cpp

+ 2 - 1
src/modules/physics/box2d/Fixture.cpp

@@ -284,7 +284,8 @@ int Fixture::rayCast(lua_State *L) const
 int Fixture::getBoundingBox(lua_State *L) const
 {
 	int childIndex = (int) luaL_optnumber(L, 1, 1) - 1; // Convert from 1-based index
-	b2AABB box = fixture->GetAABB(childIndex);
+	b2AABB box;
+	luax_catchexcept(L, [&]() { box = fixture->GetAABB(childIndex); });
 	box = Physics::scaleUp(box);
 	lua_pushnumber(L, box.lowerBound.x);
 	lua_pushnumber(L, box.lowerBound.y);