Curve: Remove duplicated and confusing argument
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 13 May 2019 07:42:32 +0000 (09:42 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 13 May 2019 13:06:50 +0000 (15:06 +0200)
Curve function had two arguments:

- for_render, which was originally supposed to be used to control
  whether viewport or render visibility for modifiers is to be
  used.

- use_render_resolution, which sounds like it is supposed to control
  whether viewport or render resolution for curves is to be used.

What is totally confusing is that those arguments were used
interchangeably: sometimes use_render_resolution would control
modifiers visibility.

This commit makes it so there is one single argument for this.

Reviewers: brecht

Reviewed By: brecht

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

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/mesh_convert.c

index 66c03550df9a5c6f638fcbb2db8569ea29da6004..4356d39be36532bf3bc9ac315f9db8f731d0563c 100644 (file)
@@ -143,7 +143,6 @@ void BKE_curve_bevel_make(struct Depsgraph *depsgraph,
                           struct Object *ob,
                           struct ListBase *disp,
                           const bool for_render,
-                          const bool use_render_resolution,
                           struct LinkNode *ob_cyclic_list);
 
 void BKE_curve_forward_diff_bezier(
index 91033fc61d5c10a570e24390af5bff4a8dc067c7..db57df42d024bdfe54a0de314d7a78db4f98bae1 100644 (file)
@@ -85,8 +85,7 @@ void BKE_displist_make_surf(struct Depsgraph *depsgraph,
                             struct ListBase *dispbase,
                             struct Mesh **r_final,
                             const bool for_render,
-                            const bool for_orco,
-                            const bool use_render_resolution);
+                            const bool for_orco);
 void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph,
                                   struct Scene *scene,
                                   struct Object *ob,
@@ -99,7 +98,6 @@ void BKE_displist_make_curveTypes_forRender(struct Depsgraph *depsgraph,
                                             struct ListBase *dispbase,
                                             struct Mesh **r_final,
                                             const bool for_orco,
-                                            const bool use_render_resolution,
                                             struct LinkNode *ob_cyclic_list);
 void BKE_displist_make_mball(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
 void BKE_displist_make_mball_forRender(struct Depsgraph *depsgraph,
index e15e645694c0433fd0e7e06ef4c41da8910a7528..2775cf9691f51664b1ae1327e3fef6d004f3e629 100644 (file)
@@ -1744,7 +1744,6 @@ void BKE_curve_bevel_make(Depsgraph *depsgraph,
                           Object *ob,
                           ListBase *disp,
                           const bool for_render,
-                          const bool use_render_resolution,
                           LinkNode *ob_cyclic_list)
 {
   DispList *dl, *dlnew;
@@ -1777,7 +1776,6 @@ void BKE_curve_bevel_make(Depsgraph *depsgraph,
                                                  &bevdisp,
                                                  NULL,
                                                  false,
-                                                 use_render_resolution,
                                                  &(LinkNode){
                                                      .link = ob,
                                                      .next = ob_cyclic_list,
index a7f01545f3a5f13815dd5ee6f1f89aa1298a9401..cc1c73b1e68ba66a953b9277c16ec502ff3bcc5b 100644 (file)
@@ -315,8 +315,7 @@ bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, i
 static void curve_to_displist(Curve *cu,
                               ListBase *nubase,
                               ListBase *dispbase,
-                              const bool for_render,
-                              const bool use_render_resolution)
+                              const bool for_render)
 {
   Nurb *nu;
   DispList *dl;
@@ -329,7 +328,7 @@ static void curve_to_displist(Curve *cu,
   nu = nubase->first;
   while (nu) {
     if (nu->hide == 0 || editmode == false) {
-      if (use_render_resolution && cu->resolu_ren != 0) {
+      if (for_render && cu->resolu_ren != 0) {
         resolu = cu->resolu_ren;
       }
       else {
@@ -801,7 +800,7 @@ void BKE_displist_make_mball_forRender(Depsgraph *depsgraph,
 
 static ModifierData *curve_get_tessellate_point(Scene *scene,
                                                 Object *ob,
-                                                const bool use_render_resolution,
+                                                const bool for_render,
                                                 const bool editmode)
 {
   VirtualModifierData virtualModifierData;
@@ -809,7 +808,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene,
   ModifierData *pretessellatePoint;
   int required_mode;
 
-  if (use_render_resolution) {
+  if (for_render) {
     required_mode = eModifierMode_Render;
   }
   else {
@@ -848,12 +847,8 @@ static ModifierData *curve_get_tessellate_point(Scene *scene,
   return pretessellatePoint;
 }
 
-static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
-                                     Scene *scene,
-                                     Object *ob,
-                                     ListBase *nurb,
-                                     const bool for_render,
-                                     const bool use_render_resolution)
+static void curve_calc_modifiers_pre(
+    Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb, const bool for_render)
 {
   VirtualModifierData virtualModifierData;
   ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -871,7 +866,7 @@ static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
   if (editmode) {
     app_flag |= MOD_APPLY_USECACHE;
   }
-  if (use_render_resolution) {
+  if (for_render) {
     app_flag |= MOD_APPLY_RENDER;
     required_mode = eModifierMode_Render;
   }
@@ -881,7 +876,7 @@ static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
 
   const ModifierEvalContext mectx = {depsgraph, ob, app_flag};
 
-  pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
+  pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode);
 
   if (editmode) {
     required_mode |= eModifierMode_Editmode;
@@ -979,8 +974,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
                                       ListBase *nurb,
                                       ListBase *dispbase,
                                       Mesh **r_final,
-                                      const bool for_render,
-                                      const bool use_render_resolution)
+                                      const bool for_render)
 {
   VirtualModifierData virtualModifierData;
   ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -993,7 +987,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
   int useCache = !for_render;
   ModifierApplyFlag app_flag = 0;
 
-  if (use_render_resolution) {
+  if (for_render) {
     app_flag |= MOD_APPLY_RENDER;
     required_mode = eModifierMode_Render;
   }
@@ -1006,7 +1000,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
   const ModifierEvalContext mectx_apply = {
       depsgraph, ob, useCache ? app_flag | MOD_APPLY_USECACHE : app_flag};
 
-  pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
+  pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode);
 
   if (editmode) {
     required_mode |= eModifierMode_Editmode;
@@ -1205,8 +1199,7 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
                             ListBase *dispbase,
                             Mesh **r_final,
                             const bool for_render,
-                            const bool for_orco,
-                            const bool use_render_resolution)
+                            const bool for_orco)
 {
   ListBase nubase = {NULL, NULL};
   Nurb *nu;
@@ -1223,14 +1216,14 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
   }
 
   if (!for_orco) {
-    curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
+    curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render);
   }
 
   for (nu = nubase.first; nu; nu = nu->next) {
     if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
       int resolu = nu->resolu, resolv = nu->resolv;
 
-      if (use_render_resolution) {
+      if (for_render) {
         if (cu->resolu_ren) {
           resolu = cu->resolu_ren;
         }
@@ -1301,8 +1294,7 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
 
   if (!for_orco) {
     BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
-    curve_calc_modifiers_post(
-        depsgraph, scene, ob, &nubase, dispbase, r_final, for_render, use_render_resolution);
+    curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_final, for_render);
   }
 
   BKE_nurbList_free(&nubase);
@@ -1535,7 +1527,6 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
                                       ListBase *dispbase,
                                       const bool for_render,
                                       const bool for_orco,
-                                      const bool use_render_resolution,
                                       LinkNode *ob_cyclic_list,
                                       Mesh **r_final)
 {
@@ -1547,8 +1538,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
   }
 
   if (ob->type == OB_SURF) {
-    BKE_displist_make_surf(
-        depsgraph, scene, ob, dispbase, r_final, for_render, for_orco, use_render_resolution);
+    BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco);
   }
   else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
     ListBase dlbev;
@@ -1575,18 +1565,17 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
     }
 
     if (!for_orco) {
-      curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
+      curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render);
     }
 
-    BKE_curve_bevelList_make(ob, &nubase, use_render_resolution);
+    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, use_render_resolution, ob_cyclic_list);
+    BKE_curve_bevel_make(depsgraph, scene, ob, &dlbev, for_render, ob_cyclic_list);
 
     /* no bevel or extrude, and no width correction? */
     if (!dlbev.first && cu->width == 1.0f) {
-      curve_to_displist(cu, &nubase, dispbase, for_render, use_render_resolution);
+      curve_to_displist(cu, &nubase, dispbase, for_render);
     }
     else {
       float widfac = cu->width - 1.0f;
@@ -1786,8 +1775,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
 
     if (!for_orco) {
       BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
-      curve_calc_modifiers_post(
-          depsgraph, scene, ob, &nubase, dispbase, r_final, for_render, use_render_resolution);
+      curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_final, for_render);
     }
 
     if (cu->flag & CU_DEFORM_FILL && !ob->runtime.mesh_eval) {
@@ -1828,7 +1816,6 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
                             dispbase,
                             for_render,
                             for_orco,
-                            false,
                             ob_cyclic_list,
                             &ob->runtime.mesh_eval);
 
@@ -1841,22 +1828,14 @@ void BKE_displist_make_curveTypes_forRender(Depsgraph *depsgraph,
                                             ListBase *dispbase,
                                             Mesh **r_final,
                                             const bool for_orco,
-                                            const bool use_render_resolution,
                                             LinkNode *ob_cyclic_list)
 {
   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,
-                            use_render_resolution,
-                            ob_cyclic_list,
-                            r_final);
+  do_makeDispListCurveTypes(
+      depsgraph, scene, ob, dispbase, true, for_orco, ob_cyclic_list, r_final);
 }
 
 void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
index 3f4e504867c925158f74f87cd79f34bdaa29bd6b..fe8d053c1df1e68deff8194d7c8077a9602941ad 100644 (file)
@@ -1007,7 +1007,7 @@ Mesh *BKE_mesh_new_from_object(Depsgraph *depsgraph,
 
       /* get updated display list, and convert to a mesh */
       BKE_displist_make_curveTypes_forRender(
-          depsgraph, sce, tmpobj, &dispbase, &me_eval_final, false, render, NULL);
+          depsgraph, sce, tmpobj, &dispbase, &me_eval_final, false, NULL);
 
       copycu->editfont = NULL;
       copycu->editnurb = NULL;