martedì 2 agosto 2016

Day 158: Collision impulses

Today I studied and implemented the code to apply impulses during collisions.
This is done in order to simulate a bounce, not unlike the particle engine. The main difference is the rotation part.

The code is divided in a few main functions:

- A function to calculate the necessary velocity to resolve the contact
- A function to calculate the impulse strength: this was a little harder to understand due to a bad naming convention used in the book that made me misinterpret a variable meaning. In the end it does this: it calculates a unit_delta_velocity, which is the velocity imprinted by an impulse of 1. So the final impulse has a strength of desired_delta_velocity / unit_delta_velocity.
-A function to apply the movement: given the impulse, it is possible to extract the linear and angular velocities pretty easily, and apply them.

This doesn't account for interpenetrarion yet (which I'll hopefully do tomorrow).

Nessun commento:

Posta un commento