Commit: bac7573dc50e2ebf48f583ebebd470fc36b55db4
Author: Lukas Tönne
Date:   Fri May 22 18:04:44 2015 +0200
Branches: gooseberry
https://developer.blender.org/rBbac7573dc50e2ebf48f583ebebd470fc36b55db4

Merge branch 'alembic' into gooseberry

Conflicts:
        source/blender/blenkernel/BKE_key.h
        source/blender/blenkernel/intern/key.c
        source/blender/bmesh/intern/bmesh_strands_conv.c

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



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

diff --cc source/blender/blenkernel/BKE_key.h
index 45571fe,c5769fd..3335a6c
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@@ -76,12 -73,7 +76,12 @@@ float *BKE_key_evaluate_strands_ex
          int *r_totelem, float *arr, size_t arr_size);
  float *BKE_key_evaluate_strands(
          struct Strands *strand, struct Key *key, struct KeyBlock *actkbs, 
bool lock_shape,
-         int *r_totelem);
+         int *r_totelem, bool use_motion);
 +float *BKE_key_evaluate_particles_ex(
 +        struct Object *ob, struct ParticleSystem *psys, float cfra, int 
*r_totelem,
 +        float *arr, size_t arr_size);
 +float *BKE_key_evaluate_particles(
 +        struct Object *ob, struct ParticleSystem *psys, float cfra, int 
*r_totelem);
  
  struct Key      *BKE_key_from_object(struct Object *ob);
  struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
diff --cc source/blender/blenkernel/intern/key.c
index 65228ec,3bcb1bf..1554e27
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@@ -1127,7 -1220,199 +1250,199 @@@ static void do_key(const int start, in
        if (freek4) MEM_freeN(freek4);
  }
  
