diff options
author | Jens Ole Wund <bjornmose@gmx.net> | 2006-10-02 01:49:10 +0400 |
---|---|---|
committer | Jens Ole Wund <bjornmose@gmx.net> | 2006-10-02 01:49:10 +0400 |
commit | ab92fca3062356572a695225fa4389419ac25029 (patch) | |
tree | d6cb4d7ecc3235d51396c3db657fc9359db782ac /source | |
parent | 1ea97e5552bfb9c9845a7cfc5e0a2ce5ecf23cb4 (diff) |
softbodies
mostly reshuffeling UI to have things where i'd expect them to be
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 24 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_force.h | 3 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 168 |
3 files changed, 118 insertions, 77 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index eed086035ca..e97d0396499 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -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*/ } diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 0508d7bac60..4af5c356a30 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -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 } diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 749ff17c4e9..3597f71dec6 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -2249,54 +2249,61 @@ 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"); - uiButSetFunc(but, object_softbodies__enable, ob, NULL); - uiDefBut(block, LABEL, 0, "", 160, 200,150,20, NULL, 0.0, 0.0, 0, 0, ""); // alignment reason + val = modifiers_isSoftbodyEnabled(ob); + 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)) { + 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"); + } + } } - - if(modifiers_isSoftbodyEnabled(ob)) { + else { SoftBody *sb= ob->soft; int defCount; char *menustr; - + if(sb==NULL) { sb= ob->soft= sbNew(); 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"); - + if(ob->softflag & OB_SB_BAKESET) { uiBlockBeginAlign(block); uiDefButI(block, NUM, B_DIFF, "Start:", 10, 170,100,20, &sb->sfra, 1.0, 10000.0, 10, 0, "Start frame for baking"); uiDefButI(block, NUM, B_DIFF, "End:", 110, 170,100,20, &sb->efra, 1.0, 10000.0, 10, 0, "End frame for baking"); uiDefButI(block, NUM, B_DIFF, "Interval:", 210, 170,100,20, &sb->interval, 1.0, 10.0, 10, 0, "Interval in frames between baked keys"); uiBlockEndAlign(block); - + 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); - + if(sb->keys) { char str[128]; uiDefIconTextBut(block, BUT, B_SOFTBODY_BAKE_FREE, ICON_X, "FREE BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 0, 0, "Free baked result"); @@ -2305,62 +2312,79 @@ 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 { - /* GENERAL STUFF */ - uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_DIFF, "Friction:", 10, 170,150,20, &sb->mediafrict, 0.0, 50.0, 10, 0, "General media friction for point movements"); - uiDefButF(block, NUM, B_DIFF, "Mass:", 160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower"); - uiDefButF(block, NUM, B_DIFF, "Grav:", 10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement"); - uiDefButF(block, NUM, B_DIFF, "Speed:", 160,150,150,20, &sb->physics_speed , 0.01, 100.0, 10, 0, "Tweak timing for physics to control frequency and speed"); - uiDefButF(block, NUM, B_DIFF, "Error Limit:", 10,130,150,20, &sb->rklimit , 0.01, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision"); - if(ob->type==OB_MESH) { - uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Rigidity:", 160,130,150,20, &sb->secondspring, 0.0, 10.0, 10, 0, "Strenght of Springs over 2 Edges"); - } - uiBlockEndAlign(block); - - /* GOAL STUFF */ - 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"); - - 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"); + 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"); } - else - 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"); + uiDefBut(block, LABEL, 0, "",0,0,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 0,0*/ + } else { - uiDefButS(block, TOG, B_SOFTBODY_CHANGE, "W", 140,100,20,20, &sb->vertgroup, 0, 1, 0, 0, "Use control point 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"); - } + /* GENERAL STUFF */ + uiBlockBeginAlign(block); + uiDefButF(block, NUM, B_DIFF, "Friction:", 10, 170,150,20, &sb->mediafrict, 0.0, 50.0, 10, 0, "General media friction for point movements"); + uiDefButF(block, NUM, B_DIFF, "Mass:", 160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower"); + uiDefButF(block, NUM, B_DIFF, "Grav:", 10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement"); + uiDefButF(block, NUM, B_DIFF, "Speed:", 160,150,150,20, &sb->physics_speed , 0.01, 100.0, 10, 0, "Tweak timing for physics to control frequency and speed"); + uiDefButF(block, NUM, B_DIFF, "Error Limit:", 10,130,150,20, &sb->rklimit , 0.01, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision"); + if(ob->type==OB_MESH) { + uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Rigidity:", 160,130,150,20, &sb->secondspring, 0.0, 10.0, 10, 0, "Strenght of Springs over 2 Edges"); + } + uiBlockEndAlign(block); - 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, 50.0, 10, 0, "Goal (vertex target position) friction"); - uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Min:", 10,60,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Goal minimum, vertex group weights are scaled to match this range"); - uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Max:", 160,60,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range"); - uiBlockEndAlign(block); - - /* EDGE SPRING STUFF */ - if(ob->type!=OB_SURF) { + /* GOAL STUFF */ 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"); - 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"); + 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"); + + 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 + 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 control point 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"); + } + + 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, 50.0, 10, 0, "Goal (vertex target position) friction"); + uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Min:", 10,60,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Goal minimum, vertex group weights are scaled to match this range"); + uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Max:", 160,60,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range"); uiBlockEndAlign(block); + + /* EDGE SPRING STUFF */ + if(ob->type!=OB_SURF) { + 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, ""); */ + 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); + } } } } |