-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Add unit tests for Node2D helper methods #91654
Conversation
e1cce78
to
513dd56
Compare
513dd56
to
9bb4db4
Compare
10f9ded
to
42e1319
Compare
When you pass in a sibling into Node2D::get_relative_transform_to_parent, it must return Transform2D() according to the code, but it doesn't seem to do so. Does anyone know why?
|
That's not what happens with the code, it doesn't check for that, it just goes up the tree until it finds a non-2D node or no parent, it errors if the parent isn't a 2D node and then returns the empty transform, but it first combines this with the local transform: Lines 392 to 406 in c4279fe
|
The macro ERR_FAIL_NULL_V_MSG returns from the function if the pointer is null, and it doesnt combine with the local transform. Here's how i think it executes: because I'm passing in a sibling, we climb up the tree until we hit the root and then the root at the top of the tree will return null for get_parent(), and that causes the macro to err and return Transform(). I would like to debug this with breakpoints, but my breakpoints doesn't seem to hit on visual studio for tests, is there something I need to change to make that work?
|
No it calls for the steps until the parent is not a return parent_2d->get_relative_transform_to_parent(p_parent) * get_transform(); |
42e1319
to
9789156
Compare
@AThousandShips Ah yes, you're right, I somehow seemed to have forgotten about recursion going back down the stack. |
d1ee595
to
27b342e
Compare
Hello, can someone review this PR, it is ready to merge. |
48ba0ef
to
f359115
Compare
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.
Code looks good to me.
There's been some changes to the unit test system so a rebase to make sure everything still works right would be good |
You used a merge commit to update your branch, please use rebase in the future instead, see here, you should remove the merge commit and rebase instead |
991f6d2
to
5402b74
Compare
You need to reset your branch to a safe state, and then rebase, do |
5402b74
to
be072de
Compare
Ah, thank you @AThousandShips, I think it looks good now. |
Thanks! |
Add Unit tests for Node2D helper methods (look_at, get_angle_to, to_local, to_global, get_relative_transform_to_parent)
Link to #43440