mirror of https://github.com/bjornbytes/lovr.git
Mesh:setVertexMap accepts a Blob for fast updates;
This commit is contained in:
parent
471540433c
commit
f9ce6d3425
|
@ -203,6 +203,14 @@ int l_lovrMeshSetVertexMap(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TUSERDATA) {
|
||||
Blob* blob = luax_checktypeof(L, 2, Blob);
|
||||
size_t size = luaL_optinteger(L, 3, 4);
|
||||
lovrAssert(size == 2 || size == 4, "Size of Mesh indices should be 2 bytes or 4 bytes");
|
||||
uint32_t count = blob->size / size;
|
||||
IndexPointer indices = lovrMeshWriteIndices(mesh, count, size);
|
||||
memcpy(indices.raw, blob->data, blob->size);
|
||||
} else {
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
uint32_t count = lua_objlen(L, 2);
|
||||
uint32_t vertexCount = lovrMeshGetVertexCount(mesh);
|
||||
|
@ -228,6 +236,7 @@ int l_lovrMeshSetVertexMap(lua_State* L) {
|
|||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue