Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2014-09-02 17:03:15 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:29:56 +0300
commitdbf78406435b0ebed9fa69d3d1a96c083098b29c (patch)
treef26a214c477a939376bb85125acc0e5aa5535b0e /source/blender/blenkernel/intern/collision.c
parentd43f7608923bb3ff84c5eed0631d0457d68416e0 (diff)
Fix bounce/repulse calculation.
Diffstat (limited to 'source/blender/blenkernel/intern/collision.c')
-rw-r--r--source/blender/blenkernel/intern/collision.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index c421296e4eb..e8cad3d6374 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));