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?
FPS drop from CollisionObjects even with disabled simulation
-
- Posts: 5
- Joined: Sun Jul 30, 2017 7:09 pm
-
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: FPS drop from CollisionObjects even with disabled simula
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:
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.
Code: Select all
dynamicsWorld->setForceUpdateAllAabbs(false);
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.
-
- Posts: 5
- Joined: Sun Jul 30, 2017 7:09 pm
Re: FPS drop from CollisionObjects even with disabled simula
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: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: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.Code: Select all
dynamicsWorld->setForceUpdateAllAabbs(false);
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: 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.
Thank you for this useful info, in my case I'm not adding / removing any objects, but I'll keep that in mind!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.
-
- Posts: 72
- Joined: Wed Feb 24, 2010 9:49 pm
Re: FPS drop from CollisionObjects even with disabled simula
ForceUpdateAllAabbs is a property of CollisionWorld in all versions of BulletSharp. Look again.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?
Code: Select all
dynamicsWorld.ForceUpdateAllAabbs = false;
-
- Posts: 5
- Joined: Sun Jul 30, 2017 7:09 pm
Re: FPS drop from CollisionObjects even with disabled simula
Ah its a world property! Don't know why I assumed it was object property, I totally misread your example.anthrax11 wrote:ForceUpdateAllAabbs is a property of CollisionWorld in all versions of BulletSharp. Look again.
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!