diff options
author | Ton Roosendaal <ton@blender.org> | 2005-08-22 00:09:50 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-08-22 00:09:50 +0400 |
commit | 5a381a5a1222e3774df77d8223c3c0ee332260f2 (patch) | |
tree | 9ab3aad257e41aab7c0d5127d40504df6b308d32 /source/blender/src/vpaint.c | |
parent | d2f6ff1900aa859483d186ed2321af245e93cd83 (diff) |
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.
Diffstat (limited to 'source/blender/src/vpaint.c')
-rw-r--r-- | source/blender/src/vpaint.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index ea20b1f9956..01a2e987a73 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -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); + } + /* 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); @@ -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; |