forked from bartvdbraak/blender
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
This commit is contained in:
parent
7686e2cc5c
commit
85615f7ac8
@ -2154,6 +2154,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow)
|
|||||||
|
|
||||||
/* gravitation */
|
/* gravitation */
|
||||||
bp->force[2]-= gravity*sb->nodemass; /* individual mass of node here */
|
bp->force[2]-= gravity*sb->nodemass; /* individual mass of node here */
|
||||||
|
|
||||||
|
|
||||||
/* particle field & vortex */
|
/* particle field & vortex */
|
||||||
if(do_effector) {
|
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;
|
aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f;
|
||||||
|
|
||||||
/* claim a minimum mass for vertex */
|
/* claim a minimum mass for vertex */
|
||||||
if (sb->nodemass > 0.09999f) timeovermass = forcetime/sb->nodemass;
|
if (sb->nodemass > 0.009999f) timeovermass = forcetime/sb->nodemass;
|
||||||
else timeovermass = forcetime/0.09999f;
|
else timeovermass = forcetime/0.009999f;
|
||||||
|
|
||||||
for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
||||||
if(bp->goal < SOFTGOALSNAP){
|
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 (err){ /* so step size will be controlled by biggest difference in slope */
|
||||||
|
if (sb->solverflags & SBSO_OLDERR)
|
||||||
*err = MAX2(maxerrpos,maxerrvel);
|
*err = MAX2(maxerrpos,maxerrvel);
|
||||||
|
else
|
||||||
|
*err = maxerrpos;
|
||||||
//printf("EP %f EV %f \n",maxerrpos,maxerrvel);
|
//printf("EP %f EV %f \n",maxerrpos,maxerrvel);
|
||||||
if (fuzzy){
|
if (fuzzy){
|
||||||
*err /= sb->fuzzyness;
|
*err /= sb->fuzzyness;
|
||||||
@ -3024,9 +3028,9 @@ SoftBody *sbNew(void)
|
|||||||
|
|
||||||
sb->mediafrict= 0.5f;
|
sb->mediafrict= 0.5f;
|
||||||
sb->nodemass= 1.0f;
|
sb->nodemass= 1.0f;
|
||||||
sb->grav= 0.0f;
|
sb->grav= 9.8f;
|
||||||
sb->physics_speed= 1.0f;
|
sb->physics_speed= 1.0f;
|
||||||
sb->rklimit= 0.5f;
|
sb->rklimit= 0.1f;
|
||||||
|
|
||||||
sb->goalspring= 0.5f;
|
sb->goalspring= 0.5f;
|
||||||
sb->goalfrict= 0.0f;
|
sb->goalfrict= 0.0f;
|
||||||
@ -3041,8 +3045,8 @@ SoftBody *sbNew(void)
|
|||||||
sb->sfra= G.scene->r.sfra;
|
sb->sfra= G.scene->r.sfra;
|
||||||
sb->efra= G.scene->r.efra;
|
sb->efra= G.scene->r.efra;
|
||||||
|
|
||||||
sb->colball = 0.5f;
|
sb->colball = 0.49f;
|
||||||
sb->balldamp = 0.05f;
|
sb->balldamp = 0.50f;
|
||||||
sb->ballstiff= 1.0f;
|
sb->ballstiff= 1.0f;
|
||||||
sb->sbc_mode = 1;
|
sb->sbc_mode = 1;
|
||||||
sb_new_scratch(sb);
|
sb_new_scratch(sb);
|
||||||
@ -3308,7 +3312,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts
|
|||||||
}
|
}
|
||||||
if(sb->solverflags & SBSO_MONITOR ){
|
if(sb->solverflags & SBSO_MONITOR ){
|
||||||
sct=PIL_check_seconds_timer();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ typedef struct SoftBody {
|
|||||||
#define OB_SB_COLLFINAL 4096
|
#define OB_SB_COLLFINAL 4096
|
||||||
|
|
||||||
#define SBSO_MONITOR 1
|
#define SBSO_MONITOR 1
|
||||||
|
#define SBSO_OLDERR 2
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -2338,9 +2338,10 @@ static void object_softbodies_II(Object *ob)
|
|||||||
|
|
||||||
uiBlockEndAlign(block);
|
uiBlockEndAlign(block);
|
||||||
/*SOLVER SETTINGS*/
|
/*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, 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, "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, "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 ");
|
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 {
|
else {
|
||||||
/* GENERAL STUFF */
|
/* 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);
|
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, "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, "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, "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);
|
uiBlockEndAlign(block);
|
||||||
|
Loading…
Reference in New Issue
Block a user