Commits

Mathieu Capdegelle committed 88e85e4

Add getChildrenIndexes method to Contact.
Useful for chainShape contact callbacks.

  • Participants
  • Parent commits f3e7481

Comments (0)

Files changed (4)

File src/modules/physics/box2d/Contact.cpp

 	return contact != NULL ? true : false;
 }
 
+int Contact::getChildrenIndexes(lua_State *L)
+{
+	love::luax_assert_argc(L, 1, 1);
+	lua_pushnumber(L, contact->GetChildIndexA());
+	lua_pushnumber(L, contact->GetChildIndexB());
+	return 2;
+}
+
 int Contact::getPositions(lua_State *L)
 {
 	love::luax_assert_argc(L, 1, 1);

File src/modules/physics/box2d/Contact.h

 	 **/
 	bool isValid();
 
+    /**
+	 * Gets the children indexes.
+	 * @return the child primitive index for fixture A.
+	 * @return the child primitive index for fixture B.
+	 **/
+	int getChildrenIndexes(lua_State *L);
+
 	/**
 	 * Gets the position of each point of contact.
 	 * @return The position along the x-axis.

File src/modules/physics/box2d/wrap_Contact.cpp

 	return c;
 }
 
+int w_Contact_getChildrenIndexes(lua_State *L)
+{
+	Contact *t = luax_checkcontact(L, 1);
+	return t->getChildrenIndexes(L);
+}
+
 int w_Contact_getPositions(lua_State *L)
 {
 	Contact *t = luax_checkcontact(L, 1);
 {
 	static const luaL_Reg functions[] =
 	{
+		{ "getChildrenIndexes", w_Contact_getChildrenIndexes },
 		{ "getPositions", w_Contact_getPositions },
 		{ "getNormal", w_Contact_getNormal },
 		{ "getFriction", w_Contact_getFriction },

File src/modules/physics/box2d/wrap_Contact.h

 {
 
 Contact *luax_checkcontact(lua_State *L, int idx);
+int w_Contact_getChildrenIndexes(lua_State *L);
 int w_Contact_getPositions(lua_State *L);
 int w_Contact_getNormal(lua_State *L);
 int w_Contact_getFriction(lua_State *L);