Hello Everyone,
i'm looking for thoughts and ideas about optimizing Per Pixel Collisions with DX 9 for 2D game, the performance now is good but if there are some others things to do in order to optimize it further, then why not?
Currently i have done the following (there is nothing special in the code since its the standard algorithm):
1. Build Bool Collision mask for every frame in Texture Sprite Sheet. so it goes with lockRect , nested loops and get alpha color then populate the mask with 0,1 based on that.
2. Checking normal collisions with Rect Intersection first, if collision detected then perform per pixel collision check based on collisions masks per the
displayed frames. first IntresectRect, if true then check the intersectedRect pixels for source and destination for non alpha pixels colliding.
3. Put a timer to check per pixel collisions if any collision detected for every 2-3 frames instead of every frame since the user will not notice the difference.
Now one of my concerns is loading time when building collisions masks, now it takes less than 1 second to populate a sprite sheet 3200x1600 which is the level's boss, most of other sprite sheets are like 1/4 or 1/3 the size of Boss's sheet, but my CPU is pretty powerful 3770k@ 4.5Ghz and cannot take it as standard.
so what others things i can do to optimize and improve performance for loading and collision further?
Thanks