Fix T83117: Curve bevel not handle aligned at end-points

Caused by fix for T80742, 4987b7d347.

Keep the fix that calculates the start/end direction
from adjacent points but only use it as a fallback.
This commit is contained in:
Campbell Barton 2020-12-08 12:14:27 +11:00
parent ab9952e55f
commit 5f1a155a5e
Notes: blender-bot 2023-02-13 20:24:56 +01:00
Referenced by issue #83117, Bezier curves behavior change
1 changed files with 15 additions and 6 deletions

View File

@ -2185,19 +2185,28 @@ static void bevel_list_calc_bisect(BevList *bl)
bevp2++;
}
/* In the unlikely situation that handles define a zeroed direction,
* calculate it from the adjacent points, see T80742.
*
* Only do this as a fallback since we typically want the end-point directions
* to be exactly aligned with the handles at the end-point, see T83117. */
if (is_cyclic == false) {
bevp0 = &bl->bevpoints[0];
bevp1 = &bl->bevpoints[1];
sub_v3_v3v3(bevp0->dir, bevp1->vec, bevp0->vec);
if (normalize_v3(bevp0->dir) == 0.0f) {
copy_v3_v3(bevp0->dir, bevp1->dir);
if (UNLIKELY(is_zero_v3(bevp0->dir))) {
sub_v3_v3v3(bevp0->dir, bevp1->vec, bevp0->vec);
if (normalize_v3(bevp0->dir) == 0.0f) {
copy_v3_v3(bevp0->dir, bevp1->dir);
}
}
bevp0 = &bl->bevpoints[bl->nr - 2];
bevp1 = &bl->bevpoints[bl->nr - 1];
sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp0->vec);
if (normalize_v3(bevp1->dir) == 0.0f) {
copy_v3_v3(bevp1->dir, bevp0->dir);
if (UNLIKELY(is_zero_v3(bevp1->dir))) {
sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp0->vec);
if (normalize_v3(bevp1->dir) == 0.0f) {
copy_v3_v3(bevp1->dir, bevp0->dir);
}
}
}
}