-
-
Notifications
You must be signed in to change notification settings - Fork 908
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
refactor: Use a temp vector for delta calculations of FollowBehavior
#3230
Conversation
if (delta.x != 0 || delta.y != 0) { | ||
owner.position = delta..add(owner.position); | ||
if (_tempDelta.x != 0 || _tempDelta.y != 0) { | ||
owner.position = _tempDelta..add(owner.position); |
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.
to go all the way avoiding object creation entirely, this could be owner.position.setValues(owner.position.x + delta.x, ...)
sadly we lose all the easiness of using vectorial math at all when doing things like this
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.
this could be owner.position.setValues(owner.position.x + delta.x, ...)
I thought the same. But unfortunately doing so causes some of the tests to fail, because the .setValues
bypasses the position
setter of PositionProvider
. Some components do extra stuff in that setter.
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.
oof, seems like a footgun waiting to happen :(
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
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
This PR add a temp vector in
FollowBehavior
to avoid creating a new vector every frame for the delta calculations.Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Related Issues
NA