Special Orange request; support for SoftBody Goal weights for Lattices.
Animating detailed clothes with softbody becomes messy, so now we'll try it this way. :) It simply uses the W (weight) value, as already available in each Lattice Point. Only had to make it editable; - NKey panel - or press W in editmode Further there's a minimalistic W button in the softbody Panel!
This commit is contained in:
@@ -1043,6 +1043,7 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff)
|
||||
static void lattice_to_softbody(Object *ob,int *rcs)
|
||||
{
|
||||
Lattice *lt= ob->data;
|
||||
SoftBody *sb= ob->soft;
|
||||
int totvert, totspring = 0;
|
||||
|
||||
totvert= lt->pntsu*lt->pntsv*lt->pntsw;
|
||||
@@ -1060,6 +1061,22 @@ static void lattice_to_softbody(Object *ob,int *rcs)
|
||||
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
|
||||
renew_softbody(ob, totvert, totspring,rcs);
|
||||
|
||||
/* weights from bpoints, same code used as for mesh vertices */
|
||||
if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) {
|
||||
BodyPoint *bp= sb->bpoint;
|
||||
BPoint *bpnt= lt->def;
|
||||
float goalfac= ABS(sb->maxgoal - sb->mingoal);
|
||||
int a;
|
||||
|
||||
for(a=0; a<totvert; a++, bp++, bpnt++) {
|
||||
|
||||
bp->goal= sb->mingoal + bpnt->vec[3]*goalfac;
|
||||
|
||||
/* a little ad hoc changing the goal control to be less *sharp* */
|
||||
bp->goal = (float)pow(bp->goal, 4.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/* create some helper edges to enable SB lattice to be usefull at all */
|
||||
if (ob->softflag & OB_SB_EDGES){
|
||||
makelatticesprings(lt,ob->soft->bspring,ob->softflag & OB_SB_QUADS);
|
||||
|
||||
@@ -1877,23 +1877,28 @@ static void object_softbodies(Object *ob)
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButBitS(block, TOG, OB_SB_GOAL, B_SOFTBODY_CHANGE, "Use Goal", 10,100,130,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
|
||||
|
||||
menustr= get_vertexgroup_menustr(ob);
|
||||
defCount=BLI_countlist(&ob->defbase);
|
||||
if(defCount==0) sb->vertgroup= 0;
|
||||
uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr, 140,100,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
|
||||
|
||||
if(sb->vertgroup) {
|
||||
bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
|
||||
if(defGroup)
|
||||
uiDefBut(block, BUT, B_DIFF, defGroup->name, 160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
|
||||
if(ob->type==OB_MESH) {
|
||||
menustr= get_vertexgroup_menustr(ob);
|
||||
defCount=BLI_countlist(&ob->defbase);
|
||||
if(defCount==0) sb->vertgroup= 0;
|
||||
uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr, 140,100,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
|
||||
MEM_freeN (menustr);
|
||||
|
||||
if(sb->vertgroup) {
|
||||
bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
|
||||
if(defGroup)
|
||||
uiDefBut(block, BUT, B_DIFF, defGroup->name, 160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
|
||||
else
|
||||
uiDefBut(block, BUT, B_DIFF, "(no group)", 160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
|
||||
uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,100,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
|
||||
}
|
||||
else
|
||||
uiDefBut(block, BUT, B_DIFF, "(no group)", 160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
|
||||
uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,100,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
|
||||
uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:", 160,100,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
|
||||
}
|
||||
else {
|
||||
uiDefButS(block, TOG, B_SOFTBODY_CHANGE, "W", 140,100,20,20, &sb->vertgroup, 0, 1, 0, 0, "Use Lattice weight values");
|
||||
uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:", 160,100,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
|
||||
}
|
||||
MEM_freeN (menustr);
|
||||
|
||||
uiDefButF(block, NUM, B_DIFF, "G Stiff:", 10,80,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) spring stiffness");
|
||||
uiDefButF(block, NUM, B_DIFF, "G Damp:", 160,80,150,20, &sb->goalfrict , 0.0, 10.0, 10, 0, "Goal (vertex target position) friction");
|
||||
|
||||
@@ -1298,7 +1298,9 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
|
||||
while(a--) {
|
||||
if(bp->f1 & SELECT) {
|
||||
VecAddf(median, median, bp->vec);
|
||||
median[3]+= bp->vec[3];
|
||||
tot++;
|
||||
totw++;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
@@ -1329,9 +1331,12 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex X:", 10, 110, 290, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Y:", 10, 90, 290, 19, &(ve_median[1]), -lim, lim, 10, 3, "");
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Z:", 10, 70, 290, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
|
||||
if(totw==1)
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 50, 290, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
|
||||
|
||||
if(totw==1) {
|
||||
if(ob->type==OB_LATTICE)
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 50, 290, 19, &(ve_median[3]), 0.0, 1.0, 10, 3, "");
|
||||
else
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 50, 290, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
|
||||
}
|
||||
if(defstr[0]) {
|
||||
uiDefBut(block, LABEL, 1, "Vertex Deform Groups", 10, 40, 290, 20, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
@@ -1344,8 +1349,12 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median X:", 10, 110, 290, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Y:", 10, 90, 290, 19, &(ve_median[1]), -lim, lim, 10, 3, "");
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Z:", 10, 70, 290, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
|
||||
if(totw==tot)
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median W:", 10, 50, 290, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
|
||||
if(totw==tot) {
|
||||
if(ob->type==OB_LATTICE)
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median W:", 10, 50, 290, 19, &(ve_median[3]), 0.0, 1.0, 10, 3, "");
|
||||
else
|
||||
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median W:", 10, 50, 290, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
|
||||
}
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
@@ -1457,8 +1466,8 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
|
||||
bp= editLatt->def;
|
||||
while(a--) {
|
||||
if(bp->f1 & SELECT) {
|
||||
VecAddf(median, median, bp->vec);
|
||||
VecAddf(bp->vec, bp->vec, median);
|
||||
bp->vec[3]+= median[3];
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
|
||||
@@ -2158,6 +2158,19 @@ void special_editmenu(void)
|
||||
else if(nr==2)
|
||||
armature_flip_names();
|
||||
}
|
||||
else if(G.obedit->type==OB_LATTICE) {
|
||||
static float weight= 1.0f;
|
||||
if(fbutton(&weight, 0.0f, 1.0f, 10, 10, "Set Weight")) {
|
||||
int a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
|
||||
BPoint *bp= editLatt->def;
|
||||
|
||||
while(a--) {
|
||||
if(bp->f1 & SELECT)
|
||||
bp->vec[3]= weight;
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
countall();
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
|
||||
@@ -1462,7 +1462,7 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i
|
||||
}
|
||||
static void do_lattice_box_select(rcti *rect, int select)
|
||||
{
|
||||
struct { rcti *rect; short select, pass, done; } data;
|
||||
struct { rcti *rect; int select, pass, done; } data;
|
||||
|
||||
data.rect = rect;
|
||||
data.select = select;
|
||||
|
||||
Reference in New Issue
Block a user