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

Author Topic: Why is intersect too "basic?"  (Read 2787 times)

0 Members and 1 Guest are viewing this topic.

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Why is intersect too "basic?"
« 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?
« Last Edit: April 30, 2020, 01:09:11 am by SFMLNewGuy »

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Why is intersect too "basic?"
« Reply #1 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Why is intersect too "basic?"
« Reply #2 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Why is intersect too "basic?"
« Reply #3 on: May 01, 2020, 09:00:16 pm »
Thanks for the response. I'd appreciate it and the example.