-
-
Notifications
You must be signed in to change notification settings - Fork 895
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: Absolute angle takes into account BodyComponent ancestors too #2678
Conversation
Good idea! |
Oops, I missed it. But it's got a lower-case O for some reason. Updated. |
Since it hasn't been exported previously, do you mind renaming it to (You can sneak it into this PR too) |
There we go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
Description
Currently, the implementation of the
absoluteAngle
getter inPositionComponent
only takes into accountPositionComponent
ancestors. The implementation simply runs through the whole hierarchy summing up the relative angles.This gives a wrong result with Forge2D because
BodyComponent
s have angles too: in the common situation where aPositionComponent
(e.g. aSpriteComponent
) is the child of aBodyComponent
, theBodyComponent
's rotation is ignored when computing theabsoluteAngle
.The fix simply introduces a new minimal interface
HasAngle
that bothPositionComponent
andBodyComponent
implement (PositionComponent
implements it automatically viaAngleProvider
), and reimplementsabsoluteAngle
so that it considers all ancestors with an angle and not just thePositionComponent
ones.Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?