-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Rework GraphEdit
connections (drawing, API, optimizations)
#86158
Conversation
Out of curiosity, why did you decide to supersede your other PR instead of pushing an update to it? Also what exactly breaks compatibility here? |
I'd probably leave it in, as I remember people using GraphNode/GraphEdit in games with a pixel art style. |
@nicolasgustafsson There is definitely some room for improvement there, but since the whole line needs to be on top we can't draw it behind the port. However, I have some ideas, e.g. you could fade the rim (which would require passing the line length as an uniform). @YuriSizov Well, although this PR includes the features of the other one, the approach for updating/rendering the connections is quite different. Since that was a big part of the other PR and @ats already approved it, I thought it would be better to open a separate PR instead of updating the existing one because a lot has changed.
@Calinou Well in that case a connection line with AA turned off might be still too smooth, for something like this you're able to override the default connection line shader and achieve a true pixelated look. You can do basically everything you like as you can see in the example below ;) |
From the production point of view, you can just dismiss a stale review to indicate that your work needs to be reviewed again (and of course I would assume you leave a comment with an explanation of updates anyway). So for everyone else's benefit this wasn't necessary. But if it helps you, then opening a new PR is fine. Feel free to close the old one if you're replacing it. As for breaking changes, if they are purely cosmetic and don't change public API in any way, we don't need to label it as breaking changes. |
As the old PR didn't have review stuff on it I'd be fine but otherwise I'd suggest avoiding superseding PRs unless most of the feedback on it is significantly outdated, to not lose a lot of progress in the feedback there |
54b5529
to
2d69006
Compare
Why does it need to draw on top of the nodes? |
Well, in a dense graph you would only see tiny segments of your dragged connection line which makes it quite unfun/a bit awkward to use. (Every graph editor I tried so far draws it over everything else while dragging, so Godot isn't an exception here) |
2d69006
to
c9bd7d0
Compare
Overall code seems fine, good job! Functionality-wise it all seems to work. Helper methods for geometry seem fine as well. So once the feedback is addressed, this should be good to go. I also noticed an issue with visual shaders as I was testing. Reported here #87337 |
d174975
to
ec83cb4
Compare
I think I addressed all the review comments :) |
Builds failing because constness change needs to be added to the extension compatibility file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the compatibility check, it's all good 👍
ec83cb4
to
d39607b
Compare
I also forgot to adjust the commit message. Both should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a compatibility method
f07a0bd
to
beab609
Compare
@AThousandShips I'm not too familiar with the compat method binding stuff, but I think I got it now :) |
beab609
to
cf3af7a
Compare
- GraphEdit now uses Line2D nodes to draw connection lines and uses a dedicated canvas item shader for them
cf3af7a
to
9d7c297
Compare
Thanks! |
I found this in git blame as I remembered that it upsets Aaronfranke's attempt to implement a disable_2d build option, forcing it to make an exception for Line2D. Would it make sense to use draw_polyline on a Control with the same shader instead?
|
draw_polyline is not sufficient (line caps and UVs are needed), but since Line2D uses another abstraction (LineBuilder) we could do something like that (basically by using the same drawing code as in Line2D). |
Supersedes #83508.
Detailed changes
API
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.get_connections_intersecting_with_rect
reset_all_connection_activity
Visual
connection_rim_color
theme property is addedconnection_hover_tint_color
)connection_valid_target_tint_color
)When zooming/panning fast this could happen before:
Optimizations, Fixes & Refactoring
Optimize connection drawing/handling
Connection lines are now drawn using Line2D nodes instead of using
draw_polyline
calls in only oneCanvasItem
Connection line shader
Keep in mind that the following is just a quick/arbitrary POC using the shader override and not included in this PR
Drawing the lines for the minimap is now completely separate, drawing the lines via a shader is not sensible here (this also paves the way for loosening up the coupling between the minimap and GraphEdit itself and allows for optimizations since the minimap is currently a bottleneck)
Change signature of
get_connection_list
(now returns the list instead of using a return parameter) [only used internally]Fixes Deleting GraphNodes when handling
delete_nodes_request
causes connection visuals to leak #36716.TODO