Made the Multi-Paint check box control what was being drawn so that it doesn't always...
authorJason Hays <jason_hays22@mymail.eku.edu>
Thu, 9 Jun 2011 16:38:47 +0000 (16:38 +0000)
committerJason Hays <jason_hays22@mymail.eku.edu>
Thu, 9 Jun 2011 16:38:47 +0000 (16:38 +0000)
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/editors/armature/editarmature.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c

index 4e570d304e53eb4196495ce83e6058979921ccb0..c71ebd915a2e7f4f5eec179267e17e8b9b59b776 100644 (file)
@@ -1607,7 +1607,7 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb)
        }
 }
 
-static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected)
+static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected, int multipaint)
 {
        Mesh *me = ob->data;
        float colf[4], input = 0.0f;
@@ -1616,12 +1616,12 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u
        if (me->dvert) {
                for (i=0; i<me->dvert[vert].totweight; i++)
                        // Jason was here
-                       if ((selected<=1 && me->dvert[vert].dw[i].def_nr==ob->actdef-1) || dg_flags[me->dvert[vert].dw[i].def_nr]) {//
+                       if ((!multipaint && me->dvert[vert].dw[i].def_nr==ob->actdef-1) || (multipaint && dg_flags[me->dvert[vert].dw[i].def_nr])) {//
                                input+=me->dvert[vert].dw[i].weight;
                        }
        }
        // Jason was here
-       if(selected) {
+       if(multipaint && selected) {
                input/=selected;
        }
 
@@ -1644,7 +1644,7 @@ void vDM_ColorBand_store(ColorBand *coba)
 {
        stored_cb= coba;
 }
-/* Jason was here */
+/* Jason was here duplicate function in paint_vertex.c*/
 static char* get_selected_defgroups(Object *ob, int defcnt) {
        bPoseChannel *chan;
        bPose *pose;
@@ -1660,8 +1660,7 @@ static char* get_selected_defgroups(Object *ob, int defcnt) {
                for (chan=pose->chanbase.first; chan; chan=chan->next) {
                        for (i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
                                if(!strcmp(defgroup->name, chan->bone->name)) {
-                                       // TODO get BONE_SELECTED flag
-                                       dg_flags[i] = (chan->bone->flag & 1);
+                                       dg_flags[i] = (chan->bone->flag & BONE_SELECTED);
                                        was_selected = TRUE;
                                }
                        }
@@ -1682,7 +1681,7 @@ static int count_true(char *list, int len)
        }
        return cnt;
 }
-static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
+static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int multipaint)
 {
        Mesh *me = ob->data;
        MFace *mf = me->mface;
@@ -1698,11 +1697,11 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
        
        memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
        for (i=0; i<me->totface; i++, mf++) {
-               calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4], dg_flags, selected); 
-               calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4], dg_flags, selected); 
-               calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4], dg_flags, selected); 
+               calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4], dg_flags, selected, multipaint); 
+               calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4], dg_flags, selected, multipaint); 
+               calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4], dg_flags, selected, multipaint); 
                if (mf->v4)
-                       calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4], dg_flags, selected); 
+                       calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4], dg_flags, selected, multipaint); 
        }
        // Jason
        MEM_freeN(dg_flags);
@@ -1913,7 +1912,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                                }
 
                                if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
-                                       add_weight_mcol_dm(ob, dm);
+                                       add_weight_mcol_dm(ob, dm, scene->toolsettings->multipaint);// Jason
 
                                /* Constructive modifiers need to have an origindex
                                 * otherwise they wont have anywhere to copy the data from.
@@ -2023,7 +2022,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                CDDM_calc_normals(finaldm);
 
                if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
-                       add_weight_mcol_dm(ob, finaldm);
+                       add_weight_mcol_dm(ob, finaldm, scene->toolsettings->multipaint);// Jason
        } else if(dm) {
                finaldm = dm;
        } else {
@@ -2035,7 +2034,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                }
 
                if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
-                       add_weight_mcol_dm(ob, finaldm);
+                       add_weight_mcol_dm(ob, finaldm, scene->toolsettings->multipaint);// Jason
        }
 
        /* add an orco layer if needed */
index b889f9938ffea43e6179b904a0281ac33e54f878..66fcced1d8e0a80da15e81a5a4de16bccf565e95 100644 (file)
@@ -4408,6 +4408,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
        Bone *nearBone;
        // Jason
        Bone *new_act_bone;
+
        if (!ob || !ob->pose) return 0;
 
        nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
@@ -5210,6 +5211,10 @@ void POSE_OT_select_inverse(wmOperatorType *ot)
 static int pose_de_select_all_exec(bContext *C, wmOperator *op)
 {
        int action = RNA_enum_get(op->ptr, "action");
+       //Jason
+       Object *ob = NULL;
+       Scene *scene= CTX_data_scene(C);
+       int multipaint = scene->toolsettings->multipaint;
 
        if (action == SEL_TOGGLE) {
                action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
@@ -5239,7 +5244,12 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
 
        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
-       
+       // Jason
+       if(multipaint) {
+               ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+               DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+       }
+
        return OPERATOR_FINISHED;
 }
 
index 5485401d5c950cd980d88e3cf123f4f103a54b18..8e6c320e49fc45a9d6df4a8f2a5c0e7b1444179b 100644 (file)
@@ -1393,8 +1393,7 @@ static char* get_selected_defgroups(Object *ob, int defcnt) {
                for (chan=pose->chanbase.first; chan; chan=chan->next) {
                        for (i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
                                if(!strcmp(defgroup->name, chan->bone->name)) {
-                                       // TODO get BONE_SELECTED flag
-                                       dg_flags[i] = (chan->bone->flag & 1);
+                                       dg_flags[i] = (chan->bone->flag & BONE_SELECTED);
                                        was_selected = TRUE;
                                }
                        }
@@ -1472,7 +1471,6 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
        }
 }
 
-
 /* *************** set wpaint operator ****************** */
 
 static int set_wpaint(bContext *C, wmOperator *UNUSED(op))             /* toggle */
index a9fb545ec3fc8223a7132e694b36b6fc6b4a0a5b..133c24e85f3fdcf3198fc17fb5f028238c7d494b 100644 (file)
@@ -214,6 +214,8 @@ int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
 void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
 void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
 void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
+//Jason
+void rna_update_active_object(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
 
 /* basic poll functions for object types */
 int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
index c6d1bfc22dbaa9c0cbd776750975a774b008ca4b..8dc095841a24303847e3c66d3c6a2c62d9b50a32 100644 (file)
@@ -218,6 +218,16 @@ void rna_Object_internal_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
        DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
 }
+// Jason
+void rna_update_active_object(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       Object *ob;
+       Base *basact = scene->basact;
+       if(basact && (ob = basact->object)) {
+               DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+               WM_main_add_notifier(NC_OBJECT|ND_DRAW, &ob->id);
+       }
+}
 
 void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
index 3f9710a58527105d34af9a61b3b70b3bda6fc916..9511ca75f7735d773ddc74ef64bc3a6ef7d34626 100644 (file)
@@ -1092,6 +1092,7 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
        RNA_def_property_ui_text(prop, "WPaint Multi-Paint", 
                "Paint across all selected bones while "
                 "weight painting");
+       RNA_def_property_update(prop, 0, "rna_update_active_object");
 
        prop= RNA_def_property(srna, "vertex_paint", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "vpaint");