pixel perfect collisions?

Discussion in 'iOS Programming' started by detz, Oct 14, 2008.

  1. detz macrumors 65816

    Joined:
    Jun 29, 2007
    #1
    Can someone give me pointers on this, bounding box is easy but it's not "accurate".
     
  2. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    Selective search through recursively smaller and smaller bounding boxes (divide each bounding rectangle in quarters, if you like). If you find a hit in any box, look for hits between any smaller boxes in the overlap rect, and recurse till you get down to a few pixels. If you don't get a hit, skip going any deeper/finer.


    at least that's one method...
     
  3. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #3
    Just curious, is this for getting better collisions, like on an object with curved sides/complicated shape, or is it because the user will sometimes see an object go into another before recognizing the collision?
     
  4. detz thread starter macrumors 65816

    Joined:
    Jun 29, 2007
    #4
    Well...both, but I'm more concerned with the first one, odd shaped objects getting hit when they shouldn't because of the bounding box. My "fix" has been to create smaller bounding boxes within but even that's not accurate on round or pointed shapes.
     
  5. detz thread starter macrumors 65816

    Joined:
    Jun 29, 2007
    #5
    That's what I'm kind of doing but it's not that accurate...I also wondering if that is slower than comparing two masks but I can't figure out how to get pixel information to actually check collisions.
     
  6. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #6
    I'm curious too then, for future reference.

    With the second problem though, just add a correction phase between collision checking and displaying. So it checks for collision, if the collision went too far, make a correction, then display it. I've only done this for simple 2D block collisions in a very small, very uncompleted mario remake I started, but it worked.
     

Share This Page