From 42e062fc882f0fb9df7671e457d8047fc6e04a39 Mon Sep 17 00:00:00 2001 From: Jason Hays Date: Thu, 9 Jun 2011 16:38:47 +0000 Subject: [PATCH] Made the Multi-Paint check box control what was being drawn so that it doesn't always draw the groups together when multiple bones are selected. --- .../blender/blenkernel/intern/DerivedMesh.c | 27 +++++++++---------- .../blender/editors/armature/editarmature.c | 12 ++++++++- .../editors/sculpt_paint/paint_vertex.c | 4 +-- source/blender/makesrna/intern/rna_internal.h | 2 ++ source/blender/makesrna/intern/rna_object.c | 10 +++++++ source/blender/makesrna/intern/rna_scene.c | 1 + 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 4e570d304e5..c71ebd915a2 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -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; idvert[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; itotface; 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 */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index b889f9938ff..66fcced1d8e 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -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; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 5485401d5c9..8e6c320e49f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -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 */ diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index a9fb545ec3f..133c24e85f3 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -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); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index c6d1bfc22db..8dc095841a2 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -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) { diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3f9710a5852..9511ca75f77 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -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");