From 0a422daa759f81421507810e2850b89fb4b1e0b1 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Fri, 10 May 2013 17:40:04 +0200 Subject: [PATCH] Add Contact:getChildren (pull request #15) --- src/modules/physics/box2d/Contact.cpp | 6 ++++++ src/modules/physics/box2d/Contact.h | 3 +++ src/modules/physics/box2d/wrap_Contact.cpp | 11 +++++++++++ src/modules/physics/box2d/wrap_Contact.h | 1 + 4 files changed, 21 insertions(+) diff --git a/src/modules/physics/box2d/Contact.cpp b/src/modules/physics/box2d/Contact.cpp index b5fc966e9..819a11d10 100644 --- a/src/modules/physics/box2d/Contact.cpp +++ b/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 diff --git a/src/modules/physics/box2d/Contact.h b/src/modules/physics/box2d/Contact.h index 0c1a92440..929627d28 100644 --- a/src/modules/physics/box2d/Contact.h +++ b/src/modules/physics/box2d/Contact.h @@ -136,6 +136,9 @@ public: **/ void resetRestitution(); + + void getChildren(int &childA, int &childB); + private: // The Box2D contact. diff --git a/src/modules/physics/box2d/wrap_Contact.cpp b/src/modules/physics/box2d/wrap_Contact.cpp index 5c8cd1eab..ce2fd0b0b 100644 --- a/src/modules/physics/box2d/wrap_Contact.cpp +++ b/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 } }; diff --git a/src/modules/physics/box2d/wrap_Contact.h b/src/modules/physics/box2d/wrap_Contact.h index 080622242..448456135 100644 --- a/src/modules/physics/box2d/wrap_Contact.h +++ b/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