Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Pixel perfect? Collision Detection

Iniciado por Mikenoworth, 06 de Enero de 2007, 11:21:24 PM

« anterior - próximo »

Mikenoworth

I was wondering how the collision is done with the Collision method. Once collision is found out the be probable - Does it check every pixel of both sprites?

 If so, here is an article on how you can cut out alot of useless pixel checking..

 http://www.gamedev.net/reference/articles/article754.asp

 Is this method similar to the one used in CRM32Pro? Or does this one cut down on pixel-checks?

 I've been looking for ways to *avoid* extreme performance loss on collision checks, because I simply cannot use the Collision method provided by CRM32Pro.

Has any one else had such high performance loss with this method?

 Anywho.. Going back to gamedev to read more. ;)

TheAzazel

Hi Mike,

yes, the collision system is implemented as that gamedev article tells.

CitarThe resulting image is black when no pixels are set, white with one pixel set, and red when both are set. A SINGLE red pixel indicates that a collision has occurred. You can count the number of overlapping pixels, if your game cares HOW MUCH something overlaps... otherwise, you might as well just check for overlapping pixels until you find ONE, then return that a collision has occurred.

In bold you have the way I have used, I dont mind how many pixels have been overlapped, so, on this way, is faster than the other way as with the first hit, it returns!.

I would like to see and check your current code (I could run a profiler to see what is going on) as I have done a few tests with the SpriteCollision example (using 1000 rabbits) and the performance is almost not affected.

A fast note, if you are using alpha per-pixel, it will be slower than with only colorkey but I think this is not your case.

Well, for now this is all. Depending on whatever I see, I could implement a bounding box function to check how is the performance, maybe it helps to you.

Waiting your feedback :)

Cheers!

Mikenoworth

I will run some tests and send you what I find. I'm currently doing alot of design crap that I wish I could skip for this game but I can't. Code is on hold for awhile.






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.