softbodies
mostly reshuffeling UI to have things where i'd expect them to be
This commit is contained in:
@@ -680,18 +680,34 @@ static void calculate_collision_balls(Object *ob)
|
||||
BodyPoint *bp;
|
||||
BodySpring *bs;
|
||||
int a,b;
|
||||
float min,max;
|
||||
|
||||
if (sb==NULL) return; /* paranoya check */
|
||||
|
||||
for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
||||
bp->colball=0;
|
||||
min = 1e22f;
|
||||
max = -1e22f;
|
||||
/* first estimation based on attached */
|
||||
for(b=bp->nofsprings;b>0;b--){
|
||||
bs = sb->bspring + bp->springs[b-1];
|
||||
bp->colball += bs->len;
|
||||
min = MIN2(bs->len,min);
|
||||
max = MAX2(bs->len,max);
|
||||
}
|
||||
|
||||
if (bp->nofsprings != 0) {
|
||||
/*bp->colball /= bp->nofsprings;*/
|
||||
bp->colball = (min + max)/2.0f;
|
||||
if (sb->colball > 0.0f){
|
||||
bp->colball=sb->colball;
|
||||
}
|
||||
if (sb->colball == -1.0f){
|
||||
bp->colball=max;
|
||||
}
|
||||
}
|
||||
if (bp->nofsprings != 0) bp->colball /= bp->nofsprings;
|
||||
else bp->colball=0;
|
||||
/* printf("collision ballsize %f \n",bp->colball); */
|
||||
printf("collision ballsize %f \n",bp->colball);
|
||||
}/*for bp*/
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef struct SoftBody {
|
||||
SBVertex **keys; /* array of size totpointkey */
|
||||
int totpointkey, totkey; /* if totpointkey != totpoint or totkey!- (efra-sfra)/interval -> free keys */
|
||||
float secondspring;
|
||||
float pad3; /* local==1: use local coords for baking */
|
||||
float colball; /* fixed collision ball zize if > 0 */
|
||||
} SoftBody;
|
||||
|
||||
/* pd->forcefield: Effector Fields types */
|
||||
@@ -124,6 +124,7 @@ typedef struct SoftBody {
|
||||
#define OB_SB_BAKEDO 128
|
||||
#define OB_SB_RESET 256
|
||||
#define OB_SB_SELF 512
|
||||
#define OB_SB_COLLISIONSET 1024
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -2249,29 +2249,33 @@ static void object_softbodies__enable(void *ob_v, void *arg2)
|
||||
static void object_softbodies(Object *ob)
|
||||
{
|
||||
uiBlock *block;
|
||||
static int val;
|
||||
uiBut *but;
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "object_softbodies", UI_EMBOSS, UI_HELV, curarea->win);
|
||||
if(uiNewPanel(curarea, block, "Soft Body", "Physics", 640, 0, 318, 204)==0) return;
|
||||
|
||||
if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
|
||||
|
||||
/* do not allow to combine with force fields */
|
||||
/* if(ob->pd && ob->pd->deflect) { */
|
||||
/* no reason for that any more BM */
|
||||
if(0) {
|
||||
uiDefBut(block, LABEL, 0, "Object has Deflection,", 10,160,300,20, NULL, 0.0, 0, 0, 0, "");
|
||||
uiDefBut(block, LABEL, 0, "no Soft Body possible", 10,140,300,20, NULL, 0.0, 0, 0, 0, "");
|
||||
} else {
|
||||
static int val;
|
||||
uiBut *but;
|
||||
|
||||
val = modifiers_isSoftbodyEnabled(ob);
|
||||
but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Enable Soft Body", 10,200,150,20, &val, 0, 0, 0, 0, "Sets object to become soft body");
|
||||
but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Soft Body", 10,200,70,20, &val, 0, 0, 0, 0, "Sets object to become soft body");
|
||||
uiButSetFunc(but, object_softbodies__enable, ob, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 160, 200,150,20, NULL, 0.0, 0.0, 0, 0, ""); // alignment reason
|
||||
}
|
||||
|
||||
if(modifiers_isSoftbodyEnabled(ob)) {
|
||||
if(!modifiers_isSoftbodyEnabled(ob)) {
|
||||
uiDefButBitS(block, TOG, OB_SB_COLLISIONSET, REDRAWBUTSOBJECT, "Collision", 90,200,70,20, &ob->softflag, 0, 0, 0, 0, "Collision Settings");
|
||||
uiDefBut(block, LABEL, 0, "",0,0,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 0,0*/
|
||||
if(ob->pd && (ob->softflag & OB_SB_COLLISIONSET)){
|
||||
/* OTHER OBJECTS COLLISION STUFF */
|
||||
uiDefButBitS(block, TOG, 1, B_REDR, "Visible",10,40,150,20, &ob->pd->deflect, 0, 0, 0, 0, "Makes this object visible to softbody objects");
|
||||
if(ob->pd->deflect) {
|
||||
uiDefButF(block, NUM, B_DIFF, "Damping:", 160,40,150,20, &ob->pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
|
||||
uiDefButF(block, NUM, B_DIFF, "Inner:", 160,20,150,20, &ob->pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
|
||||
uiDefButF(block, NUM, B_DIFF, "Outer:", 160, 0,150,20, &ob->pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
SoftBody *sb= ob->soft;
|
||||
int defCount;
|
||||
char *menustr;
|
||||
@@ -2281,6 +2285,8 @@ static void object_softbodies(Object *ob)
|
||||
ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
|
||||
}
|
||||
|
||||
uiDefButBitS(block, TOG, OB_SB_COLLISIONSET, REDRAWBUTSOBJECT, "Collision", 90,200,70,20, &ob->softflag, 0, 0, 0, 0, "Collision Settings");
|
||||
|
||||
uiDefButBitS(block, TOG, OB_SB_BAKESET, REDRAWBUTSOBJECT, "Bake settings", 180,200,130,20, &ob->softflag, 0, 0, 0, 0, "To convert simulation into baked (cached) result");
|
||||
|
||||
if(sb->keys) uiSetButLock(1, "Soft Body is baked, free it first");
|
||||
@@ -2294,6 +2300,7 @@ static void object_softbodies(Object *ob)
|
||||
|
||||
uiDefButS(block, TOG, B_DIFF, "Local", 10, 145,100,20, &sb->local, 0.0, 0.0, 0, 0, "Use local coordinates for baking");
|
||||
|
||||
|
||||
uiClearButLock();
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
@@ -2305,6 +2312,22 @@ static void object_softbodies(Object *ob)
|
||||
}
|
||||
else
|
||||
uiDefBut(block, BUT, B_SOFTBODY_BAKE, "BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 10, 0, "Start baking. Press ESC to exit without baking");
|
||||
|
||||
}
|
||||
else {
|
||||
if(ob->softflag & OB_SB_COLLISIONSET) {
|
||||
/* COLLISION STUFF */
|
||||
uiDefButBitS(block, TOG, OB_SB_SELF, B_DIFF, "Self Collision", 10,170,90,20, &ob->softflag, 0, 0, 0, 0, "enable naive vertex ball self collision");
|
||||
uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Self RT:", 110,170,170,20, &sb->colball, -10.0, 10.0, 10, 0, "Experimental Self coll ==0 off; >0 set collision ball manual; -1 use longest attached spring for ball radius");
|
||||
/* OTHER OBJECTS COLLISION STUFF */
|
||||
uiDefButBitS(block, TOG, 1, B_REDR, "Visible",10,40,150,20, &ob->pd->deflect, 0, 0, 0, 0, "Makes this object visible to other softbody objects");
|
||||
if(ob->pd->deflect) {
|
||||
uiDefButF(block, NUM, B_DIFF, "Damping:", 160,40,150,20, &ob->pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
|
||||
uiDefButF(block, NUM, B_DIFF, "Inner:", 160,20,150,20, &ob->pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
|
||||
uiDefButF(block, NUM, B_DIFF, "Outer:", 160, 0,150,20, &ob->pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
|
||||
}
|
||||
uiDefBut(block, LABEL, 0, "",0,0,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 0,0*/
|
||||
|
||||
}
|
||||
else {
|
||||
/* GENERAL STUFF */
|
||||
@@ -2357,13 +2380,14 @@ static void object_softbodies(Object *ob)
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButBitS(block, TOG, OB_SB_EDGES, B_SOFTBODY_CHANGE, "Use Edges", 10,30,90,20, &ob->softflag, 0, 0, 0, 0, "Use Edges as springs");
|
||||
uiDefButBitS(block, TOG, OB_SB_QUADS, B_SOFTBODY_CHANGE, "Stiff Quads", 110,30,90,20, &ob->softflag, 0, 0, 0, 0, "Adds diagonal springs on 4-gons");
|
||||
uiDefButBitS(block, TOG, OB_SB_SELF, B_DIFF, "Self Collision", 220,30,90,20, &ob->softflag, 0, 0, 0, 0, "Use Edges as springs");
|
||||
/* uiDefButBitS(block, TOG, OB_SB_SELF, B_DIFF, "Self Collision", 220,30,90,20, &ob->softflag, 0, 0, 0, 0, ""); */
|
||||
uiDefButF(block, NUM, B_DIFF, "E Stiff:", 10,10,150,20, &sb->inspring, 0.0, 0.999, 10, 0, "Edge spring stiffness");
|
||||
uiDefButF(block, NUM, B_DIFF, "E Damp:", 160,10,150,20, &sb->infrict, 0.0, 50.0, 10, 0, "Edge spring friction");
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user