2.5/Paint:
authorNicholas Bishop <nicholasbishop@gmail.com>
Sat, 15 Aug 2009 21:46:25 +0000 (21:46 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Sat, 15 Aug 2009 21:46:25 +0000 (21:46 +0000)
* Weightpaint is now object-local like sculpt and vertexpaint.
* Fixed a bug spotted by DingTo, going from editmode to sculptmode didn't fully leave editmode

24 files changed:
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/paint.c
source/blender/blenkernel/intern/particle_system.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/poseobject.c
source/blender/editors/object/object_edit.c
source/blender/editors/screen/screen_context.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_orientations.c
source/blender/makesdna/DNA_object_types.h

index 1d09ff2f2c6fb45b48c8a51c51c40276b81fff2d..1b20fe92a0eb2172267359033e94816740cfa220 100644 (file)
@@ -115,7 +115,6 @@ typedef struct Global {
 #define G_DEBUG                        (1 << 12)
 #define G_DOSCRIPTLINKS (1 << 13)
 
-#define G_WEIGHTPAINT  (1 << 15)       
 #define G_TEXTUREPAINT (1 << 16)
 /* #define G_NOFROZEN  (1 << 17) also removed */
 #define G_GREASEPENCIL         (1 << 17)
index 3f20d37974842352218164ca3dde4d0116461a9a..3b7ea6f3fcde830656f0f4649eb08253716725cf 100644 (file)
@@ -226,7 +226,7 @@ static void clear_global(void)
 
        G.main= NULL;
        
-       G.f &= ~(G_WEIGHTPAINT + G_FACESELECT + G_PARTICLEEDIT);
+       G.f &= ~(G_FACESELECT + G_PARTICLEEDIT);
 }
 
 /* make sure path names are correct for OS */
index 392872dafd1c4a7cba0202e89389ac4159515631..e026ccdcec6cf7786100a01d71fc71b3f2a8b9d2 100644 (file)
@@ -195,9 +195,9 @@ Brush **current_brush_source(Scene *sce)
                        return &sce->toolsettings->sculpt->brush;
                else if(ob->mode & OB_MODE_VERTEX_PAINT)
                        return &sce->toolsettings->vpaint->brush;
+               else if(ob->mode & OB_MODE_WEIGHT_PAINT)
+                       return &sce->toolsettings->wpaint->brush;
        }
-       else if(G.f & G_WEIGHTPAINT)
-               return &sce->toolsettings->wpaint->brush;
        else if(G.f & G_TEXTUREPAINT)
                return &sce->toolsettings->imapaint.brush;
        return NULL;
index ba06768b12a58c6ef96d4fc196640adedf85be65..3210206e16df6301856913d5f252a967a45a748e 100644 (file)
@@ -688,7 +688,7 @@ char *CTX_data_mode_string(const bContext *C)
                
                if(ob && (ob->flag & OB_POSEMODE)) return "posemode";
                else if (ob && ob->mode & OB_MODE_SCULPT)  return "sculpt_mode";
-               else if (G.f & G_WEIGHTPAINT) return "weightpaint";
+               else if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) return "weightpaint";
                else if (ob && ob->mode & OB_MODE_VERTEX_PAINT) return "vertexpaint";
                else if (G.f & G_TEXTUREPAINT) return "texturepaint";
                else if(G.f & G_PARTICLEEDIT) return "particlemode";
index e945c218217a3511bf15fadd3bc1671aa3205110..4081729ec5e055c52f6a2dc9189562a193103b0b 100644 (file)
@@ -32,6 +32,6 @@
 
 int paint_facesel_test(Object *ob)
 {
-       return (G.f&G_FACESELECT) && ((G.f & (G_WEIGHTPAINT|G_TEXTUREPAINT)) || (ob && (ob->mode & OB_MODE_VERTEX_PAINT)));
+       return (G.f&G_FACESELECT) && ((G.f & G_TEXTUREPAINT) || (ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))));
 
 }
