Cycles: svn merge -r39870:r40266 https://svn.blender.org/svnroot/bf-blender/trunk...
[blender-staging.git] / source / blender / blenkernel / intern / key.c
index 4b532362cd8e03098b7013c318a404801c765e97..2aef5b39c71866112d4706cb090d37b8a78c0b2b 100644 (file)
@@ -63,6 +63,7 @@
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
+#include "BKE_deform.h"
 
 
 #include "RNA_access.h"
@@ -473,20 +474,20 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
 
 }
 
-static void flerp(int aantal, float *in, float *f0, float *f1, float *f2, float *f3, float *t) 
+static void flerp(int tot, float *in, float *f0, float *f1, float *f2, float *f3, float *t)
 {
        int a;
 
-       for(a=0; a<aantal; a++) {
+       for(a=0; a<tot; a++) {
                in[a]= t[0]*f0[a]+t[1]*f1[a]+t[2]*f2[a]+t[3]*f3[a];
        }
 }
 
-static void rel_flerp(int aantal, float *in, float *ref, float *out, float fac)
+static void rel_flerp(int tot, float *in, float *ref, float *out, float fac)
 {
        int a;
        
-       for(a=0; a<aantal; a++) {
+       for(a=0; a<tot; a++) {
                in[a]-= fac*(ref[a]-out[a]);
        }
 }
@@ -1005,7 +1006,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
        MDeformVert *dvert= NULL;
        EditMesh *em= NULL;
        EditVert *eve;
-       int totvert= 0, index= 0;
+       int totvert= 0, defgrp_index= 0;
        
        /* no vgroup string set? */
        if(vgroup[0]==0) return NULL;
@@ -1028,10 +1029,10 @@ static float *get_weights_array(Object *ob, char *vgroup)
        if(dvert==NULL) return NULL;
        
        /* find the group (weak loop-in-loop) */
-       index= defgroup_name_index(ob, vgroup);
-       if(index >= 0) {
+       defgrp_index= defgroup_name_index(ob, vgroup);
+       if(defgrp_index >= 0) {
                float *weights;
-               int i, j;
+               int i;
                
                weights= MEM_callocN(totvert*sizeof(float), "weights");
 
@@ -1040,23 +1041,13 @@ static float *get_weights_array(Object *ob, char *vgroup)
                                dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 
                                if(dvert) {
-                                       for(j=0; j<dvert->totweight; j++) {
-                                               if(dvert->dw[j].def_nr == index) {
-                                                       weights[i]= dvert->dw[j].weight;
-                                                       break;
-                                               }
-                                       }
+                                       weights[i]= defvert_find_weight(dvert, defgrp_index);
                                }
                        }
                }
                else {
                        for(i=0; i < totvert; i++, dvert++) {
-                               for(j=0; j<dvert->totweight; j++) {
-                                       if(dvert->dw[j].def_nr == index) {
-                                               weights[i]= dvert->dw[j].weight;
-                                               break;
-                                       }
-                               }
+                               weights[i]= defvert_find_weight(dvert, defgrp_index);
                        }
                }
 
@@ -1409,7 +1400,7 @@ float *do_ob_key(Scene *scene, Object *ob)
                /* do shapekey local drivers */
                float ctime= (float)scene->r.cfra; // XXX this needs to be checked
                
-               BKE_animsys_evaluate_animdata(&key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
+               BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
                
                if(ob->type==OB_MESH) do_mesh_key(scene, ob, key, out, tot);
                else if(ob->type==OB_LATTICE) do_latt_key(scene, ob, key, out, tot);