Position-Based-Dynamics
Position-Based-Dynamics copied to clipboard
Question About The Distance Constraint
It seems that the distance constraint function is different from the one from C++ version. In your code:
double invMass = 1.0 / mass;
double sum = mass * 2.0;
corr = CompressionStiffness * n * (d - RestLength) * sum;
Body.Predicted[i0] += invMass * corr * di;
But in the C++ version:
Real wSum = invMass0 + invMass1;
corr = compressionStiffness * n * (d - restLength) / wSum;
corr0 = invMass0 * corr;
The results are different even though I assume mass0 equals to mass1. Is it a bug or something else?
And I also wonder what's the theory of your bending constraint? The C++'s bending constraint is different too.
Finally, thanks for your contribution in PBD's unity version which helps me a lot!
Looks like a bug. Will have a closer look sometime.
Cant remember if the bending constraint is different. It may have come from a different source.