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

feat: Add reusable vector to the Vector2 extension #2429

Merged
merged 10 commits into from
Mar 26, 2023

Conversation

Hwan-seok
Copy link
Contributor

@Hwan-seok Hwan-seok commented Mar 24, 2023

Description

Add a reusable static member which is Vector for reducing object(Vector2) creation overheads if available.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #2427

double ds,
) {
double ds, {
Vector2? efficientDiff,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could just have a private static vector in here instead so that the user doesn't have to pass in this vector?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea!
What do you think about sharing it inside the extension by naming it generally?
It might be useful when there is some point to save performance same as moveToTarget.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good :)

@Hwan-seok Hwan-seok changed the title feat: Reuse diff vector in the Vector2.moveToTarget feat: Add reusable vector to the Vector2 extension Mar 26, 2023
@Hwan-seok Hwan-seok requested a review from spydon March 26, 2023 05:59
packages/flame/lib/src/extensions/vector2.dart Outdated Show resolved Hide resolved
@spydon spydon merged commit 03d45df into flame-engine:main Mar 26, 2023
@Hwan-seok Hwan-seok deleted the hwanseok.efficient-move-to-target branch March 26, 2023 10:06
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.

Improve moveToTarget performance by reusing the diff vector
2 participants