Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

As of now I am working on optimizing the performance of the physics and collision, and as of now I am having some slowdowns on my other computers from my main.

I have well over 3000 btSphereShape Rigidbodies and 2/3 of them do not move at all, but I am noticing(by the profile below) that collision is taking a bit of time to maneuver.

    Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 10.09      0.65     0.65                             SphereTriangleDetector::collide(btVector3 const&, btVector3&, btVector3&, float&, float&, float)
  7.61      1.14     0.49                             btSphereTriangleCollisionAlgorithm::processCollision(btCollisionObject*, btCollisionObject*, btDispatcherInfo const&, btManifoldResult*)
  5.59      1.50     0.36                             btConvexTriangleCallback::processTriangle(btVector3*, int, int)
  5.43      1.85     0.35                             btQuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback*, btVector3 const&, btVector3 const&) const
  4.97      2.17     0.32                             btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback*, btVector3 const&, btVector3 const&) const::MyNodeOverlapCallback::processNode(int, int)
  4.19      2.44     0.27                             btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btRigidBody&, btRigidBody&, btSolverConstraint const&)
  4.04      2.70     0.26                             btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btRigidBody&, btRigidBody&, btSolverConstraint const&)
  3.73      2.94     0.24                             Ogre::OctreeSceneManager::walkOctree(Ogre::OctreeCamera*, Ogre::RenderQueue*, Ogre::Octree*, Ogre::VisibleObjectsBoundsInfo*, bool, bool)
  3.42      3.16     0.22                             btTriangleShape::getVertex(int, btVector3&) const
  2.48      3.32     0.16                             Ogre::Frustum::isVisible(Ogre::AxisAlignedBox const&, Ogre::FrustumPlane*) const
  2.33      3.47     0.15  1246357     0.00     0.00  Gorilla::Layer::setVisible(bool)
  2.33      3.62     0.15                             SphereTriangleDetector::getClosestPoints(btDiscreteCollisionDetectorInterface::ClosestPointInput const&, btDiscreteCollisionDetectorInterface::Result&, btIDebugDraw*, bool)
  1.86      3.74     0.12                             btCollisionDispatcher::findAlgorithm(btCollisionObject*, btCollisionObject*, btPersistentManifold*)
  1.86      3.86     0.12                             btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstraint&, btCollisionObject*, btCollisionObject*, btManifoldPoint&, btContactSolverInfo const&, btVector3&, float&, float&, btVector3&, btVector3&)
  1.71      3.97     0.11                             btTriangleShape::getEdge(int, btVector3&, btVector3&) const
  1.55      4.07     0.10                             _Unwind_SjLj_Register
  1.55      4.17     0.10                             _Unwind_SjLj_Unregister
  1.55      4.27     0.10                             Ogre::D3D9HardwareVertexBuffer::updateBufferResources(char const*, Ogre::D3D9HardwareVertexBuffer::BufferResources*)
  1.40      4.36     0.09                             btManifoldResult::addContactPoint(btVector3 const&, btVector3 const&, float)
  1.40      4.45     0.09                             btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstraint&, btVector3 const&, btRigidBody*, btRigidBody*, btManifoldPoint&, btVector3 const&, btVector3 const&, btCollisionObject*, btCollisionObject*, float, float, float)
  1.24      4.53     0.08                             btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold*, btContactSolverInfo const&)
  1.09      4.60     0.07   408760     0.00     0.00  Living::MapHide()
  1.09      4.67     0.07                             btSphereTriangleCollisionAlgorithm::~btSphereTriangleCollisionAlgorithm()
  1.09      4.74     0.07                             inflate_fast

EDIT: Updated to show current Profile. I have only listed the functions using over 1% time from the many functions that are being used. Another thing is that each monster has a certain area that they stay in and are only active when a player is in said area. I was wondering if maybe there is a way to deactivate the non-active monsters from bullet(reactivating once in the area again) or maybe theres a different broadphase interface that I should use.

The current BPI is btDbvtBroadphase.

