[Bf-blender-cvs] [2bd3c108764] override-recursive-resync: Cleanup: Reduce indentation from redundant check

Hans Goudey noreply at git.blender.org
Mon Jun 14 16:35:03 CEST 2021


Commit: 2bd3c108764363680cc437713051a442f86fa01a
Author: Hans Goudey
Date:   Sun Jun 13 18:56:52 2021 -0500
Branches: override-recursive-resync
https://developer.blender.org/rB2bd3c108764363680cc437713051a442f86fa01a

Cleanup: Reduce indentation from redundant check

===================================================================

M	source/blender/blenkernel/intern/displist.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc
index a22a30aa2ee..70355f3883d 100644
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@ -1420,237 +1420,237 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
 
   if (ob->type == OB_SURF) {
     displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco);
+    return;
   }
-  else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
-    ListBase nubase = {nullptr, nullptr};
-    bool force_mesh_conversion = false;
 
-    BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
+  ListBase nubase = {nullptr, nullptr};
+  bool force_mesh_conversion = false;
 
-    /* We only re-evaluate path if evaluation is not happening for orco.
-     * If the calculation happens for orco, we should never free data which
-     * was needed before and only not needed for orco calculation. */
-    if (!for_orco) {
-      if (ob->runtime.curve_cache->anim_path_accum_length) {
-        MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
-      }
-      ob->runtime.curve_cache->anim_path_accum_length = nullptr;
-    }
+  BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
 
-    if (ob->type == OB_FONT) {
-      BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
-    }
-    else {
-      BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast<Curve *>(cu)));
+  /* We only re-evaluate path if evaluation is not happening for orco.
+   * If the calculation happens for orco, we should never free data which
+   * was needed before and only not needed for orco calculation. */
+  if (!for_orco) {
+    if (ob->runtime.curve_cache->anim_path_accum_length) {
+      MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
     }
+    ob->runtime.curve_cache->anim_path_accum_length = nullptr;
+  }
 
-    if (!for_orco) {
-      force_mesh_conversion = BKE_curve_calc_modifiers_pre(
-          depsgraph, scene, ob, &nubase, &nubase, for_render);
-    }
+  if (ob->type == OB_FONT) {
+    BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
+  }
+  else {
+    BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast<Curve *>(cu)));
+  }
 
-    BKE_curve_bevelList_make(ob, &nubase, for_render);
+  if (!for_orco) {
+    force_mesh_conversion = BKE_curve_calc_modifiers_pre(
+        depsgraph, scene, ob, &nubase, &nubase, for_render);
+  }
 
-    /* If curve has no bevel will return nothing */
-    ListBase dlbev = BKE_curve_bevel_make(cu);
+  BKE_curve_bevelList_make(ob, &nubase, for_render);
 
