One of the things I'm really trying to achieve is reduction of physics time spended on static objects.
My scenario:
- around 60-70 ms stepsim on Q6600 @ 2,7ghz
- most/all objects have 0 mass (!)
- heightfield 4096x4096
- around 12k objects (shapes provided by HACD(HACD demo imported via btBulletWorldImporter), btCollisionShape, that i believe btCompundShape is inside)
- basic filtering between objects via masks (grass doesn't collide with other objects or other grass, around 40% total)
- removing heightfield or setting bitmask to 0 is not improving much
- most objects have diffrent sizes (I have one instance of shape in specyfic scale, if shape and scale matches - it uses same shape)
- setting scale of all objects to 1.0 (higher reusing of existing shapes) gives around 30% boost but it's not practical
- if I'm correct I can't use uniform or scaled shape to instance it even more because it works only with convex or triangle shapes not compund shapes(?)
- second parameter of stepsim is set to 5 because it was too common for player/objects to fell under heightfield or fly thru objects (is there any more way to avoid that? especialy player falling under terrain [mountainsides are worst])
- bullet 2.82
flags for heightfield and objects:
Code: Select all
rigid_body->setCollisionFlags(rigid_body->getCollisionFlags() | btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT|btCollisionObject::CF_STATIC_OBJECT);
I believe it is possible to make it work much better (especialy when almost/all objects are static [0 mass]).
Info about physics initialization:
Code: Select all
broadphase = new btDbvtBroadphase();
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
solver = new btSequentialImpulseConstraintSolver;
dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
debugDraw = new cEngine_physics_debugdraw;
Profiling info:
CProfileManager::dumpAll();
Code: Select all
Profiling: Root (total running time: 64.435 ms) ---
0 -- stepSimulation (99.99 %) :: 64.429 ms / frame (1 calls)
Unaccounted: (0.009 %) :: 0.006 ms
...----------------------------------
...Profiling: stepSimulation (total running time: 64.429 ms) ---
...0 -- synchronizeMotionStates (0.00 %) :: 0.002 ms / frame (5 calls)
...1 -- internalSingleStepSimulation (98.59 %) :: 63.519 ms / frame (5 calls)
...Unaccounted: (1.409 %) :: 0.908 ms
......----------------------------------
......Profiling: internalSingleStepSimulation (total running time: 63.519 ms) --
-
......0 -- updateActivationState (0.00 %) :: 0.000 ms / frame (5 calls)
......1 -- updateActions (0.00 %) :: 0.000 ms / frame (5 calls)
......2 -- integrateTransforms (0.00 %) :: 0.003 ms / frame (5 calls)
......3 -- solveConstraints (0.08 %) :: 0.049 ms / frame (5 calls)
......4 -- calculateSimulationIslands (17.55 %) :: 11.145 ms / frame (5 calls)
......5 -- performDiscreteCollisionDetection (82.29 %) :: 52.267 ms / frame (5 c
alls)
......6 -- createPredictiveContacts (0.00 %) :: 0.003 ms / frame (5 calls)
......7 -- predictUnconstraintMotion (0.00 %) :: 0.001 ms / frame (5 calls)
......Unaccounted: (0.080 %) :: 0.051 ms
.........----------------------------------
.........Profiling: solveConstraints (total running time: 0.049 ms) ---
.........0 -- solveGroup (44.90 %) :: 0.022 ms / frame (5 calls)
.........1 -- processIslands (2.04 %) :: 0.001 ms / frame (5 calls)
.........2 -- islandUnionFindAndQuickSort (18.37 %) :: 0.009 ms / frame (5 calls
)
.........Unaccounted: (34.694 %) :: 0.017 ms
............----------------------------------
............Profiling: solveGroup (total running time: 0.022 ms) ---
............0 -- solveGroupCacheFriendlyIterations (45.45 %) :: 0.010 ms / frame
(5 calls)
............1 -- solveGroupCacheFriendlySetup (31.82 %) :: 0.007 ms / frame (5 c
alls)
............Unaccounted: (22.727 %) :: 0.005 ms
.........----------------------------------
.........Profiling: performDiscreteCollisionDetection (total running time: 52.26
7 ms) ---
.........0 -- dispatchAllCollisionPairs (30.85 %) :: 16.124 ms / frame (5 calls)
.........1 -- calculateOverlappingPairs (0.09 %) :: 0.046 ms / frame (5 calls)
.........2 -- updateAabbs (69.01 %) :: 36.072 ms / frame (5 calls)
.........Unaccounted: (0.048 %) :: 0.025 ms
.........----------------------------------
.........Profiling: createPredictiveContacts (total running time: 0.003 ms) ---
.........0 -- release predictive contact manifolds (66.67 %) :: 0.002 ms / frame
(5 calls)
.........Unaccounted: (33.333 %) :: 0.001 ms