diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_vertex.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 14e9626212a..0380dba7592 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -288,6 +288,43 @@ static void make_vertexcol(Object *ob) /* single ob */ } +/* mirror_vgroup is set to -1 when invalid */ +static void wpaint_mirror_vgroup_ensure(Object *ob, int *vgroup_mirror) +{ + bDeformGroup *defgroup= BLI_findlink(&ob->defbase, ob->actdef - 1); + + if(defgroup) { + bDeformGroup *curdef; + int mirrdef; + char name[MAXBONENAME]; + + flip_side_name(name, defgroup->name, FALSE); + + if(strcmp(name, defgroup->name) != 0) { + for (curdef= ob->defbase.first, mirrdef; curdef; curdef=curdef->next, mirrdef++) { + if (!strcmp(curdef->name, name)) { + break; + } + } + + if(curdef==NULL) { + int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ + curdef= ED_vgroup_add_name(ob, name); + ob->actdef= olddef; + } + + /* curdef should never be NULL unless this is + * a lamp and ED_vgroup_add_name fails */ + if(curdef) { + *vgroup_mirror= mirrdef; + return; + } + } + } + + *vgroup_mirror= -1; +} + static void copy_vpaint_prev(VPaint *vp, unsigned int *mcol, int tot) { if(vp->vpaint_prev) { @@ -383,32 +420,11 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) } vgroup= ob->actdef-1; - - /* directly copied from weight_paint, should probaby split into a separate function */ + /* if mirror painting, find the other group */ if(me->editflag & ME_EDIT_MIRROR_X) { - bDeformGroup *defgroup= BLI_findlink(&ob->defbase, ob->actdef-1); - if(defgroup) { - bDeformGroup *curdef; - int actdef= 0; - char name[32]; - - flip_side_name(name, defgroup->name, FALSE); - - for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) - if (!strcmp(curdef->name, name)) - break; - if(curdef==NULL) { - int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ - curdef= ED_vgroup_add_name (ob, name); - ob->actdef= olddef; - } - - if(curdef && curdef!=defgroup) - vgroup_mirror= actdef; - } + wpaint_mirror_vgroup_ensure(ob, &vgroup_mirror); } - /* end copy from weight_paint*/ copy_wpaint_prev(wp, me->dvert, me->totvert); @@ -942,7 +958,7 @@ void PAINT_OT_weight_sample(wmOperatorType *ot) } /* samples cursor location, and gives menu with vertex groups to activate */ -static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { if (C) { wmWindow *win= CTX_wm_window(C); @@ -1351,26 +1367,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED /* if mirror painting, find the other group */ if(me->editflag & ME_EDIT_MIRROR_X) { - bDeformGroup *defgroup= BLI_findlink(&ob->defbase, ob->actdef-1); - if(defgroup) { - bDeformGroup *curdef; - int actdef= 0; - char name[32]; - - flip_side_name(name, defgroup->name, FALSE); - - for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) - if (!strcmp(curdef->name, name)) - break; - if(curdef==NULL) { - int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ - curdef= ED_vgroup_add_name (ob, name); - ob->actdef= olddef; - } - - if(curdef && curdef!=defgroup) - wpd->vgroup_mirror= actdef; - } + wpaint_mirror_vgroup_ensure(ob, &wpd->vgroup_mirror); } return 1; |