Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-06-14 02:56:52 +0300
committerHans Goudey <h.goudey@me.com>2021-06-14 02:56:52 +0300
commit54a03d4247ccde0f6c46707e9c91bebfb76e08bc (patch)
tree928490e95c1ee67cb06502edc65fe171d27f575a
parent84adc23941fada85fa4c1557628a95d21273a190 (diff)
Cleanup: Reduce indentation from redundant check
-rw-r--r--source/blender/blenkernel/intern/displist.cc364
1 files changed, 182 insertions, 182 deletions
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 {
- taper_factor = ((float)a - (1.0f - first_blend)) / len;
- }
+ if (a == 0) {
+ taper_factor = 0.0f;
+ }
+ else if (a == steps - 1) {
+ taper_factor = 1.0f;
}
else {
- float len = bl->nr - 1;
- taper_factor = (float)i / len;
-
- if (a == 0) {
- taper_factor += (1.0f - first_blend) / len;
- }
- else if (a == steps - 1) {
- taper_factor -= (1.0f - last_blend) / len;
- }
+ taper_factor = ((float)a - (1.0f - first_blend)) / len;
}
+ }
+ else {
+ float len = bl->nr - 1;
+ taper_factor = (float)i / len;
- radius_factor = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_factor);
-
- if (cu->taper_radius_mode == CU_TAPER_RADIUS_MULTIPLY) {
- radius_factor *= bevp->radius;
+ if (a == 0) {
+ taper_factor += (1.0f - first_blend) / len;
}
- else if (cu->taper_radius_mode == CU_TAPER_RADIUS_ADD) {
- radius_factor += bevp->radius;
+ else if (a == steps - 1) {
+ taper_factor -= (1.0f - last_blend) / len;
}
}
- /* rotate bevel piece and write in data */
- if ((a == 0) && (bevp != bevp_last)) {
- rotateBevelPiece(
- cu, bevp, bevp + 1, dlb, 1.0f - first_blend, widfac, radius_factor, &data);
- }
- else if ((a == steps - 1) && (bevp != bevp_first)) {
- rotateBevelPiece(
- cu, bevp, bevp - 1, dlb, 1.0f - last_blend, widfac, radius_factor, &data);
+ radius_factor = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_factor);
+
+ if (cu->taper_radius_mode == CU_TAPER_RADIUS_MULTIPLY) {
+ radius_factor *= bevp->radius;
}
- else {
- rotateBevelPiece(cu, bevp, nullptr, dlb, 0.0f, widfac, radius_factor, &data);
+ else if (cu->taper_radius_mode == CU_TAPER_RADIUS_ADD) {
+ radius_factor += bevp->radius;
}
+ }
- if ((cu->flag & CU_FILL_CAPS) && !(nu->flagu & CU_NURB_CYCLIC)) {
- if (a == 1) {
- fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase);
- copy_v3_v3(bottom_no, bevp->dir);
- }
- if (a == steps - 1) {
- fillBevelCap(nu, dlb, cur_data, &top_capbase);
- negate_v3_v3(top_no, bevp->dir);
- }
- }
+ /* rotate bevel piece and write in data */
+ if ((a == 0) && (bevp != bevp_last)) {
+ rotateBevelPiece(
+ cu, bevp, bevp + 1, dlb, 1.0f - first_blend, widfac, radius_factor, &data);
+ }
+ else if ((a == steps - 1) && (bevp != bevp_first)) {
+ rotateBevelPiece(
+ cu, bevp, bevp - 1, dlb, 1.0f - last_blend, widfac, radius_factor, &data);
+ }
+ else {
+ rotateBevelPiece(cu, bevp, nullptr, dlb, 0.0f, widfac, radius_factor, &data);
}
- /* gl array drawing: using indices */
- displist_surf_indices(dl);
+ if ((cu->flag & CU_FILL_CAPS) && !(nu->flagu & CU_NURB_CYCLIC)) {
+ if (a == 1) {
+ fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase);
+ copy_v3_v3(bottom_no, bevp->dir);
+ }
+ if (a == steps - 1) {
+ fillBevelCap(nu, dlb, cur_data, &top_capbase);
+ negate_v3_v3(top_no, bevp->dir);
+ }
+ }
}
- if (bottom_capbase.first) {
- BKE_displist_fill(&bottom_capbase, dispbase, bottom_no, false);
- BKE_displist_fill(&top_capbase, dispbase, top_no, false);
- BKE_displist_free(&bottom_capbase);
- BKE_displist_free(&top_capbase);
- }
+ /* gl array drawing: using indices */
+ displist_surf_indices(dl);
}
- }
- BKE_displist_free(&dlbev);
- }
- if (!(cu->flag & CU_DEFORM_FILL)) {
- curve_to_filledpoly(cu, dispbase);
+ if (bottom_capbase.first) {
+ BKE_displist_fill(&bottom_capbase, dispbase, bottom_no, false);
+ BKE_displist_fill(&top_capbase, dispbase, top_no, false);
+ BKE_displist_free(&bottom_capbase);
+ BKE_displist_free(&top_capbase);
+ }
+ }
}
+ BKE_displist_free(&dlbev);
+ }
- if (!for_orco) {
- if ((cu->flag & CU_PATH) ||
- DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH) {
- BKE_anim_path_calc_data(ob);
- }
+ if (!(cu->flag & CU_DEFORM_FILL)) {
+ curve_to_filledpoly(cu, dispbase);
+ }
- BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(
- depsgraph, scene, ob, dispbase, for_render, force_mesh_conversion, r_final);
+ if (!for_orco) {
+ if ((cu->flag & CU_PATH) ||
+ DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH) {
+ BKE_anim_path_calc_data(ob);
}
- if (cu->flag & CU_DEFORM_FILL && !ob->runtime.data_eval) {
- curve_to_filledpoly(cu, dispbase);
- }
+ BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
+ curve_calc_modifiers_post(
+ depsgraph, scene, ob, dispbase, for_render, force_mesh_conversion, r_final);
+ }
- BKE_nurbList_free(&nubase);
+ if (cu->flag & CU_DEFORM_FILL && !ob->runtime.data_eval) {
+ curve_to_filledpoly(cu, dispbase);
}
+
+ BKE_nurbList_free(&nubase);
}
void BKE_displist_make_curveTypes(Depsgraph *depsgraph,