merge with 2.5 (not trunk, last merge message said that on accident) at r22252
[blender.git] / source / blender / makesrna / intern / rna_object_api.c
index 9d65c9be78a23c4d2bbebd1feccd9c8f997a34cc..1bb341b4c9d029a516c660c6f0aea1881015f65b 100644 (file)
@@ -34,6 +34,8 @@
 
 #ifdef RNA_RUNTIME
 
+#include "MEM_guardedalloc.h"
+
 #include "BKE_customdata.h"
 #include "BKE_DerivedMesh.h"
 
@@ -61,6 +63,25 @@ Mesh *rna_Object_create_render_mesh(Object *ob, Scene *scene)
        DM_to_mesh(dm, me);
        dm->release(dm);
 
+
+       {       /* update the material */
+               short i, *totcol =give_totcolp(ob);
+
+               /* free the current material list */
+               if(me->mat)
+                       MEM_freeN((void *)me->mat);
+
+               me->mat= (Material **)MEM_callocN(sizeof(void *)*(*totcol), "matarray");
+
+               for(i=0; i<*totcol; i++) {
+                       Material *mat= give_current_material(ob, i+1);
+                       if(mat) {
+                               me->mat[i]= mat;
+                               mat->id.us++;
+                       }
+               }
+       }
+
        return me;
 }