Page 1 of 1

Optimization for many physics controller objects on map!

Posted: Thu Mar 02, 2006 10:27 am
by myintkt
Hi, I am new to Bullet but i found out that it is a really great library. thank you for sharing it for free!

I m testing if i can use Bullet as my physics component in a game I m writing. It is OK for Bullet to handle about 10 objects on a map but the actual map would have about 1000 objects on them. that's a lot for simulation and when i run the program my FPS crawl to 0.1!

But most of the object on the map need not to be considered for simulation since they are not visible. All I have to do is process all objects in my current portal. So I want to know if I can do physics simulation on objects that I select from my current portal list each frame.

If not, I want to know if there is solution to come around to handle many objects by removing unnecessary objects (physics controllers) from physics environment.

I can do manual add()/remove() but I am not sure it is the right thing to do.

Could you plz help? Thanks a lot!

mkt

Posted: Sat Mar 04, 2006 6:26 pm
by Erwin Coumans
Do all the physics objects need to be 'active' ? Usually physics objects get deactivated after they don't move (based on velocity and time tresholds). Once the physics objects is deactivated (sleeping) it doesn't cost processor time anymore.

So one way (frequently used by games) is to create the rigidbody objects and set them manually to be deactivated/sleeping.

Also, currently there is a brute-force broadphase. I got a contribution for a faster sweep and prune broadphase.

Posted: Sun Mar 05, 2006 12:33 pm
by myintkt
i found out that Sleeping Island does not do enough optimization. In SimpleBroadphase, it is doing N^2 on even none-sleeping objects. that is really where framerate is eaten. When objects get to 400, it is doing 400^2 calculation which is bad.

So I do my own Broadphase that only check active objects against active objects and dead objects. That improves a lots. I think it should be considered for implementation in Bullet future release.

But I also do Oct-tree optimization for bounding box, this really increase performance.

Anyway, I have a question. Penerating Depth recover on Bullet is only doing on small scale. Since some of my object move at high speed, it penerating right in objects and does not bounce back well. How can I a better penerating algorithm in Bullet?

Thank again!

mkt

Posted: Sun Mar 05, 2006 10:29 pm
by Erwin Coumans
myintkt wrote:i found out that Sleeping Island does not do enough optimization. In SimpleBroadphase, it is doing N^2 on even none-sleeping objects. that is really where framerate is eaten. When objects get to 400, it is doing 400^2 calculation which is bad.

So I do my own Broadphase that only check active objects against active objects and dead objects. That improves a lots. I think it should be considered for implementation in Bullet future release.

But I also do Oct-tree optimization for bounding box, this really increase performance. However, thanks for the tip on the culling in the brute force broadphase.
The upcoming sweep and prune broadphase should tackle all those problems.
Anyway, I have a question. Penerating Depth recover on Bullet is only doing on small scale. Since some of my object move at high speed, it penerating right in objects and does not bounce back well. How can I a better penerating algorithm in Bullet?
What kind of shapes do the objects have? Do you have some example?

One option is adding EPA to Bullet. Some send me some work in progress contribution, which should have higher quality and better performance.

Erwin

Posted: Sun Mar 05, 2006 11:46 pm
by Eternl Knight
Do you have an estimate on when the sweep&prune method will be added, Erwin?

I am currently looking at bullet as the collision/physics library (i.e. combined with ODE) for a simulation experiment I am playing with. Currently I've hacked my sim to put all objects into two layered "quad" spaces but the code is ugly and a sweep&prune would make things much nicer :)

--EK

Posted: Wed Mar 08, 2006 5:15 am
by myintkt
yeah, that would be great! I am looking forward to sweep&prune broadphase as well!

Erwin write->
"What kind of shapes do the objects have? Do you have some example?

One option is adding EPA to Bullet. Some send me some work in progress contribution, which should have higher quality and better performance."

I use ConvexHull collision shape and simply add 4 vertex to create a box. Box collision shapes does not work because it take center of object as its "pivot" but my models uses pivot directly below the model. but convexhull should be no problem.

I try to use EPA like u said and it improve a lot. but does it make a problem if i try to distribute my game commercially? should i have to pay license fee or something for it?

I also have a question. CcdPhysicsEnvironment does not use Toi (Time of Impact) collision algorithm. Toi maybe better for solving penerating depth (i maybe wrong)? If so, how can i switch to use Toi algorithm in physics environment?

Thank a lot for ur help erwin!

mkt

Posted: Wed Mar 08, 2006 8:35 pm
by Erwin Coumans
I received the Sweep and Prune, and some other useful code. It requires some integration, so it depends on when I get some spare time. Likely within a week or 2.
if i try to distribute my game commercially? should i have to pay license fee or something for it?
The EPA in the Extras/Solid35 folder is QPL. So you can license the file (contact http://www.dtecta.com it won't be expensive I guess). Or alternatively you need to provide source code and modifications along with the game.

Time of Impact is not enabled in CcdPhysicsEnvironment indeed. You are right, the ToI would prevent deep penetrations for fast moving objects. The general case (dynamic-dynamic) requires more work. But for dynamic versus static it should be easy to enable. But not yet.

Erwin