-
Notifications
You must be signed in to change notification settings - Fork 222
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
Remove unnecessary operations for set_rotation and rectangle collision #820
base: master
Are you sure you want to change the base?
Conversation
This PR still needs to run clang-format. |
Just did. |
This will need a squash and I would suggest renaming the commit message to |
It's done. I'll do this from now on. |
Awesome, we appreciate it a lot |
Could you write tests in |
I don't know if you guys are going to decide to completely replace transform2d but in case you don't: I don't think this needs a programmed test. The only thing that can make this go wrong is if When it comes to a Vector2, setting an axis to The reason for this part of the pr is that the old (inlined set_size and added comments for an easier read)
|
Yeah the issue with Transform2D is this specific function isn't being tested anywhere even though it probably should be, since you're messing with it already it might as well be tested reinforcing it'll still spit out the right values, it doesn't just matter if this theoretically performs the same behavior, the tests reinforce expected behavior to reduce the chances of regressions, and which is trivial for this case anyway. Since you're already messing with a Transform2D method that isn't being tested we might as well be comprehensive and add it as well, it needs the test regardless. |
Added the test, is it accurate enough? |
…on and added set_rotation test.
This pr is just 2 simple performance optimizations.
set_rotation now doesn't re-normalized the normals produced by sin and cos.
Rectangle collision doesn't normalize the 2nd pillar of transform anymore. Instead it picks the 1st already normalized pillar and simply does {x2 = -y1; y2 = x1} which gives the same result and is less costly.