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
parent0e54475adaafa4c6db738e7ce8f48a86a375397b (diff)
Cloth: fixed completely useless/wrong friction force; changed some initial settings
-rw-r--r--source/blender/blenkernel/intern/cloth.c2
-rw-r--r--source/blender/blenkernel/intern/collision.c26
-rw-r--r--source/blender/src/buttons_object.c4
3 files changed, 13 insertions, 19 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);
}
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 54c592173ce..da06351404e 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -5221,7 +5221,7 @@ static void object_panel_cloth(Object *ob)
MEM_freeN (clvg2);
}
- uiDefButF(block, NUM, B_CLOTH_RENEW, "Pin Stiff:", 10,50,150,20, &clmd->sim_parms->goalspring, 0.0, 500.0, 10, 0, "Pin (vertex target position) spring stiffness");
+ uiDefButF(block, NUM, B_CLOTH_RENEW, "Pin Stiff:", 10,50,150,20, &clmd->sim_parms->goalspring, 0.0, 50.0, 50, 0, "Pin (vertex target position) spring stiffness");
uiDefBut(block, LABEL, 0, "",160,50,150,20, NULL, 0.0, 0, 0, 0, "");
// uiDefButI(block, NUM, B_CLOTH_RENEW, "Pin Damp:", 160,50,150,20, &clmd->sim_parms->goalfrict, 1.0, 100.0, 10, 0, "Pined damping (higher = doesn't oszilate so much)");
/*
@@ -5335,7 +5335,7 @@ static void object_panel_cloth_II(Object *ob)
{
uiDefButF(block, NUM, REDRAWBUTSOBJECT, "Min Distance:", 160,60,150,20, &clmd->coll_parms->epsilon, 0.001f, 1.0, 0.01f, 0, "Minimum distance between collision objects before collision response takes in, can be changed for each frame");
uiDefButS(block, NUM, REDRAWBUTSOBJECT, "Collision Quality:", 10,40,150,20, &clmd->coll_parms->loop_count, 1.0, 20.0, 1.0, 0, "How many collision iterations should be done. (higher = better = slower), can be changed for each frame");
- uiDefButF(block, NUM, REDRAWBUTSOBJECT, "Friction:", 160,40,150,20, &clmd->coll_parms->friction, 0.0, 10.0, 1.0, 0, "Friction force if a collision happened (high=slower movement when collided)");
+ uiDefButF(block, NUM, REDRAWBUTSOBJECT, "Friction:", 160,40,150,20, &clmd->coll_parms->friction, 0.0, 80.0, 1.0, 0, "Friction force if a collision happened (0=movement not changed, 100=no movement left)");
uiDefButBitI(block, TOG, CLOTH_COLLSETTINGS_FLAG_SELF, B_CLOTH_RENEW, "Enable selfcollisions", 10,20,150,20, &clmd->coll_parms->flags, 0, 0, 0, 0, "Enable selfcollisions with this object");
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF)