这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@MrStevns
Copy link
Member

@MrStevns MrStevns commented Aug 21, 2022

This PR sought to fix that a selection would be drawn correct, however to make this viable a lot of assumptions had to be changed about the current implementation.

Demonstration:
transform-preview

Main points:

  • A selection is always based on a transform now, there's no hacking using multiple selection rects as we previously had.
  • The selection box will now be properly visualized when rotated
  • When in transform mode, the selection can be modified as much as needed even in a rotated state. Previously the transform wasn't calculated properly so the result would be skewed in continuous attempts to transform.
  • A selection is always applied after deselecting, meaning that the apply dialog is no more. I had tried various attempts to keep it but in the end found it too difficult fit it in without making huge modifications, see Fix inconsistent usage of apply transform dialog #1712 - This also fixes Can't move keyframes on timeline while using move tool #1671
  • Anchors are only drawn when move or select tool is in use.

Known issues:

  • Anchor arrows does not take rotation into effect (cosmetic)

Mitigations:

  • Added setCurrentLayer to undo/redo
    Reason:
    A lot of our core logic assumes the current layer changes when painting and applying changes, meaning you can't apply vector transformations while you're on bitmap layer and vise versa. This will fix that, by making sure you are on the correct layer.

In the future we should figure out how we want this to behave...

There's still room for improvement, especially when it comes to QRect vs QRectF... this is a mess tbh... but it's not something i'm going to fix with this PR. I believe that the selectionManager should be purely for bitmap and vector should either have its own or be kept to the VectorImage object.

- Rotation is now properly visualized
- Transformed object after rotating keeps correct transform
- Cleaned up selection painting logic
- Removed last selection visual
- Moved setModified to Editor instead of scribblearea
- Fixed selection info should diff from center of rect
Given that a lot of our rendering and transform code is based around the current layer index and not the modified frame and layer, and the fact that there's shared responsibility across the codebase... we apply the changes when switching layer, otherwise the selection transform might affect the wrong layer.
This happens because our logic assumes the current layer changes, meaning you can't apply vector transformations while you're on bitmap layer and vise versa. This will fix that, by making sure you are on the correct layer.

In the future we should figure out how we want this to behave...
Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the wait, but I wanted to finish reviewing David’s PR first. I looked over your changes and they look good to me for the most part. I did some cleanup and smaller fixes which I’ll push in a moment. Everything seems to work as intended as well, with the exception of selection flipping.

First of all, it seems to suffer from that cache issue which you took care of a while ago. That is, the change doesn’t become visible until you change the zoom level or something like that. Secondly, the selection is no longer flipped in place like it was before but it also changes position. Additionally, flipping the selection vertically now also flips it horizontally in addition to vertically. And last but not least, the action is no longer undoable.

That aside, I noticed that at least in debug builds the move tool feels quite a bit more sluggish than before. It’s not that noticeable in release builds, and perhaps it’s exacerbated by the fact that I’m currently running on a ten year old low-end notebook, but maybe it’d be a good idea to whip out a profiler and make sure there are no performance bottlenecks. I might take a look myself tomorrow, but for now I need to get some sleep.

Those issues aside, I’m very happy about these changes. Great job!

@MrStevns
Copy link
Member Author

MrStevns commented Oct 9, 2022

Thanks for a thorough review Jacob!

I've pushed a bunch of commits, fixing the issues you mentioned and re-adding undo/redo. It's funny how when I reviewed the selection flipping last time, it worked fine.. I must have accidentally moved the selection first before testing, which is why it worked for me.

I agree that it feels more sluggish now, though I haven't been able to figure out the root cause yet. Doing a quick profile does not seem to point to anything particular except painting but what I've done shouldn't really affect that much.

Your changes looks good too, thanks for applying them 👍

@J5lx
Copy link
Member

J5lx commented Oct 9, 2022

Thanks for addressing those issues, those changes all look good. I did some profiling myself and that so much time is spent painting is indeed kind of the issue. Editor::frameModified is now emitted in both MoveTool::pointerMoveEvent and MoveTool::transformSelection. Because MoveTool::pointerMoveEvent also calls MoveTool::transformSelection, that effectively means that, when transforming a selection, Editor::frameModified is emitted twice for every move event, which therefore causes the entire timeline (!) to be redrawn twice. (It also results in ScribbleArea caches being invalidated, but that doesn’t make nearly as much of a difference than the timeline redraw.) On master, transforming the selection does not cause the timeline to be repainted at all.

With that in mind, please update this PR so that transforming the selection no longer causes timeline repaints, like before. The double frameModified signal should be fixed as well, I reckon. Technically the timeline should probably also defer the actual painting until the next paintEvent, but that is clearly out-of-scope for this PR, so no need to worry about that.

Once this performance issue is dealt with, the PR should be ready for merge. Thank you for all of your work!

@MrStevns
Copy link
Member Author

MrStevns commented Oct 10, 2022

Ah yes good point, I did notice the timeline calls but as I said I didn't spend too much time on the profiling but that was indeed the main culprit. The performance issue should have been addressed now. Given the way frameModified used now for triggering cache invalidation's we'll still call timeline and therefore still cause a repaint, but it will only happen on release events.

Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, that sounds good to me. Thanks for taking care of it! Time to merge this :)

@J5lx J5lx merged commit 24c267f into pencil2d:master Oct 12, 2022
J5lx added a commit that referenced this pull request Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status
Status: No status

Development

Successfully merging this pull request may close these issues.

Can't move keyframes on timeline while using move tool

2 participants