mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Mesh:getVertexMap now returns nil rather than an empty table, if no vertex map is set (resolves issue #1096.)
This commit is contained in:
@@ -331,6 +331,13 @@ int w_Mesh_setVertexMap(lua_State *L)
|
||||
{
|
||||
Mesh *t = luax_checkmesh(L, 1);
|
||||
|
||||
if (lua_isnoneornil(L, 2))
|
||||
{
|
||||
// Disable the vertex map / index buffer.
|
||||
luax_catchexcept(L, [&](){ t->setVertexMap(); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_table = lua_istable(L, 2);
|
||||
int nargs = is_table ? (int) luax_objlen(L, 2) : lua_gettop(L) - 1;
|
||||
|
||||
@@ -361,7 +368,14 @@ int w_Mesh_getVertexMap(lua_State *L)
|
||||
Mesh *t = luax_checkmesh(L, 1);
|
||||
|
||||
std::vector<uint32> vertex_map;
|
||||
luax_catchexcept(L, [&](){ t->getVertexMap(vertex_map); });
|
||||
bool has_vertex_map = false;
|
||||
luax_catchexcept(L, [&](){ has_vertex_map = t->getVertexMap(vertex_map); });
|
||||
|
||||
if (!has_vertex_map)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int element_count = (int) vertex_map.size();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user