loodakrawa / SpriterDotNet

A pure C# Spriter implementation
zlib License
220 stars 75 forks source link

Major changes in duplicate key handling #100

Closed rfadeev closed 6 years ago

rfadeev commented 6 years ago

Since it’s perfectly fine to have two keys with the same timeline position and MathHelper’s GetFactor method does not check a and b values not to be equal, special handling of double key with the same timeline position is added. This resulted in UnityEngine errors when assigning local position with coordinate values equal NaN.

Reproduction case is having animation with first key at timeline position zero and last two keys at timeline position of animation end. When trying to get FrameData for time equal to animation end, factor calculation would return NaN.

Maximum duplicate key which can appear in a row is two, for more info see https://brashmonkey.com/forum/index.php?/topic/4083-multiple-keys-with-the-same-timestamp-in-timeline/

One thing I'm not sure about:

Example Spriter project to reproduce issue this pull request fixes: DuplicateKeyRepro.zip

Closes #98

loodakrawa commented 6 years ago

Thanks!