Merging r58464 through r58474 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / blenkernel / intern / anim.c
index c555b7de5d9bf3f871594b360702a76b7e2b4f91..b817236781de5479eb3710454f40ac616b0f1fa0 100644 (file)
@@ -488,7 +488,7 @@ void free_path(Path *path)
 /* calculate a curve-deform path for a curve 
  *  - only called from displist.c -> do_makeDispListCurveTypes
  */
-void calc_curvepath(Object *ob)
+void calc_curvepath(Object *ob, ListBase *nurbs)
 {
        BevList *bl;
        BevPoint *bevp, *bevpn, *bevpfirst, *bevplast;
@@ -499,7 +499,6 @@ void calc_curvepath(Object *ob)
        float *fp, *dist, *maxdist, xyz[3];
        float fac, d = 0, fac1, fac2;
        int a, tot, cycl = 0;
-       ListBase *nurbs;
        
        /* in a path vertices are with equal differences: path->len = number of verts */
        /* NOW WITH BEVELCURVE!!! */
@@ -509,19 +508,18 @@ void calc_curvepath(Object *ob)
        }
        cu = ob->data;
 
-       if (cu->path) free_path(cu->path);
-       cu->path = NULL;
+       if (ob->curve_cache->path) free_path(ob->curve_cache->path);
+       ob->curve_cache->path = NULL;
        
        /* weak! can only use first curve */
-       bl = cu->bev.first;
+       bl = ob->curve_cache->bev.first;
        if (bl == NULL || !bl->nr) {
                return;
        }
 
-       nurbs = BKE_curve_nurbs_get(cu);
        nu = nurbs->first;
 
-       cu->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
+       ob->curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
        
        /* if POLY: last vertice != first vertice */
        cycl = (bl->poly != -1);
@@ -626,18 +624,19 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
        float fac;
        float data[4];
        int cycl = 0, s0, s1, s2, s3;
+       ListBase *nurbs;
 
        if (ob == NULL || ob->type != OB_CURVE) return 0;
        cu = ob->data;
-       if (cu->path == NULL || cu->path->data == NULL) {
+       if (ob->curve_cache == NULL || ob->curve_cache->path == NULL || ob->curve_cache->path->data == NULL) {
                printf("no path!\n");
                return 0;
        }
-       path = cu->path;
+       path = ob->curve_cache->path;
        pp = path->data;
        
        /* test for cyclic */
-       bl = cu->bev.first;
+       bl = ob->curve_cache->bev.first;
        if (!bl) return 0;
        if (!bl->nr) return 0;
        if (bl->poly > -1) cycl = 1;
@@ -668,8 +667,11 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
        /* make compatible with vectoquat */
        negate_v3(dir);
        //}
-       
-       nu = cu->nurb.first;
+
+       nurbs = BKE_curve_editNurbs_get(cu);
+       if (!nurbs)
+               nurbs = &cu->nurb;
+       nu = nurbs->first;
 
        /* make sure that first and last frame are included in the vectors here  */
        if (nu->type == CU_POLY) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
@@ -780,10 +782,10 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int persiste
                        if (!is_zero_v3(group->dupli_ofs)) {
                                copy_m4_m4(tmat, go->ob->obmat);
                                sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
-                               mult_m4_m4m4(mat, ob->obmat, tmat);
+                               mul_m4_m4m4(mat, ob->obmat, tmat);
                        }
                        else {
-                               mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
+                               mul_m4_m4m4(mat, ob->obmat, go->ob->obmat);
                        }
                        
                        dob = new_dupli_object(lb, go->ob, mat, ob->lay, persistent_id, level, id, OB_DUPLIGROUP, flag);
@@ -960,7 +962,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
        /* simple preventing of too deep nested groups */
        if (level > MAX_DUPLI_RECUR) return;
        
-       em = BMEdit_FromObject(par);
+       em = BKE_editmesh_from_object(par);
        
        /* get derived mesh */
        dm_mask = CD_MASK_BAREMESH;
@@ -1014,7 +1016,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                                         * when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                         */
                                        if (par_space_mat)
-                                               mult_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
+                                               mul_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(vdd.obmat, ob->obmat);
 
@@ -1087,7 +1089,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
        if (level > MAX_DUPLI_RECUR) return;
        
        copy_m4_m4(pmat, par->obmat);
-       em = BMEdit_FromObject(par);
+       em = BKE_editmesh_from_object(par);
 
        /* get derived mesh */
        dm_mask = CD_MASK_BAREMESH;
@@ -1149,7 +1151,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                         * when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                         */
                                        if (par_space_mat)
-                                               mult_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
+                                               mul_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(ob__obmat, ob->obmat);
                                        
@@ -1328,7 +1330,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
                psys_check_group_weights(part);
 
-               psys->lattice = psys_get_lattice(&sim);
+               psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
                /* gather list of objects or single object */
                if (part->ren_as == PART_DRAW_GR) {
@@ -1467,10 +1469,10 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        if (!is_zero_v3(part->dup_group->dupli_ofs))
                                                sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
                                        /* individual particle transform */
-                                       mult_m4_m4m4(tmat, pamat, tmat);
+                                       mul_m4_m4m4(tmat, pamat, tmat);
 
                                        if (par_space_mat)
-                                               mult_m4_m4m4(mat, par_space_mat, tmat);
+                                               mul_m4_m4m4(mat, par_space_mat, tmat);
                                        else
                                                copy_m4_m4(mat, tmat);
 
@@ -1510,7 +1512,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        
                                        /* add scaling if requested */
                                        if ((part->draw & PART_DRAW_NO_SCALE_OB) == 0)
-                                               mult_m4_m4m4(obmat, obmat, size_mat);
+                                               mul_m4_m4m4(obmat, obmat, size_mat);
                                }
                                else if (part->draw & PART_DRAW_NO_SCALE_OB) {
                                        /* remove scaling */
@@ -1520,22 +1522,22 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        size_to_mat4(size_mat, original_size);
                                        invert_m4(size_mat);
 
-                                       mult_m4_m4m4(obmat, obmat, size_mat);
+                                       mul_m4_m4m4(obmat, obmat, size_mat);
                                }
                                
                                /* Normal particles and cached hair live in global space so we need to
                                 * remove the real emitter's transformation before 2nd order duplication.
                                 */
                                if (par_space_mat && GS(id->name) != ID_GR)
-                                       mult_m4_m4m4(mat, psys->imat, pamat);
+                                       mul_m4_m4m4(mat, psys->imat, pamat);
                                else
                                        copy_m4_m4(mat, pamat);
 
-                               mult_m4_m4m4(tmat, mat, obmat);
+                               mul_m4_m4m4(tmat, mat, obmat);
                                mul_mat3_m4_fl(tmat, size * scale);
 
                                if (par_space_mat)
-                                       mult_m4_m4m4(mat, par_space_mat, tmat);
+                                       mul_m4_m4m4(mat, par_space_mat, tmat);
                                else
                                        copy_m4_m4(mat, tmat);
 
@@ -1565,9 +1567,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
        if (obcopylist)
                MEM_freeN(obcopylist);
 
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 }
 
@@ -1720,8 +1722,11 @@ ListBase *object_duplilist_ex(Scene *sce, Object *ob, bool update, bool for_rend
        int persistent_id[MAX_DUPLI_RECUR] = {0};
        int flag = 0;
 
-       if (update)     flag |= DUPLILIST_DO_UPDATE;
-       if (for_render) flag |= DUPLILIST_FOR_RENDER;
+       /* don't allow BKE_object_handle_update for viewport during render, can crash */
+       if (update && !(G.is_rendering && !for_render))
+               flag |= DUPLILIST_DO_UPDATE;
+       if (for_render)
+               flag |= DUPLILIST_FOR_RENDER;
 
        duplilist->first = duplilist->last = NULL;
        object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, persistent_id, 0, 0, flag);