Allright guys, I just wanted to ask a few questions about panda and how it handles the collisions etc. In my game the results i am getting arent making much sense.
So we are making this level that spawns up asteroids flying at you; We managed to get ~80 colliders on the screen at one time. The person who wrote the asteroid handler wasn’t very familiar with collisions and accidentally made them all from colliders. So we have ~80 from colliders (spheres) on the scene at one time.
To my understanding, this would result in 80+79+78… so n *(n+1)/2 number of collision tests; assuming panda doesnt be default do any oct tree stuff etc.
I was under the impression 30+ of from colliders would be enough to result in serious performance issues. I understand that collision tests between spheres is fairly inexpensive - but my brain is telling me 80 from colliders should bring the system to its knees.
Perhaps anyone could explain this to be a bit better? Or perhaps panda does some some spatial optimizations i dont know about.
80 spheres should not be that much of a problem. even if you check each sphere against all others each frame. that would “only” make about 6400 checks (which , in case of spheres, are not that complex).
if you’r uncertain if , or what part of your application is slow. use pstats. it’s an excellent tool panda provides to help you finding bottle-necks.
Thomas describes it pretty well. To clarify a bit further on the 30+ limit, the point here is that much of the time spent within the collision traverser is the time it takes to actually walk the scene graph and discover the “into” nodes. The actual intersection tests are one thing, but the overhead of traversing the graph can add up after a while. Panda minimizes this overhead by carrying a vector of up to 32 “from” objects at a time as it traverses the graph. It can’t carry more than 32 at a time (at least not on a 32-bit machine), because it uses a bitmask to keep track of them. So, if you have 80 “from” objects, it means the collision traverser has to make three passes through the scene graph in order to test them all.
But, if your scene graph is simple enough, or well-structured enough, the time it takes to traverse it may be minimal, so three passes may not cost very much at all. So having 80 “from” objects is not necessarily a death sentence to your frame rate.
Right on. thank you guys.