From f78ba0df02a9734740d7ccddbe315020f56852f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 May 2017 19:03:30 +1000 Subject: Fix T51350: 2D curve normals flip when deformed Deforming 2D curves & text with modifiers/shape-keys could flip the normals. Now check the back-facing flag instead of `z < 0`. --- source/blender/blenkernel/intern/displist.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index f8a9d57f579..2a300cbe47b 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -167,10 +167,12 @@ void BKE_displist_normals_add(ListBase *lb) if (dl->nors == NULL) { dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors"); - if (dl->verts[2] < 0.0f) + if (dl->flag & DL_BACK_CURVE) { dl->nors[2] = -1.0f; - else + } + else { dl->nors[2] = 1.0f; + } } } else if (dl->type == DL_SURF) { @@ -469,6 +471,7 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, const float normal_proj sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__); while (cont) { + int dl_flag_accum = 0; cont = 0; totvert = 0; nextcol = 0; @@ -514,6 +517,7 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, const float normal_proj nextcol = 1; } } + dl_flag_accum |= dl->flag; } dl = dl->next; } @@ -526,6 +530,7 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, const float normal_proj if (tot) { dlnew = MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type = DL_INDEX3; + dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE)); dlnew->col = colnr; dlnew->nr = totvert; dlnew->parts = tot; @@ -603,6 +608,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) dlnew->nr = dl->parts; dlnew->parts = 1; dlnew->type = DL_POLY; + dlnew->flag = DL_BACK_CURVE; dlnew->col = dl->col; dlnew->charidx = dl->charidx; @@ -623,6 +629,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) dlnew->nr = dl->parts; dlnew->parts = 1; dlnew->type = DL_POLY; + dlnew->flag = DL_FRONT_CURVE; dlnew->col = dl->col; dlnew->charidx = dl->charidx; -- cgit v1.2.3