Page 1 of 1

Physics scene management?

Posted: Tue Apr 02, 2013 6:15 am
by chebob69
What's the best way to include physics in my game's scene management. So for example, there are some parts of my physics
that need to be running all the time. Others will only ever be needed when the character is within proximity. So I'm thinking things
like buoyancy for a stationary boat, joints used on the branches of trees, rope bridges etc
Is there a good way of making sure these types of calculations aren't wasting cpu time when they're not needed or will bepu do
enough of this automatically?
Thanks

Re: Physics scene management?

Posted: Tue Apr 02, 2013 4:46 pm
by Norbo
Is there a good way of making sure these types of calculations aren't wasting cpu time when they're not needed or will bepu do enough of this automatically?
That depends heavily on the simulation. Sometimes, yes; deactivated objects are pretty cheap, and most things will end up inactive if they aren't being actively interacted with.

However, if you have 50,000 physics entities in the world at the same time, it will still be a little expensive even when all of them are deactivated. This is primarily due to the broad phase and a few other minor bits of bookkeeping. These pieces have to run for deactivated objects to see if those deactivated objects need to wake up. [I have some long term plans of improving this, but there are limits.]

In this situation or any situation similar enough in scope to make leaving everything in the space infeasible, it can be useful to manually prune the simulation of elements that are known to be unnecessary at the time. This is possible because the game often has more guarantees than the physics simulation has about the nature of interaction. Those guarantees can be used to design the pruning mechanism.

A detailed look at one possible pruning strategy can be found in my second post in this thread: viewtopic.php?f=4&t=1917

Re: Physics scene management?

Posted: Fri Apr 05, 2013 2:09 pm
by chebob69
Ok, I read the other post. Seems easy enough with my situation to just remove some things from the space. All of the items in question are of a fixed position and won't really be interacting with anything other than the character- so that seems the best option. Thanks Norbo.