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

rename FlxPoint->FlxBasePoint, FlxVector->FlxPoint #2557

Merged
merged 15 commits into from
May 26, 2022

Conversation

Geokureli
Copy link
Member

@Geokureli Geokureli commented May 15, 2022

The One True FlxPoint

Renamed FlxPoint to FlxBasePoint, which will be hidden from docs and completion, FlxVector was renamed to FlxPoint, a new typedef FlxVector was made as a simple alias to FlxPoint (with a deprecation warning) for backwards compatibility.

Math Operators

  • A += B adds the value of B to A
  • A -= B subtracts the value of B from A
  • A *= k scales A by float k in both x and y components
  • A + B returns a new point that is sum of A and B
  • A - B returns a new point that is difference of A and B
  • A * k returns a new point that is A scaled with coefficient k

Pooling

Operators grab points from the pool but don't put any (non-weak) points back, this could be a serious caveat. It makes me want to remove point-pooling altogether and inline the point constructor, however because set_x, set_y and set are not inlined there would be almost no benefit to this. these setters can't be inlined because they are overriden in FlxCallbackPoint, which is needed for the monstrosity known as FlxSpriteGroup

I'm assuming the impact to GC and pooling is small, but I added FLX_NO_POINT_POOL to allow side by side benchmark testing on existing games. In some cases, pool management is worse than letting GC take care of it

@Cheemsandfriends
Copy link
Contributor

Isn't this gonna affect old repos that used FlxVector?

@Geokureli
Copy link
Member Author

Geokureli commented May 18, 2022

Isn't this gonna affect old repos that used FlxVector?

FlxVector still exists as an alias for FlxPoint, but they'll get deprecation warnings (no errors)

@Cheemsandfriends
Copy link
Contributor

Oh
Oh wait you're right, I haven't seen that commit lmao srry

@Cheemsandfriends
Copy link
Contributor

wait, what happens with the old FlxPoint?

@Geokureli
Copy link
Member Author

wait, what happens with the old FlxPoint?

wdym? references to flixel.math.FlxPoint will still work

@Cheemsandfriends
Copy link
Contributor

wdym? references to flixel.math.FlxPoint will still work

Yeah but it'll be using the new one right? What happens to the old one?

@Geokureli
Copy link
Member Author

can you give an example of existing code that would cause problems? How can code specifically target an "old" implementation of a class?

@Cheemsandfriends
Copy link
Contributor

Oh wait
Now that you mention it, FlxVector has the same functions as FlxPoint.
I thought they were completely different shit

@ShaharMS
Copy link

might be a good time to also add some nice features to FlxBasePoint, like math functions with FlxBasePoints (additions, subtractions...)

@Geokureli
Copy link
Member Author

Geokureli commented May 23, 2022

might be a good time to also add some nice features to FlxBasePoint, like math functions with FlxBasePoints (additions, subtractions...)

The idea is to hide FlxBasePoint from devs as much as possible, just use FlxPoint which has all the functionality

@Geokureli Geokureli merged commit 1c11ea1 into HaxeFlixel:dev May 26, 2022
@Geokureli Geokureli deleted the vector_to_point branch May 26, 2022 20:21
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.

3 participants