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

Author Topic: Algorithmic complexity of sf::Rect::intersects  (Read 2605 times)

0 Members and 1 Guest are viewing this topic.

JosephSummerhays

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Algorithmic complexity of sf::Rect::intersects
« on: April 11, 2020, 05:10:04 pm »
I'm writing up some collision detection code, and I want to know how well it's going to scale. If every object in the scene needs to check for a collision with every other object in the scene, that's going to be O(n^2) calls to  intersects (where n = number of objects). How much does it take per intesection?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Algorithmic complexity of sf::Rect::intersects
« Reply #1 on: April 11, 2020, 08:58:00 pm »
Quote
How much does it take per intesection?
How much of what?

The AABB/AABB intersection test is pretty simple, if you need to optimize something it's most likely by reducing the number of tests, with a quad-tree or any other partitionning structure.
Laurent Gomila - SFML developer