Problems with bottleneck

Post Reply
spixxel
Posts: 8
Joined: Sun Feb 05, 2012 12:25 am

Problems with bottleneck

Post by spixxel » Sun Feb 05, 2012 12:46 am

Hello, I have currently two objects in the my world. One static terrain and one dynamic convex object, they are kind of large and I have problems with a bottleneck in
"dispatchAllCollisonPairs" which takes up to 20 ms in some frames (when there is a call to it according to the bullet profiler)

an example of how the profiler info might look like.

Profiling StepSimulation total running 19.180 ms
0 internalSingleStepSimulation ((99.94%) :: 19.168 ms / frame (1 calls)
1 synchronizeMotionStates (0.04 %) :: 0.007 ms /frame (1 calls)

Profiling internalSingleStepSimulation (total running time: 19.168 ms)
0 updateActivationState (0.00 %) :: 0.000 ms / frame (1 calls)
1 updateActions (35.62 %) :: 6.828 ms / frame (1 calls) (this is also wierd, i have 1 of bullets standard charactercontrollers
2 integrateTransforms (0.05 %) :: 0.009 ms / frame (1 calls)
3 solveConstraints (0.20 %) 0.039 ms / frame (1 calls)
4 calculateSimulationIslands (0.04 %) :: 0.007 ms / frame (1 calls)
5 performDiscreteCollisonDetection (64.03 %) :: 12.274 ms / frame (1 calls)
6 predictUnconstrantMotion (0.04 %) :: 0.007 ms / frame (1 calls)

Profiling solveConstraints (total running time: 0.039 ms)
0 solveGroup (23.08 %) :: 0.009 ms / frame (1 calls)
1 processIslands (53.85 %) :: 0.021 ms / frame (1 calls)
2 islandUnionFindAndQuickSort (10.26 %) :: 0.004 ms /frame (1 calls)

Profiling solveGroup (total running time: 0.009 ms)
0 solveGroupCacheFriendlyIterations (11.11 %) :: 0.001 ms / frame (1 calls)
1 solveGroupCacheFriendlySetup (55.56 %) :: 0.005 ms / frame (1 calls)

profiling performDiscreteCollisonDetection (total running time 12.274 ms)
0 dispatchAllCollisonPairs (99.29 %) :: 12.187 ms / frame (1 calls)
1 calculateOverlappingPairs (0.02 %) :: 0.003 ms / frame (1 calls)
2 updateAabbs (0.68 %) :: 0.083 ms / frame (1 calls)


thats all, i dont know what more to send, but would appreciate all the help I can get and provide the information needed

Thanks

spixxel
Posts: 8
Joined: Sun Feb 05, 2012 12:25 am

Re: Problems with bottleneck

Post by spixxel » Sun Feb 05, 2012 10:45 am

Someone got an idea what it can be?, When I run in a previous project with the same terrain (but not the same dynamic object, but a lot of other) the same bottlenecks takes 0.000 ms

and I have dubbelchecked so that the physics is set up in the same way. Any1 got an idea what it can be?

spixxel
Posts: 8
Joined: Sun Feb 05, 2012 12:25 am

Re: Problems with bottleneck

Post by spixxel » Sun Feb 05, 2012 10:47 am

Here is the init code of the dynamicsworld

m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btVector3 worldAabbMin(-100,-100,-100);
btVector3 worldAabbMax(100,100,100);

btHashedOverlappingPairCache* pairCache = new btHashedOverlappingPairCache();
sweepBP = new btAxisSweep3(worldAabbMin,worldAabbMax,3500,pairCache);
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver();
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,sweepBP,m_solver,m_collisionConfiguration);
m_dynamicsWorld->getSolverInfo().m_solverMode |=SOLVER_ENABLE_FRICTION_DIRECTION_CACHING; //don't recalculate friction values each frame
m_dynamicsWorld->getSolverInfo().m_numIterations = 5; //few solver iterations
btScalar m_defaultContactProcessingThreshold;
m_defaultContactProcessingThreshold = 0.f;//used when creating bodies: body->setContactProcessingThreshold(...);
m_dynamicsWorld->setGravity(btVector3(0,-10,0));

spixxel
Posts: 8
Joined: Sun Feb 05, 2012 12:25 am

Re: Problems with bottleneck

Post by spixxel » Sun Feb 05, 2012 11:25 am

I guess that dispatch all collision pairs is just applying collision response to them or?. Is this usually a bottleneck?, I changed some parameters now for example the maximum simulation steps and also

m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,3500,pairCache);

the 3500 to something larger and smaller, but then the time that dispatchallcollisionpairs took would raise to over 100 ms.

Can it be because of a lot collisions between the 2 objects?

I use this code to create the dynamic object


btTransform localTrans;
localTrans.setIdentity();
btConvexHullShape* nonStaticShape = new btConvexHullShape();
for (unsigned int i=0; i<numVertices ;i++)
{
btVector3 vtx(vertex.x,vertex.y,vertex.z);
nonStaticShape->addPoint(vtx);
}
btShapeHull* hull = new btShapeHull(nonStaticShape);
btScalar margin = nonStaticShape->getMargin();
hull->buildHull(margin);
btConvexHullShape* simplifiednonStaticShape = new btConvexHullShape(&hull->getVertexPointer()->x(),hull->numVertices());
btVector3 localInertia(0,0,0);
if(mass)
simplifiednonStaticShape->calculateLocalInertia(mass,localInertia);
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo cInfo(mass,myMotionState,simplifiednonStaticShape,localInertia);
btRigidBody* body = new btRigidBody(cInfo);
body->setContactProcessingThreshold(0.f);
m_dynamicsWorld->addRigidBody(body);

Ripiz
Posts: 47
Joined: Mon Aug 16, 2010 10:43 am

Re: Problems with bottleneck

Post by Ripiz » Sun Feb 05, 2012 12:01 pm

1. How many vertices you have in your convex mesh?

2. Have you tried using btDbvtBroadphase instead of btAxisSweep3?

spixxel
Posts: 8
Joined: Sun Feb 05, 2012 12:25 am

Re: Problems with bottleneck

Post by spixxel » Sat Feb 11, 2012 10:52 am

It doesn't get any better. But now I use a character controller instead of the dynamic object, but can it be a problem if it is too big?

spixxel
Posts: 8
Joined: Sun Feb 05, 2012 12:25 am

Re: Problems with bottleneck

Post by spixxel » Sat Feb 11, 2012 12:46 pm

is it normal to get very low performance with a charactercontroller consistes of a capsule with like 20*20 to 60*60 in dimensions?, because it gets a lot better when they are like 0.75*0.75 or is it that they collide with more vertices on the terrain?

kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: Problems with bottleneck

Post by kloplop321 » Sat Feb 11, 2012 7:13 pm

have you considered splitting your terrain mesh into paged sections?

Post Reply