-
Notifications
You must be signed in to change notification settings - Fork 459
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
Conversation
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) |
Oh |
wait, what happens with the old FlxPoint? |
wdym? references to |
Yeah but it'll be using the new one right? What happens to the old one? |
can you give an example of existing code that would cause problems? How can code specifically target an "old" implementation of a class? |
Oh wait |
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 |
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 ofB
toA
A -= B
subtracts the value ofB
fromA
A *= k
scalesA
by floatk
in both x and y componentsA + B
returns a new point that is sum ofA
andB
A - B
returns a new point that is difference ofA
andB
A * k
returns a new point that isA
scaled with coefficientk
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 asFlxSpriteGroup
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