index f81eba2badfda638d59f304993edbb0f826ae988..dcd3fcd2f89ddc70c4f2ce8065e8dae01a8bb955 100644 (file)
@@ -3726,7 +3726,7 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif
        if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
                alloc=1;
 
-       if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT)))
+       if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)))
                distr=1;
 
        if(distr){
index c1b24375b3d509031a758f0c7e84a294bae95da9..07da42e4cbb1b1d9b7e8213db4ba7ae05c1c1547 100644 (file)
@@ -4332,7 +4332,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
                }
                
                /* in weightpaint we select the associated vertex group too */
-               if (G.f & G_WEIGHTPAINT) {
+               if (ob->mode & OB_MODE_WEIGHT_PAINT) {
                        if (nearBone->flag & BONE_ACTIVE) {
                                vertexgroup_select_by_name(OBACT, nearBone->name);
                                DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
@@ -4424,7 +4424,7 @@ static int bone_skinnable(Object *ob, Bone *bone, void *datap)
        int a, segments;
        struct { Object *armob; void *list; int heat; } *data = datap;
 
-       if(!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) {
+       if(!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) {
                if (!(bone->flag & BONE_NO_DEFORM)) {
                        if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name))
                                segments = bone->segments;
@@ -4489,7 +4489,7 @@ static int dgroup_skinnable(Object *ob, Bone *bone, void *datap)
        int a, segments;
        struct { Object *armob; void *list; int heat; } *data= datap;
 
-       if (!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) {
+       if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) {
           if (!(bone->flag & BONE_NO_DEFORM)) {
                        if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name))
                                segments = bone->segments;
@@ -4588,7 +4588,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m
        float (*root)[3], (*tip)[3], (*verts)[3];
        int *selected;
        int numbones, vertsfilled = 0, i, j, segments = 0;
-       int wpmode = (G.f & G_WEIGHTPAINT);
+       int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT);
        struct { Object *armob; void *list; int heat; } looper_data;
 
        looper_data.armob = par;
index 63f18ca6caf9a26b48d25ed1f7a828977170315b..fe723a875a216dd717e07d14534c2292810c57a3 100644 (file)
@@ -1647,7 +1647,7 @@ void pose_activate_flipped_bone(Scene *scene)
        
        if(ob==NULL) return;
 
-       if(G.f & G_WEIGHTPAINT) {
+       if(ob->mode && OB_MODE_WEIGHT_PAINT) {
                ob= modifiers_isDeformedByArmature(ob);
        }
        if(ob && (ob->flag & OB_POSEMODE)) {
@@ -1671,7 +1671,7 @@ void pose_activate_flipped_bone(Scene *scene)
                                pchanf->bone->flag |= (BONE_SELECTED|BONE_ACTIVE);
                        
                                /* in weightpaint we select the associated vertex group too */
-                               if(G.f & G_WEIGHTPAINT) {
+                               if(ob->mode & OB_MODE_WEIGHT_PAINT) {
                                        vertexgroup_select_by_name(OBACT, name);
                                        DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
                                }
index f5a93fae8e9a5bd0569ee7549b3433da7c5a29ee..de77b80a29a4890f738cc9e45b6972594eb59874 100644 (file)
@@ -2247,7 +2247,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op)
        int armature_clear= 0;
 
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
-               if((G.f & G_WEIGHTPAINT)==0) {
+               if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
                        if ((ob->protectflag & OB_LOCK_LOCX)==0)
                                ob->loc[0]= ob->dloc[0]= 0.0f;
                        if ((ob->protectflag & OB_LOCK_LOCY)==0)
@@ -2290,7 +2290,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op)
        int armature_clear= 0;
 
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
-               if((G.f & G_WEIGHTPAINT)==0) {
+               if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
                        /* eulers can only get cleared if they are not protected */
                        if ((ob->protectflag & OB_LOCK_ROTX)==0)
                                ob->rot[0]= ob->drot[0]= 0.0f;
@@ -2334,7 +2334,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op)
        int armature_clear= 0;
 
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
-               if((G.f & G_WEIGHTPAINT)==0) {
+               if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
                        if ((ob->protectflag & OB_LOCK_SCALEX)==0) {
                                ob->dsize[0]= 0.0f;
                                ob->size[0]= 1.0f;
@@ -3701,7 +3701,7 @@ void ED_object_exit_editmode(bContext *C, int flag)
                        me->edit_mesh= NULL;
                }
                
-               if(G.f & G_WEIGHTPAINT)
+               if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT)
                        mesh_octree_table(obedit, NULL, NULL, 'e');
        }
        else if (obedit->type==OB_ARMATURE) {   
@@ -4178,7 +4178,7 @@ void special_editmenu(Scene *scene, View3D *v3d)
                                DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
                        }
                }
-               else if(G.f & G_WEIGHTPAINT) {
+               else if(ob->mode & OB_MODE_WEIGHT_PAINT) {
                        Object *par= modifiers_isDeformedByArmature(ob);
 
                        if(par && (par->flag & OB_POSEMODE)) {
@@ -7043,5 +7043,7 @@ void ED_object_toggle_modes(bContext *C, int mode)
        if(mode & OB_MODE_SCULPT)
                WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
        if(mode & OB_MODE_VERTEX_PAINT)
-               WM_operator_name_call(C, "SCULPT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+               WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+       if(mode & OB_MODE_WEIGHT_PAINT)
+               WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 }
index 0ac9333aafcaac663967d3dc619635fa20aedc09..31e301f06bc25128b44862508127c1d8cb4abb0f 100644 (file)
@@ -128,7 +128,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
                return 1;
        }
        else if(CTX_data_equals(member, "weight_paint_object")) {
-               if(G.f & G_WEIGHTPAINT && scene->basact)
+               if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT))
                        CTX_data_id_pointer_set(result, &scene->basact->object->id);
 
                return 1;
index b8ee2710152bb67e44a08ec4abb008dda37d946b..8419c3fd1887b48010b3126469f262d271568ea9 100644 (file)
@@ -123,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);
@@ -1094,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,
@@ -1109,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)
@@ -1612,7 +1614,7 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
                
                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)
index d438490ff7e47b4e188045800c50334c73375dec..a1e1c589449cb0edbd8c4eb6e82d5654f1cb30d7 100644 (file)
@@ -325,7 +325,7 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
                        br= ts->sculpt->brush;
                else if(obact && obact->mode & OB_MODE_VERTEX_PAINT)
                        br= ts->vpaint->brush;
-               else if(G.f & G_WEIGHTPAINT)
+               else if(obact && obact->mode & OB_MODE_WEIGHT_PAINT)
                        br= ts->wpaint->brush;
                else if(G.f & G_TEXTUREPAINT)
                        br= ts->imapaint.brush;
index 5a9790390b78b1bf3c3b96918d4b291e1b2279d4..1f8314f9aae55f12b20009dcd4d813762b3fc208 100644 (file)
@@ -2530,7 +2530,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int
                                        if ((flag & DRAW_SCENESET)==0) {
                                                if(ob==OBACT) 
                                                        arm->flag |= ARM_POSEMODE;
-                                               else if(G.f & G_WEIGHTPAINT) {
+                                               else if(ob->mode & OB_MODE_WEIGHT_PAINT) {
                                                        if(OBACT && ob==modifiers_isDeformedByArmature(OBACT))
                                                                arm->flag |= ARM_POSEMODE;
                                                }
index 294d970b9fdc3ef0dffa651c028028649fe3baff..78ff84906d204edcb26ef3c21dc191cf3681b9ba 100644 (file)
@@ -563,7 +563,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
        if(ob == scene->obedit) {
                dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh);
        } else if(faceselect) {
-               if(G.f & G_WEIGHTPAINT)
+               if(ob->mode & OB_MODE_WEIGHT_PAINT)
                        dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1);
                else
                        dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me);
index 3f3cb401959f7c996befb8927acc9d6e2e948ee9..6a053d6f7da147c02706c505d8346a2c0980504a 100644 (file)
@@ -212,7 +212,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
                return 0;
        if(!CHECK_OB_DRAWTEXTURE(v3d, dt))
                return 0;
-       if(ob==OBACT && (G.f & G_WEIGHTPAINT))
+       if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
                return 0;
        
        return ((G.fileflags & G_FILE_GAME_MAT) &&
@@ -2328,7 +2328,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base
                
                if(ob==OBACT) {
                        do_draw= 0;
-                       if( (G.f & G_WEIGHTPAINT)) {
+                       if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
                                /* enforce default material settings */
                                GPU_enable_material(0, NULL);
                                
@@ -5073,7 +5073,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        dtx= 0;
 
        /* faceselect exception: also draw solid when dt==wire, except in editmode */
-       if(ob==OBACT && (G.f & (G_TEXTUREPAINT+G_WEIGHTPAINT) || ob->mode & OB_MODE_VERTEX_PAINT)) {
+       if(ob==OBACT && (G.f & G_TEXTUREPAINT || ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))) {
                if(ob->type==OB_MESH) {
 
                        if(ob==scene->obedit);
@@ -5711,7 +5711,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        if(G.f & G_RENDER_SHADOW) return;
 
        /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
-       if(ob!=OBACT || ((G.f & (G_TEXTUREPAINT|G_WEIGHTPAINT))==0) || ob->mode & OB_MODE_VERTEX_PAINT) {
+       if(ob!=OBACT || ((G.f & G_TEXTUREPAINT)==0) || !(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))) {
                int do_draw_center= -1; /* defines below are zero or positive... */
 
                if((scene->basact)==base) 
index 8057ed9f819bb0071c624dd6c0bbf62aa54e07b7..45d49f3964262f074397333aa5d78375edb1988f 100644 (file)
@@ -1058,7 +1058,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
 
 // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
        
-       if(ob->mode & OB_MODE_VERTEX_PAINT || G.f & (G_TEXTUREPAINT|G_WEIGHTPAINT)) {
+       if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) || G.f & G_TEXTUREPAINT) {
        }
        else {
                //bt= uiDefBut(block, TEX, B_IDNAME, "OB: ",    10,180,140,20, ob->id.name+2, 0.0, 21.0, 0, 0, "");
index c1f02c74460957c955794263f41b80b7c29b2bb0..54abe9e35ed8df21d1d4b86495339a7e255b7a80 100644 (file)
@@ -1103,9 +1103,8 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
        int m;
 #endif
 
-       if(G.f & G_WEIGHTPAINT ||
-          (base && (base->object->mode & OB_MODE_VERTEX_PAINT ||
-                    paint_facesel_test(base->object))));
+       if(base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) ||
+                    paint_facesel_test(base->object)));
        else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE));
        else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
        else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
@@ -1884,13 +1883,14 @@ static CustomDataMask get_viewedit_datamask(bScreen *screen, Object *ob)
        }
        
        /* check if we need mcols due to vertex paint or weightpaint */
-       if(ob && ob->mode & OB_MODE_VERTEX_PAINT)
-               mask |= CD_MASK_MCOL;
-       if(G.f & G_WEIGHTPAINT)
-               mask |= CD_MASK_WEIGHT_MCOL;
-       
-       if(ob && ob->mode & OB_MODE_SCULPT)
-               mask |= CD_MASK_MDISPS;
+       if(ob) {
+               if(ob->mode & OB_MODE_VERTEX_PAINT)
+                       mask |= CD_MASK_MCOL;
+               if(ob->mode & OB_MODE_WEIGHT_PAINT)
+                       mask |= CD_MASK_WEIGHT_MCOL;
+               if(ob->mode & OB_MODE_SCULPT)
+                       mask |= CD_MASK_MDISPS;
+       }
 
        return mask;
 }
@@ -2122,7 +2122,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        
        /* XXX here was the blockhandlers for floating panels */
 
-       if((ob && ob->mode & OB_MODE_VERTEX_PAINT) || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT) {
+       if((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) || G.f & G_TEXTUREPAINT) {
                v3d->flag |= V3D_NEEDBACKBUFDRAW;
                // XXX addafterqueue(ar->win, BACKBUFDRAW, 1);
        }
index 64e72399a065bcb86b5af22b33a71a9ccb47b0e1..f4b15647459f5e3bdd45ad2ff6b5e12732e27b14 100644 (file)
@@ -951,7 +951,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
 
        INIT_MINMAX(min, max);
 
-       if (G.f & G_WEIGHTPAINT) {
+       if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
                /* hardcoded exception, we look for the one selected armature */
                /* this is weak code this way, we should make a generic active/selection callback interface once... */
                Base *base;
index 26e2918c0328654aac1d5721b54d7f9882b03210..20ce252a4a39f9878f6a4067f8023dd0198a8329 100644 (file)
@@ -139,8 +139,6 @@ static void ED_toggle_paint_modes(bContext *C, int mode)
 {
        if(mode & G_TEXTUREPAINT)
                WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       else if(mode & G_WEIGHTPAINT)
-               WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 
        if(mode & G_PARTICLEEDIT)
                WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
@@ -153,7 +151,7 @@ int ED_view3d_exit_paint_modes(bContext *C)
 
        ED_toggle_paint_modes(C, G.f);
        
-       G.f &= ~(G_TEXTUREPAINT+G_WEIGHTPAINT+G_PARTICLEEDIT);
+       G.f &= ~(G_TEXTUREPAINT+G_PARTICLEEDIT);
 
        return restore;
 }
@@ -3467,7 +3465,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event)
                                v3d->flag &= ~V3D_MODE;
                                ED_view3d_exit_paint_modes(C);
                                ED_object_toggle_modes(C, ob->mode);
-                               if(obedit) ED_object_exit_editmode(C, EM_FREEUNDO|EM_FREEUNDO|EM_WAITCURSOR);   /* exit editmode and undo */
+                               if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);   /* exit editmode and undo */
                                        
                                WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
                        }
