[Bf-blender-cvs] [0f3cbf3] master: Transform the constraint matrix and target solver vector z according to the root frame transforms as well.

Lukas Tönne noreply at git.blender.org
Tue Jan 20 09:50:22 CET 2015


Commit: 0f3cbf3f56a609451c669771ac0fdcda40dab1a8
Author: Lukas Tönne
Date:   Fri Sep 12 12:30:13 2014 +0200
Branches: master
https://developer.blender.org/rB0f3cbf3f56a609451c669771ac0fdcda40dab1a8

Transform the constraint matrix and target solver vector z according to
the root frame transforms as well.

This ensures the hair constraints are actually in root space and applied
correctly by the solver.

===================================================================

M	source/blender/blenkernel/intern/implicit.c

===================================================================

diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index e9ceac5..98f5713 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -2094,10 +2094,12 @@ bool implicit_hair_volume_get_texture_data(Object *UNUSED(ob), ClothModifierData
  * This is part of the modified CG method suggested by Baraff/Witkin in
  * "Large Steps in Cloth Simulation" (Siggraph 1998)
  */
-static void setup_constraint_matrix(ClothModifierData *clmd, ColliderContacts *contacts, int totcolliders, lfVector *V, fmatrix3x3 *S, lfVector *z, float dt)
+static void setup_constraint_matrix(ClothModifierData *clmd, ColliderContacts *contacts, int totcolliders, lfVector *X, lfVector *V, fmatrix3x3 *S, lfVector *z, float dt)
 {
-	ClothVertex *verts = clmd->clothObject->verts;
-	int numverts = clmd->clothObject->numverts;
+	Cloth *cloth = clmd->clothObject;
+	ClothVertex *verts = cloth->verts;
+	int numverts = cloth->numverts;
+	RootTransform *roots = cloth->implicit->root;
 	int i, j, v;
 
 	for (v = 0; v < numverts; v++) {
@@ -2149,6 +2151,17 @@ static void setup_constraint_matrix(ClothModifierData *clmd, ColliderContacts *c
 			}
 		}
 	}
+	
+	/* transform to root space */
+	for (v = 0; v < numverts; v++) {
+		float t[3][3];
+		copy_m3_m3(t, roots[v].rot);
+		transpose_m3(t);
+		mul_m3_m3m3(S[v].m, S[v].m, t);
+		mul_m3_m3m3(S[v].m, roots[v].rot, S[v].m);
+		
+		vel_world_to_root(z[v], X[v], z[v], &roots[v]);
+	}
 }
 
 static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M)
@@ -2493,7 +2506,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase *
 		}
 		
 		/* setup vertex constraints for pinned vertices and contacts */
-		setup_constraint_matrix(clmd, contacts, totcolliders, id->V, id->S, id->z, dt);
+		setup_constraint_matrix(clmd, contacts, totcolliders, id->X, id->V, id->S, id->z, dt);
 		
 		// damping velocity for artistic reasons
 		mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);




More information about the Bf-blender-cvs mailing list