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>2020-11-22 19:25:10 +0300
committerHans Goudey <h.goudey@me.com>2020-11-22 19:25:10 +0300
commit1cc3a0e2cf73a5ff4f9e0a7f5338eda77266b300 (patch)
treec747fb5f10706c590966f8c35b1238ff67ffdf07 /source/blender/blenkernel/intern/displist.c
parent0f3ca3f4bcbcbc56a72d5b2420372366952d9d01 (diff)
Cleanup: Reduce indentation
Having up to nine levels of indentation make this function hard to follow. Instead of indenting the rest of the loop for a simple special case, just continue.
Diffstat (limited to 'source/blender/blenkernel/intern/displist.c')
-rw-r--r--source/blender/blenkernel/intern/displist.c275
1 files changed, 138 insertions, 137 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index f5257eb12ab..2da52febfe4 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1577,175 +1577,176 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
float *data;
int a;
- if (bl->nr) { /* blank bevel lists can happen */
+ if (bl->nr == 0) { /* blank bevel lists can happen */
+ continue;
+ }
- /* exception handling; curve without bevel or extrude, with width correction */
- if (BLI_listbase_is_empty(&dlbev)) {
- BevPoint *bevp;
- dl = MEM_callocN(sizeof(DispList), "makeDispListbev");
- dl->verts = MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
- BLI_addtail(dispbase, dl);
+ /* exception handling; curve without bevel or extrude, with width correction */
+ if (BLI_listbase_is_empty(&dlbev)) {
+ BevPoint *bevp;
+ dl = MEM_callocN(sizeof(DispList), "makeDispListbev");
+ dl->verts = MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
+ BLI_addtail(dispbase, dl);
- if (bl->poly != -1) {
- dl->type = DL_POLY;
- }
- else {
- dl->type = DL_SEGM;
- }
+ if (bl->poly != -1) {
+ dl->type = DL_POLY;
+ }
+ else {
+ dl->type = DL_SEGM;
+ }
- if (dl->type == DL_SEGM) {
- dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
- }
+ if (dl->type == DL_SEGM) {
+ dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
+ }
- dl->parts = 1;
- dl->nr = bl->nr;
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
+ dl->parts = 1;
+ dl->nr = bl->nr;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
- /* dl->rt will be used as flag for render face and */
- /* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ /* dl->rt will be used as flag for render face and */
+ /* CU_2D conflicts with R_NOPUNOFLIP */
+ dl->rt = nu->flag & ~CU_2D;
- a = dl->nr;
- 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;
- }
+ a = dl->nr;
+ 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 {
+ DispList *dlb;
+ ListBase bottom_capbase = {NULL, NULL};
+ ListBase top_capbase = {NULL, NULL};
+ float bottom_no[3] = {0.0f};
+ float top_no[3] = {0.0f};
+ float firstblend = 0.0f, lastblend = 0.0f;
+ int i, start, steps = 0;
+
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ calc_bevfac_mapping_default(bl, &start, &firstblend, &steps, &lastblend);
}
else {
- DispList *dlb;
- ListBase bottom_capbase = {NULL, NULL};
- ListBase top_capbase = {NULL, NULL};
- float bottom_no[3] = {0.0f};
- float top_no[3] = {0.0f};
- float firstblend = 0.0f, lastblend = 0.0f;
- int i, start, steps = 0;
-
- if (nu->flagu & CU_NURB_CYCLIC) {
- calc_bevfac_mapping_default(bl, &start, &firstblend, &steps, &lastblend);
+ 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, &firstblend, &steps, &lastblend);
- }
+ calc_bevfac_mapping(cu, bl, nu, &start, &firstblend, &steps, &lastblend);
+ }
- for (dlb = dlbev.first; dlb; dlb = dlb->next) {
- BevPoint *bevp_first, *bevp_last;
- BevPoint *bevp;
+ for (dlb = dlbev.first; dlb; dlb = dlb->next) {
+ BevPoint *bevp_first, *bevp_last;
+ BevPoint *bevp;
- /* for each part of the bevel use a separate displblock */
- dl = MEM_callocN(sizeof(DispList), "makeDispListbev1");
- dl->verts = data = MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
- BLI_addtail(dispbase, dl);
+ /* for each part of the bevel use a separate displblock */
+ dl = MEM_callocN(sizeof(DispList), "makeDispListbev1");
+ dl->verts = data = MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
+ BLI_addtail(dispbase, dl);
- dl->type = DL_SURF;
+ 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;
- }
+ 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;
+ }
+
+ dl->parts = steps;
+ dl->nr = dlb->nr;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
- dl->parts = steps;
- dl->nr = dlb->nr;
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
+ /* dl->rt will be used as flag for render face and */
+ /* CU_2D conflicts with R_NOPUNOFLIP */
+ dl->rt = nu->flag & ~CU_2D;
- /* dl->rt will be used as flag for render face and */
- /* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->bevel_split = BLI_BITMAP_NEW(steps, "bevel_split");
- dl->bevel_split = BLI_BITMAP_NEW(steps, "bevel_split");
+ /* for each point of poly make a bevel piece */
+ bevp_first = bl->bevpoints;
+ bevp_last = &bl->bevpoints[bl->nr - 1];
+ bevp = &bl->bevpoints[start];
+ for (i = start, a = 0; a < steps; i++, bevp++, a++) {
+ float fac = 1.0;
+ float *cur_data = data;
- /* for each point of poly make a bevel piece */
- bevp_first = bl->bevpoints;
- bevp_last = &bl->bevpoints[bl->nr - 1];
- bevp = &bl->bevpoints[start];
- for (i = start, a = 0; a < steps; i++, bevp++, a++) {
- float fac = 1.0;
- float *cur_data = data;
+ if (cu->taperobj == NULL) {
+ fac = bevp->radius;
+ }
+ else {
+ float len, taper_fac;
- if (cu->taperobj == NULL) {
- fac = bevp->radius;
- }
- else {
- float len, taper_fac;
-
- if (cu->flag & CU_MAP_TAPER) {
- len = (steps - 3) + firstblend + lastblend;
-
- if (a == 0) {
- taper_fac = 0.0f;
- }
- else if (a == steps - 1) {
- taper_fac = 1.0f;
- }
- else {
- taper_fac = ((float)a - (1.0f - firstblend)) / len;
- }
+ if (cu->flag & CU_MAP_TAPER) {
+ len = (steps - 3) + firstblend + lastblend;
+
+ if (a == 0) {
+ taper_fac = 0.0f;
+ }
+ else if (a == steps - 1) {
+ taper_fac = 1.0f;
}
else {
- len = bl->nr - 1;
- taper_fac = (float)i / len;
-
- if (a == 0) {
- taper_fac += (1.0f - firstblend) / len;
- }
- else if (a == steps - 1) {
- taper_fac -= (1.0f - lastblend) / len;
- }
+ taper_fac = ((float)a - (1.0f - firstblend)) / len;
}
-
- fac = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_fac);
- }
-
- if (bevp->split_tag) {
- BLI_BITMAP_ENABLE(dl->bevel_split, a);
- }
-
- /* rotate bevel piece and write in data */
- if ((a == 0) && (bevp != bevp_last)) {
- rotateBevelPiece(cu, bevp, bevp + 1, dlb, 1.0f - firstblend, widfac, fac, &data);
- }
- else if ((a == steps - 1) && (bevp != bevp_first)) {
- rotateBevelPiece(cu, bevp, bevp - 1, dlb, 1.0f - lastblend, widfac, fac, &data);
}
else {
- rotateBevelPiece(cu, bevp, NULL, dlb, 0.0f, widfac, fac, &data);
- }
+ len = bl->nr - 1;
+ taper_fac = (float)i / len;
- 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 == 0) {
+ taper_fac += (1.0f - firstblend) / len;
}
- if (a == steps - 1) {
- fillBevelCap(nu, dlb, cur_data, &top_capbase);
- negate_v3_v3(top_no, bevp->dir);
+ else if (a == steps - 1) {
+ taper_fac -= (1.0f - lastblend) / len;
}
}
+
+ fac = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_fac);
}
- /* gl array drawing: using indices */
- displist_surf_indices(dl);
- }
+ if (bevp->split_tag) {
+ BLI_BITMAP_ENABLE(dl->bevel_split, a);
+ }
+
+ /* rotate bevel piece and write in data */
+ if ((a == 0) && (bevp != bevp_last)) {
+ rotateBevelPiece(cu, bevp, bevp + 1, dlb, 1.0f - firstblend, widfac, fac, &data);
+ }
+ else if ((a == steps - 1) && (bevp != bevp_first)) {
+ rotateBevelPiece(cu, bevp, bevp - 1, dlb, 1.0f - lastblend, widfac, fac, &data);
+ }
+ else {
+ rotateBevelPiece(cu, bevp, NULL, dlb, 0.0f, widfac, fac, &data);
+ }
- 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);
+ 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);
+ }
+ }
}
+
+ /* gl array drawing: using indices */
+ displist_surf_indices(dl);
+ }
+
+ 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);
}
}
}