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

[spine-ts][player] Fix skeleton bounds now incorporate clippings #2220

Closed

Conversation

Disorrder
Copy link

Fixes #2219
Calculate only bounding of clipping attachments, if they exist.
Example: Violet border is debug of clipping

Before:
image
After:
image

Spineboy
Before
image
After
image

@Disorrder
Copy link
Author

Disorrder commented Dec 30, 2022

Not sure it is totally correct, because in spineboy animation clipping applies only for boy, but portal is visible and should be included in bounding. But idk how to recognise clipped components
image

@badlogic
Copy link
Collaborator

Ah, yes, that won't work I'm afraid. What needs to be done is replicating large parts of the SkeletonRenderer logic:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-ts/spine-webgl/src/SkeletonRenderer.ts#L65

The bounds need to be evaluated by getting the min/max x/y for clipped region and mesh attachments. Basically, the SkeletonRenderer.draw() method needs to be duplicated. That shouldn't be done in getBounds() I think, but rather in the Player itself. Other people's projects rely on Skeleton.getBounds() not taking into account clipping attachments.

@Disorrder
Copy link
Author

Disorrder commented Dec 30, 2022

Thanks for fast replies!
But viewport size also relies on Skeleton.getBounds(). And any other projects could rely on this behaviour 🤔 . Do you think it should use new bounding method? Like getBoundsVisible or something?
Did I understand you correct? Viewport size should be calculated from clipped regions and only visible meshes that aren't clipped.
I don't think we really need to repeat draw method, just need to filter all attachments that aren't clipped and clipping regions itself, that's it. But I still not sure how to recognise is element clipped or not. Are slotRangeStart , slotRangeEnd responsible for that? Multiple clip regions are not supported, right? Or they just somehow sorted 🤔
I've just started to use your player couple days ago, haven't dived too deep yet.

@davidetan
Copy link
Collaborator

@Disorrder Thanks for you PR and the discussion.
This inspired us to change Skeleton.getBounds() in all our runtimes.
Now the method gets an additionional SkeletonClipping parameter. If passed, the bounds are calculated taking clipping attachments into consideration.
You can see the updates to the Player and TS runtime here: 03f8f67 and f309722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[player] Take clipping into account when calculating animation viewport
3 participants