diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-02-14 18:46:29 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-02-15 13:53:58 +0300 |
commit | 67cec97387965009dfaa57f7f4c8ab948e048e70 (patch) | |
tree | 7e2ec71d0db86c28a2a7ce051a4593661637f726 /source/blender/blenkernel/intern/particle_child.c | |
parent | ffde74a878882618ab4d4179ba8dd9b98aab15e2 (diff) |
Simple hair children: Make twist affected by vertex group
The idea is to give a control over direction of twist, and maybe amount of
twist as well. More concrete example: make braids on left and right side of
character head to be twisting opposite directions.
Now, tricky part: we need some negative values to flip direction, but weights
can not be negative. So we use same trick as displacement map and tangent normal
maps, where 0.5 is neutral, values below 0.5 are considered negative and values
above 0.5 are considered positive.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_child.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_child.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c index 53bf577d4f4..fae304d6580 100644 --- a/source/blender/blenkernel/intern/particle_child.c +++ b/source/blender/blenkernel/intern/particle_child.c @@ -734,6 +734,7 @@ static void do_twist(const ParticleChildModifierContext *modifier_ctx, { ParticleThreadContext *thread_ctx = modifier_ctx->thread_ctx; ParticleSimulationData *sim = modifier_ctx->sim; + ParticleTexture *ptex = modifier_ctx->ptex; ParticleSettings *part = sim->psys->part; /* Early output checks. */ if (part->childtype != PART_CHILD_PARTICLES) { @@ -757,6 +758,9 @@ static void do_twist(const ParticleChildModifierContext *modifier_ctx, twist_get_axis(modifier_ctx, time, axis); /* Angle of rotation. */ float angle = part->twist; + if (ptex != NULL) { + angle *= (ptex->twist - 0.5f) * 2.0f; + } if (twist_curve != NULL) { const int num_segments = twist_num_segments(modifier_ctx); angle *= curvemapping_integrate_clamped(twist_curve, |