[Bf-blender-cvs] [5f1a155a5ef] master: Fix T83117: Curve bevel not handle aligned at end-points

Campbell Barton noreply at git.blender.org
Tue Dec 8 02:28:10 CET 2020


Commit: 5f1a155a5ef39a4db144b38a607c19b763f965a3
Author: Campbell Barton
Date:   Tue Dec 8 12:14:27 2020 +1100
Branches: master
https://developer.blender.org/rB5f1a155a5ef39a4db144b38a607c19b763f965a3

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

Caused by fix for T80742, 4987b7d347a885916916a888c18401ea2fe552f4.

Keep the fix that calculates the start/end direction
from adjacent points but only use it as a fallback.

===================================================================

M	source/blender/blenkernel/intern/curve.c

===================================================================

diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 2df9f362b9c..ebce28c4e23 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -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);
+      }
     }
   }
 }



More information about the Bf-blender-cvs mailing list