-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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 test for Node3D
#97143
base: master
Are you sure you want to change the base?
Add unit test for Node3D
#97143
Conversation
The commit is associated with another user, you will need to reset the author with |
075a8bf
to
18594e0
Compare
18594e0
to
0493a4d
Compare
If the tests still fail on the last build it will be because you generated your expected values on a non-doubles build, then you'll need to build a double precision build (or print the values in the test run) and update them, so they work in both cases (the double precision values will work for single precision) |
0493a4d
to
10299b6
Compare
10299b6
to
ed2c195
Compare
CHECK(test_node3->get_global_position().is_equal_approx(Vector3(200, 0, 110))); | ||
CHECK(wrap_rotation_angles(test_node3->get_global_rotation_degrees()).is_equal_approx(Vector3(0, 180, 270))); | ||
CHECK(test_node3->get_position().is_equal_approx(Vector3(0, 0, 10))); | ||
CHECK(wrap_rotation_angles(test_node3->get_rotation_degrees()).is_equal_approx(Vector3(180, 0, 90))); |
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.
Unfortunately, posmod(360)
only works in the main cases and not in the corner case I have in this line of code (182).
The corner case: When executing with floats, the value of the y axes is -0.000009. When executing with doubles, the value of the y axes is 0.00000000000001. That means in the case of posmod(360) for double, no modulo is applied and the value stays the same. In the case of float precision, since it has a negative value, the value is adapted to 359,999991, which will lead to a failing test result since the test checks for 0. I hope that makes the situation clear.
We can leave it like that, or I could remove this case and take other values to avoid this corner case. Then there is no need for the wrap_rotation_angles()
method since it only appears in this specific case.
This commit adds several test cases for the Node3D class for #43440.
The test consists of two basic test cases and nine test cases that cover several utility methods like
look_at
,rotate_object_local
,to_local
and more.