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

Author Topic: Various fast ways of collision detection?  (Read 2071 times)

0 Members and 1 Guest are viewing this topic.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Various fast ways of collision detection?
« on: April 30, 2014, 08:52:16 pm »
Asking since the usual two loops of each sprite against the others gets slower than I'd like after a while.  I know of quadtrees but puzzled how to get one working for a map that goes all the way out the the max/min boundaries of the datatype.  Could just go for resizing its outer most size area as needed but that would end up causing the treenodes to rebuild their area as well.


Meantime any other ways of fast collision detection that could be used too? ???  Also any ideas on how to get them working for what I have in mind?
I have many ideas but need the help of others to find way to make use of them.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Various fast ways of collision detection?
« Reply #1 on: April 30, 2014, 09:11:03 pm »
Like Nexus said in the other thread, all methods to achieve what you want boil down to spatial partitioning.  And if you have an insanely huge map, you are going to have to partition the entirety of that map, be it with a quadtree or something else.

Do you have an actual program that's suffering performance problems because of this?  If not you probably shouldn't be worrying about it yet.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: Various fast ways of collision detection?
« Reply #2 on: April 30, 2014, 09:15:51 pm »
Was working on collisions in a space shooter I'm working on which is why I was asking.  Didn't think the usual nested loops would lag as bad as they did.  :-[  ::)

Starting work on a quadtree right now actually and checking to see if there is anything else that could either replace or go along with it. :)
I have many ideas but need the help of others to find way to make use of them.

didii

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Various fast ways of collision detection?
« Reply #3 on: April 30, 2014, 10:15:05 pm »
I don't know how you handle collisions, but you could check for collisions in a couple of steps. You could start with getting the maximum radius from an object (e.g. half diagonal length of a square) and do a circular collision check. This is easy and fast. If they do not collide, you can be certain all the more detailed collision checks will also fail.
Problem with this method is that it's probably less stable in terms of fps. When suddenly lots of objects are close to each other it also suddenly has to do a lot more checks.