@@ -3493,7 +3491,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event)
                        }
                } 
                else if (v3d->modeselect == V3D_WEIGHTPAINTMODE_SEL) {
-                       if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) {
+                       if (ob && ob->type == OB_MESH && !(ob->mode & OB_MODE_WEIGHT_PAINT)) {
                                v3d->flag &= ~V3D_MODE;
                                ED_view3d_exit_paint_modes(C);
                                ED_object_toggle_modes(C, ob->mode);
@@ -3702,7 +3700,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
                }
                
        }
-       else if (G.f & G_WEIGHTPAINT) {
+       else if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
                xmax= GetButStringLength("Paint");
                uiDefPulldownBut(block, view3d_wpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, "");
                xco+= xmax;
@@ -3800,7 +3798,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
        if (obedit) v3d->modeselect = V3D_EDITMODE_SEL;
        else if(ob && (ob->flag & OB_POSEMODE)) v3d->modeselect = V3D_POSEMODE_SEL;
        else if (ob && (ob->mode & OB_MODE_SCULPT))  v3d->modeselect = V3D_SCULPTMODE_SEL;
-       else if (G.f & G_WEIGHTPAINT) v3d->modeselect = V3D_WEIGHTPAINTMODE_SEL;
+       else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) v3d->modeselect = V3D_WEIGHTPAINTMODE_SEL;
        else if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->modeselect = V3D_VERTEXPAINTMODE_SEL;
        else if (G.f & G_TEXTUREPAINT) v3d->modeselect = V3D_TEXTUREPAINTMODE_SEL;
        /*else if(G.f & G_FACESELECT) v3d->modeselect = V3D_FACESELECTMODE_SEL;*/
@@ -3812,7 +3810,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
        if(obedit) v3d->flag |= V3D_EDITMODE;
        if(ob && (ob->flag & OB_POSEMODE)) v3d->flag |= V3D_POSEMODE;
        if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->flag |= V3D_VERTEXPAINT;
-       if(G.f & G_WEIGHTPAINT) v3d->flag |= V3D_WEIGHTPAINT;
+       if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) v3d->flag |= V3D_WEIGHTPAINT;
        if (G.f & G_TEXTUREPAINT) v3d->flag |= V3D_TEXTUREPAINT;
        if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT;
        
@@ -3857,7 +3855,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                        uiBlockEndAlign(block);
                }
        } else {
-               if (obedit==NULL && ((ob && ob->mode & OB_MODE_VERTEX_PAINT) || G.f & (G_WEIGHTPAINT|G_TEXTUREPAINT))) {
+               if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) || G.f & G_TEXTUREPAINT)) {
                        uiDefIconButBitI(block, TOG, G_FACESELECT, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)");
                        header_xco_step(ar, &xco, &yco, &maxco, XIC+10);
                } else {
index a6a42c0ba677f9fa4059e48bab4002e184159b23..e810ea1f88280d91bb86b4b3d5feb6ad475bf2d2 100644 (file)
@@ -699,7 +699,7 @@ void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short
        if(vc->obedit==NULL) {
                if(paint_facesel_test(ob))
                        do_lasso_select_facemode(vc, mcords, moves, select);
-               else if(G.f & (G_TEXTUREPAINT|G_WEIGHTPAINT) || (ob && ob->mode & OB_MODE_VERTEX_PAINT))
+               else if(G.f & G_TEXTUREPAINT || (ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)))
                        ;
                else if(G.f & G_PARTICLEEDIT)
                        PE_lasso_select(C, mcords, moves, select);
@@ -1112,7 +1112,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter)
                                        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object);
                                        
                                        /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
-                                       if(G.f & G_WEIGHTPAINT) {
+                                       if(basact->object->mode & OB_MODE_WEIGHT_PAINT) {
                                                /* prevent activating */
                                                basact= NULL;
                                        }
index be677c8523d29ea69cffa0e2727158f90d8cd007..eac13245c23a86530b3c685ea72d97eb0b6f2b5b 100644 (file)
@@ -5239,7 +5239,7 @@ void createTransData(bContext *C, TransInfo *t)
                // XXX active-layer checking isn't done as that should probably be checked through context instead
                createTransPose(C, t, ob);
        }
-       else if (G.f & G_WEIGHTPAINT) {
+       else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
                /* exception, we look for the one selected armature */
                CTX_DATA_BEGIN(C, Object*, ob_armature, selected_objects)
                {
index be377f6af8397193f4aeb5fff12f79fca79f58a6..40966380ccaa29a0434c8e2c83eca7dc9af83e53 100644 (file)
@@ -358,10 +358,10 @@ int calc_manipulator_stats(const bContext *C)
                        Mat4MulVecfl(ob->obmat, scene->twmax);
                }
        }
-       else if(G.f & (G_TEXTUREPAINT + G_WEIGHTPAINT)) {
+       else if(G.f & G_TEXTUREPAINT) {
                ;
        }
-       else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT))) {
+       else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))) {
                ;
        }
        else if(G.f & G_PARTICLEEDIT) {
index 6ba67084387ded0e5a51faa579d420da18129ce0..9c142d2c650ef15971c8c71e697633ef226e86b2 100644 (file)
@@ -894,10 +894,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
                        result = ORIENTATION_EDGE;
                }
        }
-       else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT)))
+       else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)))
        {
        }
-       else if(G.f & (G_TEXTUREPAINT + G_WEIGHTPAINT))
+       else if(G.f & G_TEXTUREPAINT)
        {
        }
        else if(G.f & G_PARTICLEEDIT)
index 63037a8efe47062789e928b48a38b917b99d15af..5323514fcc6fbd90f187447ab756b82e4f100807 100644 (file)
@@ -515,6 +515,7 @@ extern Object workob;
 #define OB_MODE_NONE           0
 #define OB_MODE_SCULPT         1
 #define OB_MODE_VERTEX_PAINT   2
+#define OB_MODE_WEIGHT_PAINT   4
 
 /* ob->softflag in DNA_object_force.h */