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

Update dependent positions on origin change #1202

Merged
merged 5 commits into from
Dec 8, 2018

Conversation

starwed
Copy link
Member

@starwed starwed commented Dec 8, 2018

Setting the origin 'mid scene' was not properly updating the overall entity state.

When the origin of a rotated entity changes, we need to:

  • Adjust the position of attached children (such as collision hitboxes)
  • Recalculate the MBR
  • Update the spatial map, since the MBR might have changed
  • Flag for re-rendering

When the origin of a rotated entity changes, we need to update the
position of any attached entities.

Rotation around an origin is equivalent to shifting to the origin,
rotating, and then shifting back.  When the origin changes, conceptually
we can handle this by reversing the current rotation, changing the origin,
and then rotating back.

However, this turns out to be equivavent to a simple shift in position,
dependent on the current rotation, and the shift in origin.
So th implementation calculates this shift and propagates it to child entities.
When the origin changes, this affects attached entities
and the MBR.  Add tests for this behavior.
@starwed
Copy link
Member Author

starwed commented Dec 8, 2018

This should fix #1201, and might also resolve #1200. (For the latter, it could be that the MBR/map not being updated upon setting the origin could cause a rotated entity on the edge of the view to not be rendered -- the pre origin change position would have been off of the screen)

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