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

Fix for token rotation bug #848

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Petruchio
Copy link

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

  • Simplify the logic using modulo arithmetic
  • Simplify the code generally, for legibility
  • Suppress bug by using (from.rotation % 360) rather than (from.rotation)

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.

which causes rotation to sometimes go the wrong way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant