SFML community forums

Help => Graphics => Topic started by: Elusive on September 25, 2011, 04:28:08 am

Title: sf::View culling
Post 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
Title: sf::View culling
Post by: Laurent on September 25, 2011, 08:58:52 am
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.
Title: sf::View culling
Post by: Elusive on September 25, 2011, 01:09:27 pm
That was my first guess, but what about the view rotation?
Title: sf::View culling
Post by: Laurent on September 25, 2011, 01:52:43 pm
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.
Title: sf::View culling
Post by: Elusive on September 25, 2011, 01:59:36 pm
That is not part of SFML, right? I'll look into that. Thanks!
Title: sf::View culling
Post by: Nexus on September 25, 2011, 02:06:30 pm
Here (http://www.metanetsoftware.com/technique.html) you find a tutorial that explains the Separate Axis Theorem.
Title: sf::View culling
Post by: Elusive on September 25, 2011, 02:08:04 pm
Awesome! Thanks a lot! :)