+ static void do_key_strands(const int start, int end, const int tot, char 
*poin, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, const int mode)
+ {
+       float k1tot = 0.0, k2tot = 0.0, k3tot = 0.0, k4tot = 0.0;
+       float k1d = 0.0, k2d = 0.0, k3d = 0.0, k4d = 0.0;
+       int a, ofs;
+       int flagdo = 15, flagflo = 0, elemsize, poinsize = 0;
+       char *k1, *k2, *k3, *k4, *freek1, *freek2, *freek3, *freek4;
+ 
+       /* currently always 0, in future key_pointer_size may assign */
+       if (!key_pointer_size(key, mode, &poinsize, &ofs))
+               return;
+       
+       if (end > tot) end = tot;
+ 
+       k1 = key_block_get_data(key, actkb, k[0], &freek1);
+       k2 = key_block_get_data(key, actkb, k[1], &freek2);
+       k3 = key_block_get_data(key, actkb, k[2], &freek3);
+       k4 = key_block_get_data(key, actkb, k[3], &freek4);
+ 
+       /*  test for more or less points (per key!) */
+       if (tot != k[0]->totelem) {
+               k1tot = 0.0;
+               flagflo |= 1;
+               if (k[0]->totelem) {
+                       k1d = k[0]->totelem / (float)tot;
+               }
+               else {
+                       flagdo -= 1;
+               }
+       }
+       if (tot != k[1]->totelem) {
+               k2tot = 0.0;
+               flagflo |= 2;
+               if (k[0]->totelem) {
+                       k2d = k[1]->totelem / (float)tot;
+               }
+               else {
+                       flagdo -= 2;
+               }
+       }
+       if (tot != k[2]->totelem) {
+               k3tot = 0.0;
+               flagflo |= 4;
+               if (k[0]->totelem) {
+                       k3d = k[2]->totelem / (float)tot;
+               }
+               else {
+                       flagdo -= 4;
+               }
+       }
+       if (tot != k[3]->totelem) {
+               k4tot = 0.0;
+               flagflo |= 8;
+               if (k[0]->totelem) {
+                       k4d = k[3]->totelem / (float)tot;
+               }
+               else {
+                       flagdo -= 8;
+               }
+       }
+ 
+       /* this exception is needed for curves with multiple splines */
+       if (start != 0) {
+ 
+               poin += poinsize * start;
+               
+               if (flagdo & 1) {
+                       if (flagflo & 1) {
+                               k1tot += start * k1d;
+                               a = (int)floor(k1tot);
+                               if (a) {
+                                       k1tot -= a;
+                                       k1 += a * key->elemsize;
+                               }
+                       }
+                       else {
+                               k1 += start * key->elemsize;
+                       }
+               }
+               if (flagdo & 2) {
+                       if (flagflo & 2) {
+                               k2tot += start * k2d;
+                               a = (int)floor(k2tot);
+                               if (a) {
+                                       k2tot -= a;
+                                       k2 += a * key->elemsize;
+                               }
+                       }
+                       else {
+                               k2 += start * key->elemsize;
+                       }
+               }
+               if (flagdo & 4) {
+                       if (flagflo & 4) {
+                               k3tot += start * k3d;
+                               a = (int)floor(k3tot);
+                               if (a) {
+                                       k3tot -= a;
+                                       k3 += a * key->elemsize;
+                               }
+                       }
+                       else {
+                               k3 += start * key->elemsize;
+                       }
+               }
+               if (flagdo & 8) {
+                       if (flagflo & 8) {
+                               k4tot += start * k4d;
+                               a = (int)floor(k4tot);
+                               if (a) {
+                                       k4tot -= a;
+                                       k4 += a * key->elemsize;
+                               }
+                       }
+                       else {
+                               k4 += start * key->elemsize;
+                       }
+               }
+ 
+       }
+ 
+       /* only here, not above! */
+       elemsize = key->elemsize;
+       if (mode == KEY_MODE_BEZTRIPLE) elemsize *= 3;
+ 
+       for (a = start; a < end; a++) {
+               
+               zero_v3((float *)poin);
+               madd_v3_v3fl((float *)poin, (float *)k1, t[0]);
+               madd_v3_v3fl((float *)poin, (float *)k2, t[1]);
+               madd_v3_v3fl((float *)poin, (float *)k3, t[2]);
+               madd_v3_v3fl((float *)poin, (float *)k4, t[3]);
+               
+               poin += ofs;
+               
+               /* lets do it the difficult way: when keys have a different 
size */
+               if (flagdo & 1) {
+                       if (flagflo & 1) {
+                               k1tot += k1d;
+                               while (k1tot >= 1.0f) {
+                                       k1tot -= 1.0f;
+                                       k1 += elemsize;
+                               }
+                       }
+                       else k1 += elemsize;
+               }
+               if (flagdo & 2) {
+                       if (flagflo & 2) {
+                               k2tot += k2d;
+                               while (k2tot >= 1.0f) {
+                                       k2tot -= 1.0f;
+                                       k2 += elemsize;
+                               }
+                       }
+                       else {
+                               k2 += elemsize;
+                       }
+               }
+               if (flagdo & 4) {
+                       if (flagflo & 4) {
+                               k3tot += k3d;
+                               while (k3tot >= 1.0f) {
+                                       k3tot -= 1.0f;
+                                       k3 += elemsize;
+                               }
+                       }
+                       else {
+                               k3 += elemsize;
+                       }
+               }
+               if (flagdo & 8) {
+                       if (flagflo & 8) {
+                               k4tot += k4d;
+                               while (k4tot >= 1.0f) {
+                                       k4tot -= 1.0f;
+                                       k4 += elemsize;
+                               }
+                       }
+                       else {
+                               k4 += elemsize;
+                       }
+               }
+               
+               if (mode == KEY_MODE_BEZTRIPLE) a += 2;
+       }
+ 
+       if (freek1) MEM_freeN(freek1);
+       if (freek2) MEM_freeN(freek2);
+       if (freek3) MEM_freeN(freek3);
+       if (freek4) MEM_freeN(freek4);
+ }
+ 
 -static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache 
*cache)
 +static float *get_object_weights_array(Object *ob, char *vgroup, 
WeightsArrayCache *cache)
  {
        MDeformVert *dvert = NULL;
        BMEditMesh *em = NULL;
@@@ -1487,32 -1685,6 +1802,32 @@@ static void do_latt_key(Object *ob, Ke
        if (lt->flag & LT_OUTSIDE) outside_lattice(lt);
  }
  
 +static void do_psys_key(Object *ob, ParticleSystem *psys, float cfra, Key 
*key, char *out, const int tot)
 +{
 +      KeyBlock *k[4], *actkb = BKE_keyblock_from_particles(psys);
 +      float t[4];
 +      int flag = 0;
 +      
 +      if (key->type == KEY_RELATIVE) {
 +              WeightsArrayCache cache = {0, NULL};
 +              float **per_keyblock_weights;
 +              
 +              per_keyblock_weights = 
BKE_keyblock_get_per_block_particle_weights(ob, psys, cfra, key, &cache);
 +              BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, 
per_keyblock_weights, KEY_MODE_DUMMY);
 +              BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, 
&cache);
 +      }
 +      else {
 +              const float ctime_scaled = key->ctime / 100.0f;
 +              
 +              flag = setkeys(ctime_scaled, &key->block, k, t, 0);
 +              
 +              if (flag == 0)
 +                      do_key(0, tot, tot, (char *)out, key, actkb, k, t, 
KEY_MODE_DUMMY);
 +              else
-                       cp_key(0, tot, tot, (char *)out, key, actkb, k[2], 
NULL, KEY_MODE_DUMMY, NULL);
++                      cp_key(0, tot, tot, (char *)out, key, actkb, k[2], 
NULL, KEY_MODE_DUMMY);
 +      }
 +}
 +
  /* returns key coordinates (+ tilt) when key applied, NULL otherwise */
  float *BKE_key_evaluate_object_ex(
          Object *ob, int *r_totelem,
@@@ -1587,9 -1759,9 +1902,9 @@@
                }
                
                if (OB_TYPE_SUPPORT_VGROUP(ob->type)) {
 -                      float *weights = get_weights_array(ob, kb->vgroup, 
NULL);
 +                      float *weights = get_object_weights_array(ob, 
kb->vgroup, NULL);
  
-                       cp_key(0, tot, tot, out, key, actkb, kb, weights, 0, 
NULL);
+                       cp_key(0, tot, tot, out, key, actkb, kb, weights, 0);
  
                        if (weights) MEM_freeN(weights);
                }
