forked from bartvdbraak/blender
Another useful tool for efficient usage of WeightPaint:
Press SHIFT+LMB, and it shows a menu with all Vertex Groups the vertices of the indicated face has, also allowing selection of Groups.
This commit is contained in:
parent
de655553ab
commit
84f6642437
@ -813,12 +813,14 @@ static MDeformWeight *get_defweight(MDeformVert *dv, int defgroup)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* used for 3d view */
|
/* used for 3d view, on active object, assumes me->dvert exists */
|
||||||
/* cant sample frontbuf, weight colors are interpolated too unpredictable */
|
/* if mode==1: */
|
||||||
/* so we return the closest value to vertex, wich is actually correct anyway */
|
/* samples cursor location, and gives menu with vertex groups to activate */
|
||||||
void sample_wpaint()
|
/* else */
|
||||||
|
/* sets editbutvweight to the closest weight value to vertex */
|
||||||
|
/* note: we cant sample frontbuf, weight colors are interpolated too unpredictable */
|
||||||
|
static void sample_wpaint(int mode)
|
||||||
{
|
{
|
||||||
extern float editbutvweight;
|
|
||||||
Object *ob= OBACT;
|
Object *ob= OBACT;
|
||||||
Mesh *me= get_mesh(ob);
|
Mesh *me= get_mesh(ob);
|
||||||
int index;
|
int index;
|
||||||
@ -829,15 +831,82 @@ void sample_wpaint()
|
|||||||
|
|
||||||
if(index && index<=me->totface) {
|
if(index && index<=me->totface) {
|
||||||
MFace *mface;
|
MFace *mface;
|
||||||
|
|
||||||
|
mface= ((MFace *)me->mface) + index-1;
|
||||||
|
|
||||||
|
if(mode==1) { /* sampe which groups are in here */
|
||||||
|
MDeformVert *dv;
|
||||||
|
int a, totgroup;
|
||||||
|
|
||||||
|
totgroup= BLI_countlist(&ob->defbase);
|
||||||
|
if(totgroup) {
|
||||||
|
int totmenu=0;
|
||||||
|
int *groups=MEM_callocN(totgroup*sizeof(int), "groups");
|
||||||
|
|
||||||
|
dv= me->dvert+mface->v1;
|
||||||
|
for(a=0; a<dv->totweight; a++) {
|
||||||
|
if (dv->dw[a].def_nr<totgroup)
|
||||||
|
groups[dv->dw[a].def_nr]= 1;
|
||||||
|
}
|
||||||
|
dv= me->dvert+mface->v2;
|
||||||
|
for(a=0; a<dv->totweight; a++) {
|
||||||
|
if (dv->dw[a].def_nr<totgroup)
|
||||||
|
groups[dv->dw[a].def_nr]= 1;
|
||||||
|
}
|
||||||
|
dv= me->dvert+mface->v3;
|
||||||
|
for(a=0; a<dv->totweight; a++) {
|
||||||
|
if (dv->dw[a].def_nr<totgroup)
|
||||||
|
groups[dv->dw[a].def_nr]= 1;
|
||||||
|
}
|
||||||
|
if(mface->v4) {
|
||||||
|
dv= me->dvert+mface->v4;
|
||||||
|
for(a=0; a<dv->totweight; a++) {
|
||||||
|
if (dv->dw[a].def_nr<totgroup)
|
||||||
|
groups[dv->dw[a].def_nr]= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(a=0; a<totgroup; a++)
|
||||||
|
if(groups[a]) totmenu++;
|
||||||
|
|
||||||
|
if(totmenu==0) {
|
||||||
|
notice("No Vertex Group Selected");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bDeformGroup *dg;
|
||||||
|
short val;
|
||||||
|
char item[40], *str= MEM_mallocN(40*totmenu+40, "menu");
|
||||||
|
|
||||||
|
strcpy(str, "Vertex Groups %t");
|
||||||
|
for(a=0, dg=ob->defbase.first; dg && a<totgroup; a++, dg= dg->next) {
|
||||||
|
if(groups[a]) {
|
||||||
|
sprintf(item, "|%s %%x%d", dg->name, a);
|
||||||
|
strcat(str, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val= pupmenu(str);
|
||||||
|
if(val>=0) {
|
||||||
|
ob->actdef= val+1;
|
||||||
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||||
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
|
allqueue(REDRAWOOPS, 0);
|
||||||
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
|
}
|
||||||
|
MEM_freeN(str);
|
||||||
|
}
|
||||||
|
MEM_freeN(groups);
|
||||||
|
}
|
||||||
|
else notice("No Vertex Groups in Object");
|
||||||
|
}
|
||||||
|
else {
|
||||||
DerivedMesh *dm;
|
DerivedMesh *dm;
|
||||||
MDeformWeight *dw;
|
MDeformWeight *dw;
|
||||||
|
extern float editbutvweight;
|
||||||
float w1, w2, w3, w4, co[3], fac;
|
float w1, w2, w3, w4, co[3], fac;
|
||||||
int needsFree;
|
int needsFree;
|
||||||
|
|
||||||
dm = mesh_get_derived_deform(ob, &needsFree);
|
dm = mesh_get_derived_deform(ob, &needsFree);
|
||||||
|
|
||||||
mface= ((MFace *)me->mface) + index-1;
|
|
||||||
|
|
||||||
/* calc 3 or 4 corner weights */
|
/* calc 3 or 4 corner weights */
|
||||||
dm->getVertCo(dm, mface->v1, co);
|
dm->getVertCo(dm, mface->v1, co);
|
||||||
project_short_noclip(co, sco);
|
project_short_noclip(co, sco);
|
||||||
@ -877,9 +946,9 @@ void sample_wpaint()
|
|||||||
if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f;
|
if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsFree)
|
if (needsFree)
|
||||||
dm->release(dm);
|
dm->release(dm);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
allqueue(REDRAWBUTSEDIT, 0);
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
@ -936,7 +1005,11 @@ void weight_paint(void)
|
|||||||
create_dverts(me);
|
create_dverts(me);
|
||||||
|
|
||||||
if(G.qual & LR_CTRLKEY) {
|
if(G.qual & LR_CTRLKEY) {
|
||||||
sample_wpaint();
|
sample_wpaint(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(G.qual & LR_SHIFTKEY) {
|
||||||
|
sample_wpaint(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,7 +1245,6 @@ void weight_paint(void)
|
|||||||
if(ob->soft) ob->softflag |= OB_SB_REDO;
|
if(ob->soft) ob->softflag |= OB_SB_REDO;
|
||||||
|
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vertex_paint()
|
void vertex_paint()
|
||||||
|
Loading…
Reference in New Issue
Block a user