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.
This commit is contained in:
Ton Roosendaal 2009-01-10 17:20:34 +00:00
parent 446933c73f
commit 619e5423fb
3 changed files with 22 additions and 22 deletions

@ -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; a<tot; a++, bp++) {
if(bp->f1 & 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 */

@ -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; index<totindex; index++) {
if(indexar[index] && indexar[index]<=me->totface) {

@ -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;