EDIT: Here is the Profile on the other computer(the top one is my main)

    Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 12.18      1.19     1.19                             SphereTriangleDetector::collide(btVector3 const&, btVector3&, btVector3&, float&, float&, float)
  6.76      1.85     0.66                             btSphereTriangleCollisionAlgorithm::processCollision(btCollisionObject*, btCollisionObject*, btDispatcherInfo const&, btManifoldResult*)
  5.83      2.42     0.57                             btQuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback*, btVector3 const&, btVector3 const&) const
  5.12      2.92     0.50                             btConvexTriangleCallback::processTriangle(btVector3*, int, int)
  4.61      3.37     0.45                             btTriangleShape::getVertex(int, btVector3&) const
  4.09      3.77     0.40                             _Unwind_SjLj_Register
  3.48      4.11     0.34                             btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback*, btVector3 const&, btVector3 const&) const::MyNodeOverlapCallback::processNode(int, int)
  2.46      4.35     0.24                             btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btRigidBody&, btRigidBody&, btSolverConstraint const&)
  2.15      4.56     0.21                             _Unwind_SjLj_Unregister
  2.15      4.77     0.21                             SphereTriangleDetector::getClosestPoints(btDiscreteCollisionDetectorInterface::ClosestPointInput const&, btDiscreteCollisionDetectorInterface::Result&, btIDebugDraw*, bool)
  1.84      4.95     0.18                             btTriangleShape::getEdge(int, btVector3&, btVector3&) const
  1.64      5.11     0.16                             btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btRigidBody&, btRigidBody&, btSolverConstraint const&)
  1.54      5.26     0.15                             btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstraint&, btCollisionObject*, btCollisionObject*, btManifoldPoint&, btContactSolverInfo const&, btVector3&, float&, float&, btVector3&, btVector3&)
  1.43      5.40     0.14                             Ogre::D3D9HardwareVertexBuffer::updateBufferResources(char const*, Ogre::D3D9HardwareVertexBuffer::BufferResources*)
  1.33      5.53     0.13                             btManifoldResult::addContactPoint(btVector3 const&, btVector3 const&, float)
  1.13      5.64     0.11                             btRigidBody::predictIntegratedTransform(float, btTransform&)
  1.13      5.75     0.11                             btTriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(unsigned char const**, int&, PHY_ScalarType&, int&, unsigned char const**, int&, int&, PHY_ScalarType&, int) const
  1.02      5.85     0.10                             btSphereTriangleCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo&, btCollisionObject*, btCollisionObject*)
  1.02      5.95     0.10                             btSphereTriangleCollisionAlgorithm::btSphereTriangleCollisionAlgorithm(btPersistentManifold*, btCollisionAlgorithmConstructionInfo const&, btCollisionObject*, btCollisionObject*, bool)

Edited same as other Profile.

share|improve this question
    
does bullet support sleep which usually either eliminates the call to update(), or just does a boolean check on the sleep. most systems that use sleep still have the ability to have collisions and such. its just a matter of waking them up when you need to. also have you compared the profile of the "main" system to the "other" systems to see if they have different bottlenecks –  gardian06 May 5 '12 at 18:24
    
Actually, I havent checked both bottlenecks at once. I should go try that and Ill post results –  Molmasepic May 5 '12 at 18:32
    
depending on hardware some systems can do some operations faster. some processors have dedicated threads for converting specific data types while others try to push math operations to the GPU to save object handling to the CPU. –  gardian06 May 5 '12 at 18:34
    
Okay, as requested I have posted the profile from the other computer. –  Molmasepic May 5 '12 at 18:41
    
by inspection I would say that both of them seem to share the bottleneck to sphereTriangleDetector::collide() though 19.01 seconds being 12.28% is scary, but I think this might be a hardware performance thing, so to compensate I would maybe air on the side of caution, and see if you can modify the sleep values of the rigid bodies maybe modifying the threshold bulletphysics.com/Bullet/BulletFull/classbtRigidBody.html (find:sleep) –  gardian06 May 5 '12 at 20:35
show 2 more comments

1 Answer

The broadphase is not the bottleneck, it seems narrowphase sphere versus triangle.

Is this a profile using full optimizations? What platform?

It could be the trianglemesh is not optimized for collision, but for rendering? Too many small triangles slows down a lot.

You can also dump the Bullet timings using CProfileManager::dumpAll() right after stepSimulation, to get more details. We could add a faster sphere trangle collider, file a request to http://bullet.googlecode.com

Deactivation would help too, you could create sphere rigid bodies in deactivated )sleeping) state.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.