[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29412] branches/hairsim: commit of working copy, so I can compile this on another computer that' s fast enough for real testing.

Joseph Eagar joeedh at gmail.com
Fri Jun 11 19:26:54 CEST 2010


Revision: 29412
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29412
Author:   joeedh
Date:     2010-06-11 19:26:53 +0200 (Fri, 11 Jun 2010)

Log Message:
-----------
commit of working copy, so I can compile this on another computer that's fast enough for real testing.

Modified Paths:
--------------
    branches/hairsim/release/scripts/ui/properties_physics_common.py
    branches/hairsim/source/blender/blenkernel/intern/cloth.c
    branches/hairsim/source/blender/blenkernel/intern/collision.c
    branches/hairsim/source/blender/blenkernel/intern/derivatives.cpp
    branches/hairsim/source/blender/blenkernel/intern/implicit.c
    branches/hairsim/source/blender/blenkernel/intern/particle.c
    branches/hairsim/source/blender/blenlib/intern/BLI_ghash.c
    branches/hairsim/source/blender/blenlib/intern/math_geom.c
    branches/hairsim/source/blender/blenlib/intern/math_vector_inline.c
    branches/hairsim/source/blender/editors/interface/interface_handlers.c

Modified: branches/hairsim/release/scripts/ui/properties_physics_common.py
===================================================================
--- branches/hairsim/release/scripts/ui/properties_physics_common.py	2010-06-11 17:17:02 UTC (rev 29411)
+++ branches/hairsim/release/scripts/ui/properties_physics_common.py	2010-06-11 17:26:53 UTC (rev 29412)
@@ -72,7 +72,7 @@
             sub.prop(cache, "quick_cache")
 
             sub = col.column()
-            sub.enabled = bpy.data.file_is_saved
+            #sub.enabled = bpy.data.file_is_saved
             sub.prop(cache, "disk_cache")
             col.label(text=cache.info)
 

Modified: branches/hairsim/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/hairsim/source/blender/blenkernel/intern/cloth.c	2010-06-11 17:17:02 UTC (rev 29411)
+++ branches/hairsim/source/blender/blenkernel/intern/cloth.c	2010-06-11 17:26:53 UTC (rev 29412)
@@ -319,9 +319,9 @@
 			ClothVertex *v1 = cloth->verts + spring->ij, *v2 = cloth->verts + spring->kl;
 			float co2[4][3];
 
-			VECCOPY(co2[0], v1->txold);
+			VECCOPY(co2[0], v1->txold2);
 			VECCOPY(co2[1], v1->tx);
-			VECCOPY(co2[2], v2->txold);
+			VECCOPY(co2[2], v2->txold2);
 			VECCOPY(co2[3], v2->tx);
 
 			ret = BLI_bvhtree_update_node(cloth->bvhspringtree, i, (float*)co2, NULL, 4);

Modified: branches/hairsim/source/blender/blenkernel/intern/collision.c
===================================================================
--- branches/hairsim/source/blender/blenkernel/intern/collision.c	2010-06-11 17:17:02 UTC (rev 29411)
+++ branches/hairsim/source/blender/blenkernel/intern/collision.c	2010-06-11 17:26:53 UTC (rev 29412)
@@ -76,16 +76,16 @@
 		g = guesstab[(int)ceil(g2)];\
 	} else g = g*0.5;
 
-#define FAST_SQRT(n, g, t)  (t=(n/g + g)*0.5, t=(n/t + t)*0.5, t=(n/t + t)*0.5, t=(n/t + t)*0.5, t)
-/*#define normalize_fast_d(v) {\
+/*#define FAST_SQRT(n, g, t)  (t=(n/g + g)*0.5, t=(n/t + t)*0.5, t=(n/t + t)*0.5, t=(n/t + t)*0.5, t)
+#define normalize_fast_d(v) {\
 double _d =  v[0]*v[0] + v[1]*v[1] + v[2]*v[2], _g, _t; \
 			 GUESS(_d, _g);\
 			 _d = FAST_SQRT(_d, _g, _t); \
 				  _d = 1.0/_d; \
 					   v[0]*=_d; v[1]*=_d; v[2]*=_d;\
 											 }
+*/
 
