diff options
author | sanine <sanine.not@pm.me> | 2022-09-18 16:09:24 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-09-18 16:09:24 -0500 |
commit | 64b1fcb3e7e55e55bb8da8cd9f5c3d9d4d92fdb8 (patch) | |
tree | c58aab3c8621392914520f2cff65e1acdd3068df /src/import/import.c | |
parent | 33a88ffe0cdab355547573b0fc566adbf91b8d23 (diff) |
add normal pushing
Diffstat (limited to 'src/import/import.c')
-rw-r--r-- | src/import/import.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/import/import.c b/src/import/import.c index 2debc3a..a68ac05 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -47,11 +47,24 @@ void push_mesh(lua_State *L, struct aiMesh mesh) int vertices = lua_gettop(L); pop_count += 1; + int normals = 0; + if (mesh.mNormals != NULL) { + lua_createtable(L, count, 0); + normals = lua_gettop(L); + pop_count += 1; + } + /* populate vertices */ for (int i=0; i<count; i++) { /* positions */ push_vector(L, mesh.mVertices[i]); lua_rawseti(L, vertices, i+1); + + /* normals */ + if (normals) { + push_vector(L, mesh.mNormals[i]); + lua_rawseti(L, normals, i+1); + } } /* populate faces */ @@ -70,6 +83,11 @@ void push_mesh(lua_State *L, struct aiMesh mesh) lua_pushvalue(L, vertices); lua_setfield(L, meshtbl, "vertices"); + if (normals) { + lua_pushvalue(L, normals); + lua_setfield(L, meshtbl, "normals"); + } + if (faces) { lua_pushvalue(L, faces); lua_setfield(L, meshtbl, "faces"); |