Update the physics simulation * @param timeStep The amount of time to step the simulation by (in seconds) */
| 237 | * @param timeStep The amount of time to step the simulation by (in seconds) |
| 238 | */ |
| 239 | void PhysicsWorld::update(decimal timeStep) { |
| 240 | |
| 241 | #ifdef IS_RP3D_PROFILING_ENABLED |
| 242 | |
| 243 | // Increment the frame counter of the profiler |
| 244 | mProfiler->incrementFrameCounter(); |
| 245 | #endif |
| 246 | |
| 247 | RP3D_PROFILE("PhysicsWorld::update()", mProfiler); |
| 248 | |
| 249 | // Reset the debug renderer |
| 250 | if (mIsDebugRenderingEnabled) { |
| 251 | mDebugRenderer.reset(); |
| 252 | } |
| 253 | |
| 254 | // Compute the collision detection |
| 255 | mCollisionDetection.computeCollisionDetection(); |
| 256 | |
| 257 | // Create the islands |
| 258 | createIslands(); |
| 259 | |
| 260 | // Create the actual narrow-phase contacts |
| 261 | mCollisionDetection.createContacts(); |
| 262 | |
| 263 | // Report the contacts to the user |
| 264 | mCollisionDetection.reportContactsAndTriggers(); |
| 265 | |
| 266 | // Recompute the inverse inertia tensors of rigid bodies |
| 267 | updateBodiesInverseWorldInertiaTensors(); |
| 268 | |
| 269 | // Enable or disable the joints |
| 270 | enableDisableJoints(); |
| 271 | |
| 272 | // Integrate the velocities |
| 273 | mDynamicsSystem.integrateRigidBodiesVelocities(timeStep); |
| 274 | |
| 275 | // Solve the contacts and constraints |
| 276 | solveContactsAndConstraints(timeStep); |
| 277 | |
| 278 | // Integrate the position and orientation of each body |
| 279 | mDynamicsSystem.integrateRigidBodiesPositions(timeStep, mContactSolverSystem.isSplitImpulseActive()); |
| 280 | |
| 281 | // Solve the position correction for constraints |
| 282 | solvePositionCorrection(); |
| 283 | |
| 284 | // Update the state (positions and velocities) of the bodies |
| 285 | mDynamicsSystem.updateBodiesState(); |
| 286 | |
| 287 | // Update the colliders components |
| 288 | mCollisionDetection.updateColliders(); |
| 289 | |
| 290 | if (mIsSleepingEnabled) updateSleepingBodies(timeStep); |
| 291 | |
| 292 | // Reset the external force and torque applied to the bodies |
| 293 | mDynamicsSystem.resetBodiesForceAndTorque(); |
| 294 | |
| 295 | // Reset the islands |
| 296 | mIslands.clear(); |
nothing calls this directly
no test coverage detected