-#undef normalize_fast_d*/
 #define normalize_fast_d normalize_v3_d
 
 #define GUESSTAB_LEN    8000
@@ -101,6 +101,7 @@
 }
 
 //#define saacos_d acos_fast
+//#define acos acos_fast
 
 static void init_guess_tab(void) {
 	int i;
@@ -177,6 +178,8 @@
 	cdouble_t vec[3], dis;
 
 	VECSUB(vec, v1->tx, v2->tx);
+		
+//	return;
 
 	dis = len_v3_d(vec);
 
@@ -234,14 +237,17 @@
 	cdouble_t sign, elen1, elen2;
 } EdgeConstraint;
 
+void solve_bending_gradient(double ip1[3], double ip2[3], double ip3[3], double grad1[3],
+							double grad2[3], double grad3[3], double restangle);
+
 double solve_tetra_gradient(double ip1[3], double ip2[3], double ip3[3], double ip4[3],
                             double grad1[3], double grad2[3], double grad3[3], 
-							double grad4[3], double elen1, double elen2);
+							double grad4[3], double upno[3], double elen1, double elen2);
 
 static void eval_edge_constraint(void *vself) {
 	EdgeConstraint *self = vself;
 	ClothVertex *v1=self->v1, *v2=self->v2, *v3=self->v3, *v4=self->v4;
-	cdouble_t g1[3], g2[3], g3[3], g4[3], offv1[3], offv2[3], l1[3], l2[3];
+	cdouble_t g1[3], g2[3], g3[3], g4[3], n[3], vec1[3], vec2[3], offv1[3], offv2[3], l1[3], l2[3], t[4][3];
 	
 	copy_v3_v3_d(l1, v1->tx);
 	copy_v3_v3_d(l2, v2->tx);
@@ -252,16 +258,45 @@
 	add_v3_v3v3_d(offv2, v4->tx, self->off);
 
 	scale_line_v3_d(offv1, offv2, EDGE_SCALE);
+	
+	sub_v3_v3v3_d(vec1, l1, l2);
+	sub_v3_v3v3_d(vec2, offv1, offv2);
+	cross_v3_v3v3_d(n, vec1, vec2);
+	normalize_v3_d(n);
+	
+	add_v3_v3_d(n, l1);
 
-	self->coll.head.result = solve_tetra_gradient(l1, l2, offv1, offv2, g1, g2, g3, g4, self->elen1, self->elen2);
+	sub_v3_v3v3_d(vec1, n, l2);
+	sub_v3_v3v3_d(vec2, offv1, l2);
+	normalize_v3_d(vec1);
+	normalize_v3_d(vec2);
+	
+	self->coll.head.result = solve_tetra_gradient(l1, l2, offv1, offv2, g1, g2, g3, g4, self->coll.no, self->elen1, self->elen2);
+	
+	if (self->coll.head.result < -0.2) {
+		self->coll.head.result = 0.0;
+		return;
+	}
 
+	copy_v3_v3_d(t[0], v1->tx);
+	copy_v3_v3_d(t[1], v2->tx);
+	copy_v3_v3_d(t[2], offv1);
+	copy_v3_v3_d(t[3], offv2);
+
 	if (isnan(g1[0]) || isnan(g2[0]) || isnan(g3[0]) || isnan(g4[0]))
 		self->coll.head.result = 0.0;
-
+	
 	copy_v3_v3_d(self->coll.head.grad[0], g1);
 	copy_v3_v3_d(self->coll.head.grad[1], g2);
 	copy_v3_v3_d(self->coll.head.grad[2], g3);
 	copy_v3_v3_d(self->coll.head.grad[3], g4);
+
+#if 0
+	mul_v3_d(self->coll.head.grad[0], 0.1);
+	mul_v3_d(self->coll.head.grad[1], 0.1);
+	mul_v3_d(self->coll.head.grad[2], 0.1);
+	mul_v3_d(self->coll.head.grad[3], 0.1);
+#endif
 }
 
 static EdgeConstraint *make_edge_constraint(ClothVertex *v1, ClothVertex *v2, ClothVertex *v3,
@@ -281,7 +316,7 @@
 	con->elen1 = len_v3v3_d(v1->tx, v2->tx);
 	con->elen2 = len_v3v3_d(v3->tx, v4->tx);
 
-	mindis *= 1.01;
+	//mindis *= 1.00001;
 
 	copy_v3_v3_d(con->off, no);
 	copy_v3_v3_d(con->coll.no, no);
@@ -302,9 +337,6 @@
 	return con;
 }
 
-
-void solve_bending_gradient(double ip1[3], double ip2[3], double ip3[3], double grad1[3],
-							double grad2[3], double grad3[3], double restangle);
 void derivatives_set_memarena(MemArena *arena);
 
 static void eval_point_constraint(void *vcon) {
@@ -359,7 +391,7 @@
 		return;
 	//}
 
-	con->coll.head.result = 0.0;
+	//con->coll.head.result = 0.0;
 }
 
 static PointConstraint *make_point_constraint(ClothVertex *point, ClothTri *colltri,
@@ -379,24 +411,24 @@
 	con->v3 = colltri->verts[2];
 	con->colltri = colltri;
 
-	VECCOPY(ov1, v1->txold);
-	VECCOPY(ov2, v2->txold);
-	VECCOPY(ov3, v3->txold);
+	VECCOPY(ov1, v1->txold2);
+	VECCOPY(ov2, v2->txold2);
+	VECCOPY(ov3, v3->txold2);
 
 	normal_tri_v3_d(con->coll.no, ov1, ov2, ov3);
 	VECCOPY(no, con->coll.no);
 
 	con->coll.head.type = CON_POINT;
 	con->coll.head.k = 1.0;
-	con->coll.mindis = mindis+0.002;
+	con->coll.mindis = mindis*1.001;
 	con->coll.friction = friction;
 
 	con->coll.head.eval = eval_point_constraint;
 
 	VECCOPY(co, point->tx);
-	VECCOPY(oco, point->txold);
+	VECCOPY(oco, point->txold2);
 
-	VECSUB(off, oco, v1->txold);
+	VECSUB(off, oco, v1->txold2);
 	normalize_fast_d(off);
 	if (dot_v3v3_d(off, no) < -DBL_EPSILON) {
 		//con->flip = 1;
@@ -508,7 +540,7 @@
 	mul_v3_d(g1, -1.0);
 	copy_v3_v3_d(self->head.grad[0], g1);
 
-	self->head.result = -saacos(dot); //dot < 0.0 ? -saacos_d(dot) : saacos_d(dot);
+	self->head.result = -saacos_d(dot); //dot < 0.0 ? -saacos_d(dot) : saacos_d(dot);
 
 	return;
 }
@@ -577,10 +609,6 @@
 		return;
 	}
 
-	//mul_v3_d(g1, 1.0/3.0);
-	//mul_v3_d(g2, 1.0/3.0);
-	//mul_v3_d(g3, 1.0/3.0);
-
 	copy_v3_v3_d(self->head.grad[0], g1);
 	copy_v3_v3_d(self->head.grad[1], g2);
 	copy_v3_v3_d(self->head.grad[2], g3);
@@ -666,8 +694,8 @@
 	add_v3_v3_d(ct->cent, v3->tx);
 	mul_v3_d(ct->cent, 1.0/3.0);
 
-	add_v3_v3v3_d(ct->ocent, v1->txold, v2->txold);
-	add_v3_v3_d(ct->ocent, v3->txold);
+	add_v3_v3v3_d(ct->ocent, v1->txold2, v2->txold2);
+	add_v3_v3_d(ct->ocent, v3->txold2);
 	mul_v3_d(ct->ocent, 1.0/3.0);
 
 	ct->dis = FLT_MAX;
@@ -681,6 +709,9 @@
 static void ensure_tri_edges(Cloth *cloth, ClothTri *tri) {
 	ClothEdge *e1;
 	ClothVertex *v1 = tri->verts[0], *v2 = tri->verts[1], *v3 = tri->verts[2];
+	
+	if (tri->edges[0] && tri->edges[1] && tri->edges[2])
+		return;
 
 	e1 = get_cloth_edge(cloth, v1, v2);
 	tri->edges[0] = e1;
@@ -740,7 +771,7 @@
 			cv->mass = 1000000.0; /*supposed to represent infinite mass*/
 
 			VECADD2(tri->cent, cv->tx);
-			VECADD2(tri->ocent, cv->txold);
+			VECADD2(tri->ocent, cv->txold2);
 		}
 		normal_tri_v3_d(tri->no, tri->verts[0]->tx, tri->verts[1]->tx, tri->verts[2]->tx);
 
