Many rigid boies, bad performance ?

Lanquemar
Posts: 3
Joined: Wed Dec 25, 2013 10:50 pm

Many rigid boies, bad performance ?

Post by Lanquemar »

Hi !

Sorry for the inconvenience, I have only one btBvhTriangleMeshShape (with 50 triangles) and many btCylinderShape,
I tried to optimize my C++ program, but at 250 btCylinderShape and more, my app falls to 1 FPS and it's unplayable :(

In fact, I try to make a pile of coins, but 250 coins is not enough for what I want to do :(

Do I need to create a thread for the physics only ?

Thanks a lot !

(And sorry for my bad language)
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Many rigid boies, bad performance ?

Post by c6burns »

And did you compile that with optimizations off? Like visual studio debug mode?

Make a release build and verify it's that slow in release. And if it is then provide additional details about your setup.

PS - Your english is fine :)
Lanquemar
Posts: 3
Joined: Wed Dec 25, 2013 10:50 pm

Re: Many rigid boies, bad performance ?

Post by Lanquemar »

Thank you for the answer !

I tried Debug and Release build, and both falls to 1 FPS at 250 rigid bodies :(

I use mingw32 compiler on Windows, without any problems, but I need to find what can I do to improve performance with many rigid bodies, like maybe create an other thread specially for physics ?

When I have a pile of btCylinderShape, Bullet deactivates rigid bodies and so my FPS are increased to more 2500, but if I add one more btCylinderShape, all rigidbodies are reactivated and there is a big big lag (less 1 FPS), so maybe I need to change the reactivation sensibility ?

Thanks for help :)
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Many rigid boies, bad performance ?

Post by Basroil »

Lanquemar wrote:When I have a pile of btCylinderShape, Bullet deactivates rigid bodies and so my FPS are increased to more 2500, but if I add one more btCylinderShape, all rigidbodies are reactivated and there is a big big lag (less 1 FPS), so maybe I need to change the reactivation sensibility ?
Having 250 bodies and having 250 bodies in contact are two different things, 250 bodies in contact is going to be generating a lot more data than 250 bodies touching the ground, and dips are to be expected. Even AAA games get bogged down when you introduce stacking, and you might have to do a bit more fancy things to get the number of activated items down a magnitude
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Many rigid boies, bad performance ?

Post by c6burns »

What Basroil said ...

But also you have told us nothing about your environment. You could have a 5 year old CPU ... we have no idea. I have an i5-3570k @ 3.4ghz (not a bad chip but nothing special) and I can drop 500 cylinders into a pile without going below 60fps. I am not using any threading of any kind ... this is off a single core of the CPU

Then again if I tried the same thing on my galaxy nexus, it prob wouldn't go so smooth. Environment matters.
Lanquemar
Posts: 3
Joined: Wed Dec 25, 2013 10:50 pm

Re: Many rigid boies, bad performance ?

Post by Lanquemar »

Yes I see..

I have an i5-2500K @ 3.3ghz, but I'll need to share my program to other environment in the future, so I need to have better performance for lowest environment

What Basroil said is exactly what's my problem, I don't know how to change my code to have better performance with many rigid bodies in contact

Actually, I have a std::vector<btRigidBody> (to be simplest), so I don't know what I need to change

Lot of thanks for the answers !
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Many rigid boies, bad performance ?

Post by Erwin Coumans »

Something in your setup is wrong, the performance should be much better.

Can you reproduce the issue by modifying one of the Bullet demos and share the source code? The others might be able to help you.
Thanks,
Erwin