Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/softbody.c')
-rw-r--r--source/blender/blenkernel/intern/softbody.c146
1 files changed, 145 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index e4ea839770a..e3bd6f9860f 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -972,6 +972,9 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), struct Object
GHashIterator *ihash;
float aabbmin[3], aabbmax[3];
int deflected=0;
+#if 0
+ int a;
+#endif
if ((sb == NULL) || (sb->scratch ==NULL)) return 0;
copy_v3_v3(aabbmin, sb->scratch->aabbmin);
@@ -1804,6 +1807,45 @@ static int sb_deflect_face(Object *ob, float *actpos, float *facenormal, float *
return(deflected);
}
+/* hiding this for now .. but the jacobian may pop up on other tasks .. so i'd like to keep it */
+#if 0
+static void dfdx_spring(int ia, int ic, int op, float dir[3], float L, float len, float factor)
+{
+ float m, delta_ij;
+ int i, j;
+ if (L < len) {
+ for (i=0;i<3;i++) {
+ for (j=0;j<3;j++) {
+ delta_ij = (i==j ? (1.0f): (0.0f));
+ m=factor*(dir[i]*dir[j] + (1-L/len)*(delta_ij - dir[i]*dir[j]));
+ EIG_linear_solver_matrix_add(ia+i, op+ic+j, m);
+ }
+ }
+ }
+ else {
+ for (i=0;i<3;i++) {
+ for (j=0;j<3;j++) {
+ m=factor*dir[i]*dir[j];
+ EIG_linear_solver_matrix_add(ia+i, op+ic+j, m);
+ }
+ }
+ }
+}
+
+
+static void dfdx_goal(int ia, int ic, int op, float factor)
+{
+ int i;
+ for (i=0;i<3;i++) EIG_linear_solver_matrix_add(ia+i, op+ic+i, factor);
+}
+
+static void dfdv_goal(int ia, int ic, float factor)
+{
+ int i;
+ for (i=0;i<3;i++) EIG_linear_solver_matrix_add(ia+i, ic+i, factor);
+}
+#endif /* if 0 */
+
static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float UNUSED(forcetime))
{
SoftBody *sb= ob->soft; /* is supposed to be there */
@@ -1811,15 +1853,25 @@ static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, floa
float dir[3], dvel[3];
float distance, forcefactor, kd, absvel, projvel, kw;
-
+#if 0 /* UNUSED */
+ int ia, ic;
+#endif
/* prepare depending on which side of the spring we are on */
if (bpi == bs->v1) {
bp1 = &sb->bpoint[bs->v1];
bp2 = &sb->bpoint[bs->v2];
+#if 0 /* UNUSED */
+ ia =3*bs->v1;
+ ic =3*bs->v2;
+#endif
}
else if (bpi == bs->v2) {
bp1 = &sb->bpoint[bs->v2];
bp2 = &sb->bpoint[bs->v1];
+#if 0 /* UNUSED */
+ ia =3*bs->v2;
+ ic =3*bs->v1;
+#endif
}
else {
/* TODO make this debug option */
@@ -2444,6 +2496,13 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
aabbmin[0]=aabbmin[1]=aabbmin[2] = 1e20f;
aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f;
+ /* old one with homogeneous masses */
+ /* claim a minimum mass for vertex */
+#if 0
+ if (sb->nodemass > 0.009999f) timeovermass = forcetime / sb->nodemass;
+ else timeovermass = forcetime / 0.009999f;
+#endif
+
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* now we have individual masses */
/* claim a minimum mass for vertex */
@@ -2488,6 +2547,16 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* x(t + dt) = x(t) + v(t~) * dt */
mul_v3_fl(dx, forcetime);
+ /* the freezer coming sooner or later */
+#if 0
+ if ((dot_v3v3(dx, dx)<freezeloc )&&(dot_v3v3(bp->force, bp->force)<freezeforce )) {
+ bp->frozen /=2;
+ }
+ else {
+ bp->frozen = min_ff(bp->frozen*1.05f, 1.0f);
+ }
+ mul_v3_fl(dx, bp->frozen);
+#endif
/* again some nasty if's to have heun in here too */
if (mode ==1) {
copy_v3_v3(bp->prevpos, bp->pos);
@@ -2552,6 +2621,81 @@ static void softbody_restore_prev_step(Object *ob)
}
}
+#if 0
+static void softbody_store_step(Object *ob)
+{
+ SoftBody *sb= ob->soft; /* is supposed to be there*/
+ BodyPoint *bp;
+ int a;
+
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ copy_v3_v3(bp->prevvec, bp->vec);
+ copy_v3_v3(bp->prevpos, bp->pos);
+ }
+}
+
+
+/* used by predictors and correctors */
+static void softbody_store_state(Object *ob, float *ppos, float *pvel)
+{
+ SoftBody *sb= ob->soft; /* is supposed to be there*/
+ BodyPoint *bp;
+ int a;
+ float *pp=ppos, *pv=pvel;
+
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+
+ copy_v3_v3(pv, bp->vec);
+ pv+=3;
+
+ copy_v3_v3(pp, bp->pos);
+ pp+=3;
+ }
+}
+
+/* used by predictors and correctors */
+static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel)
+{
+ SoftBody *sb= ob->soft; /* is supposed to be there*/
+ BodyPoint *bp;
+ int a;
+ float *pp=ppos, *pv=pvel;
+
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+
+ copy_v3_v3(bp->vec, pv);
+ pv+=3;
+
+ copy_v3_v3(bp->pos, pp);
+ pp+=3;
+ }
+}
+
+/* used by predictors and correctors */
+static void softbody_swap_state(Object *ob, float *ppos, float *pvel)
+{
+ SoftBody *sb= ob->soft; /* is supposed to be there*/
+ BodyPoint *bp;
+ int a;
+ float *pp=ppos, *pv=pvel;
+ float temp[3];
+
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+
+ copy_v3_v3(temp, bp->vec);
+ copy_v3_v3(bp->vec, pv);
+ copy_v3_v3(pv, temp);
+ pv+=3;
+
+ copy_v3_v3(temp, bp->pos);
+ copy_v3_v3(bp->pos, pp);
+ copy_v3_v3(pp, temp);
+ pp+=3;
+ }
+}
+#endif
+
+
/* care for bodypoints taken out of the 'ordinary' solver step
* because they are screwed to goal by bolts
* they just need to move along with the goal in time