From 619e5423fb591e2fb30fa3ea67c2ef520ca3d853 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 10 Jan 2009 17:20:34 +0000 Subject: [PATCH] 2.5 Removed another bad global "editbutvweight", a value from buttons used to paint weights with, or to set weights. Is now part of weightpaint struct in scene. --- source/blender/editors/mesh/editdeform.c | 18 +++++++-------- source/blender/editors/space_view3d/vpaint.c | 23 ++++++++++---------- source/blender/makesdna/DNA_scene_types.h | 3 ++- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/mesh/editdeform.c b/source/blender/editors/mesh/editdeform.c index 703ae2b9fc8..0533c37b292 100644 --- a/source/blender/editors/mesh/editdeform.c +++ b/source/blender/editors/mesh/editdeform.c @@ -678,9 +678,8 @@ void add_vert_to_defgroup (Object *ob, bDeformGroup *dg, int vertnum, } /* Only available in editmode */ -void assign_verts_defgroup (Object *obedit) +void assign_verts_defgroup (Object *obedit, float weight) { - float editbutvweight; /* XXX */ Object *ob; EditVert *eve; bDeformGroup *dg, *eg; @@ -722,7 +721,7 @@ void assign_verts_defgroup (Object *obedit) eg = BLI_findlink (&ob->defbase, dvert->dw[i].def_nr); /* Find the actual group */ if (eg==dg){ - dvert->dw[i].weight=editbutvweight; + dvert->dw[i].weight= weight; done=1; break; } @@ -736,7 +735,7 @@ void assign_verts_defgroup (Object *obedit) } dvert->dw=newdw; - dvert->dw[dvert->totweight].weight= editbutvweight; + dvert->dw[dvert->totweight].weight= weight; dvert->dw[dvert->totweight].def_nr= ob->actdef-1; dvert->totweight++; @@ -757,7 +756,7 @@ void assign_verts_defgroup (Object *obedit) tot= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw; for(a=0, bp= editLatt->def; af1 & SELECT) - add_vert_defnr (ob, ob->actdef-1, a, editbutvweight, WEIGHT_REPLACE); + add_vert_defnr (ob, ob->actdef-1, a, weight, WEIGHT_REPLACE); } } break; @@ -969,13 +968,14 @@ void vertexgroup_select_by_name(Object *ob, char *name) * and Lattices. (currently only restricted to those two) * It is only responsible for */ -void vgroup_assign_with_menu(Object *ob) +void vgroup_assign_with_menu(Scene *scene, Object *ob) { + VPaint *wp= scene->toolsettings->wpaint; int defCount; int mode; /* prevent crashes */ - if (ob==NULL) return; + if (wp==NULL || ob==NULL) return; defCount= BLI_countlist(&ob->defbase); @@ -989,11 +989,11 @@ void vgroup_assign_with_menu(Object *ob) switch (mode) { case 1: /* add to new group */ add_defgroup(ob); - assign_verts_defgroup(ob); + assign_verts_defgroup(ob, wp->weight); BIF_undo_push("Assign to vertex group"); break; case 2: /* add to current group */ - assign_verts_defgroup(ob); + assign_verts_defgroup(ob, wp->weight); BIF_undo_push("Assign to vertex group"); break; case 3: /* remove from current group */ diff --git a/source/blender/editors/space_view3d/vpaint.c b/source/blender/editors/space_view3d/vpaint.c index 73d0096739c..b8fe979a17f 100644 --- a/source/blender/editors/space_view3d/vpaint.c +++ b/source/blender/editors/space_view3d/vpaint.c @@ -119,6 +119,7 @@ static VPaint *new_vpaint(int wpaint) vp->flag= VP_AREA+VP_SOFT+VP_SPRAY; if(wpaint) { + vp->weight= 1.0f; vp->a= 1.0f; vp->flag= VP_AREA+VP_SOFT; } @@ -358,8 +359,7 @@ void clear_vpaint_selectedfaces(Scene *scene) void clear_wpaint_selectedfaces(Scene *scene) { VPaint *wp= scene->toolsettings->wpaint; - float editbutvweight; - float paintweight= editbutvweight; + float paintweight= wp->weight; Mesh *me; MFace *mface; Object *ob; @@ -426,7 +426,7 @@ void clear_wpaint_selectedfaces(Scene *scene) dw= verify_defweight(me->dvert+faceverts[i], vgroup); if(dw) { uw= verify_defweight(wp->wpaint_prev+faceverts[i], vgroup); - uw->weight= dw->weight; /* set the undio weight */ + uw->weight= dw->weight; /* set the undo weight */ dw->weight= paintweight; if(wp->flag & VP_MIRROR_X) { /* x mirror painting */ @@ -881,11 +881,12 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float /* if mode==1: */ /* samples cursor location, and gives menu with vertex groups to activate */ /* else */ -/* sets editbutvweight to the closest weight value to vertex */ +/* sets wp->weight to the closest weight value to vertex */ /* note: we cant sample frontbuf, weight colors are interpolated too unpredictable */ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode) { ViewContext vc; + VPaint *wp= scene->toolsettings->wpaint; Object *ob= OBACT; Mesh *me= get_mesh(ob); int index; @@ -965,7 +966,6 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode) else { DerivedMesh *dm; MDeformWeight *dw; - float editbutvweight; float w1, w2, w3, w4, co[3], fac; dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); @@ -996,20 +996,20 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode) fac= MIN4(w1, w2, w3, w4); if(w1==fac) { dw= get_defweight(me->dvert+mface->v1, ob->actdef-1); - if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f; + if(dw) wp->weight= dw->weight; else wp->weight= 0.0f; } else if(w2==fac) { dw= get_defweight(me->dvert+mface->v2, ob->actdef-1); - if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f; + if(dw) wp->weight= dw->weight; else wp->weight= 0.0f; } else if(w3==fac) { dw= get_defweight(me->dvert+mface->v3, ob->actdef-1); - if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f; + if(dw) wp->weight= dw->weight; else wp->weight= 0.0f; } else if(w4==fac) { if(mface->v4) { dw= get_defweight(me->dvert+mface->v4, ob->actdef-1); - if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f; + if(dw) wp->weight= dw->weight; else wp->weight= 0.0f; } } } @@ -1209,7 +1209,6 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) { ToolSettings *ts= CTX_data_tool_settings(C); VPaint *wp= ts->wpaint; - float editbutvweight= 1.0f; // XXX switch(event->type) { case LEFTMOUSE: @@ -1226,7 +1225,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) Object *ob= vc->obact; Mesh *me= ob->data; float mat[4][4]; - float paintweight= editbutvweight; // XXX + float paintweight= wp->weight; int *indexar= wpd->indexar; int totindex, index, alpha, totw; short mval[2]; @@ -1283,7 +1282,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) if(wp->mode==VP_BLUR) paintweight= 0.0f; else - paintweight= editbutvweight; + paintweight= wp->weight; for(index=0; indextotface) { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index ad280f46b26..db36772eb29 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -375,7 +375,8 @@ typedef struct TransformOrientation { } TransformOrientation; typedef struct VPaint { - float r, g, b, a; + float r, g, b, a; /* paint color */ + float weight; /* weight paint */ float size; /* of brush */ float gamma, mul; short mode, flag;