[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12088] branches/cloth/blender/source/ blender/blenkernel/intern: Fix: kicked springs caching since it' s unused and needs lots of memory
Daniel Genrich
daniel.genrich at gmx.net
Tue Sep 18 21:56:59 CEST 2007
Revision: 12088
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12088
Author: genscher
Date: 2007-09-18 21:56:58 +0200 (Tue, 18 Sep 2007)
Log Message:
-----------
Fix: kicked springs caching since it's unused and needs lots of memory
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-09-18 19:39:25 UTC (rev 12087)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2007-09-18 19:56:58 UTC (rev 12088)
@@ -518,12 +518,13 @@
memcpy(cloth->verts, frame->verts, cloth->numverts*sizeof(ClothVertex));
implicit_set_positions(clmd);
}
-
+ /*
if(frame->springs)
{
// copy ClothSpring struct
memcpy(cloth->springs, frame->springs, cloth->numsprings*sizeof(ClothSpring));
}
+ */
}
}
}
@@ -546,7 +547,10 @@
// creat new frame cache
frame = (Frame *)MEM_callocN(sizeof(Frame), "cloth frame cache");
frame->verts = (ClothVertex *)MEM_callocN(sizeof(ClothVertex)*cloth->numverts, "cloth frame vertex cache");
+ frame->springs = NULL;
+ /*
frame->springs = (ClothSpring *)MEM_callocN(sizeof(ClothSpring)*cloth->numsprings, "cloth frame spring cache");
+ */
frame->time = newtime;
// copy ClothVertex struct
@@ -554,13 +558,13 @@
{
memcpy(&frame->verts[i], &cloth->verts[i], sizeof(ClothVertex));
}
-
+ /*
// copy ClothSpring struct
for(i = 0; i < cloth->numsprings; i++)
{
memcpy(&frame->springs[i], &cloth->springs[i], sizeof(ClothSpring));
}
-
+ */
}
if(frame)
{
@@ -600,7 +604,7 @@
&& (frame->time > newtime)) // do not delete the first frame
{
MEM_freeN(frame->verts);
- MEM_freeN(frame->springs);
+ // MEM_freeN(frame->springs);
MEM_freeN(frame);
MEM_freeN(search);
last_search->next = next;
@@ -608,7 +612,7 @@
else if(clmd->sim_parms.flags & CSIMSETT_FLAG_CCACHE_FREE_ALL) // free COMPLETE cache
{
MEM_freeN(frame->verts);
- MEM_freeN(frame->springs);
+ // MEM_freeN(frame->springs);
MEM_freeN(frame);
}
else
@@ -770,7 +774,7 @@
solvers [clmd->sim_parms.solver_type].solver (ob, framenr, clmd, effectors,0,0);
tend();
- // printf("Cloth simulation time: %f\n", (float)tval());
+ printf("Cloth simulation time: %f\n", (float)tval());
cloth_cache_set_frame(clmd, framenr);
Modified: branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/implicit.c 2007-09-18 19:39:25 UTC (rev 12087)
+++ branches/cloth/blender/source/blender/blenkernel/intern/implicit.c 2007-09-18 19:56:58 UTC (rev 12088)
@@ -947,7 +947,7 @@
return conjgrad_loopcount<conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
}
/*
-int cg_filtered_pre(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, lfVector *X0, float dt)
+int cg_filtered_pre(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, lfVector *X0, fmatrix3x3 *P, fmatrix3x3 *Pinv, float dt)
{
// Solves for unknown X in equation AX=B
unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
@@ -1348,7 +1348,7 @@
/* calculate and apply spring forces */
#pragma omp parallel private(i)
- {
+{
#pragma omp for nowait
for(i = 0; i < cloth->numsprings/2; i++)
{
@@ -1367,7 +1367,8 @@
cloth_calc_spring_force(clmd, &springs[i], lF, lX, lV, dFdV, dFdX);
// }
}
-#pragma omp for nowait
+} // pragma omp parallel
+
for(i = 0; i < cloth->numsprings; i++)
{
// only handle active springs
@@ -1393,15 +1394,13 @@
}
}
}
- }
}
-void simulate_implicit_euler(lfVector *Vnew, lfVector *lX, lfVector *lV, lfVector *lF, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, float dt, fmatrix3x3 *A, lfVector *B, lfVector *dV, fmatrix3x3 *S, lfVector *z, lfVector *olddV)
+void simulate_implicit_euler(lfVector *Vnew, lfVector *lX, lfVector *lV, lfVector *lF, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, float dt, fmatrix3x3 *A, lfVector *B, lfVector *dV, fmatrix3x3 *S, lfVector *z, lfVector *olddV, fmatrix3x3 *P, fmatrix3x3 *Pinv)
{
unsigned int numverts = dFdV[0].vcount;
lfVector *dFdXmV = create_lfvector(numverts);
-
initdiag_bfmatrix(A, I);
zero_lfvector(dV, numverts);
@@ -1414,7 +1413,7 @@
itstart();
cg_filtered(dV, A, B, z, S); /* conjugate gradient algorithm to solve Ax=b */
- // cg_filtered_pre(dV, A, B, z, olddV, dt);
+ // cg_filtered_pre(dV, A, B, z, olddV, P, Pinv, dt);
itend();
// printf("cg_filtered calc time: %f\n", (float)itval());
@@ -1459,7 +1458,7 @@
// calculate
cloth_calc_force(clmd, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step );
- simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt, id->A, id->B, id->dV, id->S, id->z, id->olddV);
+ simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv);
add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts);
@@ -1521,7 +1520,7 @@
// calculate
cloth_calc_force(clmd, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step);
- simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV);
+ simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv);
}
// itend();
More information about the Bf-blender-cvs
mailing list