diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2015-04-28 00:24:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-28 00:30:04 +0300 |
commit | 4288ab16e5c83bd0763d8ee580731d9ea7eacde1 (patch) | |
tree | 76f101e6849d8fcdfa6ec334b4a97b7f84c752b1 /source/blender/blenkernel/intern/mesh.c | |
parent | 58a2b10a65872b2e4a3654a54a83e6f94bf4e229 (diff) |
Add material slot reorder buttons
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 87325a7ff47..12379bedb36 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1773,6 +1773,36 @@ void BKE_mesh_material_index_clear(Mesh *me) } } +void BKE_mesh_material_remap(Mesh *me, const unsigned int *remap, unsigned int remap_len) +{ + const short remap_len_short = (short)remap_len; + +#define MAT_NR_REMAP(n) \ + if (n < remap_len_short) { \ + BLI_assert(n >= 0 && remap[n] < remap_len_short); \ + n = remap[n]; \ + } ((void)0) + + if (me->edit_btmesh) { + BMEditMesh *em = me->edit_btmesh; + BMIter iter; + BMFace *efa; + + BM_ITER_MESH(efa, &iter, em->bm, BM_FACES_OF_MESH) { + MAT_NR_REMAP(efa->mat_nr); + } + } + else { + int i; + for (i = 0; i < me->totpoly; i++) { + MAT_NR_REMAP(me->mpoly[i].mat_nr); + } + } + +#undef MAT_NR_REMAP + +} + void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth) { Mesh *me = meshOb->data; |