@@@ -1712,93 -1890,6 +2033,93 @@@ float *BKE_key_evaluate_strands(Strand
        return result;
  }
  
 +/* returns key coordinates when key applied, NULL otherwise */
 +float *BKE_key_evaluate_particles_ex(Object *ob, ParticleSystem *psys, float 
cfra, int *r_totelem,
 +                                     float *arr, size_t arr_size)
 +{
 +      const bool use_editmode = (ob->mode & OB_MODE_PARTICLE_EDIT) && psys == 
psys_get_current(ob) && (psys->edit || psys->pointcache->edit) && 
!psys->renderdata;
 +      Key *key = psys->key;
 +      KeyBlock *actkb = BKE_keyblock_from_particles(psys);
 +      char *out;
 +      int tot = 0, size = 0;
 +      int i;
 +      
 +      if (key == NULL || BLI_listbase_is_empty(&key->block))
 +              return NULL;
 +      
 +      /* compute size of output array */
 +      tot = 0;
 +      for (i = 0; i < psys->totpart; ++i)
 +              tot += psys->particles[i].totkey;
 +      size = tot * 3 * sizeof(float);
 +      
 +      /* if nothing to interpolate, cancel */
 +      if (tot == 0 || size == 0)
 +              return NULL;
 +      
 +      /* allocate array */
 +      if (arr == NULL) {
 +              out = MEM_callocN(size, "BKE_key_evaluate_object out");
 +      }
 +      else {
 +              if (arr_size != size) {
 +                      return NULL;
 +              }
 +              
 +              out = (char *)arr;
 +      }
 +      
 +      /* prevent python from screwing this up? anyhoo, the from pointer could 
be dropped */
 +      BKE_key_set_from_particles(key, ob, psys);
 +      
 +      if (use_editmode) {
 +              /* in edit mode, only evaluate the active shape */
 +              KeyBlock *kb = BLI_findlink(&key->block, psys->shapenr - 1);
 +              
 +              if (kb && (kb->flag & KEYBLOCK_MUTE))
 +                      kb = key->refkey;
 +              
 +              if (kb == NULL) {
 +                      kb = key->block.first;
 +                      psys->shapenr = 1;
 +              }
 +              
-               cp_key(0, tot, tot, out, key, actkb, kb, NULL, 0, NULL);
++              cp_key(0, tot, tot, out, key, actkb, kb, NULL, 0);
 +      }
 +      else if (ob->shapeflag & OB_SHAPE_LOCK) {
 +              /* shape locked, copy the locked shape instead of blending */
 +              KeyBlock *kb = BLI_findlink(&key->block, psys->shapenr - 1);
 +              float *weights;
 +              
 +              if (kb && (kb->flag & KEYBLOCK_MUTE))
 +                      kb = key->refkey;
 +              
 +              if (kb == NULL) {
 +                      kb = key->block.first;
 +                      psys->shapenr = 1;
 +              }
 +              
 +              weights = get_particle_weights_array(ob, psys, kb->name, cfra);
 +              
-               cp_key(0, tot, tot, out, key, actkb, kb, weights, 0, NULL);
++              cp_key(0, tot, tot, out, key, actkb, kb, weights, 0);
 +              
 +              if (weights) MEM_freeN(weights);
 +      }
 +      else {
 +              do_psys_key(ob, psys, cfra, key, out, tot);
 +      }
 +      
 +      if (r_totelem) {
 +              *r_totelem = tot;
 +      }
 +      return (float *)out;
 +}
 +
 +float *BKE_key_evaluate_particles(Object *ob, ParticleSystem *psys, float 
cfra, int *r_totelem)
 +{
 +      return BKE_key_evaluate_particles_ex(ob, psys, cfra, r_totelem, NULL, 
0);
 +}
 +
  Key *BKE_key_from_object(Object *ob)
  {
        if (ob == NULL) return NULL;

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

Reply via email to