2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 21:07:42 +00:00

bmesh generation tweaks

This commit is contained in:
Jack Andersen
2015-09-10 18:53:32 -10:00
parent cb7c642dac
commit 40c39ee83b
4 changed files with 44 additions and 1 deletions

View File

@@ -145,6 +145,16 @@ void FinishBlenderMesh(HECL::BlenderConnection::PyOutStream& os,
"\n"
"bm.to_mesh(mesh)\n"
"bm.free()\n"
"\n"
"# Remove redundant materials\n"
"present_mats = set()\n"
"for poly in mesh.polygons:\n"
" present_mats.add(poly.material_index)\n"
"for mat_idx in reversed(range(len(mesh.materials))):\n"
" if mat_idx not in present_mats:\n"
" mesh.materials.pop(index=mat_idx, update_data=True)\n"
"\n"
"mesh.update()\n"
"\n";
}