Can someone explain per-pixel collision detection?

ant the man picture ant the man · Oct 6, 2008 · Viewed 17.7k times · Source

Can someone explain the pros and cons of it and any math involved with it?

Answer

Peter Parker picture Peter Parker · Oct 6, 2008

For 2D: You do not need any math for this problem, you need only a custom bitblit-routine. You will blit collision candidates into a hidden surface by painting their collisionmasks onto this surface and checking, if the pixels you just want to draw are (pixel != 0) . Then you will have a collision. Of course, you should precheck by bounding rectangles if an collision can occur.

For 3D: You will need math(a lot)!

basically you will check each surface of your actor against each surface of your enemy. This will be done by calculating a plane-ray intersection. There is a lot of optimization possible here, but it depends on your 3d representation. This is also no Per-Pixel-Collision, but Per-Vertex-Collision