[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28465] branches/render25/source/blender: moved goal code to be an external force processed by the implicit system, not part of the internal solver itself (the code there doesn't work, is hacked, explodes, etc)

Joseph Eagar joeedh at gmail.com
Tue Apr 27 17:55:35 CEST 2010


Revision: 28465
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28465
Author:   joeedh
Date:     2010-04-27 17:55:35 +0200 (Tue, 27 Apr 2010)

Log Message:
-----------
moved goal code to be an external force processed by the implicit system, not part of the internal solver itself (the code there doesn't work, is hacked, explodes, etc)

Modified Paths:
--------------
    branches/render25/source/blender/blenkernel/intern/cloth.c
    branches/render25/source/blender/blenkernel/intern/collision.c
    branches/render25/source/blender/blenkernel/intern/implicit.c
    branches/render25/source/blender/makesrna/intern/rna_cloth.c

Modified: branches/render25/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/cloth.c	2010-04-27 15:46:58 UTC (rev 28464)
+++ branches/render25/source/blender/blenkernel/intern/cloth.c	2010-04-27 15:55:35 UTC (rev 28465)
@@ -437,7 +437,7 @@
 	for(i = 0; i < clmd->clothObject->numverts; i++, verts++) {
 		/* save the previous position. */
 		VECCOPY(verts->xold, verts->xconst);
-		VECCOPY(verts->txold, verts->x);
+		//VECCOPY(verts->txold, verts->x);
 
 		/* Get the current position. */
 		VECCOPY(verts->xconst, mvert[i].co);
@@ -953,6 +953,7 @@
 		return 0;
 	}
 	
+#if 0
 	for ( i = 0; i < dm->getNumVerts(dm); i++)
 	{
 		if((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
@@ -960,7 +961,8 @@
 			cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
 		}
 	}
-	
+#endif
+
 	// init our solver
 	if ( solvers [clmd->sim_parms->solver_type].init ) {
 		solvers [clmd->sim_parms->solver_type].init ( ob, clmd );

Modified: branches/render25/source/blender/blenkernel/intern/collision.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/collision.c	2010-04-27 15:46:58 UTC (rev 28464)
+++ branches/render25/source/blender/blenkernel/intern/collision.c	2010-04-27 15:55:35 UTC (rev 28465)
@@ -1539,8 +1539,12 @@
 		
 		if (lambda < 0.0)
 			lambda = 0.0;
+
 		mul_v3_fl(no, lambda);
 		add_v3_v3(cv->txold, no);
+
+		mul_v3_fl(cv->tv, lambda);
+		//add_v3_v3(cv->tv, no);
 	}
 
 	MEM_freeN(frefs);

Modified: branches/render25/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/implicit.c	2010-04-27 15:46:58 UTC (rev 28464)
+++ branches/render25/source/blender/blenkernel/intern/implicit.c	2010-04-27 15:55:35 UTC (rev 28465)
@@ -1292,7 +1292,7 @@
 	}
 	else if(s->type & CLOTH_SPRING_TYPE_GOAL)
 	{
-		float tvect[3];
+		/*float tvect[3];
 		
 		s->flags |= CLOTH_SPRING_FLAG_NEEDED;
 		
@@ -1319,7 +1319,7 @@
 		
 		// HERE IS THE PROBLEM!!!!
 		// dfdx_spring(s->dfdx, dir, length, 0.0, k);
-		// dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0)));
+		// dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0)));*/
 	}
 	else // calculate force of bending springs
 	{
@@ -1353,7 +1353,7 @@
 
 		VECADD(lF[s->ij], lF[s->ij], s->f);
 		
-		if(!(s->type & CLOTH_SPRING_TYPE_GOAL))
+		//if(!(s->type & CLOTH_SPRING_TYPE_GOAL))
 			VECSUB(lF[s->kl], lF[s->kl], s->f);
 		
 		sub_fmatrix_fmatrix(dFdX[s->kl].m, dFdX[s->kl].m, s->dfdx);
@@ -1871,12 +1871,27 @@
 			// update verts to current positions
 			for(i = 0; i < numverts; i++)
 			{	
+				VECCOPY(verts[i].txold, verts[i].tx);
 				VECCOPY(verts[i].tx, id->Xnew[i]);
 				
+				/*apply goal forces*/
+				if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) &&
+				   !(verts [i].flags & CLOTH_VERT_FLAG_PINNED))
+				{
+					float vec[3], fac;
+
+					fac = 1.0 - pow(1.0 - verts[i].goal*clmd->sim_parms->goalspring, 1.0 / (float)(clmd->sim_parms->stepsPerFrame));
+
+					sub_v3_v3v3(vec, verts[i].xconst, verts[i].tx);
+					mul_v3_fl(vec, fac);
+
+					add_v3_v3(verts[i].tx, vec);
+				}
+
 				VECSUB(verts[i].tv, verts[i].tx, verts[i].txold);
 				VECCOPY(verts[i].v, verts[i].tv);
 			}
-			
+
 			// call collision function
 			// TODO: check if "step" or "step+dt" is correct - dg
 			if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) {

Modified: branches/render25/source/blender/makesrna/intern/rna_cloth.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_cloth.c	2010-04-27 15:46:58 UTC (rev 28464)
+++ branches/render25/source/blender/makesrna/intern/rna_cloth.c	2010-04-27 15:55:35 UTC (rev 28465)
@@ -292,7 +292,7 @@
 
 	prop= RNA_def_property(srna, "quality", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "stepsPerFrame");
-	RNA_def_property_range(prop, 4, 80);
+	RNA_def_property_range(prop, 1, 80);
 	RNA_def_property_ui_text(prop, "Quality", "Quality of the simulation in steps per frame. (higher is better quality but slower)");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 





More information about the Bf-blender-cvs mailing list