giovedì 4 agosto 2016

Day 160: Contact resolver

Yesterday I wrote the algorithms to resolve the velocity and interpenetration of a contact.

Today I wrote the ContactResolver, which is in charge of resolving all the contacts in the correct order. It has three main methods:

- prepare_contacts: calls the calculate_internals method on each contact, which basically sets up a few importand data

-adjust_positions: it iterates N times, and resolves the contact with the greatest penetration at each iteration. It also needs to update each other contact containing one of the two recently resolved rigidbodies. 

-adjust_velocities: basically the same process of adjust_positions, but with velocities.

These last two functions are quite "iteratively" intensive, and it could be possible to experiment with alternatives. For instance by using linked lists it could be possible to avoid iterating so much.
I'll probably go back to this point once the engine will be running, for now I'll leave it like that, because it's easy and works nicely.

That being said, finally the engine is quite complete! I'm still missing friction, optimizations, resting objects and a good broad phase algorithm (like octrees), but it should be possible to use it now!
So tomorrow I'll try to integrate it inside the engine, with one main goal in mind: hide the implementation details, and make it easy to use.
After that I'll add friction and octrees, and proceed to polish the engine until I'm fine with it.

Nessun commento:

Posta un commento