From 3ef2ae934da7ebc89809f5801e0c20b0b8a4b0a5 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Thu, 29 May 2025 19:29:34 +0200 Subject: [PATCH] [optimization] skip bezier skip bezier if all handles sit on their points --- butils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/butils.py b/butils.py index a8a9a14..3fe2098 100644 --- a/butils.py +++ b/butils.py @@ -94,6 +94,8 @@ def calc_point_on_bezier(bezier_point_1, bezier_point_2, t): h1 = bezier_point_1.handle_right p2 = bezier_point_2.co h2 = bezier_point_2.handle_left + if p1 == h1 and p2 == h2: + return p1 + t * (p2 - p1) return ( ((1 - t) ** 3) * p1 + (3 * t * (1 - t) ** 2) * h1 @@ -126,6 +128,8 @@ def calc_tangent_on_bezier(bezier_point_1, bezier_point_2, t): h1 = bezier_point_1.handle_right p2 = bezier_point_2.co h2 = bezier_point_2.handle_left + if p1 == h1 and p2 == h2: + return (p2 - p1).normalized() return ( (-3 * (1 - t) ** 2) * p1 + (-6 * t * (1 - t) + 3 * (1 - t) ** 2) * h1