The refraction information was incorrect in the previous implementation.
We never updated the medium information when going out of a transparent
material. It is now handled using a small structure holding both the old
index, and new_index.
We can now handle any number of successive medium changes, with the
associated change of indices correctly.
This implementation assumes that any ray going into an object is going
to come out in the same medium that it was originally travelling in
before entering said object. This is an acceptable approximation to me.