reactphysics3d
reactphysics3d copied to clipboard
Inconsistent physics time with VSync enabled/disabled in testbed
Hello, I tried out your testbed, and I really liked what I saw, but there is something which I find weird. For example in the Cubes Scene, with Vsync disabled I have a physics-time of mostly 0.0 ms (shown on the GUI), but when enabling Vsync, the physics-time reaches nearly 1 ms. The same happens in the other demos, and is especially noticeable in the concave mesh Scene, where physics-time reaches sometimes nearly 4 ms! Do you know what happens here, and is there a way to mitigate this? Here are the corresponding profiling statistics taken with one run of the Cubes Scene: without VSync:
---------------
| Profiling : Root (total running time : 13152.3 ms) ---
| 0 -- DynamicsWorld::update() : 0.856368 % | 0.145144 ms/frame (776 calls)
| 1 -- RigidBody::updateBroadPhaseState() : 2.90041e-05 % | 4.91585e-06 ms/frame (7 calls)
| 2 -- CollisionShape::computeAABB() : 0.000208467 % | 3.53327e-05 ms/frame (155 calls)
| Unaccounted : 13039.6 ms (99.1434 %)
---------------
| Profiling : DynamicsWorld::update() (total running time : 112.632 ms) ---
| 0 -- DynamicsWorld::updateSleepingBodies() : 0.235388 % | 0.000341651 ms/frame (776 calls)
| 1 -- DynamicsWorld::updateBodiesState() : 11.433 % | 0.0165944 ms/frame (776 calls)
| 2 -- DynamicsWorld::solvePositionCorrection() : 0.0273067 % | 3.9634e-05 ms/frame (776 calls)
| 3 -- DynamicsWorld::integrateRigidBodiesPositions() : 1.72328 % | 0.00250124 ms/frame (776 calls)
| 4 -- DynamicsWorld::solveContactsAndConstraints() : 43.0237 % | 0.0624463 ms/frame (776 calls)
| 5 -- DynamicsWorld::integrateRigidBodiesVelocities() : 5.97487 % | 0.00867217 ms/frame (776 calls)
| 6 -- DynamicsWorld::computeIslands() : 1.60114 % | 0.00232397 ms/frame (776 calls)
| 7 -- CollisionDetection::computeCollisionDetection() : 34.5061 % | 0.0500836 ms/frame (776 calls)
| Unaccounted : 1.66154 ms (1.4752 %)
---------------
| Profiling : DynamicsWorld::updateBodiesState() (total running time : 12.8772 ms) ---
| 0 -- RigidBody::updateBroadPhaseState() : 72.4223 % | 0.012018 ms/frame (21211 calls)
| Unaccounted : 3.55124 ms (27.5777 %)
---------------
| Profiling : RigidBody::updateBroadPhaseState() (total running time : 9.32598 ms) ---
| 0 -- DynamicAABBTree::updateObject() : 35.4203 % | 0.00425682 ms/frame (21211 calls)
| 1 -- CollisionShape::computeAABB() : 23.1107 % | 0.00277745 ms/frame (21211 calls)
| Unaccounted : 3.86739 ms (41.469 %)
---------------
| Profiling : DynamicsWorld::solveContactsAndConstraints() (total running time : 48.4583 ms) ---
| 0 -- ContactSolver::solve() : 80.8535 % | 0.05049 ms/frame (68880 calls)
| 1 -- ContactSolver::initializeForIsland() : 9.73683 % | 0.00608029 ms/frame (4592 calls)
| Unaccounted : 4.55976 ms (9.40964 %)
---------------
| Profiling : CollisionDetection::computeCollisionDetection() (total running time : 38.8649 ms) ---
| 0 -- CollisionDetection::computeNarrowPhase() : 94.912 % | 0.0475353 ms/frame (776 calls)
| 1 -- CollisionDetection::computeBroadPhase() : 4.78311 % | 0.00239555 ms/frame (776 calls)
| Unaccounted : 0.118494 ms (0.304887 %)
---------------
| Profiling : CollisionDetection::computeNarrowPhase() (total running time : 36.8874 ms) ---
| 0 -- GJKAlgorithm::testCollision() : 73.0947 % | 0.0347458 ms/frame (12970 calls)
| Unaccounted : 9.92465 ms (26.9053 %)
---------------
| Profiling : GJKAlgorithm::testCollision() (total running time : 26.9628 ms) ---
| 0 -- GJKAlgorithm::computePenetrationDepthForEnlargedObjects() : 29.3262 % | 0.0101896 ms/frame (880 calls)
| Unaccounted : 19.0556 ms (70.6738 %)
---------------
| Profiling : GJKAlgorithm::computePenetrationDepthForEnlargedObjects() (total running time : 7.90715 ms) ---
| 0 -- EPAAlgorithm::computePenetrationDepthAndContactPoints() : 83.567 % | 0.00851517 ms/frame (877 calls)
| Unaccounted : 1.29938 ms (16.433 %)
---------------
| Profiling : RigidBody::updateBroadPhaseState() (total running time : 0.0038147 ms) ---
| 0 -- DynamicAABBTree::updateObject() : 50 % | 2.45792e-06 ms/frame (7 calls)
| 1 -- CollisionShape::computeAABB() : 0 % | 0 ms/frame (7 calls)
| Unaccounted : 0.00190735 ms (50 %)
With VSync:
---------------
| Profiling : Root (total running time : 10658.8 ms) ---
| 0 -- DynamicsWorld::update() : 3.45046 % | 0.587506 ms/frame (626 calls)
| 1 -- RigidBody::updateBroadPhaseState() : 2.90786e-05 % | 4.95118e-06 ms/frame (7 calls)
| 2 -- CollisionShape::computeAABB() : 0.000266181 % | 4.53224e-05 ms/frame (155 calls)
| Unaccounted : 10291 ms (96.5492 %)
---------------
| Profiling : DynamicsWorld::update() (total running time : 367.779 ms) ---
| 0 -- DynamicsWorld::updateSleepingBodies() : 0.249323 % | 0.00146479 ms/frame (626 calls)
| 1 -- DynamicsWorld::updateBodiesState() : 11.125 % | 0.0653602 ms/frame (626 calls)
| 2 -- DynamicsWorld::solvePositionCorrection() : 0.0227541 % | 0.000133682 ms/frame (626 calls)
| 3 -- DynamicsWorld::integrateRigidBodiesPositions() : 1.72102 % | 0.0101111 ms/frame (626 calls)
| 4 -- DynamicsWorld::solveContactsAndConstraints() : 44.0885 % | 0.259022 ms/frame (626 calls)
| 5 -- DynamicsWorld::integrateRigidBodiesVelocities() : 5.54708 % | 0.0325895 ms/frame (626 calls)
| 6 -- DynamicsWorld::computeIslands() : 1.41471 % | 0.00831152 ms/frame (626 calls)
| 7 -- CollisionDetection::computeCollisionDetection() : 34.4902 % | 0.202632 ms/frame (626 calls)
| Unaccounted : 4.93336 ms (1.34139 %)
---------------
| Profiling : DynamicsWorld::updateBodiesState() (total running time : 40.9155 ms) ---
| 0 -- RigidBody::updateBroadPhaseState() : 72.425 % | 0.0473371 ms/frame (20011 calls)
| Unaccounted : 11.2824 ms (27.575 %)
---------------
| Profiling : RigidBody::updateBroadPhaseState() (total running time : 29.633 ms) ---
| 0 -- DynamicAABBTree::updateObject() : 36.1284 % | 0.0171022 ms/frame (20011 calls)
| 1 -- CollisionShape::computeAABB() : 22.2238 % | 0.0105201 ms/frame (20011 calls)
| Unaccounted : 12.3415 ms (41.6478 %)
---------------
| Profiling : DynamicsWorld::solveContactsAndConstraints() (total running time : 162.148 ms) ---
| 0 -- ContactSolver::solve() : 80.5709 % | 0.208697 ms/frame (68880 calls)
| 1 -- ContactSolver::initializeForIsland() : 9.90343 % | 0.0256521 ms/frame (4592 calls)
| Unaccounted : 15.4457 ms (9.52569 %)
---------------
| Profiling : CollisionDetection::computeCollisionDetection() (total running time : 126.848 ms) ---
| 0 -- CollisionDetection::computeNarrowPhase() : 94.8878 % | 0.192273 ms/frame (626 calls)
| 1 -- CollisionDetection::computeBroadPhase() : 4.84082 % | 0.00980906 ms/frame (626 calls)
| Unaccounted : 0.344276 ms (0.271409 %)
---------------
| Profiling : CollisionDetection::computeNarrowPhase() (total running time : 120.363 ms) ---
| 0 -- GJKAlgorithm::testCollision() : 77.102 % | 0.148246 ms/frame (12970 calls)
| Unaccounted : 27.5607 ms (22.898 %)
---------------
| Profiling : GJKAlgorithm::testCollision() (total running time : 92.8023 ms) ---
| 0 -- GJKAlgorithm::computePenetrationDepthForEnlargedObjects() : 30.6504 % | 0.0454382 ms/frame (880 calls)
| Unaccounted : 64.358 ms (69.3496 %)
---------------
| Profiling : GJKAlgorithm::computePenetrationDepthForEnlargedObjects() (total running time : 28.4443 ms) ---
| 0 -- EPAAlgorithm::computePenetrationDepthAndContactPoints() : 83.3426 % | 0.0378693 ms/frame (877 calls)
| Unaccounted : 4.73809 ms (16.6574 %)
---------------
| Profiling : RigidBody::updateBroadPhaseState() (total running time : 0.00309944 ms) ---
| 0 -- DynamicAABBTree::updateObject() : 38.4615 % | 1.9043e-06 ms/frame (7 calls)
| 1 -- CollisionShape::computeAABB() : 30.7692 % | 1.52344e-06 ms/frame (7 calls)
| Unaccounted : 0.000953674 ms (30.7692 %)