-
-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Highlight points on hover in the Polygon2D editor #107890
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
base: master
Are you sure you want to change the base?
Highlight points on hover in the Polygon2D editor #107890
Conversation
Does this also apply to the polygon editor in the scene view? If not, it should! |
If I understand correctly what you mean, it seems like it was already implemented. polygon2d-editor-highlighting-2.mp4 |
Ah, yup! Maybe use the same colors then? |
The main performance problem of Polygon2D editor is because it still uses the inefficient canvas draw functions for every single line and handle texture, aka every single vertex edge segment is its own canvas item and draw in the editor. It basically creates a new throwaway mesh for every single handle point that it deletes on the next redraw, oc performance is bad with that on larger polygons. Should be switched to use static meshes and multimeshes like done for Path2D editor in PR #105606 |
9bf2e67
to
c6c305d
Compare
Do you think I should apply the same fix in this PR? It's a little bit out of its scope. |
Nono that is very much out of scope and should be its own PR. That was in response to the comment about performance. |
8f7d6c0
to
ec5ca6e
Compare
@@ -135,6 +135,7 @@ class Polygon2DEditor : public AbstractPolygon2DEditor { | |||
int point_drag_index = -1; | |||
bool is_dragging = false; | |||
bool is_creating = false; | |||
int highlighted_point = -1; |
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.
int highlighted_point = -1; | |
int hovered_point = -1; |
More accurate.
@@ -776,6 +779,41 @@ void Polygon2DEditor::_canvas_input(const Ref<InputEvent> &p_input) { | |||
Ref<InputEventMouseMotion> mm = p_input; | |||
|
|||
if (mm.is_valid()) { | |||
// Highlight a point near the cursor |
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.
// Highlight a point near the cursor | |
// Highlight a point near the cursor. |
ec5ca6e
to
8ea9fbb
Compare
The Polygon2D editor now highlights a point, if it's near the mouse cursor. It especially useful on touchpads, where it's much harder to aim.
But I was surprised how much it improves the mouse experience as well. And now I don't want to go back to the previuos behavior, because it was awful.
However, the Polygon2D editor is far from perfect and still needs a few improvements.
polygon2d-editor-highlighting.mp4
The downside of this improvement is performance, because now the editor needs to redraw more often and iterate through the array of points on every mouse move. However, it's well optimized, because it redraws only when the highlighted point is changed and avoids looping when is_creating is true, checking only the first point.