Fix T64842: crash rendering files with bevel curves
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 21 May 2019 12:54:08 +0000 (14:54 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 21 May 2019 13:07:01 +0000 (15:07 +0200)
This is old logic that no longer makes sense in the new depsgraph, and causes
issues when multiple threads try to modify the same bevel object.

Differential Revision: https://developer.blender.org/D4913

source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/mesh_convert.c
source/blender/blenkernel/intern/object_update.c
source/blender/editors/curve/editcurve.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_relations.c

index 4356d39..df1e7a7 100644 (file)
@@ -138,12 +138,7 @@ float *BKE_curve_surf_make_orco(struct Object *ob);
 
 void BKE_curve_bevelList_free(struct ListBase *bev);
 void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
-void BKE_curve_bevel_make(struct Depsgraph *depsgraph,
-                          struct Scene *scene,
-                          struct Object *ob,
-                          struct ListBase *disp,
-                          const bool for_render,
-                          struct LinkNode *ob_cyclic_list);
+void BKE_curve_bevel_make(struct Object *ob, struct ListBase *disp);
 
 void BKE_curve_forward_diff_bezier(
     float q0, float q1, float q2, float q3, float *p, int it, int stride);
index db57df4..c57639a 100644 (file)
@@ -90,15 +90,13 @@ void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph,
                                   struct Scene *scene,
                                   struct Object *ob,
                                   const bool for_render,
-                                  const bool for_orco,
-                                  struct LinkNode *ob_cyclic_list);
+                                  const bool for_orco);
 void BKE_displist_make_curveTypes_forRender(struct Depsgraph *depsgraph,
                                             struct Scene *scene,
                                             struct Object *ob,
                                             struct ListBase *dispbase,
                                             struct Mesh **r_final,
-                                            const bool for_orco,
-                                            struct LinkNode *ob_cyclic_list);
+                                            const bool for_orco);
 void BKE_displist_make_mball(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
 void BKE_displist_make_mball_forRender(struct Depsgraph *depsgraph,
                                        struct Scene *scene,
index 2775cf9..5945fa4 100644 (file)
@@ -1739,12 +1739,7 @@ static void forward_diff_bezier_cotangent(const float p0[3],
 
 /* ***************** BEVEL ****************** */
 
-void BKE_curve_bevel_make(Depsgraph *depsgraph,
-                          Scene *scene,
-                          Object *ob,
-                          ListBase *disp,
-                          const bool for_render,
-                          LinkNode *ob_cyclic_list)
+void BKE_curve_bevel_make(Object *ob, ListBase *disp)
 {
   DispList *dl, *dlnew;
   Curve *bevcu, *cu;
@@ -1768,25 +1763,7 @@ void BKE_curve_bevel_make(Depsgraph *depsgraph,
       facx = cu->bevobj->scale[0];
       facy = cu->bevobj->scale[1];
 
-      if (for_render) {
-        if (BLI_linklist_index(ob_cyclic_list, cu->bevobj) == -1) {
-          BKE_displist_make_curveTypes_forRender(depsgraph,
-                                                 scene,
-                                                 cu->bevobj,
-                                                 &bevdisp,
-                                                 NULL,
-                                                 false,
-                                                 &(LinkNode){
-                                                     .link = ob,
-                                                     .next = ob_cyclic_list,
-                                                 });
-          dl = bevdisp.first;
-        }
-        else {
-          dl = NULL;
-        }
-      }
-      else if (cu->bevobj->runtime.curve_cache) {
+      if (cu->bevobj->runtime.curve_cache) {
         dl = cu->bevobj->runtime.curve_cache->disp.first;
       }
       else {
index cc1c73b..c8d6f7a 100644 (file)
@@ -723,7 +723,7 @@ static float displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *tap
 
   dl = taperobj->runtime.curve_cache ? taperobj->runtime.curve_cache->disp.first : NULL;
   if (dl == NULL) {
-    BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false, false, NULL);
+    BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false, false);
     dl = taperobj->runtime.curve_cache->disp.first;
   }
   if (dl) {
@@ -1527,7 +1527,6 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
                                       ListBase *dispbase,
                                       const bool for_render,
                                       const bool for_orco,
-                                      LinkNode *ob_cyclic_list,
                                       Mesh **r_final)
 {
   Curve *cu = ob->data;
@@ -1571,7 +1570,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
     BKE_curve_bevelList_make(ob, &nubase, for_render);
 
     /* If curve has no bevel will return nothing */
-    BKE_curve_bevel_make(depsgraph, scene, ob, &dlbev, for_render, ob_cyclic_list);
+    BKE_curve_bevel_make(ob, &dlbev);
 
     /* no bevel or extrude, and no width correction? */
     if (!dlbev.first && cu->width == 1.0f) {
@@ -1786,12 +1785,8 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
   }
 }
 
-void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
-                                  Scene *scene,
-                                  Object *ob,
-                                  const bool for_render,
-                                  const bool for_orco,
-                                  LinkNode *ob_cyclic_list)
+void BKE_displist_make_curveTypes(
+    Depsgraph *depsgraph, Scene *scene, Object *ob, const bool for_render, const bool for_orco)
 {
   ListBase *dispbase;
 
@@ -1810,14 +1805,8 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
 
   dispbase = &(ob->runtime.curve_cache->disp);
 
-  do_makeDispListCurveTypes(depsgraph,
-                            scene,
-                            ob,
-                            dispbase,
-                            for_render,
-                            for_orco,
-                            ob_cyclic_list,
-                            &ob->runtime.mesh_eval);
+  do_makeDispListCurveTypes(
+      depsgraph, scene, ob, dispbase, for_render, for_orco, &ob->runtime.mesh_eval);
 
   boundbox_displist_object(ob);
 }
@@ -1827,15 +1816,13 @@ void BKE_displist_make_curveTypes_forRender(Depsgraph *depsgraph,
                                             Object *ob,
                                             ListBase *dispbase,
                                             Mesh **r_final,
-                                            const bool for_orco,
-                                            LinkNode *ob_cyclic_list)
+                                            const bool for_orco)
 {
   if (ob->runtime.curve_cache == NULL) {
     ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
   }
 
-  do_makeDispListCurveTypes(
-      depsgraph, scene, ob, dispbase, true, for_orco, ob_cyclic_list, r_final);
+  do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, true, for_orco, r_final);
 }
 
 void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
index 51715c3..7cbd5b6 100644 (file)
@@ -172,7 +172,7 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef
     if (cu->flag & CU_PATH) {
       if (eff->ob->runtime.curve_cache == NULL || eff->ob->runtime.curve_cache->path == NULL ||
           eff->ob->runtime.curve_cache->path->data == NULL) {
-        BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false, false, NULL);
+        BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false, false);
       }
 
       if (eff->ob->runtime.curve_cache->path && eff->ob->runtime.curve_cache->path->data) {
index dca5248..461adc8 100644 (file)
@@ -1005,8 +1005,7 @@ static void curve_to_mesh_eval_ensure(Object *object)
                                          &remapped_object,
                                          &remapped_object.runtime.curve_cache->disp,
                                          &remapped_object.runtime.mesh_eval,
-                                         false,
-                                         NULL);
+                                         false);
 
   BKE_object_free_curve_cache(&bevel_object);
   BKE_object_free_curve_cache(&taper_object);
