0
\$\begingroup\$

It seems like creating a bunch of rigid bodies (say 100K) causes a huge slowdown. However, what if the model the rigid body is attached to isn't visible. Is there a way to remove the rigid body from any sort of iteration from Newton so it doesn't cause a slowdown during run-time?

\$\endgroup\$
4
  • \$\begingroup\$ if the object is not visible you spare the rendering costs but physics calculations are still done. I don't understand your question. If you remove something it's not calculated so it's faster but the point is that the calculation is missing then. \$\endgroup\$ Dec 23, 2015 at 23:58
  • \$\begingroup\$ So I would assume rigid bodies are added to some internal list of physics objects. Creating rigid bodies has overhead so you wouldn't want to create/destroy a lot at run-time. So instead you may want to "hide" it to the physics system so it doesn't have to get iterated over and slow down the game. Basically I would assume Newton should have 2 lists. "Visible" list that is iterated over and a "hidden" list that isn't iterated over. When we want a rigid body to be "visible" it moves from 1 list to the other and vise verse. \$\endgroup\$
    – user441521
    Dec 24, 2015 at 0:01
  • \$\begingroup\$ Do you mean 'newton dynamics' by 'newton physics'? \$\endgroup\$
    – Ali1S232
    Dec 24, 2015 at 9:01
  • \$\begingroup\$ you should not use the word "hide" if you mean "remove". "hiding" is a term describing visibility and therefore I thought you were speaking about rendering. \$\endgroup\$ Dec 25, 2015 at 14:38

2 Answers 2

1
\$\begingroup\$

Is there a way to remove the rigid body from any sort of iteration from Newton so it doesn't cause a slowdown during run-time?

Yes!

To prevent wasting CPU power on mathematically intensive Narrow Phase calculations, all good physics engines will implement some form of Broad Phase detection. This could include spatial partitioning like octrees and bounding spheres.

If desired, this concept of reducing calculations via Broad Phase can be taken one step further, beyond collisions, to completely remove a rigid body from any kinematic calculations entirely if that's desired.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ The broadphase doesn't reduce the cost of calculating kinematic physics on of performing collision detection. 100000 falling boxes all need basic kinematic equations run whether there is a broadphase or not. Broadphase helps reduce cost of pairwise collision detection. \$\endgroup\$
    – Steven
    Dec 24, 2015 at 21:10
  • \$\begingroup\$ @Steven There's no reason a broad phase couldn't also prevent a rigid body from calculating physics all together. He says in the question Is there a way to remove the rigid body from any sort of iteration from Newton so I assume that means even basic kinematics; the answer is still yes. \$\endgroup\$
    – Foggzie
    Dec 24, 2015 at 21:57
  • 1
    \$\begingroup\$ @Gunther How so? An object that's not in collision should still fall etc. Sleep can be used for objects that haven't moved for a while. \$\endgroup\$ Dec 24, 2015 at 22:24
  • \$\begingroup\$ @RichardTingle I'll quote it once more. He asked to remove the rigid body from any sort of iteration from Newton. Yes, an object not in collision should still fall but we're talking about optimization here and he explicitly asked if something can be removed from Newtons laws all together; it's right there in the question. \$\endgroup\$
    – Foggzie
    Dec 24, 2015 at 22:26
  • 1
    \$\begingroup\$ @Gunthen yes and you can do that, but you can't call it a broadphase. The broadphases job is to separate "maybe colliding" from "not colliding". Not to separate "Care" and "don't care". If anything that's outside of the physics engines domain and within the game logic (the physics engine can provide "disable" methods to help with this \$\endgroup\$ Dec 24, 2015 at 22:39
0
\$\begingroup\$

Depending on which physics system you use it may be that rigid bodies can be disabled, removed from the world or destroyed and recreated. It depends entirely on the system you are using.

Generally inactive or not yet spawned objects are not added to the world until needed. However as one person noted the hidden object won't get any collisions or simulation.

As an aside I wonder are you creating all the bodies on top of each othet? Any engine will be slow if forced to evaluate many bodies overlapping at once.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .