[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12631] branches/cloth/blender/source/ blender/blenkernel/intern: Bugfix: scaling/rotation/translation works again
Daniel Genrich
daniel.genrich at gmx.net
Tue Nov 20 00:45:26 CET 2007
Revision: 12631
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12631
Author: genscher
Date: 2007-11-20 00:45:26 +0100 (Tue, 20 Nov 2007)
Log Message:
-----------
Bugfix: scaling/rotation/translation works again
Modified Paths:
--------------
branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2007-11-19 21:49:15 UTC (rev 12630)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2007-11-19 23:45:26 UTC (rev 12631)
@@ -862,13 +862,7 @@
/* create springs */
clmd->clothObject->springs = NULL;
clmd->clothObject->numsprings = -1;
-
- if (!cloth_build_springs (clmd->clothObject, dm) )
- {
- modifier_setError (&(clmd->modifier), "Can't build springs.");
- return 0;
- }
-
+
/* set initial values */
for (i = 0; i < numverts; ++i)
{
@@ -889,6 +883,12 @@
clmd->clothObject->verts [i].impulse_count = 0;
VECCOPY ( clmd->clothObject->verts [i].impulse, tnull );
}
+
+ if (!cloth_build_springs (clmd->clothObject, dm) )
+ {
+ modifier_setError (&(clmd->modifier), "Can't build springs.");
+ return 0;
+ }
/* apply / set vertex groups */
if (clmd->sim_parms->vgroup_mass > 0)
@@ -1044,7 +1044,6 @@
unsigned int numverts = dm->getNumVerts ( dm );
unsigned int numedges = dm->getNumEdges ( dm );
unsigned int numfaces = dm->getNumFaces ( dm );
- MVert *mvert = CDDM_get_verts ( dm );
MEdge *medge = CDDM_get_edges ( dm );
MFace *mface = CDDM_get_faces ( dm );
unsigned int index2 = 0; // our second vertex index
@@ -1081,7 +1080,7 @@
{
spring->ij = medge[i].v1;
spring->kl = medge[i].v2;
- VECSUB ( temp, mvert[spring->kl].co, mvert[spring->ij].co );
+ VECSUB ( temp, cloth->x[spring->kl], cloth->x[spring->ij] );
spring->restlen = sqrt ( INPR ( temp, temp ) );
spring->type = CLOTH_SPRING_TYPE_STRUCTURAL;
spring->flags = 0;
@@ -1102,7 +1101,7 @@
spring->ij = mface[i].v1;
spring->kl = mface[i].v3;
- VECSUB ( temp, mvert[spring->kl].co, mvert[spring->ij].co );
+ VECSUB ( temp, cloth->x[spring->kl], cloth->x[spring->ij] );
spring->restlen = sqrt ( INPR ( temp, temp ) );
spring->type = CLOTH_SPRING_TYPE_SHEAR;
@@ -1119,7 +1118,7 @@
spring->ij = mface[i].v2;
spring->kl = mface[i].v4;
- VECSUB ( temp, mvert[spring->kl].co, mvert[spring->ij].co );
+ VECSUB ( temp, cloth->x[spring->kl], cloth->x[spring->ij] );
spring->restlen = sqrt ( INPR ( temp, temp ) );
spring->type = CLOTH_SPRING_TYPE_SHEAR;
@@ -1156,7 +1155,7 @@
spring->ij = tspring2->ij;
spring->kl = index2;
- VECSUB ( temp, mvert[index2].co, mvert[tspring2->ij].co );
+ VECSUB ( temp, cloth->x[index2], cloth->x[tspring2->ij] );
spring->restlen = sqrt ( INPR ( temp, temp ) );
spring->type = CLOTH_SPRING_TYPE_BENDING;
BLI_edgehash_insert ( edgehash, spring->ij, index2, NULL );
Modified: branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/implicit.c 2007-11-19 21:49:15 UTC (rev 12630)
+++ branches/cloth/blender/source/blender/blenkernel/intern/implicit.c 2007-11-19 23:45:26 UTC (rev 12631)
@@ -1233,6 +1233,7 @@
VECADD(s->f, s->f, damping_force);
// Formula from Ascher / Boxman, Speeding up cloth simulation
+ // couldn't see any speedup
// if((dt * (k*dt + 2 * clmd->sim_parms->Cdis * 0.01)) > 0.01 )
{
dfdx_spring_type1(s->dfdx, dir,length,L,clmd->sim_parms->structural);
@@ -1256,12 +1257,12 @@
// DG: My formula to handle bending for the AIMEX scheme
// multiply with 1000 because of numerical problems
- // if( ((k*1000)*dt*dt) < -0.18 )
+ if( ((k*1000.0)*dt*dt) < -0.18 )
{
dfdx_spring_type2(s->dfdx, dir,length,L,clmd->sim_parms->bending, cb);
clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_BIG_FORCE;
}
- // printf("(dt*k*dt) ): %f, k: %f\n", (dt*dt*k*-1.0), k);
+ // printf("(dt*k*dt) ): %f, k: %f\n", (dt*dt*(1000.0*k)), k);
}
}
}
@@ -1279,8 +1280,8 @@
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
}
- else if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_BIG_FORCE))
- return 0;
+ // else if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_BIG_FORCE))
+ // return 0;
sub_fmatrix_fmatrix(dFdX[s->ij].m, dFdX[s->ij].m, s->dfdx);
sub_fmatrix_fmatrix(dFdX[s->kl].m, dFdX[s->kl].m, s->dfdx);
@@ -1466,8 +1467,8 @@
add_lfvectorS_lfvectorS(B, lF, dt, dFdXmV, (dt*dt), numverts);
- // cg_filtered(dV, A, B, z, S); // conjugate gradient algorithm to solve Ax=b
- cg_filtered_pre(dV, A, B, z, S, P, Pinv);
+ cg_filtered(dV, A, B, z, S); // conjugate gradient algorithm to solve Ax=b
+ // cg_filtered_pre(dV, A, B, z, S, P, Pinv);
// advance velocities
add_lfvector_lfvector(Vnew, lV, dV, numverts);
More information about the Bf-blender-cvs
mailing list