- use a flag define for bDeformGroup->flag rather than setting TRUE/FALSE
authorCampbell Barton <ideasman42@gmail.com>
Wed, 14 Sep 2011 07:07:17 +0000 (07:07 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 14 Sep 2011 07:07:17 +0000 (07:07 +0000)
- rename RNA bDeformGroup.flag to "lock_weight"

source/blender/editors/interface/interface_templates.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/makesdna/DNA_object_types.h
source/blender/makesrna/intern/rna_object.c

index 2f6a84b..a696e48 100644 (file)
@@ -2125,10 +2125,10 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
                uiBlockSetEmboss(block, UI_EMBOSS);
        }
        /* Jason was here: I need the RNA struct for vertex groups */
-       else if(RNA_struct_is_a(itemptr->type, &RNA_VertexGroup)) {
+       else if(itemptr->type == &RNA_VertexGroup) {
                uiItemL(sub, name, icon);
                uiBlockSetEmboss(block, UI_EMBOSS);
-               uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "flag", 0, 0, 0, 0, 0,  NULL);
+               uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "lock_weight", 0, 0, 0, 0, 0,  NULL);
        }
        else if(itemptr->type == &RNA_KeyingSetPath) {
                KS_Path *ksp = (KS_Path*)itemptr->data;
index e729ac9..bbc707d 100644 (file)
@@ -1306,7 +1306,7 @@ static void vgroup_lock_all(Object *ob)
 {
        bDeformGroup *dg = ob->defbase.first;
        while(dg) {
-               dg->flag = TRUE;
+               dg->flag |= DG_LOCK_WEIGHT;
                dg = dg->next;
        }
 }
@@ -1315,7 +1315,7 @@ static void vgroup_unlock_all(Object *ob)
 {
        bDeformGroup *dg = ob->defbase.first;
        while(dg) {
-               dg->flag = FALSE;
+               dg->flag &= ~DG_LOCK_WEIGHT;
                dg = dg->next;
        }
 }
index 83d1c2d..584e88d 100644 (file)
@@ -363,7 +363,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol)
        MFace *mf;
        unsigned int *mcol;
        int i, selected;
-       
+
        me= get_mesh(ob);
        if(me==NULL || me->totface==0) return;
 
@@ -442,9 +442,9 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
                        faceverts[2]= mface->v3;
                        faceverts[3]= mface->v4;
                        for (i=0; i<3 || faceverts[i]; i++) {
-                               if(!((me->dvert+faceverts[i])->flag)) {
+                               if(me->dvert[faceverts[i]].flag) {
                                        // Jason
-                                       if(selectedVerts && !((me->mvert+faceverts[i])->flag & SELECT)) {
+                                       if(selectedVerts && ((me->mvert[faceverts[i]].flag & SELECT) == 0)) {
                                                continue;
                                        }
 
@@ -1167,10 +1167,8 @@ static char *gen_lck_flags(Object* ob, int defbase_len)
        bDeformGroup *defgroup;
 
        for(i = 0, defgroup = ob->defbase.first; i < defbase_len && defgroup; defgroup = defgroup->next, i++) {
-               flags[i] = defgroup->flag;
-               if(flags[i]) {
-                       is_locked = TRUE;
-               }
+               flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0);
+               is_locked |= flags[i];
        }
        if(is_locked){
                return flags;
@@ -1519,7 +1517,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
        //                                              Jason: tdw, tuw
        MDeformWeight *dw, *uw, *tdw = NULL, *tuw;
        int vgroup= ob->actdef-1;
-
+       
        /* Jason was here */
        char *flags;
        char *bone_groups;
@@ -1569,7 +1567,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
                dv = MEM_mallocN(sizeof (*(me->dvert+index)), "prevMDeformVert");
 
                dv->dw= MEM_dupallocN((me->dvert+index)->dw);
-               dv->flag = (me->dvert+index)->flag;
+               dv->flag = me->dvert[index].flag;
                dv->totweight = (me->dvert+index)->totweight;
                tdw = dw;
                tuw = uw;
@@ -1647,6 +1645,7 @@ 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 */
@@ -1808,7 +1807,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
        struct WPaintData *wpd;
        Mesh *me;
        float mat[4][4], imat[4][4];
-
+       
        if(scene->obedit) return OPERATOR_CANCELLED;
        
        me= get_mesh(ob);
@@ -1819,14 +1818,13 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
                ED_vgroup_data_create(&me->id);
                WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
        }
-
-
+       
        /* make mode data storage */
        wpd= MEM_callocN(sizeof(struct WPaintData), "WPaintData");
        paint_stroke_set_mode_data(stroke, wpd);
        view3d_set_viewcontext(C, &wpd->vc);
        wpd->vgroup_mirror= -1;
-
+       
        /*set up auto-normalize, and generate map for detecting which
          vgroups affect deform bones*/
        wpd->auto_normalize = ts->auto_normalize;
@@ -1881,7 +1879,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
        if(me->editflag & ME_EDIT_MIRROR_X) {
                wpaint_mirror_vgroup_ensure(ob, &wpd->vgroup_mirror);
        }
-
+       
        return 1;
 }
 
@@ -1977,11 +1975,19 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        for(index=0; index<totindex; index++) {
                if(indexar[index] && indexar[index]<=me->totface) {
                        MFace *mface= me->mface + (indexar[index]-1);
-                                       
-                       (me->dvert+mface->v1)->flag= selectedVerts ? ((me->mvert+mface->v1)->flag & SELECT): 1;
-                       (me->dvert+mface->v2)->flag= selectedVerts ? ((me->mvert+mface->v2)->flag & SELECT): 1;
-                       (me->dvert+mface->v3)->flag= selectedVerts ? ((me->mvert+mface->v3)->flag & SELECT): 1;
-                       if(mface->v4) (me->dvert+mface->v4)->flag= selectedVerts ? ((me->mvert+mface->v4)->flag & SELECT): 1;
+
+                       if(selectedVerts) {
+                               me->dvert[mface->v1].flag = (me->mvert[mface->v1].flag & SELECT);
+                               me->dvert[mface->v2].flag = (me->mvert[mface->v2].flag & SELECT);
+                               me->dvert[mface->v3].flag = (me->mvert[mface->v3].flag & SELECT);
+                               if(mface->v4) me->dvert[mface->v4].flag = (me->mvert[mface->v4].flag & SELECT);
+                       }
+                       else {
+                               me->dvert[mface->v1].flag= 1;
+                               me->dvert[mface->v2].flag= 1;
+                               me->dvert[mface->v3].flag= 1;
+                               if(mface->v4) me->dvert[mface->v4].flag= 1;
+                       }
                                        
                        if(brush->vertexpaint_tool==VP_BLUR) {
                                MDeformWeight *dw, *(*dw_func)(MDeformVert *, const int);
@@ -2304,15 +2310,14 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index
        Brush *brush = paint_brush(&vp->paint);
        Mesh *me = get_mesh(ob);
        MFace *mface= ((MFace*)me->mface) + index;
-
        unsigned int *mcol= ((unsigned int*)me->mcol) + 4*index;
        unsigned int *mcolorig= ((unsigned int*)vp->vpaint_prev) + 4*index;
        float alpha;
        int i;
-
+       
        if((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) ||
           ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL)))
-                  return;
+               return;
 
        if(brush->vertexpaint_tool==VP_BLUR) {
                unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128);
index a215029..0b02006 100644 (file)
@@ -67,6 +67,9 @@ typedef struct bDeformGroup {
 } bDeformGroup;
 #define MAX_VGROUP_NAME 32
 
+/* bDeformGroup->flag */
+#define DG_LOCK_WEIGHT 1
+
 /**
  * The following illustrates the orientation of the 
  * bounding box in local space
index 7d03726..c460432 100644 (file)
@@ -1276,9 +1276,9 @@ static void rna_def_vertex_group(BlenderRNA *brna)
        RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
        RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */
        /* Jason was here */
-       prop= RNA_def_property(srna, "flag", PROP_BOOLEAN, PROP_NONE);
+       prop= RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
-       RNA_def_property_boolean_sdna(prop, "bDeformGroup", "flag", 0);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
        RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */
 
        prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);