I've been reviewing how Box2D joints work.
I notice most joints involve calculating an effective mass matrix, K. But frequently they recalculate it every call to SolveVelocityConstraints, or at least call Solve/Solve22/Solve33.
As we are calling solve velocity constraints many times, and the position remains unchanged throughout (position correction occurs later), wouldn't it make sense to calculate K once in InitVelocityConstraints, and invert it. Inverting cannot be more expensive than calling Solve33 3 times, and we are expecting to call it many more times than that.
I notice most joints involve calculating an effective mass matrix, K. But frequently they recalculate it every call to SolveVelocityConstraints, or at least call Solve/Solve22/Solve33.
As we are calling solve velocity constraints many times, and the position remains unchanged throughout (position correction occurs later), wouldn't it make sense to calculate K once in InitVelocityConstraints, and invert it. Inverting cannot be more expensive than calling Solve33 3 times, and we are expecting to call it many more times than that.