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

Author Topic: Logical error with sf::Rect<T>?  (Read 1967 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Logical error with sf::Rect<T>?
« on: October 13, 2009, 01:29:56 pm »
Hey,

I'm just wondering about a behaviour inside the sf::Rect<T> class:

The method Contains() checks if a point is inside the rectangle, boundaries inclusive. But GetSize() returns a size without the right and bottom boundary.

So when I've got a rectangle from (0, 0) to (2, 2), then the points (x, y) are within that rect when x = [0, 2] and y = [0, 2]. Therefore I'm able to check for 3(!) points on each axis which means that the rectangle's width and/or height must be 3.

But since you return Right - Left (Bottom - Top) in GetSize(), I get a 2 here which leads to serious errors in my quadtree implementation. ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Logical error with sf::Rect<T>?
« Reply #1 on: October 13, 2009, 01:51:41 pm »
True :)

I'll fix it for SFML 2.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Logical error with sf::Rect<T>?
« Reply #2 on: October 13, 2009, 01:52:43 pm »
Thanks. :)

 

anything