# 2D Distance Field as collision handler method

Pixeljunk Shooter has really cool fluid simulation.

I found the dev's video explaining what they did. Here

I understand that it is particle based simulation Smoothed Particle Hydrodynamic

I can find adequate resources and even books covering this topic, but I can't find resources for the "collision"

All I can find about using distance field for collision are very tough article and some vague description

The second resource states

Using a signed distance field then makes it very easy to check if a particle is colliding with our environment - simply sample the distance field at the particle position and if the magnitude of the distance is negative we have a collision (ignoring the potential for tunneling for the time being). Once a collision is detected we can then backtrack along the particle trajectory until we find where the particle collided with the surface. To calculate the collision response we then need to determine the surface normal - this is again easy as we simply need to calculate the gradient of the distance field and normalize the result.

Does it mean that I just backtrack my particle till it is no longer "inside the object"? Then take average distance from surrounding, then take normalized average as "normal vector of the sourface"?

Is that "all" I need to do?

If such is the case, don't I need to render only "inside" of distance field? I don't need how close edges are when I am outside an object? Or do I need to know that as well?

I really need clear step by step teaching material in which I can really look at it and read it through to understand. Are there any resource that teaches this technique?

• The distance field allows a low res description of the shape with higher res collision detection. For that interpolation of the boundary, + and - are both used. Commented Nov 17, 2014 at 19:33