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-19 13:15:16 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:30:02 +0300
commit7a7778d003d1a31fb4eb3411e1b0512981cc4614 (patch)
tree0488266c11cbaf505c02de1eb34bcaf42486e1d4 /source/blender/physics/intern/BPH_mass_spring.cpp
parent86a4da1c5416c36d2e860720d474f394146ecc2d (diff)
Simple initial implementation of angular bending springs.
These are much better suited for creating stiff hair. The previous bending springs are based on "push" type spring along the hypothenuse of 3 hair vertices. This sort of spring requires a very large force in the direction of the spring for any angular effect, and is still unstable in the equilibrium. The new bending spring model is based on "target" vectors defined in a local hair frame, which generates a force perpendicular to the hair segment. For further details see "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a) or "A Mass Spring Model for Hair Simulation" (Selle, Lentine, Fedkiw 2008) Currently the implementation uses a single root frame that is not yet propagated along the hair, so the resulting rest shape is not very natural. Also damping and derivatives are still missing.
Diffstat (limited to 'source/blender/physics/intern/BPH_mass_spring.cpp')
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index db371997632..56de54e4192 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -373,7 +373,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
BPH_mass_spring_force_spring_goal(data, s->ij, s->matrix_index, goal_x, goal_v, k, parms->goalfrict * 0.01f, s->f, s->dfdx, s->dfdv);
#endif
}
- else { /* calculate force of bending springs */
+ else if (s->type & CLOTH_SPRING_TYPE_BENDING) { /* calculate force of bending springs */
#ifdef CLOTH_FORCE_SPRING_BEND
float kb, cb, scaling;
@@ -385,6 +385,18 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->matrix_index, s->restlen, kb, cb, s->f, s->dfdx, s->dfdv);
#endif
}
+ else if (s->type & CLOTH_SPRING_TYPE_BENDING_ANG) {
+#ifdef CLOTH_FORCE_SPRING_BEND
+ float kb, cb, scaling;
+
+ s->flags |= CLOTH_SPRING_FLAG_NEEDED;
+
+ scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending);
+ cb = kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
+
+ BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->matrix_index, s->restlen, kb, cb, s->f, s->dfdx, s->dfdv);
+#endif
+ }
}
static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax[3])