@@ -1299,18 +1299,26 @@ List<Ref<GraphEdit::Connection>> GraphEdit::get_connections_intersecting_with_re
12991299 return intersecting_connections;
13001300}
13011301
1302- void GraphEdit::_draw_minimap_connection_line (CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_from_color, const Color &p_to_color) {
1303- const Vector<Vector2> &points = get_connection_line (p_from, p_to);
1302+ void GraphEdit::_draw_minimap_connection_line (const Vector2 &p_from_graph_position, const Vector2 &p_to_graph_position, const Color &p_from_color, const Color &p_to_color) {
1303+ Vector<Vector2> points = get_connection_line (p_from_graph_position, p_to_graph_position);
1304+ ERR_FAIL_COND_MSG (points.size () < 2 , " \" _get_connection_line()\" returned an invalid line." );
1305+ // Convert to minimap points.
1306+ for (Vector2 &point : points) {
1307+ point = minimap->_convert_from_graph_position (point) + minimap->minimap_offset ;
1308+ }
1309+
1310+ // Setup polyline colors.
13041311 LocalVector<Color> colors;
13051312 colors.reserve (points.size ());
1306-
1307- float length_inv = 1.0 / (p_from).distance_to (p_to);
1313+ const Vector2 &from = points[0 ];
1314+ const Vector2 &to = points[points.size () - 1 ];
1315+ float length_inv = 1.0 / (from).distance_to (to);
13081316 for (const Vector2 &point : points) {
1309- float normalized_curve_position = (p_from) .distance_to (point) * length_inv;
1317+ float normalized_curve_position = from .distance_to (point) * length_inv;
13101318 colors.push_back (p_from_color.lerp (p_to_color, normalized_curve_position));
13111319 }
13121320
1313- p_where ->draw_polyline_colors (points, colors, 0.5 , lines_antialiased);
1321+ minimap ->draw_polyline_colors (points, colors, 0.5 , lines_antialiased);
13141322}
13151323
13161324void GraphEdit::_update_connections () {
@@ -1565,16 +1573,17 @@ void GraphEdit::_minimap_draw() {
15651573
15661574 // Draw node connections.
15671575 for (const Ref<Connection> &c : connections) {
1568- Vector2 from_position = minimap-> _convert_from_graph_position ( c->_cache .from_pos * zoom - graph_offset) + minimap_offset ;
1569- Vector2 to_position = minimap-> _convert_from_graph_position ( c->_cache .to_pos * zoom - graph_offset) + minimap_offset ;
1576+ Vector2 from_graph_position = c->_cache .from_pos * zoom - graph_offset;
1577+ Vector2 to_graph_position = c->_cache .to_pos * zoom - graph_offset;
15701578 Color from_color = c->_cache .from_color ;
15711579 Color to_color = c->_cache .to_color ;
15721580
15731581 if (c->activity > 0 ) {
15741582 from_color = from_color.lerp (theme_cache.activity_color , c->activity );
15751583 to_color = to_color.lerp (theme_cache.activity_color , c->activity );
15761584 }
1577- _draw_minimap_connection_line (minimap, from_position, to_position, from_color, to_color);
1585+
1586+ _draw_minimap_connection_line (from_graph_position, to_graph_position, from_color, to_color);
15781587 }
15791588
15801589 // Draw the "camera" viewport.
0 commit comments