Making new faces (fkey, scanfill etc) didnt create faces with the active material.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 7 Oct 2009 15:16:08 +0000 (15:16 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 7 Oct 2009 15:16:08 +0000 (15:16 +0000)
Keep the editmesh material and active material in sync

source/blender/editors/mesh/editmesh.c
source/blender/makesrna/intern/rna_object.c

index 980d699dda51979d96c8fc97c75253e9b3bd7805..d540151337d563f45681f13d4b1e4ce658bcb00e 100644 (file)
@@ -986,6 +986,8 @@ void load_editMesh(Scene *scene, Object *ob)
        CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, mface, me->totface);
        mesh_update_customdata_pointers(me);
 
+       em->mat_nr= ob->actcol-1;
+
        /* the vertices, use ->tmp.l as counter */
        eve= em->verts.first;
        a= 0;
index 3a3842adbf146ffc0bc5ce4b41d008d124fe7b79..4fb2db42b8b4a6dd71d382ba46d7396f82e69f58 100644 (file)
@@ -99,6 +99,8 @@ EnumPropertyItem object_type_items[] = {
 #include "BKE_particle.h"
 #include "BKE_scene.h"
 
+#include "BLI_editVert.h" /* for EditMesh->mat_nr */
+
 #include "ED_object.h"
 
 void rna_Object_update(bContext *C, PointerRNA *ptr)
@@ -404,6 +406,13 @@ static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
 {
        Object *ob= (Object*)ptr->id.data;
        ob->actcol= value+1;
+
+       if(ob->mode==OB_MODE_EDIT && ob->type==OB_MESH) {
+               Mesh *me= ob->data;
+
+               if(me->edit_mesh)
+                       me->edit_mesh->mat_nr= value;
+       }
 }
 
 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max)