diff options
author | sanine <sanine.not@pm.me> | 2023-05-10 22:00:11 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-05-10 22:00:11 -0500 |
commit | f5b103de5b2b48433ce2895a1a73df40c4e86bf8 (patch) | |
tree | 4e049a26fb3ae35d1cd331918f37d49f961f6b54 | |
parent | ab3005ffd6999885deb96b476d4620eb5d0135a8 (diff) |
add ability to convert dContactGeom to table
-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 | ||||
-rw-r--r-- | src/opengl/texture.c | 10 |
4 files changed, 54 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"); } diff --git a/src/opengl/texture.c b/src/opengl/texture.c index 13b23c0..a1fda90 100644 --- a/src/opengl/texture.c +++ b/src/opengl/texture.c @@ -6,6 +6,7 @@ int gl_texture_create(lua_State *L); +int glDeleteTextures_bind(lua_State *L); int gl_texture_bind(lua_State *L); int gl_texture_image_2d(lua_State *L); int gl_texture_generate_mipmaps(lua_State *L); @@ -18,6 +19,7 @@ void setup_texture(lua_State *L, int gl_index) struct honey_tbl_t tbl[] = { /* functions */ H_FUNC("GenTextures", gl_texture_create), + H_FUNC("DeleteTextures", glDeleteTextures_bind), H_FUNC("BindTexture", gl_texture_bind), H_FUNC("TexImage2D", gl_texture_image_2d), H_FUNC("GenerateMipmap", gl_texture_generate_mipmaps), @@ -74,6 +76,14 @@ int gl_texture_create(lua_State *L) } +int glDeleteTextures_bind(lua_State *L) +{ + GLuint texture = luaL_checkinteger(L, 1); + glDeleteTextures(1, &texture); + return 0; +} + + int gl_texture_bind(lua_State *L) { lua_Integer target, texture; |