diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-14 23:45:35 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-14 23:45:35 +0400 |
commit | 9e42f76bab4a5ee766e4fe09bd9c9b3579e3da8d (patch) | |
tree | 520602f87541685ca65d5a6e8e0bd87c960594b2 /source/blender | |
parent | 2c2206a27208c3869a51528d24637806075f1804 (diff) |
Fix #36467: ends of curves - 2D differs to 3D
This is getting confused, why bevel is handled different
for 2D and 3D curves?
Anyway, made bevel work for 2D case nice again, but it's
probably nice to unify 2D and 3D cases.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2285d7d8dc0..801ed4f00a5 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2372,12 +2372,23 @@ static void make_bevel_list_2D(BevList *bl) /* note: bevp->dir and bevp->quat are not needed for beveling but are * used when making a path from a 2D curve, therefor they need to be set - Campbell */ - BevPoint *bevp2 = (BevPoint *)(bl + 1); - BevPoint *bevp1 = bevp2 + (bl->nr - 1); - BevPoint *bevp0 = bevp1 - 1; + BevPoint *bevp0, *bevp1, *bevp2; int nr; - nr = bl->nr; + if (bl->poly != -1) { + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; + nr = bl->nr; + } + else { + bevp0 = (BevPoint *)(bl + 1); + bevp1 = bevp0 + 1; + bevp2 = bevp1 + 1; + + nr = bl->nr - 2; + } + while (nr--) { const float x1 = bevp1->vec[0] - bevp0->vec[0]; const float x2 = bevp1->vec[0] - bevp2->vec[0]; @@ -2399,15 +2410,23 @@ static void make_bevel_list_2D(BevList *bl) /* correct non-cyclic cases */ if (bl->poly == -1) { - BevPoint *bevp = (BevPoint *)(bl + 1); - bevp1 = bevp + 1; - bevp->sina = bevp1->sina; - bevp->cosa = bevp1->cosa; + BevPoint *bevp; + float angle; + + /* first */ + bevp = (BevPoint *)(bl + 1); + angle = atan2(bevp->dir[0], bevp->dir[1]) - M_PI / 2.0; + bevp->sina = sinf(angle); + bevp->cosa = cosf(angle); + vec_to_quat(bevp->quat, bevp->dir, 5, 1); + + /* last */ bevp = (BevPoint *)(bl + 1); bevp += (bl->nr - 1); - bevp1 = bevp - 1; - bevp->sina = bevp1->sina; - bevp->cosa = bevp1->cosa; + angle = atan2(bevp->dir[0], bevp->dir[1]) - M_PI / 2.0; + bevp->sina = sinf(angle); + bevp->cosa = cosf(angle); + vec_to_quat(bevp->quat, bevp->dir, 5, 1); } } |