forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to make a high speed collision test?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
saulotmalo2



Joined: 10 Sep 2007
Posts: 43

PostPosted: Wed Sep 12, 2007 8:44 am    Post subject: how to make a high speed collision test? Reply with quote

hello i'm doing a game for psp using sdl. I want to know if there is a way to make a fast collision test between 2 sprites i need to not detect the colorkey... so i can't use squares.

I've been thinking in use a prod (i'm not sure of this word) first i will test if the two images get in touch if they did now i make a more intensive test for knowing if they are in a colorkey zone.

a better idea?
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Wed Sep 12, 2007 9:58 am    Post subject: Reply with quote

Use the bounding squares first to get an idea whether they might be colliding. Then you're down to the hard yards of checking whether the box that's the intersection of the two squares has pixels from both sprites in it at the same location.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
saulotmalo2



Joined: 10 Sep 2007
Posts: 43

PostPosted: Wed Sep 12, 2007 11:35 am    Post subject: Reply with quote

so as i was thinking... the only way of doing collision is with 2 collision test one using bounding box and one using pixel per pixel colorkey in the zone of collision.
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Wed Sep 12, 2007 11:59 am    Post subject: Reply with quote

Not the only one. Just the most appropriate to your cause (though you could still optimize with something like a smaller transparency map for each sprite and equal).
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Wed Sep 12, 2007 6:41 pm    Post subject: Reply with quote

One way is to have a bitmask for each sprite. Basically have a bit set if there's sprite data, and clear if it's colourkey. Then you can just SHIFT and AND the two masks together to see if there's a collision.

<reminisce>Ah, the joys of Amiga programming :)

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
saulotmalo2



Joined: 10 Sep 2007
Posts: 43

PostPosted: Wed Sep 12, 2007 9:41 pm    Post subject: Reply with quote

but having a map for all the images would waste a lot of memory and also will need a preprocess i'll try the first one and if i need more speed here i'll improve it.

regards
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Thu Sep 13, 2007 9:06 am    Post subject: Reply with quote

It's only an extra 1 bit per pixel! But yep, try it the obvious way and if it's too slow, try something else :)

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group