-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Initial tests for geometry3D #44974
Initial tests for geometry3D #44974
Conversation
Thanks for opening a pull request! Note that we don't use |
Yep just spotted that, most things are tested now or at least structured in a way that it's easy to add more cases, gonna make sure I clean this up before I mark it ready for review :) |
339772d
to
3a826fb
Compare
Marked as ready for review now. Happy to make changes as needed, almost everything is tested, or structured so that test cases can be added easily :) |
08b8729
to
16c5c67
Compare
@Xrayez I think I addressed all your comments, let me know if there are any additional actions :) happy to address |
Tests look good to me but I'm still concerned with the usage of Note that test headers are currently compiled in a single translation unit. I presume you're coming from C#? @akien-mga should confirm that Godot follows Even if this won't introduce further problems, it makes sense to follow existing style conventions in any case. |
Yes, identifiers should use |
Ahh that's annoying, yes I'm coming from C#, I'll fix the rest up tonight/tomorrow |
a8f2d5e
to
01ddbf7
Compare
Thanks! |
TEST_CASE("[Geometry3D] Build Convex Mesh") { | ||
struct Case { | ||
Vector<Plane> object; | ||
int want_faces, want_edges, want_vertices; | ||
Case(){}; | ||
Case(Vector<Plane> p_object, int p_want_faces, int p_want_edges, int p_want_vertices) : | ||
object(p_object), want_faces(p_want_faces), want_edges(p_want_edges), want_vertices(p_want_vertices){}; | ||
}; | ||
Vector<Case> tt; | ||
tt.push_back(Case(Geometry3D::build_box_planes(Vector3(5, 10, 5)), 6, 12, 8)); | ||
tt.push_back(Case(Geometry3D::build_capsule_planes(5, 5, 20, 20, Vector3::Axis()), 820, 7603, 6243)); | ||
tt.push_back(Case(Geometry3D::build_cylinder_planes(5, 5, 20, Vector3::Axis()), 22, 100, 80)); | ||
tt.push_back(Case(Geometry3D::build_sphere_planes(5, 5, 20), 220, 1011, 522)); | ||
for (int i = 0; i < tt.size(); ++i) { | ||
Case current_case = tt[i]; | ||
Geometry3D::MeshData mesh = Geometry3D::build_convex_mesh(current_case.object); | ||
CHECK(mesh.faces.size() == current_case.want_faces); | ||
CHECK(mesh.edges.size() == current_case.want_edges); | ||
CHECK(mesh.vertices.size() == current_case.want_vertices); | ||
} | ||
} |
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.
@Gorgonx7 Can you help me debug an issue with this? The problem I'm having is that this test case seems to be very fragile. Any slight change causes the test to fail.
In #37842, the constructor for Plane with normal and point had its arguments swapped, so we took the opportunity to improve the code in Geometry3D::build_sphere_planes
by just passing in the radius distance directly instead of constructing using a point and normal (which the constructor just turns back into a distance).
Here are some examples of the planes being passed. Before:
[N: (0.791327, -0.257118, 0.554700), D: 5.000001]
[N: (0.527551, -0.171412, 0.832050), D: 5.000001]
[N: (0.230665, -0.074948, 0.970142), D: 4.999999]
After:
[N: (0.791327, -0.257118, 0.554700), D: 5]
[N: (0.527551, -0.171412, 0.832050), D: 5]
[N: (0.230665, -0.074948, 0.970142), D: 5]
The after output is slightly more precise, but it breaks the test case code:
tests/test_geometry_3d.h:154:
TEST CASE: [Geometry3D] Build Convex Mesh
tests/test_geometry_3d.h:171: ERROR: CHECK( mesh.edges.size() == current_case.want_edges ) is NOT correct!
values: CHECK( 1009 == 1011 )
This same test case also fails when Godot is compiled with doubles. At this point I'm entirely convinced that this just a bad / fragile test case, hopefully you have an idea on how to make it better.
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.
@aaronfranke sorry I never got back to you, things have been a bit hectic at work, so hectic I've not had much luck working on open source at the moment, did you ever figure this out?
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.
@Gorgonx7 No, currently the test is just disabled in master.
This is part of issue #43440.
These are a a list of test cases that layout the functions to be tested within geometry 3D