MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / integrateRigidBodiesPositions

Method integrateRigidBodiesPositions

src/systems/DynamicsSystem.cpp:44–71  ·  view source on GitHub ↗

Integrate position and orientation of the rigid bodies. The positions and orientations of the bodies are integrated using the sympletic Euler time stepping scheme.

Source from the content-addressed store, hash-verified

42/// The positions and orientations of the bodies are integrated using
43/// the sympletic Euler time stepping scheme.
44void DynamicsSystem::integrateRigidBodiesPositions(decimal timeStep, bool isSplitImpulseActive) {
45
46 RP3D_PROFILE("DynamicsSystem::integrateRigidBodiesPositions()", mProfiler);
47
48 const decimal isSplitImpulseFactor = isSplitImpulseActive ? decimal(1.0) : decimal(0.0);
49
50 const uint32 nbRigidBodyComponents = mRigidBodyComponents.getNbEnabledComponents();
51 for (uint32 i=0; i < nbRigidBodyComponents; i++) {
52
53 // Get the constrained velocity
54 Vector3 newLinVelocity = mRigidBodyComponents.mConstrainedLinearVelocities[i];
55 Vector3 newAngVelocity = mRigidBodyComponents.mConstrainedAngularVelocities[i];
56
57 // Add the split impulse velocity from Contact Solver (only used
58 // to update the position)
59 newLinVelocity += isSplitImpulseFactor * mRigidBodyComponents.mSplitLinearVelocities[i];
60 newAngVelocity += isSplitImpulseFactor * mRigidBodyComponents.mSplitAngularVelocities[i];
61
62 // Get current position and orientation of the body
63 const Vector3& currentPosition = mRigidBodyComponents.mCentersOfMassWorld[i];
64 const Quaternion& currentOrientation = mTransformComponents.getTransform(mRigidBodyComponents.mBodiesEntities[i]).getOrientation();
65
66 // Update the new constrained position and orientation of the body
67 mRigidBodyComponents.mConstrainedPositions[i] = currentPosition + newLinVelocity * timeStep;
68 mRigidBodyComponents.mConstrainedOrientations[i] = currentOrientation + Quaternion(0, newAngVelocity) *
69 currentOrientation * decimal(0.5) * timeStep;
70 }
71}
72
73// Update the postion/orientation of the bodies
74void DynamicsSystem::updateBodiesState() {

Callers 1

updateMethod · 0.80

Calls 2

QuaternionClass · 0.85

Tested by

no test coverage detected