Move a component from a source to a destination index in the components array The destination location must contain a constructed object
| 168 | // Move a component from a source to a destination index in the components array |
| 169 | // The destination location must contain a constructed object |
| 170 | void FixedJointComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) { |
| 171 | |
| 172 | const Entity entity = mJointEntities[srcIndex]; |
| 173 | |
| 174 | // Copy the data of the source component to the destination location |
| 175 | new (mJointEntities + destIndex) Entity(mJointEntities[srcIndex]); |
| 176 | mJoints[destIndex] = mJoints[srcIndex]; |
| 177 | new (mLocalAnchorPointBody1 + destIndex) Vector3(mLocalAnchorPointBody1[srcIndex]); |
| 178 | new (mLocalAnchorPointBody2 + destIndex) Vector3(mLocalAnchorPointBody2[srcIndex]); |
| 179 | new (mR1World + destIndex) Vector3(mR1World[srcIndex]); |
| 180 | new (mR2World + destIndex) Vector3(mR2World[srcIndex]); |
| 181 | new (mI1 + destIndex) Matrix3x3(mI1[srcIndex]); |
| 182 | new (mI2 + destIndex) Matrix3x3(mI2[srcIndex]); |
| 183 | new (mImpulseTranslation + destIndex) Vector3(mImpulseTranslation[srcIndex]); |
| 184 | new (mImpulseRotation + destIndex) Vector3(mImpulseRotation[srcIndex]); |
| 185 | new (mInverseMassMatrixTranslation + destIndex) Matrix3x3(mInverseMassMatrixTranslation[srcIndex]); |
| 186 | new (mInverseMassMatrixRotation + destIndex) Matrix3x3(mInverseMassMatrixRotation[srcIndex]); |
| 187 | new (mBiasTranslation + destIndex) Vector3(mBiasTranslation[srcIndex]); |
| 188 | new (mBiasRotation + destIndex) Vector3(mBiasRotation[srcIndex]); |
| 189 | new (mInitOrientationDifferenceInv + destIndex) Quaternion(mInitOrientationDifferenceInv[srcIndex]); |
| 190 | |
| 191 | // Destroy the source component |
| 192 | destroyComponent(srcIndex); |
| 193 | |
| 194 | assert(!mMapEntityToComponentIndex.containsKey(entity)); |
| 195 | |
| 196 | // Update the entity to component index mapping |
| 197 | mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity, destIndex)); |
| 198 | |
| 199 | assert(mMapEntityToComponentIndex[mJointEntities[destIndex]] == destIndex); |
| 200 | } |
| 201 | |
| 202 | // Swap two components in the array |
| 203 | void FixedJointComponents::swapComponents(uint32 index1, uint32 index2) { |
nothing calls this directly
no test coverage detected