How do you check collision against 1000x1000 objects?

Started by
12 comments, last by Burnt_Fyr 11 years, 4 months ago
Also, I would say that in order for a collision to take place, one of the colliding objects must have moved. No need to test 2 objects together if neither of them moved.


Advertisement

Also, I would say that in order for a collision to take place, one of the colliding objects must have moved. No need to test 2 objects together if neither of them moved.
Unless of course you have a more advanced physics system where objects can change size. blink.png wink.png

But yeah, identifying objects that have not changed in any way and skipping those pairs, is a very useful optimisation to use at some stage in the collision detection process. It likely doesn't matter too much at what point you do it.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
In situations where you need to actually update that many objects each and every frame, well tuned spatial hashing will handily beat all other broadphase methods for large amounts (1000s) of uniformly sized objects - where the largest are within 4-8 times the radius of the smallest objects. If you can get away with only updating a subrect of your game world, that's another optimization you should consider.


Stroppy Katamari already said that, and the j = i+1 method saves checking i == j as well.

I was ninja'd! (i was interrupted mid post at work, and didn't get to finish until after many follow up posts)

+1 on the j=i+i solution though.

This topic is closed to new replies.

Advertisement