Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Aug 08, 2017 10:50 pm 
Offline

Joined: Sun Jul 30, 2017 7:09 pm
Posts: 5
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?


Top
 Profile  
 
PostPosted: Fri Aug 11, 2017 1:57 pm 
Offline
User avatar

Joined: Tue Sep 30, 2014 6:03 pm
Posts: 317
Location: San Francisco
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:
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.


Top
 Profile  
 
PostPosted: Sat Aug 12, 2017 7:07 pm 
Offline

Joined: Sun Jul 30, 2017 7:09 pm
Posts: 5
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:
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!


Top
 Profile  
 
PostPosted: Sun Aug 13, 2017 3:51 pm 
Offline

Joined: Wed Feb 24, 2010 9:49 pm
Posts: 66
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:
dynamicsWorld.ForceUpdateAllAabbs = false;


Top
 Profile  
 
PostPosted: Mon Aug 14, 2017 11:26 am 
Offline

Joined: Sun Jul 30, 2017 7:09 pm
Posts: 5
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group