Commit: b7abaf151f7c1a90a57bf314f6b29d8b58589192
Author: Lukas Tönne
Date:   Wed Jan 28 17:34:46 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBb7abaf151f7c1a90a57bf314f6b29d8b58589192

Apply shape keys directly to the hair key data, instead of only applying
to the hair dynamics input DM.

Also this calculation has to happen before caching paths, otherwise
there is a 1-update lag because parent paths still use old values.

===================================================================

M       source/blender/blenkernel/intern/particle.c
M       source/blender/blenkernel/intern/particle_system.c

===================================================================

diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index 8b821bc..d3f5664 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2501,8 +2501,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float 
cfra)
        float length, vec[3];
        float *vg_effector = NULL;
        float *vg_length = NULL, pa_length = 1.0f;
-       float *shapekey_data, *shapekey;
-       int totshapekey;
 
        /* we don't have anything valid to create paths from so let's quit here 
*/
        if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || 
psys->pointcache) == 0)
@@ -2534,8 +2532,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float 
cfra)
                DM_ensure_tessface(psmd->dm);
        }
 
-       shapekey = shapekey_data = BKE_key_evaluate_particles(sim->ob, 
sim->psys, &totshapekey);
-
        /*---first main loop: create all actual particles' paths---*/
        LOOP_PARTICLES {
                if (!psys->totchild) {
@@ -2600,23 +2596,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float 
cfra)
                        copy_v3_v3(ca->col, col);
                }
 
-               if (part->type == PART_HAIR) {
-                       HairKey *hkey;
-                       
-                       for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, 
++hkey) {
-                               float co[3];
-                               if (shapekey) {
-                                       copy_v3_v3(co, shapekey);
-                                       shapekey += 3;
-                               }
-                               else {
-                                       copy_v3_v3(co, hkey->co);
-                               }
-                               
-                               mul_v3_m4v3(hkey->world_co, hairmat, co);
-                       }
-               }
-
                /*--modify paths and calculate rotation & velocity--*/
 
                if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
@@ -2684,9 +2663,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float 
cfra)
 
        if (vg_length)
                MEM_freeN(vg_length);
-
-       if (shapekey_data)
-               MEM_freeN(shapekey_data);
 }
 void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float 
cfra)
 {
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index edfb79e..0465415 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3447,7 +3447,14 @@ static void hair_step(ParticleSimulationData *sim, float 
cfra)
        ParticleSystem *psys = sim->psys;
        ParticleSettings *part = psys->part;
        PARTICLE_P;
+       PARTICLE_PSMD;
        float disp = psys_get_current_display_percentage(psys);
+       float *shapekey_data = NULL, *shapekey;
+       int totshapekey;
+
+       if (part->type == PART_HAIR) {
+               shapekey = shapekey_data = BKE_key_evaluate_particles(sim->ob, 
sim->psys, &totshapekey);
+       }
 
        LOOP_PARTICLES {
                pa->size = part->size;
@@ -3458,8 +3465,35 @@ static void hair_step(ParticleSimulationData *sim, float 
cfra)
                        pa->flag |= PARS_NO_DISP;
                else
                        pa->flag &= ~PARS_NO_DISP;
+
+               if (part->type == PART_HAIR) {
+                       float hairmat[4][4];
+                       HairKey *hkey;
+                       int k;
+                       
+                       psys_mat_hair_to_global(sim->ob, psmd->dm, 
psys->part->from, pa, hairmat);
+                       
+                       /* update world coordinates and calculate shapekey 
result if needed */
+                       for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, 
++hkey) {
+                               const float *co;
+                               if (shapekey) {
+                                       co = shapekey;
+                                       shapekey += 3;
+                                       
+                                       copy_v3_v3(hkey->co, co);
+                               }
+                               else {
+                                       co = hkey->co;
+                               }
+                               
+                               mul_v3_m4v3(hkey->world_co, hairmat, co);
+                       }
+               }
        }
 
+       if (shapekey_data)
+               MEM_freeN(shapekey_data);
+
        if (psys->recalc & PSYS_RECALC_RESET) {
                /* need this for changing subsurf levels */
                psys_calc_dmcache(sim->ob, sim->psmd->dm, psys);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to