diff options
author | Jens Ole Wund <bjornmose@gmx.net> | 2006-11-16 23:57:02 +0300 |
---|---|---|
committer | Jens Ole Wund <bjornmose@gmx.net> | 2006-11-16 23:57:02 +0300 |
commit | 85615f7ac865c98a500c5653fea0dbcfd654a59d (patch) | |
tree | 6fc2b6974fb75e064a6c0ef58d8761d7708d0fc5 | |
parent | 7686e2cc5c1fba8ed8c2a9b4fc2698fb10e12f9f (diff) |
More Softbodies
Added a less 'strict' solver step size control.
Cuts down needed loops to a 1/5 in 'regular' collision situations.
So why be a maths smartass when we want to do a skirt in a breeze :)
Is on by default, old mode can be turned on with the 'O' button beside the RK-limit.
Some minor fixes to the UI
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 18 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_force.h | 1 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 14 |
3 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 9484ae8d969..11e7b5b3751 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2154,6 +2154,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow) /* gravitation */ bp->force[2]-= gravity*sb->nodemass; /* individual mass of node here */ + /* particle field & vortex */ if(do_effector) { @@ -2306,8 +2307,8 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f; /* claim a minimum mass for vertex */ - if (sb->nodemass > 0.09999f) timeovermass = forcetime/sb->nodemass; - else timeovermass = forcetime/0.09999f; + if (sb->nodemass > 0.009999f) timeovermass = forcetime/sb->nodemass; + else timeovermass = forcetime/0.009999f; for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { if(bp->goal < SOFTGOALSNAP){ @@ -2391,7 +2392,10 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * } if (err){ /* so step size will be controlled by biggest difference in slope */ + if (sb->solverflags & SBSO_OLDERR) *err = MAX2(maxerrpos,maxerrvel); + else + *err = maxerrpos; //printf("EP %f EV %f \n",maxerrpos,maxerrvel); if (fuzzy){ *err /= sb->fuzzyness; @@ -3024,9 +3028,9 @@ SoftBody *sbNew(void) sb->mediafrict= 0.5f; sb->nodemass= 1.0f; - sb->grav= 0.0f; + sb->grav= 9.8f; sb->physics_speed= 1.0f; - sb->rklimit= 0.5f; + sb->rklimit= 0.1f; sb->goalspring= 0.5f; sb->goalfrict= 0.0f; @@ -3041,8 +3045,8 @@ SoftBody *sbNew(void) sb->sfra= G.scene->r.sfra; sb->efra= G.scene->r.efra; - sb->colball = 0.5f; - sb->balldamp = 0.05f; + sb->colball = 0.49f; + sb->balldamp = 0.50f; sb->ballstiff= 1.0f; sb->sbc_mode = 1; sb_new_scratch(sb); @@ -3308,7 +3312,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts } if(sb->solverflags & SBSO_MONITOR ){ sct=PIL_check_seconds_timer(); - if (sct-sst > 0.5f) printf("solver time %f \r",sct-sst); + if (sct-sst > 0.5f) printf(" solver time %f %s \r",sct-sst,ob->id.name); } } diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index d9ab54b76f9..a821e209ef0 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -144,6 +144,7 @@ typedef struct SoftBody { #define OB_SB_COLLFINAL 4096 #define SBSO_MONITOR 1 +#define SBSO_OLDERR 2 #ifdef __cplusplus } diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 76c98056072..8887c401ce0 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -2338,9 +2338,10 @@ static void object_softbodies_II(Object *ob) uiBlockEndAlign(block); /*SOLVER SETTINGS*/ - uiDefButF(block, NUM, B_DIFF, "Error Limit:", 10,100,150,20, &sb->rklimit , 0.01, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision, high values speed"); + uiDefButF(block, NUM, B_DIFF, "Error Lim:", 10,100,130,20, &sb->rklimit , 0.001, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision, high values speed"); + uiDefButBitS(block, TOG, SBSO_OLDERR, B_DIFF,"O", 140,100,20,20, &sb->solverflags, 0, 0, 0, 0, "Old Error Calculation"); uiDefButS(block, NUM, B_DIFF, "Fuzzy:", 160,100,130,20, &sb->fuzzyness, 1.00, 100.0, 10, 0, "Fuzzyness while on collision, high values make collsion handling faster but less stable"); - uiDefButS(block, TOG, SBSO_MONITOR, "M", 290,100,20,20, &sb->solverflags, 0, 0.0, 10, 0, "Turn on SB diagnose console prints (Maaammmaa!)"); + uiDefButBitS(block, TOG, SBSO_MONITOR, B_DIFF,"M", 290,100,20,20, &sb->solverflags, 0, 0, 0, 0, "Turn on SB diagnose console prints"); uiDefButS(block, NUM, B_DIFF, "MinS:", 10,80,100,20, &sb->minloops, 0.00, 30000.0, 10, 0, "Minimal # solver steps/frame "); uiDefButS(block, NUM, B_DIFF, "MaxS:", 110,80,100,20, &sb->maxloops, 0.00, 30000.0, 10, 0, "Maximal # solver steps/frame "); uiDefButS(block, NUM, B_DIFF, "Choke:", 210,80,100,20, &sb->choke, 0.00, 100.0, 10, 0, "'Viscosity' inside collision target "); @@ -2414,9 +2415,16 @@ static void object_softbodies(Object *ob) } else { /* GENERAL STUFF */ + static char str[128]; + if (sb->totpoint){ + sprintf(str, "Vertex Mass; Object mass %f [k]",sb->nodemass*sb->totpoint/1000.0f); + } + else{ + sprintf(str, "Vertex Mass"); + } 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, "Mass:", 160, 170,150,20, &sb->nodemass , 0.001, 50000.0, 10, 0, str); 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"); uiBlockEndAlign(block); |