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

Rotating a sliced sprite around off-center Anchor behaves erratic #12408

Closed
lennart opened this issue Mar 10, 2024 · 3 comments · Fixed by #12769
Closed

Rotating a sliced sprite around off-center Anchor behaves erratic #12408

lennart opened this issue Mar 10, 2024 · 3 comments · Fixed by #12769
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Milestone

Comments

@lennart
Copy link

lennart commented Mar 10, 2024

Bevy version

bevy main f0a9864

What you did

I rotated a sliced and custom sized sprite around an off-center anchor

What went wrong

I expected the sprite to be correctly scaled and rotated,
but the sliced parts leave gaps and do not seem to behave correctly. See the below screenshot:

image

Additional information

I just modified the sprite_slice example, you can inspect the changed example code in my fork

Am I misusing the TextureSlicer here? Should I actually be rotating something else, like a parent entity instead of the sliced sprite entity?

@lennart lennart added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 10, 2024
@lennart
Copy link
Author

lennart commented Mar 10, 2024

a typical use-case is an arrow sprite which I want to slice to scale its length without distorting it, but rotate it around the tip or end

@TrialDragon TrialDragon added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Mar 10, 2024
@JMS55 JMS55 added this to the 0.14 milestone Mar 24, 2024
@bugsweeper
Copy link
Contributor

bugsweeper commented Mar 28, 2024

The problem is in this line caused by anchor (even without rotation), because at some moment all parts of Sprite extracts as separate extracted sprites, at this moment each of them know self size, anchor in dimensions of global sprite, but not dimensions of global sprite. That's why the smaller sprite part is, the smaller anchor impact would be. Here is result of some workaround (I changed anchor for each part of sprite from global sprite dimensions to self dimensions)
image

@lennart
Copy link
Author

lennart commented Mar 29, 2024

@bugsweeper I can confirm that my altered example works as expected against your changes in #12769

github-merge-queue bot pushed a commit that referenced this issue Apr 16, 2024
…2769)

# Objective

Fixes #12408 .
Fixes #12680.

## Solution

- Recaclulated anchor from dimensions of sprite to dimension of each
part of it (each part contains its own anchor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants