diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-09-11 19:53:25 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:29:59 +0300 |
commit | 55a5351a03712503fc8e56952456751fdf9b7ac2 (patch) | |
tree | 5141c04f2da3027644f8b186e7d05dd5b0dca653 /source/blender/blenkernel/intern/particle_system.c | |
parent | d496b308dbf6f0da9123836e6b27e79c654f6681 (diff) |
First stage of implementing moving frames of reference for hair/cloth.
This adds transformations for each hair from world to "root space".
Currently positions and velocities are simply transformed for the solver
data and inverse-transformed when copying the results back to the cloth
data. This way the hair movement becomes independent from the movement
of the emitter object. Eventually the "fictitious" forces originating
from emitter movement can be added back in a controlled way.
http://en.wikipedia.org/wiki/Fictitious_force
Ignoring these fictitious forces or scaling their effect is physically
correct, because in the absence of external forces the hair will always
return to rest position in this root frame.
External forces currently are not yet transformed into the root space.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 14082af4cbd..f2e3c774cdc 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4033,17 +4033,25 @@ static void do_hair_dynamics(ParticleSimulationData *sim) /* make vgroup for pin roots etc.. */ psys->particles->hair_index = 1; LOOP_PARTICLES { + float root_mat[4][4]; + if (p) pa->hair_index = (pa-1)->hair_index + (pa-1)->totkey + 1; psys_mat_hair_to_object(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); + mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat); for (k=0, key=pa->hair; k<pa->totkey; k++,key++) { - ClothHairRoot *root = &psys->clmd->roots[pa->hair_index + k - 1]; + ClothHairRoot *root; /* create fake root before actual root to resist bending */ if (k==0) { float temp[3]; + + root = &psys->clmd->roots[pa->hair_index - 1]; + copy_v3_v3(root->loc, root_mat[3]); + copy_m3_m4(root->rot, root_mat); + sub_v3_v3v3(temp, key->co, (key+1)->co); copy_v3_v3(mvert->co, key->co); add_v3_v3v3(mvert->co, mvert->co, temp); @@ -4066,8 +4074,9 @@ static void do_hair_dynamics(ParticleSimulationData *sim) } /* store root transform in cloth data */ - copy_v3_v3(root->loc, hairmat[3]); - copy_m3_m4(root->rot, hairmat); + root = &psys->clmd->roots[pa->hair_index + k]; + copy_v3_v3(root->loc, root_mat[3]); + copy_m3_m4(root->rot, root_mat); copy_v3_v3(mvert->co, key->co); mul_m4_v3(hairmat, mvert->co); |