SFML community forums

Help => Graphics => Topic started by: chaosblasta on June 09, 2017, 01:53:13 pm

Title: Possible Rect<T>.contains() bug?
Post by: chaosblasta 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.
Title: Re: Possible Rect<T>.contains() bug?
Post by: Laurent 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.
Title: Re: Possible Rect<T>.contains() bug?
Post by: eXpl0it3r on June 09, 2017, 02:41:37 pm
That statement was added just recently, see the discussion on GitHub (https://github.com/SFML/SFML/pull/1151).
Title: Re: Possible Rect<T>.contains() bug?
Post by: chaosblasta on June 09, 2017, 03:04:06 pm
I see now. Thank you for the quick responses!