Browse Source

Add Contact:getChildren (pull request #15)

Bart van Strien 12 years ago
parent
commit
0a422daa75

+ 6 - 0
src/modules/physics/box2d/Contact.cpp

@@ -126,6 +126,12 @@ void Contact::resetRestitution()
 	contact->ResetRestitution();
 }
 
+void Contact::getChildren(int &childA, int &childB)
+{
+	childA = contact->GetChildIndexA();
+	childB = contact->GetChildIndexB();
+}
+
 } // box2d
 } // physics
 } // love

+ 3 - 0
src/modules/physics/box2d/Contact.h

@@ -136,6 +136,9 @@ public:
 	 **/
 	void resetRestitution();
 
+
+	void getChildren(int &childA, int &childB);
+
 private:
 
 	// The Box2D contact.

+ 11 - 0
src/modules/physics/box2d/wrap_Contact.cpp

@@ -113,6 +113,16 @@ int w_Contact_resetRestitution(lua_State *L)
 	return 0;
 }
 
+int w_Contact_getChildren(lua_State *L)
+{
+	Contact *t = luax_checkcontact(L, 1);
+	int a, b;
+	t->getChildren(a, b);
+	lua_pushnumber(L, a);
+	lua_pushnumber(L, b);
+	return 2;
+}
+
 extern "C" int luaopen_contact(lua_State *L)
 {
 	static const luaL_Reg functions[] =
@@ -128,6 +138,7 @@ extern "C" int luaopen_contact(lua_State *L)
 		{ "setEnabled", w_Contact_setEnabled },
 		{ "resetFriction", w_Contact_resetFriction },
 		{ "resetRestitution", w_Contact_resetRestitution },
+		{ "getChildren", w_Contact_getChildren },
 		{ 0, 0 }
 	};
 

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

@@ -44,6 +44,7 @@ int w_Contact_setRestitution(lua_State *L);
 int w_Contact_setEnabled(lua_State *L);
 int w_Contact_resetFriction(lua_State *L);
 int w_Contact_resetRestitution(lua_State *L);
+int w_Contact_getChildren(lua_State *L);
 extern "C" int luaopen_contact(lua_State *L);
 
 } // box2d