-    /* no bevel or extrude, and no width correction? */
-    if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
-      curve_to_displist(cu, &nubase, for_render, dispbase);
-    }
-    else {
-      const float widfac = cu->width - 1.0f;
+  /* If curve has no bevel will return nothing */
+  ListBase dlbev = BKE_curve_bevel_make(cu);
 
-      BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
-      Nurb *nu = (Nurb *)nubase.first;
-      for (; bl && nu; bl = bl->next, nu = nu->next) {
-        float *data;
+  /* no bevel or extrude, and no width correction? */
+  if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
+    curve_to_displist(cu, &nubase, for_render, dispbase);
+  }
+  else {
+    const float widfac = cu->width - 1.0f;
 
-        if (bl->nr == 0) { /* blank bevel lists can happen */
-          continue;
-        }
+    BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
+    Nurb *nu = (Nurb *)nubase.first;
+    for (; bl && nu; bl = bl->next, nu = nu->next) {
+      float *data;
 
-        /* exception handling; curve without bevel or extrude, with width correction */
-        if (BLI_listbase_is_empty(&dlbev)) {
-          DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev");
-          dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
-          BLI_addtail(dispbase, dl);
+      if (bl->nr == 0) { /* blank bevel lists can happen */
+        continue;
+      }
 
-          if (bl->poly != -1) {
-            dl->type = DL_POLY;
-          }
-          else {
-            dl->type = DL_SEGM;
-            dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
-          }
+      /* exception handling; curve without bevel or extrude, with width correction */
+      if (BLI_listbase_is_empty(&dlbev)) {
+        DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev");
+        dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
+        BLI_addtail(dispbase, dl);
 
-          dl->parts = 1;
-          dl->nr = bl->nr;
-          dl->col = nu->mat_nr;
-          dl->charidx = nu->charidx;
-          dl->rt = nu->flag;
+        if (bl->poly != -1) {
+          dl->type = DL_POLY;
+        }
+        else {
+          dl->type = DL_SEGM;
+          dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
+        }
 
-          int a = dl->nr;
-          BevPoint *bevp = bl->bevpoints;
-          data = dl->verts;
-          while (a--) {
-            data[0] = bevp->vec[0] + widfac * bevp->sina;
-            data[1] = bevp->vec[1] + widfac * bevp->cosa;
-            data[2] = bevp->vec[2];
-            bevp++;
-            data += 3;
-          }
+        dl->parts = 1;
+        dl->nr = bl->nr;
+        dl->col = nu->mat_nr;
+        dl->charidx = nu->charidx;
+        dl->rt = nu->flag;
+
+        int a = dl->nr;
+        BevPoint *bevp = bl->bevpoints;
+        data = dl->verts;
+        while (a--) {
+          data[0] = bevp->vec[0] + widfac * bevp->sina;
+          data[1] = bevp->vec[1] + widfac * bevp->cosa;
+          data[2] = bevp->vec[2];
+          bevp++;
+          data += 3;
+        }
+      }
+      else {
+        ListBase bottom_capbase = {nullptr, nullptr};
+        ListBase top_capbase = {nullptr, nullptr};
+        float bottom_no[3] = {0.0f};
+        float top_no[3] = {0.0f};
+        float first_blend = 0.0f, last_blend = 0.0f;
+        int start, steps = 0;
+
+        if (nu->flagu & CU_NURB_CYCLIC) {
+          calc_bevfac_mapping_default(bl, &start, &first_blend, &steps, &last_blend);
         }
         else {
-          ListBase bottom_capbase = {nullptr, nullptr};
-          ListBase top_capbase = {nullptr, nullptr};
-          float bottom_no[3] = {0.0f};
-          float top_no[3] = {0.0f};
-          float first_blend = 0.0f, last_blend = 0.0f;
-          int start, steps = 0;
-
-          if (nu->flagu & CU_NURB_CYCLIC) {
-            calc_bevfac_mapping_default(bl, &start, &first_blend, &steps, &last_blend);
+          if (fabsf(cu->bevfac2 - cu->bevfac1) < FLT_EPSILON) {
+            continue;
           }
-          else {
-            if (fabsf(cu->bevfac2 - cu->bevfac1) < FLT_EPSILON) {
-              continue;
-            }
 
-            calc_bevfac_mapping(cu, bl, nu, &start, &first_blend, &steps, &last_blend);
+          calc_bevfac_mapping(cu, bl, nu, &start, &first_blend, &steps, &last_blend);
+        }
+
+        LISTBASE_FOREACH (DispList *, dlb, &dlbev) {
+          /* for each part of the bevel use a separate displblock */
+          DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev1");
+          dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
+          BLI_addtail(dispbase, dl);
+
+          dl->type = DL_SURF;
+
+          dl->flag = dlb->flag & (DL_FRONT_CURVE | DL_BACK_CURVE);
+          if (dlb->type == DL_POLY) {
+            dl->flag |= DL_CYCL_U;
+          }
+          if ((bl->poly >= 0) && (steps > 2)) {
+            dl->flag |= DL_CYCL_V;
           }
 
-          LISTBASE_FOREACH (DispList *, dlb, &dlbev) {
-            /* for each part of the bevel use a separate displblock */
-            DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev1");
-            dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
-            BLI_addtail(dispbase, dl);
+          dl->parts = steps;
+          dl->nr = dlb->nr;
+          dl->col = nu->mat_nr;
+          dl->charidx = nu->charidx;
+          dl->rt = nu->flag;
 
-            dl->type = DL_SURF;
+          /* for each point of poly make a bevel piece */
+          BevPoint *bevp_first = bl->bevpoints;
+          BevPoint *bevp_last = &bl->bevpoints[bl->nr - 1];
+          BevPoint *bevp = &bl->bevpoints[start];
+          for (int i = start, a = 0; a < steps; i++, bevp++, a++) {
+            float radius_factor = 1.0;
+            float *cur_data = data;
 
-            dl->flag = dlb->flag & (DL_FRONT_CURVE | DL_BACK_CURVE);
-            if (dlb->type == DL_POLY) {
-              dl->flag |= DL_CYCL_U;
-            }
-            if ((bl->poly >= 0) && (steps > 2)) {
-              dl->flag |= DL_CYCL_V;
+            if (cu->taperobj == nullptr) {
+              radius_factor = bevp->radius;
             }
+            else {
+              float taper_factor;
+              if (cu->flag & CU_MAP_TAPER) {
+                float len = (steps - 3) + first_blend + last_blend;
 
-            dl->parts = steps;
-            dl->nr = dlb->nr;
-            dl->col = nu->mat_nr;
-            dl->charidx = nu->charidx;
-            dl->rt = nu->flag;
-
-            /* for each point of poly make a bevel piece */
-            BevPoint *bevp_first = bl->bevpoints;
-            BevPoint *bevp_last = &bl->bevpoints[bl->nr - 1];
-            BevPoint *bevp = &bl->bevpoints[start];
-            for (int i = start, a = 0; a < steps; i++, bevp++, a++) {
-              float radius_factor = 1.0;
-              float *cur_data = data;
-
-              if (cu->taperobj == nullptr) {
-                radius_factor = bevp->radius;
-              }
-              else {
-                float taper_factor;
-                if (cu->flag & CU_MAP_TAPER) {
-                  float len = (steps - 3) + first_blend + last_blend;
-
-                  if (a == 0) {
-                    taper_factor = 0.0f;
-                  }
-                  else if (a == steps - 1) {
-                    taper_factor = 1.0f;
-                  }
-                  else {
-             

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list