I have read the original Position Based Dynamics paper (https://www.cs.toronto.edu/~jacobson/seminar/mueller-et-al-2007.pdf). There is the pseudo-code on the 3rd page. I implemented it exactly.
Let's run this for a case of a single particle (i.e. no constraints), which only gravity acts on. See the picture below:
![](https://uploads.gamedev.net/forums/monthly_2020_08/e313de3fead74e5c9a0423bb2bcb3fa3.image.png)
We start with position red1. After the first step it goes to red2, then red3. In the next step we have red3 position and velocity represented by the blue arrow to the right. We end up in position red4, penetrating the ground. Now we have to react. We push the position out to position green. We then calculate the velocity (step 13. in the pseudo-code). The result is the velocity vector to the left. As you can see, by only working with positions we end up with a particle that after the collision is left with way less energy than before the collision. But that is not the worst part. The worst part is that this resulting post-collision velocity will be different depending on how deeply red4 position is penetrating. If it happens to be penetrating shallowly (as in the case above) the post-collision velocity is small. If the penetration is deep then the post-collision velocity can be even almost as big as the pre-collision velocity.
Is this how it's supposed to work? What would be the elegant way to make the particle bounce without losing any energy, for instance?