SFML community forums

General => General discussions => Topic started by: SFMLNewGuy on April 30, 2020, 01:07:12 am

Title: Why is intersect too "basic?"
Post by: SFMLNewGuy on April 30, 2020, 01:07:12 am
Hello,

I was wondering what exactly is the gripe with the built-in intersect function in SFML? Why do people say to do your own for more accurate detection (along those lines)?

Can someone tell me why you wouldn't use the built-in feature and what it does that "your own" would?

How I was always taught was checking each side of a square and if it intersects, return true. So it can't be THAT different and seems exaggerated. Perhaps the built-in function would cause problems in a quadtree?
Title: Re: Why is intersect too "basic?"
Post by: G. on April 30, 2020, 03:31:03 am
It's only axis aligned bounding boxes (the square surrounding your object).
Not necessarily enough for what you want. Imagine playing pool but your balls collides as if they are squares.
Title: Re: Why is intersect too "basic?"
Post by: Hapax on May 01, 2020, 06:58:11 pm
In addition to things other than rectangles (such as circles) as mentioned by G., even rectangles can see some troubles. When a rectangle is rotated, the bounds are still axis-aligned (basically, not rotated) and they fit around the rotated rectangle.

This function can perform the collision required for rotated rectangles (it skips the extra stuff if the normal boundary test is already certain):
https://github.com/SFML/SFML/wiki/Source%3A-Rectangular-Boundary-Collision
Title: Re: Why is intersect too "basic?"
Post by: SFMLNewGuy on May 01, 2020, 09:00:16 pm
Thanks for the response. I'd appreciate it and the example.