diff options
4 files changed, 30 insertions, 30 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 68b64804526..541c82be2f3 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1585,8 +1585,7 @@ void draw_nodespace_back_pix(const bContext &C, GPU_matrix_pop(); } -bool node_link_bezier_handles(const View2D *v2d, - const SpaceNode *snode, +bool node_link_bezier_handles(const SpaceNode *snode, const bNodeLink &link, std::array<float2, 4> &points) { @@ -1637,35 +1636,38 @@ bool node_link_bezier_handles(const View2D *v2d, /* Straight line: align all points. */ points[1] = math::interpolate(points[0], points[3], 1.0f / 3.0f); points[2] = math::interpolate(points[0], points[3], 2.0f / 3.0f); - return true; } + else { + const float dist = curving * 0.1f * math::distance(points[0].x, points[3].x); - const float dist = curving * 0.10f * fabsf(points[0].x - points[3].x); + points[1].x = points[0].x + dist; + points[1].y = points[0].y; - points[1].x = points[0].x + dist; - points[1].y = points[0].y; + points[2].x = points[3].x - dist; + points[2].y = points[3].y; + } - points[2].x = points[3].x - dist; - points[2].y = points[3].y; + return true; +} - if (v2d && min_ffff(points[0].x, points[1].x, points[2].x, points[3].x) > v2d->cur.xmax) { - return false; /* clipped */ +static bool node_link_draw_is_visible(const View2D &v2d, const std::array<float2, 4> &points) +{ + if (min_ffff(points[0].x, points[1].x, points[2].x, points[3].x) > v2d.cur.xmax) { + return false; } - if (v2d && max_ffff(points[0].x, points[1].x, points[2].x, points[3].x) < v2d->cur.xmin) { - return false; /* clipped */ + if (max_ffff(points[0].x, points[1].x, points[2].x, points[3].x) < v2d.cur.xmin) { + return false; } - return true; } -bool node_link_bezier_points(const View2D *v2d, - const SpaceNode *snode, +bool node_link_bezier_points(const SpaceNode *snode, const bNodeLink &link, float coord_array[][2], const int resol) { std::array<float2, 4> points; - if (!node_link_bezier_handles(v2d, snode, link, points)) { + if (!node_link_bezier_handles(snode, link, points)) { return false; } @@ -2181,7 +2183,10 @@ void node_draw_link_bezier(const bContext &C, const bool selected) { std::array<float2, 4> points; - if (!node_link_bezier_handles(&v2d, &snode, link, points)) { + if (!node_link_bezier_handles(&snode, link, points)) { + return; + } + if (!node_link_draw_is_visible(v2d, points)) { return; } const NodeLinkDrawConfig draw_config = nodelink_get_draw_config( @@ -2246,7 +2251,7 @@ void node_draw_link_dragged(const bContext &C, } std::array<float2, 4> points; - if (!node_link_bezier_handles(&v2d, &snode, link, points)) { + if (!node_link_bezier_handles(&snode, link, points)) { return; } diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index bac1f291741..fcbb45a48f4 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -108,7 +108,7 @@ static bool add_reroute_intersect_check(const bNodeLink &link, { float coord_array[NODE_LINK_RESOL + 1][2]; - if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) { + if (node_link_bezier_points(nullptr, link, coord_array, NODE_LINK_RESOL)) { for (int i = 0; i < tot - 1; i++) { for (int b = 0; b < NODE_LINK_RESOL; b++) { if (isect_seg_seg_v2_point( diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index 694c67d160b..52e6521370e 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -229,17 +229,14 @@ void node_draw_link_bezier(const bContext &C, int th_col2, int th_col3, bool selected); -/** If v2d not nullptr, it clips and returns 0 if not visible. */ -bool node_link_bezier_points(const View2D *v2d, - const SpaceNode *snode, +bool node_link_bezier_points(const SpaceNode *snode, const bNodeLink &link, float coord_array[][2], int resol); /** - * Return quadratic beziers points for a given nodelink and clip if v2d is not nullptr. + * Return quadratic beziers points for a given nodelink. */ -bool node_link_bezier_handles(const View2D *v2d, - const SpaceNode *snode, +bool node_link_bezier_handles(const SpaceNode *snode, const bNodeLink &ink, std::array<float2, 4> &points); void draw_nodespace_back_pix(const bContext &C, diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 28977ebe662..aac05fb1d25 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -120,8 +120,6 @@ static void pick_input_link_by_link_intersect(const bContext &C, const float2 &cursor) { SpaceNode *snode = CTX_wm_space_node(&C); - const ARegion *region = CTX_wm_region(&C); - const View2D *v2d = ®ion->v2d; float2 drag_start; RNA_float_get_array(op.ptr, "drag_start", drag_start); @@ -140,7 +138,7 @@ static void pick_input_link_by_link_intersect(const bContext &C, if (link->tosock == socket) { /* Test if the cursor is near a link. */ std::array<float2, 4> points; - node_link_bezier_handles(v2d, snode, *link, points); + node_link_bezier_handles(snode, *link, points); std::array<float2, NODE_LINK_RESOL + 1> data; BKE_curve_forward_diff_bezier(points[0].x, @@ -1327,7 +1325,7 @@ static bool node_links_intersect(bNodeLink &link, const float mcoords[][2], int { float coord_array[NODE_LINK_RESOL + 1][2]; - if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) { + if (node_link_bezier_points(nullptr, link, coord_array, NODE_LINK_RESOL)) { for (int i = 0; i < tot - 1; i++) { for (int b = 0; b < NODE_LINK_RESOL; b++) { if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { @@ -1967,7 +1965,7 @@ void ED_node_link_intersect_test(ScrArea *area, int test) continue; } - if (node_link_bezier_points(nullptr, nullptr, *link, coord_array, NODE_LINK_RESOL)) { + if (node_link_bezier_points(nullptr, *link, coord_array, NODE_LINK_RESOL)) { float dist = FLT_MAX; /* loop over link coords to find shortest dist to |