diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-09-02 12:06:53 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-09-02 12:06:53 +0400 |
commit | 5db18d474fa2c8b7176806368e5bc0aa68fef325 (patch) | |
tree | d914241547c9c076e966024cb59834d013b4ce42 /source/blender/blenkernel/intern/particle.c | |
parent | 18954a711fc920da3933e71d7705f07337fd13eb (diff) |
"Fix" for [#23621] lattice modifier on particle hair when applied doesn't apply it to the hair
* Although not strictly a bug it is the expected behavior and won't mess anything else up.
* Note: the lattice is applied to the actual hair keys instead of the calculated strands so the applied result will differ a bit from the original.
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9c3a1597dd9..45662bfbd42 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4431,3 +4431,34 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] VECADDFAC(center, center, yvec, bb->offset[1]); } + +void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) { + ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys)}; + + psys->lattice = psys_get_lattice(&sim); + + if(psys->lattice) { + ParticleData *pa = psys->particles; + HairKey *hkey; + int p, h; + float hairmat[4][4], imat[4][4]; + + for(p=0; p<psys->totpart; p++, pa++) { + psys_mat_hair_to_global(sim.ob, sim.psmd->dm, psys->part->from, pa, hairmat); + invert_m4_m4(imat, hairmat); + + hkey = pa->hair; + for(h=0; h<pa->totkey; h++, hkey++) { + mul_m4_v3(hairmat, hkey->co); + calc_latt_deform(psys->lattice, hkey->co, 1.0f); + mul_m4_v3(imat, hkey->co); + } + } + + end_latt_deform(psys->lattice); + psys->lattice= NULL; + + /* protect the applied shape */ + psys->flag |= PSYS_EDITED; + } +}
\ No newline at end of file |