Tha image show teh cone colliong with oen maybe to faces and teh fsp is 5 fps, you must have something that keep the object active or some that is going terrible wrong.
the bottom line is that 200 hundred objects should not slow down the engine not even a few microsecond even if they all are active at all time regardless of how complex the object are.
even if the terrain have few tens of millions faces.
I assume you are using core 200, is this is so you can check file c:..\source\physics\dgBroadPhaseCollision.cpp
look an this function and set a break point there.
- Code: Select all
void dgBroadPhaseCollision::UpdatePairs (dgBody* const body0, dgSortArray::dgListNode* const srcnode, dgInt32 axisX, dgInt32 threadIndex) const
{
// dgFloat32 val;
// dgBody* body1;
if (!body0->m_collision->IsType (dgCollision::dgCollisionNull_RTTI)) {
dgFloat32 val = body0->m_maxAABB[axisX];
dgCollidingPairCollector& contactPair = *((dgWorld*)this);
for (dgSortArray::dgListNode* node = srcnode; node && (node->GetInfo().m_key < val); node = node->GetNext() ) {
dgBody* const body1 = node->GetInfo().m_body;
if (!body1->m_collision->IsType (dgCollision::dgCollisionNull_RTTI)) {
_ASSERTE (body0 != body1);
if (OverlapTest(body0, body1)) {
contactPair.AddPair(body0, body1, threadIndex);
}
}
}
}
}
void dgBroadPhaseCellPairsWorkerThread::ThreadExecute()
{
dgInt32 step = m_step;
dgInt32 count = m_count;
dgBroadPhaseCollision& broadPhase = *m_world;
for (dgInt32 i = 0; i < count; i += step) {
if(m_pairs[i].m_cell_B) {
broadPhase.UpdatePairs (*m_pairs[i].m_cell_A, *m_pairs[i].m_cell_B, m_threadIndex);
} else {
m_pairs[i].m_cell_A->UpdateAutoPair(m_world, m_threadIndex);
}
}
}
That is the function that is call to determine if a pair of bodies is close enough to send then to the narrow phase contact calculation.
if you have 200 cone on a terrain, if they are no touching each other they yu will have few calls
void dgBroadPhaseCollision::UpdatePairs (dgBody* const body0, dgSortArray::dgListNode* const srcnode, dgInt32 axisX, dgInt32 threadIndex) const
each with bodo0 being the terrain, and srcnode a list of few cones,
since the terrain is larger and if the cones are active then there will be 200 calls to
if (OverlapTest(body0, body1)) {
if the test pass then that pair will be send to the pair list for contact calculation
contactPair.AddPair(body0, body1, threadIndex);
there are few points here.
1) even if the cone are all active the maximum number of call is 200, not enough to slow down that function,
you can call it maybe 200,000 time before you see the impact in eh Game.
2) if the code are at rest that function should not even be called at all. so there must be something that is keeping the cone active.
this mean there are more than one reason for this.
the first thing to do is to make a simple test that can be step trough.
I suggest make a test demo with the same mesh track, but only with say 5 representative cones. do no apply anything let the cone has default values.
this test is to see if the cone fail to go to rest.
then run the demo until they are settle on the terrain,
then set a break point on function void dgBroadPhaseCellPairsWorkerThread::ThreadExecute()
that function should not be called is the cone are all resting on the floor.
that will be test 1,
can you do that before we do the next test which is making all cones actives and see if it is the search for the triangle that the cone is colliding with that is producing the slow down.
if you can produce that test and the first part fail, can you send it to me for testing?