domenica 7 agosto 2016

Day 163: Resting contacts

Today I fixed a bad bug that I noticed yesterday evening. Basically the bodies were sinking instead of resting on one another. I found the bug, which was a penetration value with a wrong sign in the sphere_sphere collision resolution.

Then I introduced the calculation of the matrix for the rigidbodies in three different points:

- at the beginning of the physics step, in order to get the correct matrix if the objects were manually moved (instead of through forces)
- after the force application and bodies integration, to get the correct matrix for contact resolution
- after contact resolution (along with the complete transform matrix) for the rendering engine.

I don't know If it is possible to reduce this number for performance, but it works fine for now and it removed a lot of bugs I had until today.

Finally I noticed a bug in the change scene process: the input() method was called after the destruction of the scene, causing a nullptr exception.

Tomorrow I'll implement friction. I was quite scared at the idea of calculating the area of contact of two objects, because there is no way to easily do that, but thankfully my high school physics knowledge failed me: friction is not dependent on the surface area! This will make everything really really easy I think, tomorrow I'll implement that.

In the gif: the top two spheres fall with a high gravity acceleration. The left one is also moved manually, while the right one shows perfectly the resting contact. The other two spheres have infinite mass.


Nessun commento:

Posta un commento