Collision check overhead for thousads of static objects
Posted: Sat Dec 01, 2012 12:14 am
I am using Bullet on a scene that has thousands of static objects. The static objects are buildings and trees and such and they act solid if a dynamic object bumps into them.
My problem is that, even with no dynamic objects, Bullet is taking many milliseconds to process each frame and decide there is nothing to do. It seems that many of the static objects overlap and thus are always collision candidates. I've tried both ISLAND_SLEEPING and DISABLE_SIMULATION and set the collision flags so these static objects should never collide, but they stay in the collision pair cache and are checked over and over.
Other than an "if it hurts, don't do it that way" type of answer (Hey! I'm not the artist. I'm just the physics guy!), what do I need to set so overlapping static objects are taken out of the collision pair cache and are never considered for inter-collision checks? Or what obvious thing am I overlooking?
I've searched around the forum a bit but haven't found the answer. Any suggestions appreciated.
Thanks.
-- mb
Some details: A scene with 70,000 static objects (meshes, zero mass, DISABLE_SIMULATION) takes > 50ms to scan (i7,Win7,64bit). Bullet stats say it spends all of the time in 'calculateSimulationIslands' and 'dispatchAllCollisionPairs' (see below). The count of objects and their activation state are at the bottom.
This is Bullet 2.81 and I'm using btCollsionDispatcher, btDbvtBroadphase, btSequentialImpulseConstraintSolver, and btDiscreteDynamicsWorld.
20121130150846102,[BULLETS UNMANAGED]:----------------------------------
20121130150846102,[BULLETS UNMANAGED]rofiling: Root (total running time: 54.165 ms) ---
20121130150846102,[BULLETS UNMANAGED]:0 -- stepSimulation (99.99 %) :: 54.161 ms / frame (1 calls)
20121130150846102,[BULLETS UNMANAGED]:Unaccounted: (0.007 %) :: 0.004 ms
20121130150846102,[BULLETS UNMANAGED]:...----------------------------------
20121130150846102,[BULLETS UNMANAGED]:...Profiling: stepSimulation (total running time: 54.161 ms) ---
20121130150846102,[BULLETS UNMANAGED]:...0 -- synchronizeMotionStates (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:...1 -- internalSingleStepSimulation (97.88 %) :: 53.014 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:...Unaccounted: (2.118 %) :: 1.147 ms
20121130150846102,[BULLETS UNMANAGED]:......----------------------------------
20121130150846102,[BULLETS UNMANAGED]:......Profiling: internalSingleStepSimulation (total running time: 53.014 ms) ---
20121130150846102,[BULLETS UNMANAGED]:......0 -- updateActivationState (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......1 -- updateActions (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......2 -- integrateTransforms (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......3 -- solveConstraints (0.06 %) :: 0.033 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......4 -- calculateSimulationIslands (61.32 %) :: 32.506 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......5 -- performDiscreteCollisionDetection (38.59 %) :: 20.457 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......6 -- createPredictiveContacts (0.00 %) :: 0.002 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......7 -- predictUnconstraintMotion (0.00 %) :: 0.001 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......Unaccounted: (0.028 %) :: 0.015 ms
20121130150846102,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846102,[BULLETS UNMANAGED]:.........Profiling: solveConstraints (total running time: 0.033 ms) ---
20121130150846102,[BULLETS UNMANAGED]:.........0 -- solveGroup (60.61 %) :: 0.020 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........1 -- processIslands (6.06 %) :: 0.002 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........2 -- islandUnionFindAndQuickSort (12.12 %) :: 0.004 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........Unaccounted: (21.212 %) :: 0.007 ms
20121130150846102,[BULLETS UNMANAGED]:............----------------------------------
20121130150846102,[BULLETS UNMANAGED]:............Profiling: solveGroup (total running time: 0.020 ms) ---
20121130150846102,[BULLETS UNMANAGED]:............0 -- solveGroupCacheFriendlyIterations (15.00 %) :: 0.003 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:............1 -- solveGroupCacheFriendlySetup (35.00 %) :: 0.007 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:............Unaccounted: (50.000 %) :: 0.010 ms
20121130150846102,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846102,[BULLETS UNMANAGED]:.........Profiling: calculateSimulationIslands (total running time: 32.506 ms) ---
20121130150846102,[BULLETS UNMANAGED]:.........0 -- storeIslandActivationState (23.35 %) :: 7.589 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........1 -- uniteIslandsFromConstraints (0.00 %) :: 0.001 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........2 -- uniteIslandsFromPredictiveManifold (0.01 %) :: 0.003 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........3 -- updateActivationState (76.62 %) :: 24.905 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........Unaccounted: (0.025 %) :: 0.008 ms
20121130150846103,[BULLETS UNMANAGED]:............----------------------------------
20121130150846103,[BULLETS UNMANAGED]:............Profiling: updateActivationState (total running time: 24.905 ms) ---
20121130150846103,[BULLETS UNMANAGED]:............0 -- findUnions (23.01 %) :: 5.731 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:............Unaccounted: (76.989 %) :: 19.174 ms
20121130150846103,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846103,[BULLETS UNMANAGED]:.........Profiling: performDiscreteCollisionDetection (total running time: 20.457 ms) ---
20121130150846103,[BULLETS UNMANAGED]:.........0 -- dispatchAllCollisionPairs (89.55 %) :: 18.320 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........1 -- calculateOverlappingPairs (0.03 %) :: 0.007 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........2 -- updateAabbs (10.37 %) :: 2.121 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........Unaccounted: (0.044 %) :: 0.009 ms
20121130150846103,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846103,[BULLETS UNMANAGED]:.........Profiling: createPredictiveContacts (total running time: 0.002 ms) ---
20121130150846103,[BULLETS UNMANAGED]:.........0 -- release predictive contact manifolds (50.00 %) :: 0.001 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........Unaccounted: (50.000 %) :: 0.001 ms
20121130150846106,[BULLETS UNMANAGED]: num CollisionObject = 69179
20121130150846106,[BULLETS UNMANAGED]: num RigidBodies = 69179
20121130150846106,[BULLETS UNMANAGED]: num ACTIVE_TAG = 0
20121130150846106,[BULLETS UNMANAGED]: num ISLAND_SLEEPING = 0
20121130150846106,[BULLETS UNMANAGED]: num WANTS_DEACTIVATION = 0
20121130150846106,[BULLETS UNMANAGED]:num DISABLE_DEACTIVATION = 0
20121130150846106,[BULLETS UNMANAGED]: num DISABLE_SIMULATION = 69179
20121130150846106,[BULLETS UNMANAGED]: num overlappingPairs = 69178
20121130150846106,0000000000,Simulate,call, frame=1000, nTaints=0, simTime=63, substeps=5, updates=0, colliders=0
My problem is that, even with no dynamic objects, Bullet is taking many milliseconds to process each frame and decide there is nothing to do. It seems that many of the static objects overlap and thus are always collision candidates. I've tried both ISLAND_SLEEPING and DISABLE_SIMULATION and set the collision flags so these static objects should never collide, but they stay in the collision pair cache and are checked over and over.
Other than an "if it hurts, don't do it that way" type of answer (Hey! I'm not the artist. I'm just the physics guy!), what do I need to set so overlapping static objects are taken out of the collision pair cache and are never considered for inter-collision checks? Or what obvious thing am I overlooking?
I've searched around the forum a bit but haven't found the answer. Any suggestions appreciated.
Thanks.
-- mb
Some details: A scene with 70,000 static objects (meshes, zero mass, DISABLE_SIMULATION) takes > 50ms to scan (i7,Win7,64bit). Bullet stats say it spends all of the time in 'calculateSimulationIslands' and 'dispatchAllCollisionPairs' (see below). The count of objects and their activation state are at the bottom.
This is Bullet 2.81 and I'm using btCollsionDispatcher, btDbvtBroadphase, btSequentialImpulseConstraintSolver, and btDiscreteDynamicsWorld.
20121130150846102,[BULLETS UNMANAGED]:----------------------------------
20121130150846102,[BULLETS UNMANAGED]rofiling: Root (total running time: 54.165 ms) ---
20121130150846102,[BULLETS UNMANAGED]:0 -- stepSimulation (99.99 %) :: 54.161 ms / frame (1 calls)
20121130150846102,[BULLETS UNMANAGED]:Unaccounted: (0.007 %) :: 0.004 ms
20121130150846102,[BULLETS UNMANAGED]:...----------------------------------
20121130150846102,[BULLETS UNMANAGED]:...Profiling: stepSimulation (total running time: 54.161 ms) ---
20121130150846102,[BULLETS UNMANAGED]:...0 -- synchronizeMotionStates (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:...1 -- internalSingleStepSimulation (97.88 %) :: 53.014 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:...Unaccounted: (2.118 %) :: 1.147 ms
20121130150846102,[BULLETS UNMANAGED]:......----------------------------------
20121130150846102,[BULLETS UNMANAGED]:......Profiling: internalSingleStepSimulation (total running time: 53.014 ms) ---
20121130150846102,[BULLETS UNMANAGED]:......0 -- updateActivationState (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......1 -- updateActions (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......2 -- integrateTransforms (0.00 %) :: 0.000 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......3 -- solveConstraints (0.06 %) :: 0.033 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......4 -- calculateSimulationIslands (61.32 %) :: 32.506 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......5 -- performDiscreteCollisionDetection (38.59 %) :: 20.457 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......6 -- createPredictiveContacts (0.00 %) :: 0.002 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......7 -- predictUnconstraintMotion (0.00 %) :: 0.001 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:......Unaccounted: (0.028 %) :: 0.015 ms
20121130150846102,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846102,[BULLETS UNMANAGED]:.........Profiling: solveConstraints (total running time: 0.033 ms) ---
20121130150846102,[BULLETS UNMANAGED]:.........0 -- solveGroup (60.61 %) :: 0.020 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........1 -- processIslands (6.06 %) :: 0.002 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........2 -- islandUnionFindAndQuickSort (12.12 %) :: 0.004 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........Unaccounted: (21.212 %) :: 0.007 ms
20121130150846102,[BULLETS UNMANAGED]:............----------------------------------
20121130150846102,[BULLETS UNMANAGED]:............Profiling: solveGroup (total running time: 0.020 ms) ---
20121130150846102,[BULLETS UNMANAGED]:............0 -- solveGroupCacheFriendlyIterations (15.00 %) :: 0.003 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:............1 -- solveGroupCacheFriendlySetup (35.00 %) :: 0.007 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:............Unaccounted: (50.000 %) :: 0.010 ms
20121130150846102,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846102,[BULLETS UNMANAGED]:.........Profiling: calculateSimulationIslands (total running time: 32.506 ms) ---
20121130150846102,[BULLETS UNMANAGED]:.........0 -- storeIslandActivationState (23.35 %) :: 7.589 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........1 -- uniteIslandsFromConstraints (0.00 %) :: 0.001 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........2 -- uniteIslandsFromPredictiveManifold (0.01 %) :: 0.003 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........3 -- updateActivationState (76.62 %) :: 24.905 ms / frame (5 calls)
20121130150846102,[BULLETS UNMANAGED]:.........Unaccounted: (0.025 %) :: 0.008 ms
20121130150846103,[BULLETS UNMANAGED]:............----------------------------------
20121130150846103,[BULLETS UNMANAGED]:............Profiling: updateActivationState (total running time: 24.905 ms) ---
20121130150846103,[BULLETS UNMANAGED]:............0 -- findUnions (23.01 %) :: 5.731 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:............Unaccounted: (76.989 %) :: 19.174 ms
20121130150846103,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846103,[BULLETS UNMANAGED]:.........Profiling: performDiscreteCollisionDetection (total running time: 20.457 ms) ---
20121130150846103,[BULLETS UNMANAGED]:.........0 -- dispatchAllCollisionPairs (89.55 %) :: 18.320 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........1 -- calculateOverlappingPairs (0.03 %) :: 0.007 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........2 -- updateAabbs (10.37 %) :: 2.121 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........Unaccounted: (0.044 %) :: 0.009 ms
20121130150846103,[BULLETS UNMANAGED]:.........----------------------------------
20121130150846103,[BULLETS UNMANAGED]:.........Profiling: createPredictiveContacts (total running time: 0.002 ms) ---
20121130150846103,[BULLETS UNMANAGED]:.........0 -- release predictive contact manifolds (50.00 %) :: 0.001 ms / frame (5 calls)
20121130150846103,[BULLETS UNMANAGED]:.........Unaccounted: (50.000 %) :: 0.001 ms
20121130150846106,[BULLETS UNMANAGED]: num CollisionObject = 69179
20121130150846106,[BULLETS UNMANAGED]: num RigidBodies = 69179
20121130150846106,[BULLETS UNMANAGED]: num ACTIVE_TAG = 0
20121130150846106,[BULLETS UNMANAGED]: num ISLAND_SLEEPING = 0
20121130150846106,[BULLETS UNMANAGED]: num WANTS_DEACTIVATION = 0
20121130150846106,[BULLETS UNMANAGED]:num DISABLE_DEACTIVATION = 0
20121130150846106,[BULLETS UNMANAGED]: num DISABLE_SIMULATION = 69179
20121130150846106,[BULLETS UNMANAGED]: num overlappingPairs = 69178
20121130150846106,0000000000,Simulate,call, frame=1000, nTaints=0, simTime=63, substeps=5, updates=0, colliders=0