JoeJ wrote:Where is the code where you do new calculations within callback?...
So it's only NewtonUserJointCalculateRowZeroAccelaration that is new. ...
Oh but is more than just that.
Before when a row violated a limit, the callback issued a friction limit and either used the joint derivative or a user calculated acceleration to stop the movement and to recover from the error.
This is a big mistake for two reasons.
1 the joint derivative does not include position, so this has to be added an adhock code by converting the violation to a velocity and then to an acceleration.
2 the joint derivatives assume the friction force is infinite, therefore they could zero any velocity, but this only works when the velocity was positive, negative velocities cause the joint to bounce back with unpredictable velocity because the friction is no infinite in that direction.
Now, the joint calculates the stop velocity for each row, but does not consider penetration error.
Then in the joint code, do some kind of one dimension prediction to see if with the current joint velocity the joint will reach the limit. look at the slider as an example.
When the prediction say the joint will reach or cross the limit,
The code calculates what speed the joint need to have to reach the limit exactly starting from zero speed.
We now can do that because the joint provides the zero speed acceleration, so all we need to do is calculated the new acceleration and add that to the zero speed acceleration.
The joint will move closer to the limit, if it does not cross the limit, the process repeat, but the joint ideally never change direction.
If because numerical errors and non linearyties the joint crosses the limit, the joint will have zero velocity and the correction is a very small velocity because the violation is not longer a constraint violation is a numerical error violation which should be an infinitesimal value. at least that's the conjecture I made, and it seem to be right in more cases. Very big difference.
The reason this is now in the joint, is because different joints measure errors in different ways,
Yes it makes the implementation more involved but, to me the results are worth the effort.