2.5/Posemode:
[blender-staging.git] / source / blender / editors / sculpt_paint / paint_vertex.c
index 812c41f430eb36c0f44b12531f7f2eb94280319c..bbc68a6bd0a856417ed11295b6b4b554c2d99bc1 100644 (file)
@@ -108,7 +108,9 @@ static void error() {}
 
 static int vp_poll(bContext *C)
 {
-       if(G.f & G_VERTEXPAINT) {
+       Object *ob = CTX_data_active_object(C);
+
+       if(ob && ob->mode & OB_MODE_VERTEX_PAINT) {
                ScrArea *sa= CTX_wm_area(C);
                if(sa->spacetype==SPACE_VIEW3D) {
                        ARegion *ar= CTX_wm_region(C);
@@ -121,7 +123,9 @@ static int vp_poll(bContext *C)
 
 static int wp_poll(bContext *C)
 {
-       if(G.f & G_WEIGHTPAINT) {
+       Object *ob = CTX_data_active_object(C);
+
+       if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
                ScrArea *sa= CTX_wm_area(C);
                if(sa->spacetype==SPACE_VIEW3D) {
                        ARegion *ar= CTX_wm_region(C);
@@ -369,12 +373,12 @@ void clear_vpaint(Scene *scene)
        unsigned int *to, paintcol;
        int a;
        
-       if((G.f & G_VERTEXPAINT)==0) return;
-
        ob= OBACT;
        me= get_mesh(ob);
        if(!ob || ob->id.lib) return;
 
+       if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return;
+
        if(me==0 || me->mcol==0 || me->totface==0) return;
 
        paintcol= vpaint_get_current_col(scene->toolsettings->vpaint);
@@ -540,10 +544,10 @@ void vpaint_dogamma(Scene *scene)
        int a, temp;
        unsigned char *cp, gamtab[256];
 
-       if((G.f & G_VERTEXPAINT)==0) return;
-
        ob= OBACT;
        me= get_mesh(ob);
+
+       if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return;
        if(me==0 || me->mcol==0 || me->totface==0) return;
 
        igam= 1.0/vp->gamma;
@@ -1092,12 +1096,12 @@ static int set_wpaint(bContext *C, wmOperator *op)              /* toggle */
        
        if(me && me->totface>=MAXINDEX) {
                error("Maximum number of faces: %d", MAXINDEX-1);
-               G.f &= ~G_WEIGHTPAINT;
+               ob->mode &= ~OB_MODE_WEIGHT_PAINT;
                return OPERATOR_CANCELLED;
        }
        
-       if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT;
-       else G.f |= G_WEIGHTPAINT;
+       if(ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT;
+       else ob->mode |= OB_MODE_WEIGHT_PAINT;
        
        
        /* Weightpaint works by overriding colors in mesh,
@@ -1107,7 +1111,7 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                */
        DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
        
-       if(G.f & G_WEIGHTPAINT) {
+       if(ob->mode & OB_MODE_WEIGHT_PAINT) {
                Object *par;
                
                if(wp==NULL)
@@ -1121,7 +1125,7 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                
                /* verify if active weight group is also active bone */
                par= modifiers_isDeformedByArmature(ob);
-               if(par && (par->flag & OB_POSEMODE)) {
+               if(par && (par->mode & OB_MODE_POSE)) {
                        bPoseChannel *pchan;
                        for(pchan= par->pose->chanbase.first; pchan; pchan= pchan->next)
                                if(pchan->bone->flag & BONE_ACTIVE)
@@ -1584,22 +1588,22 @@ static int set_vpaint(bContext *C, wmOperator *op)              /* toggle */
        me= get_mesh(ob);
        
        if(me==NULL || object_data_is_libdata(ob)) {
-               G.f &= ~G_VERTEXPAINT;
+               ob->mode &= ~OB_MODE_VERTEX_PAINT;
                return OPERATOR_PASS_THROUGH;
        }
        
        if(me && me->totface>=MAXINDEX) {
                error("Maximum number of faces: %d", MAXINDEX-1);
-               G.f &= ~G_VERTEXPAINT;
+               ob->mode &= ~OB_MODE_VERTEX_PAINT;
                return OPERATOR_FINISHED;
        }
        
        if(me && me->mcol==NULL) make_vertexcol(scene, 0);
        
        /* toggle: end vpaint */
-       if(G.f & G_VERTEXPAINT) {
+       if(ob->mode & OB_MODE_VERTEX_PAINT) {
                
-               G.f &= ~G_VERTEXPAINT;
+               ob->mode &= ~OB_MODE_VERTEX_PAINT;
                
                if(vp) {
                        toggle_paint_cursor(C, 0);
@@ -1608,9 +1612,9 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
        }
        else {
                
-               G.f |= G_VERTEXPAINT;
+               ob->mode |= OB_MODE_VERTEX_PAINT;
                /* Turn off weight painting */
-               if (G.f & G_WEIGHTPAINT)
+               if (ob->mode & OB_MODE_WEIGHT_PAINT)
                        set_wpaint(C, op);
                
                if(vp==NULL)