Browse Source

Update ChainShape API

--HG--
branch : box2d-update
Bill Meltsner 14 years ago
parent
commit
6e7d83d7ea

+ 9 - 3
src/modules/physics/box2d/ChainShape.cpp

@@ -71,23 +71,29 @@ namespace box2d
 		return new EdgeShape(&e);
 		return new EdgeShape(&e);
 	}
 	}
 	
 	
+	int ChainShape::getChildCount() const
+	{
+		b2ChainShape * c = (b2ChainShape *)shape;
+		return c->GetChildCount();
+	}
+	
 	int ChainShape::getVertexCount() const
 	int ChainShape::getVertexCount() const
 	{
 	{
 		b2ChainShape * c = (b2ChainShape *)shape;
 		b2ChainShape * c = (b2ChainShape *)shape;
-		return c->GetVertexCount();
+		return c->m_count;
 	}
 	}
 	
 	
 	b2Vec2 ChainShape::getVertex(int index) const
 	b2Vec2 ChainShape::getVertex(int index) const
 	{
 	{
 		b2ChainShape * c = (b2ChainShape *)shape;
 		b2ChainShape * c = (b2ChainShape *)shape;
-		const b2Vec2 & v = c->GetVertex(index);
+		const b2Vec2 & v = c->m_vertices[index];
 		return Physics::scaleUp(v);
 		return Physics::scaleUp(v);
 	}
 	}
 	
 	
 	const b2Vec2 * ChainShape::getVertices() const
 	const b2Vec2 * ChainShape::getVertices() const
 	{
 	{
 		b2ChainShape * c = (b2ChainShape *)shape;
 		b2ChainShape * c = (b2ChainShape *)shape;
-		return c->GetVertices();
+		return c->m_vertices;
 	}
 	}
 
 
 } // box2d
 } // box2d

+ 5 - 0
src/modules/physics/box2d/ChainShape.h

@@ -66,6 +66,11 @@ namespace box2d
 		**/
 		**/
 		void setPrevVertex(float x, float y);
 		void setPrevVertex(float x, float y);
 		
 		
+		/**
+		* Gets the number of children shapes.
+		**/
+		int getChildCount() const;
+		
 		/**
 		/**
 		* Returns a child EdgeShape.
 		* Returns a child EdgeShape.
 		* @param index The index of the child shape.
 		* @param index The index of the child shape.

+ 8 - 0
src/modules/physics/box2d/wrap_ChainShape.cpp

@@ -50,6 +50,13 @@ namespace box2d
 		return 0;
 		return 0;
 	}
 	}
 	
 	
+	int w_ChainShape_getChildCount(lua_State * L)
+	{
+		ChainShape * c = luax_checkchainshape(L, 1);
+		lua_pushinteger(L, c->getChildCount());
+		return 1;
+	}
+	
 	int w_ChainShape_getChildEdge(lua_State * L)
 	int w_ChainShape_getChildEdge(lua_State * L)
 	{
 	{
 		ChainShape * c = luax_checkchainshape(L, 1);
 		ChainShape * c = luax_checkchainshape(L, 1);
@@ -96,6 +103,7 @@ namespace box2d
 	static const luaL_Reg functions[] = {
 	static const luaL_Reg functions[] = {
 		{ "setNextVertex", w_ChainShape_setNextVertex },
 		{ "setNextVertex", w_ChainShape_setNextVertex },
 		{ "setPrevVertex", w_ChainShape_setPrevVertex },
 		{ "setPrevVertex", w_ChainShape_setPrevVertex },
+		{ "getChildCount", w_ChainShape_getChildCount },
 		{ "getChildEdge", w_ChainShape_getChildEdge },
 		{ "getChildEdge", w_ChainShape_getChildEdge },
 		{ "getVertexCount", w_ChainShape_getVertexCount },
 		{ "getVertexCount", w_ChainShape_getVertexCount },
 		{ "getVertex", w_ChainShape_getVertex },
 		{ "getVertex", w_ChainShape_getVertex },

+ 1 - 0
src/modules/physics/box2d/wrap_ChainShape.h

@@ -36,6 +36,7 @@ namespace box2d
 	
 	
 	int w_ChainShape_setNextVertex(lua_State * L);
 	int w_ChainShape_setNextVertex(lua_State * L);
 	int w_ChainShape_setPrevVertex(lua_State * L);
 	int w_ChainShape_setPrevVertex(lua_State * L);
+	int w_ChainShape_getChildCount(lua_State * L);
 	int w_ChainShape_getChildEdge(lua_State * L);
 	int w_ChainShape_getChildEdge(lua_State * L);
 	int w_ChainShape_getVertexCount(lua_State * L);
 	int w_ChainShape_getVertexCount(lua_State * L);
 	int w_ChainShape_getVertex(lua_State * L);
 	int w_ChainShape_getVertex(lua_State * L);