ncollide icon indicating copy to clipboard operation
ncollide copied to clipboard

Endless loop issue in nonlinear_time_of_impact_support_map_support_map

Open Sroka opened this issue 3 years ago • 0 comments

Hey guys, did anyone ever have had problems with query::nonlinear_time_of_impact hanging and never returning? I am able to reproduce it for two Cuboids with simple ConstantLinearVelocityRigidMotion. I dug into it a bit and it seems that the loop in nonlinear_time_of_impact_support_map_support_map_with_closest_points_function never gets broken out of. In my test case this happens when two cuboids travel in the same direction with the same speed so that they will never meet. This constantly triggers this branch of if-else condition in the loop:

                    } else if dist > max_target_distance {
                        // Too far apart, go forward in time.
                        min_t = result.toi;
                        result.toi = (result.toi + max_t) * _0_5;
                    } else {

which was supposed to increase min_t until it reached required threshold few lines below:

                    if max_t - min_t < abs_tol {
                        result.toi = min_t;
                        break;
                    }

Unfortunately at some point (result.toi + max_t) * _0_5 stops increasing and it converges to a a value that is lower then max_t - abs_tol

Sroka avatar Dec 11 '20 17:12 Sroka