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:
authorDaniel Genrich <daniel.genrich@gmx.net>2008-02-27 06:23:17 +0300
committerDaniel Genrich <daniel.genrich@gmx.net>2008-02-27 06:23:17 +0300
commit7d310f4e5c9059a7e734d852424915e8aac7319e (patch)
tree12dbf2686141232fb66ba7f89d8e9cf58b9c760e /source/blender/blenkernel/intern
parent0e54475adaafa4c6db738e7ce8f48a86a375397b (diff)
Cloth: fixed completely useless/wrong friction force; changed some initial settings
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/cloth.c2
-rw-r--r--source/blender/blenkernel/intern/collision.c26
2 files changed, 11 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 0e97a5fe9ef..b1849f8b693 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -184,7 +184,7 @@ void cloth_init ( ClothModifierData *clmd )
clmd->sim_parms->maxgoal = 1.0f;
clmd->sim_parms->mingoal = 0.0f;
clmd->sim_parms->defgoal = 0.0f;
- clmd->sim_parms->goalspring = 10.0f;
+ clmd->sim_parms->goalspring = 1.0f;
clmd->sim_parms->goalfrict = 5.0f;
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 793a4973475..6ef6758cab6 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -492,33 +492,27 @@ int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierDa
if(magrelVel < -ALMOST_ZERO)
{
// Calculate Impulse magnitude to stop all motion in normal direction.
- float tangential[3], magtangent;
+ float magtangent;
double impulse = 0.0;
float vrel_t_pre[3];
- float vrel_t[3], temp[3];
+ float temp[3];
// calculate tangential velocity
VECCOPY(temp, collpair->normal);
VecMulf(temp, magrelVel);
VECSUB(vrel_t_pre, relativeVelocity, temp);
- VECCOPY(vrel_t, vrel_t_pre);
-
- VecMulf(vrel_t, MAX2(1.0 - (clmd->coll_parms->friction * magrelVel / sqrt(INPR(vrel_t_pre,vrel_t_pre))), 0.0));
-
- VECSUB(tangential, vrel_t_pre, vrel_t);
- VecMulf(tangential, 0.5);
-
- magtangent = INPR(tangential, tangential);
+ magtangent = INPR(vrel_t_pre,vrel_t_pre) - MIN2(clmd->coll_parms->friction * 0.01 * magrelVel,INPR(vrel_t_pre,vrel_t_pre));
// Apply friction impulse.
if (magtangent > ALMOST_ZERO)
- {
- impulse = magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3);
- magtangent = sqrt(magtangent);
- VECADDMUL(cloth1->verts[collpair->ap1].impulse, tangential, w1 * impulse/magtangent);
- VECADDMUL(cloth1->verts[collpair->ap2].impulse, tangential, w2 * impulse/magtangent);
- VECADDMUL(cloth1->verts[collpair->ap3].impulse, tangential, w3 * impulse/magtangent);
+ {
+ Normalize(vrel_t_pre);
+
+ impulse = -2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3);
+ VECADDMUL(cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse);
+ VECADDMUL(cloth1->verts[collpair->ap2].impulse, vrel_t_pre, w2 * impulse);
+ VECADDMUL(cloth1->verts[collpair->ap3].impulse, vrel_t_pre, w3 * impulse);
}