summaryrefslogtreecommitdiff
path: root/src/ode/geom.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-05-10 22:00:11 -0500
committersanine <sanine.not@pm.me>2023-05-10 22:00:11 -0500
commitf5b103de5b2b48433ce2895a1a73df40c4e86bf8 (patch)
tree4e049a26fb3ae35d1cd331918f37d49f961f6b54 /src/ode/geom.c
parentab3005ffd6999885deb96b476d4620eb5d0135a8 (diff)
add ability to convert dContactGeom to table
Diffstat (limited to 'src/ode/geom.c')
-rw-r--r--src/ode/geom.c39
1 files changed, 39 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);