-
Notifications
You must be signed in to change notification settings - Fork 481
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
Enforce MustIncludeC in GetClosestPointOnTriangle #749
Conversation
I've taken a quick look at the failing unit tests. These don't mean that the collision detection code is wrong but it means that the collision response changed enough that the penetration between a simulated box and the floor is slightly larger than before. I will take a look at it, but it is going to take me some time to verify the new behavior. |
Unfortunately, the Unit test "TestLinearCastBoxVsInactiveDiscreteBoxAngled" fails. When these lines JoltPhysics/UnitTests/Physics/MotionQualityLinearCastTests.cpp Lines 306 to 310 in b9bdabe
become
then the mentioned test passes. So the accuracy is worse by a factor of 10. What is odd is that this test calls GetClosestPointOnTriangle with MustIncludeC = false. I am now investigating why that is. The test should not fail. |
The problem is the following. In the mentioned test MustIncludeC is false and swap_ac is true. The distance to edge AB is (almost) the same as to Edge AC.
In #740 (reply in thread), we also discussed the impact of swapping A and C on the dot products.
Now the big question is, which value for AB is correct? If I base my opinion on the theoretical background of GJK, that is, if I consider that GJK should improve every iteration until it converges (in an ideal world), the point (0.1, 0, 5.96e-08) seems more reasonable for AB than (0.1, 0, 0). So, the impact of swapping AC might actually be negative on the dot products. What do you think? Edit: changed my reasoning |
I changed the order of testing the edges, i.e., edge AC and BC are getting prioritized now. This change should pass all unit tests. Moreover, even if MustIncludeC is false, the closest point can be expected to be most of the time on the edge AC, BC, or inside. So it makes sense to test these cases first. |
I've been testing with this change and there was one issue with it: If we test AC before A and the closest point is A, we will find that Note that I applied a fix for this that still keeps the unit tests working. |
Thanks for your contribution btw! |
This PR is referring to the discussion #740 (reply in thread) and fixes the described problem.
Note that we can overwrite the variable ab as the function returns after testing the edge BC and, therefore, its last use only involves testing the edge AB.