diff --git a/external/b2Separator-cpp/b2Separator.cpp b/external/b2Separator-cpp/b2Separator.cpp index 10188a874..82594dd79 100644 --- a/external/b2Separator-cpp/b2Separator.cpp +++ b/external/b2Separator-cpp/b2Separator.cpp @@ -36,7 +36,9 @@ bool b2Separator::SeparateAndCreateFixtures( b2Body *body, FixtureCreator_t fixture_creator, b2Vec2Vector &vertices_vec, b2Vec2 &translate, - b2Vec2 &scale ) + b2Vec2 &scale, + bool needHull + ) { bool vertices_added = false; @@ -97,7 +99,7 @@ bool b2Separator::SeparateAndCreateFixtures( b2Body *body, DEBUG_PRINT( "*** Fixture %03d : Vertex %03d : x, y: %f, %f\n", i, j, v.x, v.y ); } - bool ok = polyShape.Set( &( vertices[ 0 ] ), (int)m ); + bool ok = polyShape.Set( &( vertices[ 0 ] ), (int)m, needHull); if( ! ok ) { // Set() failed. Skip this polygon. diff --git a/external/b2Separator-cpp/b2Separator.h b/external/b2Separator-cpp/b2Separator.h index 0ae551620..7a3849506 100644 --- a/external/b2Separator-cpp/b2Separator.h +++ b/external/b2Separator-cpp/b2Separator.h @@ -46,7 +46,7 @@ class b2Separator { FixtureCreator_t fixture_creator, b2Vec2Vector &vertices_vec, b2Vec2 &translate, - b2Vec2 &scale ); + b2Vec2 &scale, bool needHull); /** * Checks whether the vertices in verticesVec can be properly distributed into the new fixtures (more specifically, it makes sure there are no overlapping segments and the vertices are in clockwise order). diff --git a/librtt/Rtt_LuaLibPhysics.cpp b/librtt/Rtt_LuaLibPhysics.cpp index 46dde3db8..bd5f1ec51 100644 --- a/librtt/Rtt_LuaLibPhysics.cpp +++ b/librtt/Rtt_LuaLibPhysics.cpp @@ -1752,6 +1752,12 @@ InitializeFixtureUsing_Outline( lua_State *L, b2Body *body, float meter_per_pixels_scale ) { + + lua_getfield(L, lua_arg_index, "needHull"); + bool needHull = (lua_isboolean(L, -1) && + lua_toboolean(L, -1)); + lua_pop(L, 1); + lua_getfield( L, lua_arg_index, "outline" ); if( lua_istable( L, -1 ) ) { @@ -1870,7 +1876,7 @@ InitializeFixtureUsing_Outline( lua_State *L, _FixtureCreator, vertexList, translate, - scale ); + scale, needHull); if( ! ok ) { DEBUG_PRINT( "SeparateAndCreateFixtures() failed to add any fixtures." ); @@ -2099,6 +2105,11 @@ InitializeFixtureUsing_Shape( lua_State *L, b2Body *body, float meter_per_pixels_scale ) { + lua_getfield(L, lua_arg_index, "needHull"); + bool needHull = (lua_isboolean(L, -1) && + lua_toboolean(L, -1)); + lua_pop(L, 1); + lua_getfield( L, lua_arg_index, "shape" ); if ( lua_istable( L, -1 ) ) { @@ -2128,7 +2139,7 @@ InitializeFixtureUsing_Shape( lua_State *L, b2PolygonShape polygonDef; bool ok = polygonDef.Set( &vertexList[ 0 ], - (int)vertexList.size() ); + (int)vertexList.size(), needHull); if( ok ) { InitializeFixtureFromLua( L,