luax_readmesh supports Model again;

This commit is contained in:
bjorn 2022-08-13 21:09:33 -07:00
parent f894c87723
commit 2c4f5a13df
1 changed files with 15 additions and 0 deletions

View File

@ -5,6 +5,10 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#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");
}