Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Schittek <leon.schittek@gmx.net>2022-09-23 18:54:27 +0300
committerLeon Schittek <leon.schittek@gmx.net>2022-09-23 19:13:45 +0300
commit67308d73a4f9ec34ef42ad22d48dad5840a8a5fd (patch)
tree59f5447d4b27c2f700412778189f015521568a70 /source/blender/editors/space_node/drawnode.cc
parent2438f76d6f289b237aac582405a0adeb10009ea1 (diff)
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
Diffstat (limited to 'source/blender/editors/space_node/drawnode.cc')
-rw-r--r--source/blender/editors/space_node/drawnode.cc13
1 files changed, 10 insertions, 3 deletions
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;
}
}