[Bf-blender-cvs] [268d356] hair_immediate_fixes: Use repulsion forces in combination with the one-time penalty forces in collision.

Lukas Tönne noreply at git.blender.org
Mon Sep 1 18:49:26 CEST 2014


Commit: 268d356fe244f2b3d0eb2a51dab7e97d17879035
Author: Lukas Tönne
Date:   Mon Sep 1 18:49:53 2014 +0200
Branches: hair_immediate_fixes
https://developer.blender.org/rB268d356fe244f2b3d0eb2a51dab7e97d17879035

Use repulsion forces in combination with the one-time penalty forces
in collision.

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

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

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

diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index a215b9d..86ee3ed 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -968,7 +968,6 @@ static bool cloth_points_collision_response_static(ClothModifierData *clmd, Coll
 	
 	float w1, w2, u1, u2, u3;
 	float v1[3], v2_old[3], v2_new[3], v_rel_old[3], v_rel_new[3];
-//	float magrelVel;
 	float epsilon2 = BLI_bvhtree_getepsilon ( collmd->bvhtree );
 
 	for ( ; collpair != collision_end; collpair++ ) {
@@ -1034,20 +1033,18 @@ static bool cloth_points_collision_response_static(ClothModifierData *clmd, Coll
 			madd_v3_v3v3fl(v_tan_old, v_rel_old, collpair->normal, -v_nor_old);
 			madd_v3_v3v3fl(v_tan_new, v_rel_new, collpair->normal, -v_nor_new);
 			
-			mul_v3_v3fl(repulse, collpair->normal, -margin_distance * inv_dt);
-			sub_v3_v3(repulse, v1);
+			mul_v3_v3fl(repulse, collpair->normal, -(margin_distance * inv_dt + dot_v3v3(v1, collpair->normal)));
 			
-//			if (margin_distance < -epsilon2) {
-			{
+			if (margin_distance < -epsilon2) {
 				float bounce[3];
 				
 				mul_v3_v3fl(bounce, collpair->normal, -(v_nor_new + v_nor_old * restitution));
-//				max_v3_v3v3(impulse, repulse, bounce);
+				max_v3_v3v3(impulse, repulse, bounce);
 				copy_v3_v3(impulse, bounce);
 			}
-//			else {
-//				copy_v3_v3(impulse, repulse);
-//			}
+			else {
+				copy_v3_v3(impulse, repulse);
+			}
 			cloth1->verts[collpair->ap1].impulse_count++;
 			BKE_sim_debug_data_add_vector(clmd->debug_data, collpair->pa, impulse, 0.0, 1.0, 0.6, hash_collpair(873, collpair));




More information about the Bf-blender-cvs mailing list