Commit: dbf78406435b0ebed9fa69d3d1a96c083098b29c
Author: Lukas Tönne
Date:   Tue Sep 2 15:03:15 2014 +0200
Branches: master
https://developer.blender.org/rBdbf78406435b0ebed9fa69d3d1a96c083098b29c

Fix bounce/repulse calculation.

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

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

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

diff --git a/source/blender/blenkernel/intern/collision.c 
b/source/blender/blenkernel/intern/collision.c
index c421296..e8cad3d 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1020,7 +1020,7 @@ static bool 
cloth_points_collision_response_static(ClothModifierData *clmd, Coll
                if (mag_v_rel < -ALMOST_ZERO) {
                        float v_nor_old, v_nor_new;
                        float v_tan_old[3], v_tan_new[3];
-                       float repulse[3];
+                       float bounce, repulse;
                        
                        /* Collision response based on
                         * "Simulating Complex Hair with Robust Collision 
Handling" (Choe, Choi, Ko, ACM SIGGRAPH 2005)
@@ -1033,17 +1033,15 @@ 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 + dot_v3v3(v1, collpair->normal)));
+                       repulse = -margin_distance * inv_dt + dot_v3v3(v1, 
collpair->normal);
                        
                        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);
-                               copy_v3_v3(impulse, bounce);
+                               bounce = -v_nor_new + v_nor_old * restitution;
+                               mul_v3_v3fl(impulse, collpair->normal, 
max_ff(repulse, bounce));
                        }
                        else {
-                               copy_v3_v3(impulse, repulse);
+                               bounce = 0.0f;
+                               mul_v3_v3fl(impulse, collpair->normal, 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, "collision", hash_collpair(873, 
collpair));

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to