Add trimesh to reference count

This commit is contained in:
mid 2025-01-20 10:52:26 +02:00
parent 53a3f0af71
commit 1c165601c2

View File

@ -254,7 +254,14 @@ static int game_addentity(lua_State *L) {
if(lua_type(L, -1) == LUA_TSTRING) {
strncpy(c.trimesh.name, lua_tostring(L, -1), sizeof(c.trimesh.name) - 1);
} else {
c.trimesh.cache = *(struct TrimeshData**) luaL_checkudata(L, -1, "k3physics");
struct TrimeshData *tmd = *(struct TrimeshData**) luaL_checkudata(L, -1, "k3physics");
struct ResManRes *res = resman_rev(tmd);
if(res) {
res->refs++;
}
c.trimesh.cache = tmd;
}
}
lua_pop(L, 1);