[Bf-blender-cvs] [67308d73a4f] master: Node Editor: Adjust node link curving
Leon Schittek
noreply at git.blender.org
Fri Sep 23 18:14:14 CEST 2022
Commit: 67308d73a4f9ec34ef42ad22d48dad5840a8a5fd
Author: Leon Schittek
Date: Fri Sep 23 17:54:27 2022 +0200
Branches: master
https://developer.blender.org/rB67308d73a4f9ec34ef42ad22d48dad5840a8a5fd
Node Editor: Adjust node link curving
Clamp node link curving when the link is close to horizontal to prevent
overshooting at the ends.
Reviewed By: Pablo Vazquez, Hans Goudey
Differential Revision: http://developer.blender.org/D16041
===================================================================
M source/blender/editors/space_node/drawnode.cc
===================================================================
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index fbbdd40e92e..b2510df9105 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -1604,12 +1604,19 @@ static void calculate_inner_link_bezier_points(std::array<float2, 4> &points)
points[2] = math::interpolate(points[0], points[3], 2.0f / 3.0f);
}
else {
- const float dist = curving * 0.1f * math::distance(points[0].x, points[3].x);
+ const float dist_x = math::distance(points[0].x, points[3].x);
+ const float dist_y = math::distance(points[0].y, points[3].y);
- points[1].x = points[0].x + dist;
+ /* Reduce the handle offset when the link endpoints are close to horizontal. */
+ const float slope = safe_divide(dist_y, dist_x);
+ const float clamp_factor = math::min(1.0f, slope * (4.5f - 0.25f * float(curving)));
+
+ const float handle_offset = curving * 0.1f * dist_x * clamp_factor;
+
+ points[1].x = points[0].x + handle_offset;
points[1].y = points[0].y;
- points[2].x = points[3].x - dist;
+ points[2].x = points[3].x - handle_offset;
points[2].y = points[3].y;
}
}
More information about the Bf-blender-cvs
mailing list