Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphEdit connection rework (API & optimizations) #83508

Closed

Conversation

Geometror
Copy link
Member

@Geometror Geometror commented Oct 17, 2023

GE Connections

Detailed changes:

  • Add get_closest_connection_at_point which return the closest connection at a given point in GraphEdit's local screen space (with the given maximum search distance). See the docs for a usage example.
  • Optimize connection drawing/handling
    • Introduce connections HashMap (node -> its connections)
      • The old logic iterated over all connections for every GraphNode, now only the relevant connections are checked where possible.
    • Each connection now caches the line, the start and end positions (in screen space) as well as an AABB. This allows for updating/drawing only those connections visible on the screen (this had a huge performance impact for large graphs). It's also used to accelerate fetching the connection from a screen position which is introduced in this PR.
  • Adjust theming/visual appearance
    • hovering a connection now highlights it (theme item connection_hover_tint_color)
    • the highlight color when dragging a connection onto a valid port is now a theme item (theme item connection_valid_target_tint_color)
  • Change signature of get_connection_list (now returns the list instead of using a return parameter) [only used internally]

For a demonstration of these new features see #83510.

@fire
Copy link
Member

fire commented Oct 17, 2023

Is there a guide on how to get the point from whatever space to screenspace that the GraphEdit is in? I remember it was difficult to click on close buttons a long time ago. Maybe clicking on the graph line has the same issues.

Use case: 3d graph runner - can be arranged in 3d coordinates up oriented billboards.

Edited: I see your comment about See the docs for a usage example.

@Geometror Geometror force-pushed the graphedit-connection-api branch 2 times, most recently from 17384c2 to f6fa473 Compare October 19, 2023 23:37
@Geometror
Copy link
Member Author

Geometror commented Oct 19, 2023

Changes:

  • Add method get_connections_intersecting_with_rect
  • Add method reset_all_connection_activity
  • get_closest_connection_at_point (and the new method) now fully transforms the screen space coordinates internally, so get_closest_connection_at_point(local_mouse_position + get_scroll_offset()) now becomes just
    get_closest_connection_at_point(local_mouse_position)

Edit: The two new methods can now be seen in action here: #83510.

@Geometror Geometror force-pushed the graphedit-connection-api branch 3 times, most recently from 2059b75 to 7fec61f Compare October 22, 2023 01:54
@Geometror Geometror force-pushed the graphedit-connection-api branch from 7fec61f to dfec3c3 Compare November 26, 2023 00:36
@Geometror
Copy link
Member Author

Geometror commented Dec 15, 2023

Superseded by #86158.

@Geometror Geometror removed this from the 4.3 milestone Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants