[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13986] trunk/blender/source/blender: Cloth bugfix for jumpy cloth (users were complaining), so the mass can be changed on GUI now (reference: in old blendfiles, mass= 1.0 was used)

Daniel Genrich daniel.genrich at gmx.net
Thu Mar 6 02:21:40 CET 2008


Revision: 13986
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13986
Author:   genscher
Date:     2008-03-06 02:21:40 +0100 (Thu, 06 Mar 2008)

Log Message:
-----------
Cloth bugfix for jumpy cloth (users were complaining), so the mass can be changed on GUI now (reference: in old blendfiles, mass=1.0 was used)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/cloth.c
    trunk/blender/source/blender/blenkernel/intern/collision.c
    trunk/blender/source/blender/blenkernel/intern/implicit.c
    trunk/blender/source/blender/src/buttons_object.c

Modified: trunk/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cloth.c	2008-03-05 21:11:24 UTC (rev 13985)
+++ trunk/blender/source/blender/blenkernel/intern/cloth.c	2008-03-06 01:21:40 UTC (rev 13986)
@@ -970,9 +970,7 @@
 		     (clmd->sim_parms->vgroup_bend>0)))
 	{
 		for ( i = 0; i < numverts; i++, verts++ )
-		{
-			verts->mass = 1.0; // standard mass
-			
+		{	
 			dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
 			if ( dvert )
 			{
@@ -1029,6 +1027,7 @@
 	float tnull[3] = {0,0,0};
 	int cache_there = 0;
 	Cloth *cloth = NULL;
+	MFace *mfaces = NULL;
 
 	// If we have a clothObject, free it. 
 	if ( clmd->clothObject != NULL )
@@ -1091,7 +1090,8 @@
 		}
 		
 		/* no GUI interface yet */
-		verts->mass = clmd->sim_parms->mass = 1.0f;
+		verts->mass = clmd->sim_parms->mass; 
+		verts->impulse_count = 0;
 
 		if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
 			verts->goal= clmd->sim_parms->defgoal;

Modified: trunk/blender/source/blender/blenkernel/intern/collision.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/collision.c	2008-03-05 21:11:24 UTC (rev 13985)
+++ trunk/blender/source/blender/blenkernel/intern/collision.c	2008-03-06 01:21:40 UTC (rev 13986)
@@ -399,7 +399,7 @@
 }
 
 // w3 is not perfect
-void cloth_compute_barycentric (float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3)
+void collision_compute_barycentric (float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3)
 {
 	double	tempV1[3], tempV2[3], tempV4[3];
 	double	a,b,c,d,e,f;
@@ -434,7 +434,7 @@
 	w3[0] = 1.0f - w1[0] - w2[0];
 }
 
-DO_INLINE void interpolateOnTriangle(float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3) 
+DO_INLINE void collision_interpolateOnTriangle(float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3) 
 {
 	to[0] = to[1] = to[2] = 0;
 	VECADDMUL(to, v1, w1);
@@ -461,23 +461,23 @@
 		collpair = search->link;
 		
 		// compute barycentric coordinates for both collision points
-		cloth_compute_barycentric(collpair->pa,
+		collision_compute_barycentric(collpair->pa,
 					  cloth1->verts[collpair->ap1].txold,
        cloth1->verts[collpair->ap2].txold,
        cloth1->verts[collpair->ap3].txold, 
        &w1, &w2, &w3);
 		
 		// was: txold
-		cloth_compute_barycentric(collpair->pb,
+		collision_compute_barycentric(collpair->pb,
 					  collmd->current_x[collpair->bp1].co,
 					collmd->current_x[collpair->bp2].co,
 					collmd->current_x[collpair->bp3].co,
 					&u1, &u2, &u3);
 	
 		// Calculate relative "velocity".
-		interpolateOnTriangle(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3);
+		collision_interpolateOnTriangle(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3);
 		
-		interpolateOnTriangle(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3);
+		collision_interpolateOnTriangle(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3);
 		
 		VECSUB(relativeVelocity, v2, v1);
 			

Modified: trunk/blender/source/blender/blenkernel/intern/implicit.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/implicit.c	2008-03-05 21:11:24 UTC (rev 13985)
+++ trunk/blender/source/blender/blenkernel/intern/implicit.c	2008-03-06 01:21:40 UTC (rev 13986)
@@ -1669,6 +1669,7 @@
 			VECCOPY(verts[i].v, id->V[i]);
 		}
 	}
+	
 	return 1;
 }
 

Modified: trunk/blender/source/blender/src/buttons_object.c
===================================================================
--- trunk/blender/source/blender/src/buttons_object.c	2008-03-05 21:11:24 UTC (rev 13985)
+++ trunk/blender/source/blender/src/buttons_object.c	2008-03-06 01:21:40 UTC (rev 13986)
@@ -5133,36 +5133,41 @@
 	
 	if(clmd->sim_parms->presets==1) /* SILK */
 	{
-		clmd->sim_parms->structural = clmd->sim_parms->shear = 30.0;
-		clmd->sim_parms->bending = 0.1;
+		clmd->sim_parms->structural = clmd->sim_parms->shear = 5.0;
+		clmd->sim_parms->bending = 0.05;
 		clmd->sim_parms->Cdis = 0.0;
+		clmd->sim_parms->mass = 0.15;
 	}
 	else if(clmd->sim_parms->presets==2) /* COTTON */
 	{
-		clmd->sim_parms->structural = clmd->sim_parms->shear = 30.0;
-		clmd->sim_parms->bending = 1.0;
+		clmd->sim_parms->structural = clmd->sim_parms->shear = 15.0;
+		clmd->sim_parms->bending = 0.5;
 		clmd->sim_parms->Cdis = 5.0;
+		clmd->sim_parms->mass = 0.3;
 	}
 	else if(clmd->sim_parms->presets==3) /* RUBBER */
 	{
-		clmd->sim_parms->structural = clmd->sim_parms->shear = 5.0;
+		clmd->sim_parms->structural = clmd->sim_parms->shear = 15.0;
 		clmd->sim_parms->bending = 25.0;
 		clmd->sim_parms->Cdis = 25.0;
 		clmd->sim_parms->stepsPerFrame = MAX2(clmd->sim_parms->stepsPerFrame, 7.0);
+		clmd->sim_parms->mass = 3.0;
 	}
 	else if(clmd->sim_parms->presets==4) /* DENIM */
 	{
-		clmd->sim_parms->structural = clmd->sim_parms->shear = 70.0;
-		clmd->sim_parms->bending = 300.0;
+		clmd->sim_parms->structural = clmd->sim_parms->shear = 40.0;
+		clmd->sim_parms->bending = 10.0;
 		clmd->sim_parms->Cdis = 25.0;
-		clmd->sim_parms->stepsPerFrame = MAX2(clmd->sim_parms->stepsPerFrame, 15.0);
+		clmd->sim_parms->stepsPerFrame = MAX2(clmd->sim_parms->stepsPerFrame, 12.0);
+		clmd->sim_parms->mass = 1.0;
 	}
 	else if(clmd->sim_parms->presets==5) /* LEATHER */
 	{
-		clmd->sim_parms->structural = clmd->sim_parms->shear = 1000.0;
-		clmd->sim_parms->bending = 2500.0;
+		clmd->sim_parms->structural = clmd->sim_parms->shear = 80.0;
+		clmd->sim_parms->bending = 150.0;
 		clmd->sim_parms->Cdis = 25.0;
-		clmd->sim_parms->stepsPerFrame = MAX2(clmd->sim_parms->stepsPerFrame, 25.0);
+		clmd->sim_parms->stepsPerFrame = MAX2(clmd->sim_parms->stepsPerFrame, 15.0);
+		clmd->sim_parms->mass = 0.4;
 	}
 }
 
@@ -5241,6 +5246,8 @@
 		
 		uiDefButI(block, NUM, B_CLOTH_RENEW, "Quality:", 10,110,150,20, &clmd->sim_parms->stepsPerFrame, 4.0, 80.0, 5, 0, "Quality of the simulation (higher=better=slower)");
 		
+		uiDefButF(block, NUM, B_CLOTH_RENEW, "Mass:", 160,110,150,20, &clmd->sim_parms->mass, 0.0, 10.0, 1000, 0, "Mass of cloth material.");
+		
 		uiDefBut(block, LABEL, 0, "Gravity:",  10,90,60,20, NULL, 0.0, 0, 0, 0, "");
 		
 		uiDefButF(block, NUM, B_CLOTH_RENEW, "X:", 70,90,80,20, &clmd->sim_parms->gravity[0], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
@@ -5408,7 +5415,7 @@
 		if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)
 		{
 			uiDefButF(block, NUM, B_CLOTH_RENEW, "Min Distance:",	   160,60,150,20, &clmd->coll_parms->epsilon, 0.001f, 1.0, 0.01f, 0, "Minimum distance between collision objects before collision response takes in, can be changed for each frame");
-			uiDefButS(block, NUM, B_CLOTH_RENEW, "Collision Quality:",	   10,40,150,20, &clmd->coll_parms->loop_count, 1.0, 20.0, 1.0, 0, "How many collision iterations should be done. (higher = better = slower), can be changed for each frame");
+			uiDefButS(block, NUM, B_CLOTH_RENEW, "Collision Quality:",	   10,40,150,20, &clmd->coll_parms->loop_count, 1.0, 20.0, 1.0, 0, "How many collision iterations should be done. (higher = better = slower)");
 			uiDefButF(block, NUM, B_CLOTH_RENEW, "Friction:",	   160,40,150,20, &clmd->coll_parms->friction, 0.0, 80.0, 1.0, 0, "Friction force if a collision happened (0=movement not changed, 100=no movement left)");
 			
 			uiDefButBitI(block, TOG, CLOTH_COLLSETTINGS_FLAG_SELF, B_CLOTH_RENEW, "Enable selfcollisions",	10,20,150,20, &clmd->coll_parms->flags, 0, 0, 0, 0, "Enable selfcollisions with this object");





More information about the Bf-blender-cvs mailing list