From bc5dc88bda64125e77e5be675eb4af549405a595 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 12 Aug 2013 09:00:48 +0000 Subject: Fix #36420: ends of curves - caps & twist not good Forgot to calculate directions of first/last points for NURBS and POLY splines. --- source/blender/blenkernel/intern/curve.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 849c1c0d3e1..26ae1b94aee 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2408,6 +2408,23 @@ static void make_bevel_list_2D(BevList *bl) } } +static void bevlist_firstlast_direction_calc_from_bpoint(Nurb *nu, BevList *bl) +{ + if (nu->pntsu > 1) { + BPoint *first_bp = nu->bp, *last_bp = nu->bp + (nu->pntsu - 1); + BevPoint *first_bevp, *last_bevp; + + first_bevp = (BevPoint *)(bl + 1); + last_bevp = first_bevp + (bl->nr - 1); + + sub_v3_v3v3(first_bevp->dir, (first_bp + 1)->vec, first_bp->vec); + normalize_v3(first_bevp->dir); + + sub_v3_v3v3(last_bevp->dir, last_bp->vec, (last_bp - 1)->vec); + normalize_v3(last_bevp->dir); + } +} + void BKE_curve_bevelList_make(Object *ob) { /* @@ -2491,6 +2508,10 @@ void BKE_curve_bevelList_make(Object *ob) bevp++; bp++; } + + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { + bevlist_firstlast_direction_calc_from_bpoint(nu, bl); + } } else if (nu->type == CU_BEZIER) { /* in case last point is not cyclic */ @@ -2601,6 +2622,10 @@ void BKE_curve_bevelList_make(Object *ob) do_radius ? &bevp->radius : NULL, do_weight ? &bevp->weight : NULL, resolu, sizeof(BevPoint)); + + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { + bevlist_firstlast_direction_calc_from_bpoint(nu, bl); + } } } } -- cgit v1.2.3