- Home /
Broadphase CD in Unity - pile of rigid bodies unsolved
I know unity uses physX to do Collision Detection and Physics. But what kind of broad phase collision detection does it have/use? I saw some stuff in their API about sweep stuff, but other than that, I dunno. I couldn't really find anything on the interwebs.
I have a lot of rigid bodies, mostly piled up on top of each other. So I didn't know if writing my own broad phase CD algorithm would increase perf or not. Or if something good was already implemented and this was as good as it got. I doubt they're doing something dumb like O(n^2).... I figured, if not, I could tweak the size of the volumes to be roughly the size of my objects (if i use an octree).. Sweep n' Prune may also be a really good option too possibly... That way I could only have certain objects collide with other objects by somehow putting them into different lists of what can collide with what.. I'm not entirely sure this would even solve my problem though.
The game runs pretty good on the PC, but on the iPhone it's uber slow, that's the reason why I'm thinking of other methods. I've done everything else I can think of or read about. I'm using box colliders mainly and some mesh colliders. Apparently using two box colliders doesn't help perf, but I didn't try it, one of my coworkers did. I'll try that, but even so, it won't be enough. I've also adjusted time step and sleep values.. which doesn't help a whole lot...It seems to affect how things react in ways I don't want though.
The main problem is, since they're piled up, moving one object ends up waking up the whole pile of objects. Which is probably necessary. The whole game is basically based around this idea of a pile of objects, and pushing one object also pushes the others. Preferably into a hole of sorts. Similar to a bulldozer bulldozing stuff into a hole.
Any ideas? Or does anyone know what kind of Broadphase CD algos Unity uses?
Thanks, -Todd
Even the iPhone 4 has limited hardware compared to a typical PC. There's only so much you can do...PhysX is already optimized, so you have to scale things down for the iPhone.