obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.28k stars 7.99k forks source link

Moving group child with center alignment #9298

Open Durss opened 1 year ago

Durss commented 1 year ago

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

29.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/w4kHSawZNAkkfrvz

OBS Studio Crash Log URL

No response

Expected Behavior

Suppose I have a group with 2 children. The group's transform alignment is set to "center" Moving a child shouldn't affect the other one.

Current Behavior

Moving one child slowly offset the other to the bottom right. If alignment is set to anything with a "center" (ex: top center, left center, ...) it's the same. Basically if vertical alignment is centered the child will move downward, if the horizontal alignment is centered it will move to the right. If both at centered it moves down right

Steps to Reproduce

  1. create a group
  2. add two children
  3. set the alignment of the group to "center"
  4. move one of the children
  5. the other should slow get offset

Anything else we should know?

Here is a screen capture https://youtu.be/zfC6VUFaK6M

You'll also see that the cross orgin of the child moved with the mouse is completely off the actual element.

RytoEX commented 1 year ago

We've tested this and confirmed the behavior described. It does seem like the group should update its bounds if its contents are changed like this, so we've marked this Issue confirmed.

This is perhaps the same core behavior as described in #8400. Quoting excerpts of my response from there:

While unexpected, I think is by design. [...] Moving group child items in such a way that places them outside the current boundaries of the group results in the group resizing itself to accommodate the new position, which subsequently changes the coordinates of the child item according to the group's coordinate plane.

That said, this specific behavior (the position of the group itself changing) might not be intentional.

Without looking at the code, I'd hazard a guess that there might be some weirdness happening with float calculations of coordinates that results in the recalculated position coordinates of the group being rounded up/down, which produces the behavior seen here where the group appears to slowly move.

PatTheMav commented 1 year ago

I just did a few test runs with the code and while it's basic assumptions are correct the calculated values for positions are wildly off:

Taking a group sized at 1000x500 on a full HD canvas with a "bottom right" anchor point should always yield the position (1920,1080), but moving a single source inside the group makes the entire group slowly move away from the bottom right corner.

I agree that this is quite probably introduced by rounding errors on several occasions because the sources can be scaled, the group can be scaled, the preview can be scaled, etc.

FWIW the other source's actual size and coordinates are never changed, it is the x and y position of the group itself that is changed by resize_group called in the graphics thread (as moving the source marks the group for a deferred size update).