forked from bartvdbraak/blender
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:
parent
d2f6ff1900
commit
5a381a5a12
@ -1179,8 +1179,6 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
|
||||
defstr[0]= 0;
|
||||
|
||||
if(ob->type==OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
|
||||
eve= em->verts.first;
|
||||
while(eve) {
|
||||
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++){
|
||||
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 */
|
||||
}
|
||||
|
||||
|
||||
|
@ -3643,12 +3643,9 @@ static char *view3d_modeselect_pup(void)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if active object is an armature */
|
||||
@ -3836,7 +3833,7 @@ void do_view3d_buttons(short event)
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
@ -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 set_wpaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@
|
||||
#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"
|
||||
@ -62,6 +64,7 @@
|
||||
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_deform.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 (!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);
|
||||
}
|
||||
if(me==0 || me->totface==0) return;
|
||||
/* 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(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;
|
||||
}
|
||||
|
||||
// if(me && me->tface==NULL && me->mcol==NULL) make_vertexcol();
|
||||
|
||||
if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT;
|
||||
else G.f |= G_WEIGHTPAINT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user