Mix It Up! Tech Post

So I started working on this game in February of 2013. It started out as a simple liquid demo but became more when I thought of the things I could do with it. Anyway, the game uses Smoothed Particle Hydrodynamics for the water and it stores the particles in a grid for optimization. The cell size of the grid is equal to the smoothing length in the SPH equations. This grid is purely for optimization. I attempted to use the accelerate framework provided by Apple but that provided no performance boost for me.

I used box2d for the physics engine. The particle body interaction is handled in one step each frame. The collision is handled by performing a circle sweep against the body from the particle’s previous position to its current position. The particle is then moved to the position where it collided along its path. It’s velocity is then adjusted due to the collision.

The mixing is done by looping through each particle and it’s neighboring particles. The colors of the particles are then calculated by averaging its color with the neighboring particle colors and adjusting the mix rate by calculating how fast the particles are going relative to each other.

One thought on “Mix It Up! Tech Post

Leave a Reply

Your email address will not be published. Required fields are marked *