@@ -757,7 +788,7 @@
 void collision_move_object (CollisionModifierData *collmd, cdouble_t step, cdouble_t prevstep, cdouble_t epsilon, cdouble_t dt)
 {
 	float tv[3] = {0, 0, 0};
-	unsigned int i = 0;
+	int i = 0;
 
 	if (prevstep < 0.0) {
 		for ( i = 0; i < collmd->numverts; i++ )
@@ -853,9 +884,9 @@
 
 		if (!ret)
 			return;
-
-		BLI_bvhtree_update_tree ( tree );
 	}
+	
+	BLI_bvhtree_update_tree ( tree );
 }
 
 /***********************************
@@ -960,22 +991,22 @@
 	return 0;
 }
 
-static void check_and_handle_tri_coll(ClothModifierData *clmd, CollisionModifierData *collmd,
+static int check_and_handle_tri_coll(ClothModifierData *clmd, CollisionModifierData *collmd,
 									  int v11, int v12, int v13, int v21, int v22, int v23,
 									  cdouble_t mindis, cdouble_t epsilon, int selfcol) {
 	Cloth *cloth = clmd->clothObject;
 	cdouble_t cv1[3], cv2[3], cv3[3], cent[3], ocent[3];
 	cdouble_t tv1[3][3], tv2[3][3], tov1[3][3], tov2[3][3];
 	PointConstraint *newp;
-	int i, ret;
+	int i, ret, numcol=0;
 
 	VECCOPY(tv1[0], cloth->verts[v11].tx);
 	VECCOPY(tv1[1], cloth->verts[v12].tx);
 	VECCOPY(tv1[2], cloth->verts[v13].tx);
 
-	VECCOPY(tov1[0], cloth->verts[v11].txold);
-	VECCOPY(tov1[1], cloth->verts[v12].txold);
-	VECCOPY(tov1[2], cloth->verts[v13].txold);
+	VECCOPY(tov1[0], cloth->verts[v11].txold2);
+	VECCOPY(tov1[1], cloth->verts[v12].txold2);
+	VECCOPY(tov1[2], cloth->verts[v13].txold2);
 
 	if (collmd) {
 		VECCOPY(tv2[0], collmd->current_xnew[v21].co);
@@ -990,9 +1021,9 @@
 		VECCOPY(tv2[1], cloth->verts[v22].tx);
 		VECCOPY(tv2[2], cloth->verts[v23].tx);
 
-		VECCOPY(tov2[0], cloth->verts[v21].txold);
-		VECCOPY(tov2[1], cloth->verts[v22].txold);
-		VECCOPY(tov2[2], cloth->verts[v23].txold);
+		VECCOPY(tov2[0], cloth->verts[v21].txold2);
+		VECCOPY(tov2[1], cloth->verts[v22].txold2);
+		VECCOPY(tov2[2], cloth->verts[v23].txold2);
 	}
 
 	VECADD(cent, tv2[0], tv2[1]);
@@ -1045,38 +1076,44 @@
 		}
 		normalize_fast_d(vec);
 
-		VECCOPY(cv1, colltri->verts[0]->txold);
-		VECCOPY(cv2, colltri->verts[1]->txold);
-		VECCOPY(cv3, colltri->verts[2]->txold);
+		VECCOPY(cv1, colltri->verts[0]->txold2);
+		VECCOPY(cv2, colltri->verts[1]->txold2);
+		VECCOPY(cv3, colltri->verts[2]->txold2);
 
 		for (i=0; i<3; i++) {
 			newp = make_point_constraint(tri->verts[i], colltri, MAX2(tri->mindis, colltri->mindis), clmd->clothObject->arena, clmd->coll_parms->friction*0.01);
 			BLI_addhead(&clmd->clothObject->constraints, newp);
 
 			if (selfcol) newp->coll.head.k = 0.8;
+			numcol += 1;
 		}
 	}
+
+	return numcol;
 }
 
 
-void cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap)
+int cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap)
 {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list