diff options
Diffstat (limited to 'src/ode')
-rw-r--r-- | src/ode/geom.c | 39 | ||||
-rw-r--r-- | src/ode/ode_bindings.h | 1 | ||||
-rw-r--r-- | src/ode/setup.c | 4 |
3 files changed, 44 insertions, 0 deletions
diff --git a/src/ode/geom.c b/src/ode/geom.c index 9700079..31fbdca 100644 --- a/src/ode/geom.c +++ b/src/ode/geom.c @@ -75,6 +75,45 @@ void ode_push_heightfielddata(lua_State *L, dHeightfieldDataID d) } +int ContactGeomTable(lua_State *L) +{ + luaL_checktype(L, 1, LUA_TUSERDATA); + dContactGeom *cgu = lua_touserdata(L, 1); + lua_createtable(L, 0, 5); + int tbl = lua_gettop(L); + + lua_createtable(L, 3, 0); + int pos = lua_gettop(L); + lua_pushnumber(L, cgu->pos[0]); + lua_rawseti(L, pos, 1); + lua_pushnumber(L, cgu->pos[1]); + lua_rawseti(L, pos, 2); + lua_pushnumber(L, cgu->pos[2]); + lua_rawseti(L, pos, 3); + lua_setfield(L, tbl, "pos"); + + lua_createtable(L, 3, 0); + int normal = lua_gettop(L); + lua_pushnumber(L, cgu->normal[0]); + lua_rawseti(L, normal, 1); + lua_pushnumber(L, cgu->normal[1]); + lua_rawseti(L, normal, 2); + lua_pushnumber(L, cgu->normal[2]); + lua_rawseti(L, normal, 3); + lua_setfield(L, tbl, "normal"); + + lua_pushnumber(L, cgu->depth); + lua_setfield(L, tbl, "depth"); + + ode_push_geom(L, cgu->g1); + lua_setfield(L, tbl, "g1"); + ode_push_geom(L, cgu->g2); + lua_setfield(L, tbl, "g2"); + + return 1; +} + + int dGeomDestroy_bind(lua_State *L) { dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname); diff --git a/src/ode/ode_bindings.h b/src/ode/ode_bindings.h index 7d3f518..f58820c 100644 --- a/src/ode/ode_bindings.h +++ b/src/ode/ode_bindings.h @@ -350,6 +350,7 @@ void ode_push_space(lua_State *L, dSpaceID s); X("GeomEnable", dGeomEnable_bind) \ X("GeomDisable", dGeomDisable_bind) \ X("GeomIsEnabled", dGeomIsEnabled_bind) \ + X("ContactGeomTable", ContactGeomTable) \ X("Collide", dCollide_bind) \ X("SpaceCollide", dSpaceCollide_bind) \ X("SpaceCollide2", dSpaceCollide2_bind) \ diff --git a/src/ode/setup.c b/src/ode/setup.c index 3655b1e..4785de2 100644 --- a/src/ode/setup.c +++ b/src/ode/setup.c @@ -58,6 +58,10 @@ void setup_ode(lua_State *L, int honey_tbl) ode_push_space(L, 0); lua_setfield(L, ode_tbl, "Space0"); + /* add null body */ + ode_push_body(L, 0); + lua_setfield(L, ode_tbl, "Body0"); + lua_setfield(L, honey_tbl, "ode"); } |