Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::View culling  (Read 3667 times)

0 Members and 2 Guests are viewing this topic.

Elusive

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::View culling
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::View culling
« Reply #1 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.
Laurent Gomila - SFML developer

Elusive

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::View culling
« Reply #2 on: September 25, 2011, 01:09:27 pm »
That was my first guess, but what about the view rotation?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::View culling
« Reply #3 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.
Laurent Gomila - SFML developer

Elusive

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::View culling
« Reply #4 on: September 25, 2011, 01:59:36 pm »
That is not part of SFML, right? I'll look into that. Thanks!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
sf::View culling
« Reply #5 on: September 25, 2011, 02:06:30 pm »
Here you find a tutorial that explains the Separate Axis Theorem.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Elusive

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::View culling
« Reply #6 on: September 25, 2011, 02:08:04 pm »
Awesome! Thanks a lot! :)

 

anything