index 77941e7..6dee936 100644 (file)
@@ -204,7 +204,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
     case OB_SURF:
     case OB_FONT: {
       bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
-      BKE_displist_make_curveTypes(depsgraph, scene, ob, for_render, false, NULL);
+      BKE_displist_make_curveTypes(depsgraph, scene, ob, for_render, false);
       break;
     }
 
index 65f502d..fc6fd8b 100644 (file)
@@ -7026,7 +7026,7 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
   int a;
 
   if (object->runtime.curve_cache == NULL) {
-    BKE_displist_make_curveTypes(depsgraph, scene, object, false, false, NULL);
+    BKE_displist_make_curveTypes(depsgraph, scene, object, false, false);
   }
 
   INIT_MINMAX(min, max);
index 293b3a5..4cf64bf 100644 (file)
@@ -1962,7 +1962,7 @@ static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Objec
     if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
       /* We need 'for render' ON here, to enable computing bevel dipslist if needed.
        * Also makes sense anyway, we would not want e.g. to loose hidden parts etc. */
-      BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false, NULL);
+      BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false);
     }
     else if (ob->type == OB_MBALL) {
       BKE_displist_make_mball(depsgraph, scene, ob);
index e555f0d..8d3a636 100644 (file)
@@ -108,7 +108,7 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object *
     BKE_displist_make_mball(depsgraph, scene_eval, ob_eval);
   }
   else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-    BKE_displist_make_curveTypes(depsgraph, scene_eval, ob_eval, false, false, NULL);
+    BKE_displist_make_curveTypes(depsgraph, scene_eval, ob_eval, false, false);
   }
 }
 
index e15d85a..6df012c 100644 (file)
@@ -697,7 +697,7 @@ bool ED_object_parent_set(ReportList *reports,
         cu->flag |= CU_PATH | CU_FOLLOW;
         cu_eval->flag |= CU_PATH | CU_FOLLOW;
         /* force creation of path data */
-        BKE_displist_make_curveTypes(depsgraph, scene, par, false, false, NULL);
+        BKE_displist_make_curveTypes(depsgraph, scene, par, false, false);
       }
       else {
         cu->flag |= CU_FOLLOW;