Collision detection for small high speed objects

hynner
Posts: 6
Joined: Sun Aug 14, 2011 11:23 am

Collision detection for small high speed objects

Post by hynner »

Hello I am making very simple space game, I am using btCollisionWorld and btCollisionObject, for movement I just use setWorldTransform(), as I thought it won´t be problem with high framerates, but my framerate is around 20fps, 30 in best cases. And I have small box shapes moving very fast (bullets), so they just jumps from one space to another. So what I need is an advice how to encrease my framerate(framerate drop is certainly caused by Bullet, without collision detection I have framerate about 100fps) or whether I should better switch to btDynamicsWorld. I am using btCollisionWorld , because I thought it would have better performance than btDynamicsWorld. So something more about my environment, there are about 125 quite big asteroids(convex hull shapes), all of them uses the same mesh, but are different scaled, then there will be spaceships(convex hull shapes too) and of course their bullets(box shapes) all I want to do is to get collisions info, I don´t really need rigid body simulation. I am currently using btCollisionWorld::ContactResultCallback for all spaceships and their bullets each frame. So if anyone could give me some tip how to improve my performance, it will be much appreciated, thanks.
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: Collision detection for small high speed objects

Post by MaxDZ8 »

It would probably be more effective to do sweep tests on missiles instead, perhaps every n frames. If the warhead travels really fast, I'd do a ray cast instead.
To be completely honest, I'm interested in knowing more as well as I am in a similar situation.
ouch67
Posts: 17
Joined: Tue Jul 26, 2011 9:24 pm

Re: Collision detection for small high speed objects

Post by ouch67 »

hey I'm making a space game too (rts) :)

But one thing with ODE that I noticed is that if you scale a collision object it's a huge performance hit. like at least half the speed or so. It might be the same with bullet too.

I fixed it in that project by scaling my model and then creating the collision model/element to that size. that way there wasn't any scaling done on the collision element and it sped things up quite a bit.

Another thing you could try is making objects further away from the camera(s) have less collision precision.
hynner
Posts: 6
Joined: Sun Aug 14, 2011 11:23 am

Re: Collision detection for small high speed objects

Post by hynner »

Thanks a lot, when I disabled scaling it really improved the performance. I just wonder whether it is caused by some strange behaviour of scaling, or by some kind of sharing of collision shapes(without scaling all asteroids are the same) or by fact that without scaling the asteroids are a lot smaller, because for scaling I used random range 0.7 - 20 on each axis. So it helped me a lot, but I am not sure what exactly caused this improvement. So if anyone could give me an answer or another tip, I would be very glad.