Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This patch addresses a rotation bug in animateEntity.
Issue
Seems to be the same as this:
#499
This improves the behavior, but doesn't fix the point about 360-degree
rotation.
Changes Made
Testing
Done by hand. Bugs went away, and I noticed no new ones.
Details
The main problem is that at certain points, when rotation goes to 0,
the token rotates the wrong way.
This seems to be associated with stored rotation values higher than
360 degrees and lower than -360 degrees. So, for instance, if you
rotate clockwise to 288 and then to 0, it works as expected the first
time. But if you rotate clockwise to 288 again, and again to 0, the rotation
happens counter-clockwise, despite that you gave a positive rotation value.
Simplifying the logic with modular artihmetic seems to have fixed the bug
for counter-clockwise rotation. Then, using (from.rotation % 360) rather
than (from.rotation) gives what seems to be correct behavior for clockwise
rotation.
Clearly the system is elsewhere keeping track of absolute, rather than modular,
rotation. So, one full clockwise rotation stores 360, another stores 720, and
so on. I don't know whether this is desirable, but if it isn't, this problem
should be fixed at its source. If it is desirable, then we need to compensate
for it here.