Made weight-painting more bearable :)

- 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.
This commit is contained in:
Ton Roosendaal 2005-08-21 20:09:50 +00:00
parent d2f6ff1900
commit 5a381a5a12
5 changed files with 36 additions and 14 deletions

@ -1178,9 +1178,7 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
tot= totw= totedge= 0; tot= totw= totedge= 0;
defstr[0]= 0; defstr[0]= 0;
if(ob->type==OB_MESH) { if(ob->type==OB_MESH) {
Mesh *me= ob->data;
eve= em->verts.first; eve= em->verts.first;
while(eve) { while(eve) {
if(eve->f & 1) { if(eve->f & 1) {

@ -621,8 +621,10 @@ void vertexgroup_select_by_name(Object *ob, char *name)
for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++){ for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++){
if (!strcmp(curdef->name, name)) { if (!strcmp(curdef->name, name)) {
ob->actdef= actdef; ob->actdef= actdef;
return;
} }
} }
ob->actdef=0; // this signals on painting to create a new one, if a bone in posemode is selected */
} }

@ -3643,11 +3643,8 @@ static char *view3d_modeselect_pup(void)
strcat(string, tempstr); strcat(string, tempstr);
sprintf(tempstr, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT); sprintf(tempstr, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT);
strcat(string, tempstr); strcat(string, tempstr);
sprintf(tempstr, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT);
if ( ((Mesh*)(ob->data))->dvert) { 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.vd->flag &= ~V3D_MODE;
G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */ G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */
G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */ G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */

@ -767,6 +767,7 @@ int blenderqread(unsigned short event, short val)
} }
else if(ob->type==OB_MESH) { else if(ob->type==OB_MESH) {
if(ob==G.obedit) EM_selectmode_menu(); if(ob==G.obedit) EM_selectmode_menu();
else set_wpaint();
} }
} }
} }

@ -51,6 +51,8 @@
#include "BLI_arithb.h" #include "BLI_arithb.h"
#include "MTC_matrixops.h" #include "MTC_matrixops.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h" #include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h" #include "DNA_meshdata_types.h"
#include "DNA_object_types.h" #include "DNA_object_types.h"
@ -62,6 +64,7 @@
#include "BKE_DerivedMesh.h" #include "BKE_DerivedMesh.h"
#include "BKE_depsgraph.h" #include "BKE_depsgraph.h"
#include "BKE_deform.h"
#include "BKE_displist.h" #include "BKE_displist.h"
#include "BKE_global.h" #include "BKE_global.h"
#include "BKE_mesh.h" #include "BKE_mesh.h"
@ -931,10 +934,33 @@ void weight_paint(void)
if(ob->id.lib) return; if(ob->id.lib) return;
me= get_mesh(ob); me= get_mesh(ob);
if (!me->dvert){ if(me==NULL || me->totface==0) return;
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"); if(ob->lay & G.vd->lay); else error("Active object is not in this layer");
persp(PERSP_VIEW); 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; if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT;
else G.f |= G_WEIGHTPAINT; else G.f |= G_WEIGHTPAINT;