SFML community forums
Help => Graphics => Topic started by: Elusive on September 25, 2011, 04:28:08 am
-
Hi,
Is there a simple way of culling invisible items in the scene using sf::View? Is there some method of checking wether a boundary box is intersecting with the visible region?
-Elusive
-
Build the view's rectangle (from its size and position), the entities' bounding rects, and use rect1.Intersect(rect2) to find out if they intersect.
-
That was my first guess, but what about the view rotation?
-
If you have a rotation it becomes more complicated. You must use the separate axis theorem to compute the intersection between two non-aligned rectangles.
-
That is not part of SFML, right? I'll look into that. Thanks!
-
Here (http://www.metanetsoftware.com/technique.html) you find a tutorial that explains the Separate Axis Theorem.
-
Awesome! Thanks a lot! :)