FPS drop from CollisionObjects even with disabled simulation

Post Reply
TheNess
Posts: 5
Joined: Sun Jul 30, 2017 7:09 pm

FPS drop from CollisionObjects even with disabled simulation

Post by TheNess »

I have a huge level with lots of static bodies scattered around, lets call them trees. I create them as a basic CollisionObject with ActivationState set to DisableSimulation.

I noticed that if I have too many of them the FPS drops by a lot. This is not a memory issue but CPU consumption.

I though objects like these should not take any CPU at all as they all should be sleeping and since simulation is disabled no forces or gravity should affect them.

Why am I getting performance hit? Is there a way to optimize them further?
All I need them to do is to block other objects, and they should be sleeping since there's no rigid body interacting with them.

Thanks.

EDIT: they might be constantly touching the floor object, which is the same as them (collision object without simulation), is that a problem?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: FPS drop from CollisionObjects even with disabled simula

Post by drleviathan »

Bullet has a default setting where it updates the axis aligned bounding boxes (AABB) of all static objects every frame. You can disable it as follows:

Code: Select all

dynamicsWorld->setForceUpdateAllAabbs(false);
When you do this then you must manually update the AABB of any static object that you move, however if they are truly static then you shouldn't be moving them. Try that and see if it solves your problem. If you must have a static object that moves then make it kinematic and set it active whenever you move it.

Another thing to try would be to use fewer objects. Combine them all into one object, or combine many of them into a fewer number of objects. If they are truly static this is theoretically possible.

Finally, as the number of objects in the world goes up the cost of adding new objects (static or otherwise) also goes up linearly. I hear that if you have several 10k's of objects this cost starts to become detectable, but have never tested it. This all means means: if you have 100k static objects and you're adding/removing objects to the world every frame then you might see a constant high CPU cost.
TheNess
Posts: 5
Joined: Sun Jul 30, 2017 7:09 pm

Re: FPS drop from CollisionObjects even with disabled simula

Post by TheNess »

drleviathan wrote:Bullet has a default setting where it updates the axis aligned bounding boxes (AABB) of all static objects every frame. You can disable it as follows:

Code: Select all

dynamicsWorld->setForceUpdateAllAabbs(false);
When you do this then you must manually update the AABB of any static object that you move, however if they are truly static then you shouldn't be moving them. Try that and see if it solves your problem. If you must have a static object that moves then make it kinematic and set it active whenever you move it.
Hi thanks for the suggestion, but I couldn't find this property (or anything similar to it) not in RigidBody, CollisionObject or CollisionShape.. Maybe its deprecated or unsupported in BulletSharp?
drleviathan wrote: Another thing to try would be to use fewer objects. Combine them all into one object, or combine many of them into a fewer number of objects. If they are truly static this is theoretically possible.
I tried playing with that option, but didn't see much improvement. If I combine everything to a single object its even worse. I think its because when I combine them I'm losing the broadphase octree optimization.
drleviathan wrote: Finally, as the number of objects in the world goes up the cost of adding new objects (static or otherwise) also goes up linearly. I hear that if you have several 10k's of objects this cost starts to become detectable, but have never tested it. This all means means: if you have 100k static objects and you're adding/removing objects to the world every frame then you might see a constant high CPU cost.
Thank you for this useful info, in my case I'm not adding / removing any objects, but I'll keep that in mind!
anthrax11
Posts: 72
Joined: Wed Feb 24, 2010 9:49 pm

Re: FPS drop from CollisionObjects even with disabled simula

Post by anthrax11 »

TheNess wrote: Hi thanks for the suggestion, but I couldn't find this property (or anything similar to it) not in RigidBody, CollisionObject or CollisionShape.. Maybe its deprecated or unsupported in BulletSharp?
ForceUpdateAllAabbs is a property of CollisionWorld in all versions of BulletSharp. Look again. :)

Code: Select all

dynamicsWorld.ForceUpdateAllAabbs = false;
TheNess
Posts: 5
Joined: Sun Jul 30, 2017 7:09 pm

Re: FPS drop from CollisionObjects even with disabled simula

Post by TheNess »

anthrax11 wrote:ForceUpdateAllAabbs is a property of CollisionWorld in all versions of BulletSharp. Look again.
Ah its a world property! Don't know why I assumed it was object property, I totally misread your example.
Thanks I'll try it out when I get back from work and report back if improved anything :)

EDIT: nice improvements in FPS, around 100-200 more (depends on level and test). Thank you very much!
Post Reply