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?
Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests