When I filled my sparse scene with many dynamic rigid bodies on startup, the game starts very slow, like one frame per 2 seconds, and after some time, I get good speed again. The simulation world is indeed very big, but most of the objects should remain deactivated until the player get to it and interact. I believed the problem was because all the rigid bodies were active at startup, and after some time they are automatically deactivated.
To try to improve the initial speed, I deactivated all those rigid bodies with:
Code: Select all
m_pRigidBody->setActivationState(WANTS_DEACTIVATION);
Now they remain stationary until the player character gets close to them. But for my surprise, they are still generating contact points, and the first few seconds speed are not better. Using gprof I could determine that most of this time is spent on
Code: Select all
btConvexHullShape::localGetSupportingVertexWithoutMargin
After some time, precisely when the good speed is attained, they stop generating contact points.
So it seems dynamics activation is dissociated from collision activation. Is there a way to completely deactivate a rigid body, so it won't move nor generate contact points until auto or manually reactivated?
In the future, I may add the bodies to the world dynamically, based on info from the scene culling algorithm, but the best solution is still unknown.