Rectangular Raycasting?

Posted by igrad on Game Development See other posts from Game Development or by igrad
Published on 2014-05-29T03:21:06Z Indexed on 2014/05/29 4:03 UTC
Read the original article Hit count: 188

Filed under:
|
|

If you've ever played The Swapper, you'll have a good idea of what I'm asking about.

I need to check for, and isolate, areas of a rectangle that may intersect with either a circle or another rectangle. These selected areas will receive special properties, and the areas will be non-static, since the intersecting shapes themselves will also be dynamic. My first thought was to use raycasting detection, though I've only seen that in use with circles, or even ellipses.

I'm curious if there's a method of using raycasting with a more rectangular approach, or if there's a totally different method already in use to accomplish this task. I would like something more exact than checking in large chunks, and since I'm using SDL2 with a logical renderer size of 1920x1080, checking if each pixel is intersecting is out of the question, as it would slow things down past a playable speed. I already have a multi-shape collision function-template in place, and I could use that, though it only checks if sides or corners are intersecting; it does not compute the overlapping area, or even find the circle's secant line, though I can't imagine it would be overly complex to implement.

TL;DR: I need to find and isolate areas of a rectangle that may intersect with a circle or another rectangle without checking every single pixel on-screen.

© Game Development or respective owner

Related posts about c++

Related posts about sdl