why no early out for solving velocity constraints?

Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
Louis Langholtz
Posts: 22
Joined: Tue Dec 20, 2016 10:53 am

why no early out for solving velocity constraints?

Postby Louis Langholtz » Fri May 05, 2017 11:02 am

In the iterative solving in the physics engine library code there are two calls to the b2ContactSolver::SolveVelocityConstraints() method: one from b2Island::Solve() and one from b2Island::SolveTOI(). In both places, b2ContactSolver::SolveVelocityConstraints() gets called repeatedly. This is similar to how the b2ContactSolver::SolvePositionConstraints() method is also repeatedly called.

There is a difference however that I'm wondering about. In repeatedly calling the position constraints solver method, there's a possibility for an early out from calling it for all of the given position-iterations that's based "if the position errors are small". There's no early out however for the solving of the velocity constraints. Why is that?

I realize that b2ContactSolver::SolveVelocityConstraints returns void. So of course there's no return information from this method that could be used like is used from b2ContactSolver::SolvePositionConstraints(). That's a reason, sure. But why not refactor that code to return information that could be used for this? And what state(s) could be used for this? Can the degree of velocity change be used as a reasonable test? Or the amount of change in momentum that was applied be used?

At a practical level, I've tested this by simply using whether the change in velocity/impulse was zero. This appears to work without any problems. I'm able to get the same results with less actual velocity iterations being done.

Any math/physics gurus able to chime in on this and confirm whether theoretically this is a usable optimization?

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests