From f5b103de5b2b48433ce2895a1a73df40c4e86bf8 Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 10 May 2023 22:00:11 -0500 Subject: add ability to convert dContactGeom to table --- src/ode/geom.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/ode/geom.c') 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); -- cgit v1.2.1