diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 57975e56cc3..194aa06fc3b 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -518,12 +518,13 @@ void cloth_cache_get_frame(ClothModifierData *clmd, float time) 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 @@ void cloth_cache_set_frame(ClothModifierData *clmd, float time) // 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 @@ void cloth_cache_set_frame(ClothModifierData *clmd, float time) { 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 @@ void cloth_cache_free(ClothModifierData *clmd, float time) && (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 @@ void cloth_cache_free(ClothModifierData *clmd, float time) 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 @@ void clothModifier_do(ClothModifierData *clmd, Object *ob, DerivedMesh *dm, 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); diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index a6fcf7a9a5e..3b19839c77d 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -947,7 +947,7 @@ int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatr return conjgrad_loopcountnumsprings/2; i++) { @@ -1367,7 +1367,8 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec 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 cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec } } } - } } -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 @@ void simulate_implicit_euler(lfVector *Vnew, lfVector *lX, lfVector *lV, lfVecto 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 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase // 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 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase // 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();