Welcome! Log In Create A New Profile


Fine Collision Detection with Scaling

Posted by LordAshes 
Fine Collision Detection with Scaling
April 27, 2010 01:07PM
Previously I posted about doing Fine Collision. Fine Collision, as opposed to Rough Collision, involves checking not only that sprites overlap but that non-transparent pixels in the sprites overlap. For example, a ball sprite has transparent corners which, when overlapping with another sprite, would cause Rough Collision but not Fine Collision.

Anyway, I wrote some code for doing this detection. It may not be the most optimize code but basically I run through the pixels on one object and if that pixel also maps into the other object then I compare the alpha value of the point in both objects. If they exceed my threshold then Fine Collsion has occured.

This all works fine.

The issue I have is when the texture is drawn at some scale other than 1. In that case I can't use my Fine Collsion detection routine as is because the routine relies on GRRLIB's GetPixel routine. It seems to me that I need to generate a temporary texture in which to store the texture at the scaled size and then I can use the Fine Collision detection routine. So I guess I need to do a GRRLIB Compose, draw my resized texture, and then use end the GRRLIB Compose storing the result in my temporary texture.

I suppose I could also do it by GRRLIB's SetPixel but I am guessing the Compose method will be a lot faster because it should be doing more of the processing at a lower level then repeatedly using the SetPixel routine to build my temporary texture.

Am I on the right track or is there a better way to do it?
Sorry, only registered users may post in this forum.

Click here to login