Commit: b81c8b983a16fa37d4a6df2df4321df58227c819
Author: Campbell Barton
Date: Tue Apr 28 06:38:38 2015 +1000
Branches: temp-material-remap
https://developer.blender.org/rBb81c8b983a16fa37d4a6df2df4321df58227c819
use macro /w error checks for remapping
===================================================================
M source/blender/blenkernel/intern/material.c
===================================================================
diff --git a/source/blender/blenkernel/intern/material.c
b/source/blender/blenkernel/intern/material.c
index 109e0d3..490cc29 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -942,6 +942,14 @@ void BKE_material_remap_object(Object *ob, unsigned int
remap[])
BLI_array_permute(*matar, *totcol_p, remap);
}
+#define MAT_NR_REMAP(n) \
+ if (n < mat_nr_max) { \
+ BLI_assert(n >= 0); \
+ BLI_assert(remap[n] < mat_nr_max); \
+ n = remap[n]; \
+ } ((void)0)
+
+
/* Now reassign the new material order to the affected items in the
object*/
if (ob->type == OB_MESH) {
if (ob->mode == OB_MODE_EDIT) {
@@ -952,18 +960,14 @@ void BKE_material_remap_object(Object *ob, unsigned int
remap[])
BMFace *efa;
BM_ITER_MESH(efa, &iter, em->bm,
BM_FACES_OF_MESH) {
- if (efa->mat_nr < mat_nr_max) {
- efa->mat_nr =
remap[efa->mat_nr];
- }
+ MAT_NR_REMAP(efa->mat_nr);
}
}
}
else {
Mesh *me = ob->data;
for (int index = 0; index < me->totpoly; index++) {
- if (me->mpoly[index].mat_nr < mat_nr_max) {
- me->mpoly[index].mat_nr =
remap[me->mpoly[index].mat_nr];
- }
+ MAT_NR_REMAP(me->mpoly[index].mat_nr);
}
}
}
@@ -973,9 +977,7 @@ void BKE_material_remap_object(Object *ob, unsigned int
remap[])
if (nurbs) {
for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->mat_nr < mat_nr_max) {
- nu->mat_nr = remap[nu->mat_nr];
- }
+ MAT_NR_REMAP(nu->mat_nr);
}
}
}
@@ -995,15 +997,16 @@ void BKE_material_remap_object(Object *ob, unsigned int
remap[])
}
for (int i = 0; i <= charinfo_len; i++) {
- if (strinfo[i].mat_nr < mat_nr_max) {
- strinfo[i].mat_nr = remap[strinfo[i].mat_nr];
- }
+ MAT_NR_REMAP(strinfo[i].mat_nr);
}
}
else {
/* add support for this object data! */
BLI_assert(matar == NULL);
}
+
+#undef MAT_NR_REMAP
+
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs