Made weight-painting more bearable :)
authorTon Roosendaal <ton@blender.org>
Sun, 21 Aug 2005 20:09:50 +0000 (20:09 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 21 Aug 2005 20:09:50 +0000 (20:09 +0000)
- Hotkey CTRL+TAB toggles weightpaint on/off
- If Mesh has no vertex groups yet, it still accepts Weight Paint mode.
  Then, on a first painting stroke it creates a default group.
- When combining WeightPaint mode with Bone selecting, if you select a
  Bone without vertex group it draws Mesh dark blue. On a first painting
  stroke it then also creates a new group, with the Bone name.

source/blender/src/drawview.c
source/blender/src/editdeform.c
source/blender/src/header_view3d.c
source/blender/src/toets.c
source/blender/src/vpaint.c

index 7de9ed966e24ec6c93a98749c1ea2d5ac041b7c5..7f293e5f07b13f354d0b83329dcc2da6015af3f2 100644 (file)
@@ -1178,9 +1178,7 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
        tot= totw= totedge= 0;
        defstr[0]= 0;
 
        tot= totw= totedge= 0;
        defstr[0]= 0;
 
-       if(ob->type==OB_MESH) {
-               Mesh *me= ob->data;
-               
+       if(ob->type==OB_MESH) {         
                eve= em->verts.first;
                while(eve) {
                        if(eve->f & 1) {
                eve= em->verts.first;
                while(eve) {
                        if(eve->f & 1) {
index 053151e5c4b00403eab3c19e458c11b9ced6107f..97988a5c47c0df9ec3d8b0fa237654aea45da3a9 100644 (file)
@@ -621,8 +621,10 @@ void vertexgroup_select_by_name(Object *ob, char *name)
        for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++){
                if (!strcmp(curdef->name, name)) {
                        ob->actdef= actdef;
        for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++){
                if (!strcmp(curdef->name, name)) {
                        ob->actdef= actdef;
+                       return;
                }
        }
                }
        }
+       ob->actdef=0;   // this signals on painting to create a new one, if a bone in posemode is selected */
 }
 
 
 }
 
 
index fa26a05f3860f18496dafa4d1a8682369a05793c..8eff5296fe49948d5d408368d7e9bfbd673625db 100644 (file)
@@ -3643,11 +3643,8 @@ static char *view3d_modeselect_pup(void)
                strcat(string, tempstr);
                sprintf(tempstr, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT);
                strcat(string, tempstr);
                strcat(string, tempstr);
                sprintf(tempstr, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT);
                strcat(string, tempstr);
-
-               if ( ((Mesh*)(ob->data))->dvert)  {
-                       sprintf(tempstr, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT);
-                       strcat(string, tempstr);
-               }
+               sprintf(tempstr, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT);
+               strcat(string, tempstr);
        }
 
        
        }
 
        
@@ -3836,7 +3833,7 @@ void do_view3d_buttons(short event)
                        }
                } 
                else if (G.vd->modeselect == V3D_WEIGHTPAINTMODE_SEL) {
                        }
                } 
                else if (G.vd->modeselect == V3D_WEIGHTPAINTMODE_SEL) {
-                       if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) && ((((Mesh*)(ob->data))->dvert))) {
+                       if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) {
                                G.vd->flag &= ~V3D_MODE;
                                G.f &= ~G_VERTEXPAINT;          /* Switch off vertex paint */
                                G.f &= ~G_TEXTUREPAINT;         /* Switch off texture paint */
                                G.vd->flag &= ~V3D_MODE;
                                G.f &= ~G_VERTEXPAINT;          /* Switch off vertex paint */
                                G.f &= ~G_TEXTUREPAINT;         /* Switch off texture paint */
index 4743e5ce80b85b58d3ddf5a63bf5f6a80fb52ad2..d1b0844647e4c8a65e53736c3ac1df4ecfcac59c 100644 (file)
@@ -767,6 +767,7 @@ int blenderqread(unsigned short event, short val)
                                }
                                else if(ob->type==OB_MESH) {
                                        if(ob==G.obedit) EM_selectmode_menu();
                                }
                                else if(ob->type==OB_MESH) {
                                        if(ob==G.obedit) EM_selectmode_menu();
+                                       else set_wpaint();
                                }
                        }
                }
                                }
                        }
                }
index ea20b1f99569c716ea6f5c0d059b8a5f32da3392..01a2e987a7334b919c46cb337a9ba5c54f7da335 100644 (file)
@@ -51,6 +51,8 @@
 #include "BLI_arithb.h"
 #include "MTC_matrixops.h"
 
 #include "BLI_arithb.h"
 #include "MTC_matrixops.h"
 
+#include "DNA_action_types.h"
+#include "DNA_armature_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
@@ -62,6 +64,7 @@
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_depsgraph.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_depsgraph.h"
+#include "BKE_deform.h"
 #include "BKE_displist.h"
 #include "BKE_global.h"
 #include "BKE_mesh.h"
 #include "BKE_displist.h"
 #include "BKE_global.h"
 #include "BKE_mesh.h"
@@ -931,10 +934,33 @@ void weight_paint(void)
        if(ob->id.lib) return;
 
        me= get_mesh(ob);
        if(ob->id.lib) return;
 
        me= get_mesh(ob);
-       if (!me->dvert){
-               return;
+       if(me==NULL || me->totface==0) return;
+       
+       /* if nothing was added yet, we make dverts and a vertex deform group */
+       if (!me->dvert)
+               create_dverts(me);
+       if(ob->defbase.first==NULL) {
+               add_defgroup(ob);
+               allqueue(REDRAWBUTSEDIT, 0);
+       }       
+       /* this happens on a Bone select, when no vgroup existed yet */
+       if(ob->actdef==0) {
+               if(ob->parent && (ob->parent->flag & OB_POSEMODE)) {
+                       bPoseChannel *pchan;
+                       for(pchan= ob->parent->pose->chanbase.first; pchan; pchan= pchan->next)
+                               if(pchan->bone->flag & SELECT)
+                                       break;
+                       if(pchan) {
+                               bDeformGroup *dg= get_named_vertexgroup(ob, pchan->name);
+                               if(dg==NULL)
+                                       dg= add_defgroup_name(ob, pchan->name); // sets actdef
+                               else
+                                       ob->actdef= get_defgroup_num(ob, dg);
+                               allqueue(REDRAWBUTSEDIT, 0);
+                       }
+               }
        }
        }
-       if(me==0 || me->totface==0) return;
+       
        if(ob->lay & G.vd->lay); else error("Active object is not in this layer");
        
        persp(PERSP_VIEW);
        if(ob->lay & G.vd->lay); else error("Active object is not in this layer");
        
        persp(PERSP_VIEW);
@@ -1319,8 +1345,6 @@ void set_wpaint(void)             /* toggle */
                return;
        }
        
                return;
        }
        
-//     if(me && me->tface==NULL && me->mcol==NULL) make_vertexcol();
-       
        if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT;
        else G.f |= G_WEIGHTPAINT;
        
        if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT;
        else G.f |= G_WEIGHTPAINT;