diff --git a/src/api/api.c b/src/api/api.c index f6345369..180adf1b 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -5,6 +5,10 @@ #include #include #include +#ifndef LOVR_DISABLE_GRAPHICS +#include "data/modelData.h" +#include "graphics/graphics.h" +#endif typedef void voidFn(void); typedef void destructorFn(void*); @@ -522,5 +526,16 @@ int luax_readmesh(lua_State* L, int index, float** vertices, uint32_t* vertexCou return index + 2; } +#ifndef LOVR_DISABLE_GRAPHICS + Model* model = luax_totype(L, index, Model); + + if (model) { + ModelData* modelData = lovrModelGetInfo(model)->data; + lovrModelDataGetTriangles(modelData, vertices, indices, vertexCount, indexCount); + *shouldFree = false; + return index + 1; + } +#endif + return luaL_argerror(L, index, "table or Model"); }