you say 16000 objects.
If the ratio of objects with zero mass to dynamics objects is high, say may few hundred bodies are actually dynamics. then your game is spending lot of time check traversing static collision for objects that do not move.
is this some kind of vegetation terrain where many object are static?
if so, you are using the engine is the worse possible way. The engine has tow special ways to deal wit that.
1- there is the scene collision, when the zero mass object are all bundle in static compound collision.
you can have many scene collision, basically you divide your world into sectors and for each sector you add the collision of these objects, this reduces your world for 15000, to maybe a couple of dozen and you get maybe 100 fold speed up. but you have to do some house keeping. this is my prefect way
2- if your scene there are objects that need to be dynamics, you can use the persistence broadphace. On initiation select that options, and the world will be divided at the root level into two large nodes, one node for the static bodies and the other the dynamics.
- Code: Select all
#define NEWTON_BROADPHASE_DEFAULT 0
#define NEWTON_BROADPHASE_PERSINTENT 1
NewtonSelectBroadphaseAlgorithm (m_scene->GetNewton(), PERSINTENT);
this reduces the tree traversal which is what I believe where the engine is spending the time.
3- this option is using aggregates, but that more a refinement. and is a way to grouping dynamics objects and reducing iteration between them when you know that should no interact.
this is good for thongs like ragdoll, of contraction made of joints. Basically the will get a box around them that will cut check as soon at the are trivially rejected.
I would start by option 2 because is quick, just one line of code.
them I would try option 1, because this is when you will get the biggest bang provided the large majority of the objects are static (zero mass). The 7 or 5 ms will reduce to few 1 or 2 millisecond if any. Some people has successfully placed about one million tress in a terrain using that method.