As you might know, I started to write a physics engine, based on the verlet integration equotation. (http://www.bulletphysics.com/Bullet/php ... f=4&t=1952)
My problem is best descriped with moving pictures, here is the exe of my project, which shows what the problem is:
http://www.exec-dev.de/mass.zip (It looks even worse with friction ^^)

As you can see, though the center of mass of the top rectangle lies over the second rectangle, the rectangle falls down.
The rectangles are not exactly stacked, I shifted the top rectangle 1 pixel to the right, to show what the problem is.
I can reduce my collision resolver to simply push the two polygons apart and it still occurs.
This is what I do:
Code: Select all
calculate the mtd;
calculate contact points;
// Resolve Collision
suminvmasses := A.invmass + B.invmass;
mf := A.invmass * suminvmasses;
// Ac and Bc contain the contact points
for i := 0 to high(Bc) do
// p -= mtd * (1-mf)
B.vertices[Bc[i]].position := v2f_add(B.vertices[Bc[i]].position, v2f_scale(mtd, -1-mf));
for i := 0 to high(Ac) do
//p += mtd * mf
A.vertices[Ac[i]].position := v2f_add(A.vertices[Ac[i]].position, v2f_scale(mtd, mf));

thank you