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-02-17 06:40:16 +0300
committerHans Goudey <h.goudey@me.com>2021-02-17 06:40:16 +0300
commitab484ff22f4d9a1651f1b5b3475a222a056b001d (patch)
tree7cd0361b472d992933dc89b93f11f8cd0c5ed5d2 /source/blender/blenkernel/intern/displist.c
parent5c523c6578500fa8a8da676627d4e453db142cd3 (diff)
Fix T85664: 3D Viewport issues with curve poly splines
Caused by cleanup in rBcdb3cbd64401, where an index was used to index `float *` instead of `float[3]`.
Diffstat (limited to 'source/blender/blenkernel/intern/displist.c')
-rw-r--r--source/blender/blenkernel/intern/displist.c167
1 files changed, 166 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index dc274e25823..19ead2d972a 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -292,6 +292,170 @@ bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, i
/* ICC with the optimization -02 causes crashes. */
# pragma intel optimization_level 1
#endif
+
+// static void curve_to_displist(Curve *cu,
+// ListBase *nubase,
+// const bool for_render,
+// ListBase *dispbase)
+// {
+// DispList *dl;
+// BezTriple *bezt, *prevbezt;
+// BPoint *bp;
+// float *data;
+// int a, len, resolu;
+// const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
+
+// LISTBASE_FOREACH (Nurb *, nu, nubase) {
+// if (nu->hide != 0 && editmode) {
+// continue;
+// }
+
+// if (for_render && cu->resolu_ren != 0) {
+// resolu = cu->resolu_ren;
+// }
+// else {
+// resolu = nu->resolu;
+// }
+
+// if (!BKE_nurb_check_valid_u(nu)) {
+// /* pass */
+// }
+// else if (nu->type == CU_BEZIER) {
+// /* count */
+// len = 0;
+// a = nu->pntsu - 1;
+// if (nu->flagu & CU_NURB_CYCLIC) {
+// a++;
+// }
+
+// prevbezt = nu->bezt;
+// bezt = prevbezt + 1;
+// while (a--) {
+// if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) {
+// bezt = nu->bezt;
+// }
+
+// if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
+// len++;
+// }
+// else {
+// len += resolu;
+// }
+
+// if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) {
+// len++;
+// }
+
+// prevbezt = bezt;
+// bezt++;
+// }
+
+// dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
+// /* len+1 because of 'forward_diff_bezier' function */
+// dl->verts = MEM_mallocN((len + 1) * sizeof(float[3]), "dlverts");
+// BLI_addtail(dispbase, dl);
+// dl->parts = 1;
+// dl->nr = len;
+// dl->col = nu->mat_nr;
+// dl->charidx = nu->charidx;
+
+// data = dl->verts;
+
+// /* check that (len != 2) so we don't immediately loop back on ourselves */
+// if (nu->flagu & CU_NURB_CYCLIC && (dl->nr != 2)) {
+// dl->type = DL_POLY;
+// a = nu->pntsu;
+// }
+// else {
+// dl->type = DL_SEGM;
+// a = nu->pntsu - 1;
+// }
+
+// prevbezt = nu->bezt;
+// bezt = prevbezt + 1;
+
+// while (a--) {
+// if (a == 0 && dl->type == DL_POLY) {
+// bezt = nu->bezt;
+// }
+
+// if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
+// copy_v3_v3(data, prevbezt->vec[1]);
+// data += 3;
+// }
+// else {
+// int j;
+// for (j = 0; j < 3; j++) {
+// BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
+// prevbezt->vec[2][j],
+// bezt->vec[0][j],
+// bezt->vec[1][j],
+// data + j,
+// resolu,
+// sizeof(float[3]));
+// }
+
+// data += 3 * resolu;
+// }
+
+// if (a == 0 && dl->type == DL_SEGM) {
+// copy_v3_v3(data, bezt->vec[1]);
+// }
+
+// prevbezt = bezt;
+// bezt++;
+// }
+// }
+// else if (nu->type == CU_NURBS) {
+// len = (resolu * SEGMENTSU(nu));
+
+// dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
+// dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+// BLI_addtail(dispbase, dl);
+// dl->parts = 1;
+
+// dl->nr = len;
+// dl->col = nu->mat_nr;
+// dl->charidx = nu->charidx;
+
+// data = dl->verts;
+// if (nu->flagu & CU_NURB_CYCLIC) {
+// dl->type = DL_POLY;
+// }
+// else {
+// dl->type = DL_SEGM;
+// }
+// BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
+// }
+// else if (nu->type == CU_POLY) {
+// len = nu->pntsu;
+// dl = MEM_callocN(sizeof(DispList), "makeDispListpoly");
+// dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+// BLI_addtail(dispbase, dl);
+// dl->parts = 1;
+// dl->nr = len;
+// dl->col = nu->mat_nr;
+// dl->charidx = nu->charidx;
+
+// data = dl->verts;
+// if ((nu->flagu & CU_NURB_CYCLIC) && (dl->nr != 2)) {
+// dl->type = DL_POLY;
+// }
+// else {
+// dl->type = DL_SEGM;
+// }
+
+// a = len;
+// bp = nu->bp;
+// while (a--) {
+// copy_v3_v3(data, bp->vec);
+// bp++;
+// data += 3;
+// }
+// }
+// }
+// }
+
static void curve_to_displist(const Curve *cu,
const ListBase *nubase,
const bool for_render,
@@ -420,9 +584,10 @@ static void curve_to_displist(const Curve *cu,
dl->charidx = nu->charidx;
dl->type = (is_cyclic && (dl->nr != 2)) ? DL_POLY : DL_SEGM;
+ float(*coords)[3] = (float(*)[3])dl->verts;
for (int i = 0; i < len; i++) {
const BPoint *bp = &nu->bp[i];
- copy_v3_v3(&dl->verts[i], bp->vec);
+ copy_v3_v3(coords[i], bp->vec);
}
}
}