socialpoint-labs / spine-json-lib

Library to modify the JSON format of a Spine asset

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Draw orders need to be updated when removing slots

jesdi opened this issue · comments

commented

Sometimes after removing certain slots the animation gets corrupted.

After some research we found out that the offset of a symbol in a modified draw order data inside an animation is not being modified in certain cases.

The offset of a draw order data:

  • indicate the change of the order for that symbol.
  • it's positive means the symbol is going to be painted "later" and if it is negative means the symbol is going to be painted "earlier".
  • looks like it's always calculated based on the default drawOrder, even if it is modified few times along the timeline of an animation.

Taking that into account that, sometimes when removing slots it can lead to having the json of the animation corrupt. Because we are not updating the modified offsets in certain cases, this are the conditions that need to be true for us to update the draworder offset information:

  • An animation is modifying the default draw order(which is the inverse of the list of slots) of one of the remaining animations.
  • If the position of the removed slot affects the re-sorted slots in the custom draw order we have to update them potentially decreasing in 1 if it's necessary