Fix T42257: Curve vertex parent not working with animation
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 21 Oct 2014 12:44:08 +0000 (14:44 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 21 Oct 2014 12:44:08 +0000 (14:44 +0200)
Vertex parent was using original non-modified nurbs list, simply because
it didn't have something else to operate with.

Now we've got deformed by pre-tessellation modifiers nurbs in the curve
cache which might be used y the vertex parent.

source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/object.c

index 5de7d9936e68c7aa1d2ba5741b281ba87707337e..253d9edc3b5c1510534f37a92008a90169ef5ef7 100644 (file)
@@ -49,6 +49,7 @@ struct rctf;
 typedef struct CurveCache {
        ListBase disp;
        ListBase bev;
+       ListBase deformed_nurbs;
        struct Path *path;
 } CurveCache;
 
index 98f0025921d5653ad5a1e22ad3eac1dd0c2da05a..893c69741cd7b220f7906c994f039417e23ec0e3 100644 (file)
@@ -1271,6 +1271,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
        }
 
        if (!for_orco) {
+               BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
                curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final,
                                          for_render, use_render_resolution);
        }
@@ -1729,8 +1730,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                        }
                }
 
-               if (!for_orco)
+               if (!for_orco) {
+                       BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
                        curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
+               }
 
                if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
                        curve_to_filledpoly(cu, &nubase, dispbase);
index 7a8843f330894471866d9e5348208d57069f163b..53b0e0cf4a1406f288fc2790f8b8ee201c100f78 100644 (file)
@@ -185,6 +185,7 @@ void BKE_object_free_curve_cache(Object *ob)
                if (ob->curve_cache->path) {
                        free_path(ob->curve_cache->path);
                }
+               BKE_nurbList_free(&ob->curve_cache->deformed_nurbs);
                MEM_freeN(ob->curve_cache);
                ob->curve_cache = NULL;
        }
@@ -321,18 +322,7 @@ void BKE_object_free_derived_caches(Object *ob)
                ob->derivedDeform = NULL;
        }
        
-       if (ob->curve_cache) {
-               BKE_displist_free(&ob->curve_cache->disp);
-               BKE_curve_bevelList_free(&ob->curve_cache->bev);
-               if (ob->curve_cache->path) {
-                       free_path(ob->curve_cache->path);
-                       ob->curve_cache->path = NULL;
-               }
-
-               /* Signal for viewport to run DAG workarounds. */
-               MEM_freeN(ob->curve_cache);
-               ob->curve_cache = NULL;
-       }
+       BKE_object_free_curve_cache(ob);
 }
 
 /* do not free object itself */
@@ -2219,8 +2209,18 @@ static void give_parvert(Object *par, int nr, float vec[3])
                }
        }
        else if (ELEM(par->type, OB_CURVE, OB_SURF)) {
-               Curve *cu       = par->data;
-               ListBase *nurb  = BKE_curve_nurbs_get(cu);
+               ListBase *nurb;
+
+               /* Unless there's some weird depsgraph failure the cache should exist. */
+               BLI_assert(par->curve_cache != NULL);
+
+               if (par->curve_cache->deformed_nurbs.first != NULL) {
+                       nurb = &par->curve_cache->deformed_nurbs;
+               }
+               else {
+                       Curve *cu = par->data;
+                       nurb = BKE_curve_nurbs_get(cu);
+               }
 
                BKE_nurbList_index_get_co(nurb, nr, vec);
        }