There is still a question:
After create the suspension limit constraint,
the constraint is add to Sc::Scene
But where the constraint is solved?
There are so many threads, I can’t find the function to solve the constraint
Also what’s the difference between a hard constraint and spring constraint in PhysX?
Here is the Entire Derivation of soft constraint in Bullet post by Erin Catto.
softness and penetration(bias) -> (CFM and ERP)
M * (v2 - v1) = JT * lambda
Velocity constraint with softness and Baumgarte:
J * v2 + softness * lambda + bias = 0
where bias = biasFactor * C / dt
We know everything except v2 and lambda.
First solve Newton’s law for v2 in terms of lambda:
v2 = v1 + invM * JT * lambda
Substitute this expression into the velocity constraint:
Now keep in mind that v1 contains the velocities for both bodies:
v1 = column_vector(vb1, omegab1, vb2, omegab2)
Now here is where things get a bit hairy. Each iteration we are not computing the whole impulse, we are computing an increment to the impulse and we are updating the velocity. Also, as we solve each constraint we get a perfect v2, but then some other constraint will come along and mess it up. So we want to patch up the constraint while acknowledging the accumulated impulse and the damaged velocity. To help with that we use P for the accumulated impulse and dP as the update. Mathematically we have:
The constraints are solved in physx. If you have 3.4 then you will need to look in LowLevelDynamics to see the solver code. Functions like solve1D in DySolverConstraints.cpp are the place to start looking. Be aware, this is highly optimised code so following the computation will be harder than the vehicle code.
I recommend reading the User’s Guide on constraints and joints to learn more about the difference between hard and soft constraints in physx.