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

Method moveComponentToIndex

src/components/HingeJointComponents.cpp:275–325  ·  view source on GitHub ↗

Move a component from a source to a destination index in the components array The destination location must contain a constructed object

Source from the content-addressed store, hash-verified

273// Move a component from a source to a destination index in the components array
274// The destination location must contain a constructed object
275void HingeJointComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) {
276
277 const Entity entity = mJointEntities[srcIndex];
278
279 // Copy the data of the source component to the destination location
280 new (mJointEntities + destIndex) Entity(mJointEntities[srcIndex]);
281 mJoints[destIndex] = mJoints[srcIndex];
282 new (mLocalAnchorPointBody1 + destIndex) Vector3(mLocalAnchorPointBody1[srcIndex]);
283 new (mLocalAnchorPointBody2 + destIndex) Vector3(mLocalAnchorPointBody2[srcIndex]);
284 new (mR1World + destIndex) Vector3(mR1World[srcIndex]);
285 new (mR2World + destIndex) Vector3(mR2World[srcIndex]);
286 new (mI1 + destIndex) Matrix3x3(mI1[srcIndex]);
287 new (mI2 + destIndex) Matrix3x3(mI2[srcIndex]);
288 new (mImpulseTranslation + destIndex) Vector3(mImpulseTranslation[srcIndex]);
289 new (mImpulseRotation + destIndex) Vector2(mImpulseRotation[srcIndex]);
290 new (mInverseMassMatrixTranslation + destIndex) Matrix3x3(mInverseMassMatrixTranslation[srcIndex]);
291 new (mInverseMassMatrixRotation + destIndex) Matrix2x2(mInverseMassMatrixRotation[srcIndex]);
292 new (mBiasTranslation + destIndex) Vector3(mBiasTranslation[srcIndex]);
293 new (mBiasRotation + destIndex) Vector2(mBiasRotation[srcIndex]);
294 new (mInitOrientationDifferenceInv + destIndex) Quaternion(mInitOrientationDifferenceInv[srcIndex]);
295 new (mHingeLocalAxisBody1 + destIndex) Vector3(mHingeLocalAxisBody1[srcIndex]);
296 new (mHingeLocalAxisBody2 + destIndex) Vector3(mHingeLocalAxisBody2[srcIndex]);
297 new (mA1 + destIndex) Vector3(mA1[srcIndex]);
298 new (mB2CrossA1 + destIndex) Vector3(mB2CrossA1[srcIndex]);
299 new (mC2CrossA1 + destIndex) Vector3(mC2CrossA1[srcIndex]);
300 mImpulseLowerLimit[destIndex] = mImpulseLowerLimit[srcIndex];
301 mImpulseUpperLimit[destIndex] = mImpulseUpperLimit[srcIndex];
302 mImpulseMotor[destIndex] = mImpulseMotor[srcIndex];
303 mInverseMassMatrixLimitMotor[destIndex] = mInverseMassMatrixLimitMotor[srcIndex];
304 mInverseMassMatrixMotor[destIndex] = mInverseMassMatrixMotor[srcIndex];
305 mBLowerLimit[destIndex] = mBLowerLimit[srcIndex];
306 mBUpperLimit[destIndex] = mBUpperLimit[srcIndex];
307 mIsLimitEnabled[destIndex] = mIsLimitEnabled[srcIndex];
308 mIsMotorEnabled[destIndex] = mIsMotorEnabled[srcIndex];
309 mLowerLimit[destIndex] = mLowerLimit[srcIndex];
310 mUpperLimit[destIndex] = mUpperLimit[srcIndex];
311 mIsLowerLimitViolated[destIndex] = mIsLowerLimitViolated[srcIndex];
312 mIsUpperLimitViolated[destIndex] = mIsUpperLimitViolated[srcIndex];
313 mMotorSpeed[destIndex] = mMotorSpeed[srcIndex];
314 mMaxMotorTorque[destIndex] = mMaxMotorTorque[srcIndex];
315
316 // Destroy the source component
317 destroyComponent(srcIndex);
318
319 assert(!mMapEntityToComponentIndex.containsKey(entity));
320
321 // Update the entity to component index mapping
322 mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity, destIndex));
323
324 assert(mMapEntityToComponentIndex[mJointEntities[destIndex]] == destIndex);
325}
326
327// Swap two components in the array
328void HingeJointComponents::swapComponents(uint32 index1, uint32 index2) {

Callers

nothing calls this directly

Calls 2

containsKeyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected