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

Author Topic: Possible Rect<T>.contains() bug?  (Read 1346 times)

0 Members and 1 Guest are viewing this topic.

chaosblasta

  • Newbie
  • *
  • Posts: 2
    • View Profile
Possible Rect<T>.contains() bug?
« on: June 09, 2017, 01:53:13 pm »
According to documentation, the contains() function is non-inclusive and therefore will return false if the point is located on the edge of the rectangle. This isn't really the case on my tests though..

So with

sf::IntRect rect = {0,0,3,3};
sf::Vector2i point = {0,0};

rect.contains(point) returns true. In fact, every point from (0,0) (2,2) returns true, even though in theory only (1,1) should be true. I may not be understanding the documentation though, and I apologize if this is a mistake on my part.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Possible Rect<T>.contains() bug?
« Reply #1 on: June 09, 2017, 02:09:53 pm »
The documentation is obviously wrong, given how this is implemented:
return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY);

The function seems to be inclusive.
« Last Edit: June 09, 2017, 02:11:30 pm by Laurent »
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Possible Rect<T>.contains() bug?
« Reply #2 on: June 09, 2017, 02:41:37 pm »
That statement was added just recently, see the discussion on GitHub.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

chaosblasta

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Possible Rect<T>.contains() bug?
« Reply #3 on: June 09, 2017, 03:04:06 pm »
I see now. Thank you for the quick responses!