Move a component from a source to a destination index in the components array The destination location must contain a constructed object
| 130 | // Move a component from a source to a destination index in the components array |
| 131 | // The destination location must contain a constructed object |
| 132 | void JointComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) { |
| 133 | |
| 134 | const Entity entity = mJointEntities[srcIndex]; |
| 135 | |
| 136 | // Copy the data of the source component to the destination location |
| 137 | new (mJointEntities + destIndex) Entity(mJointEntities[srcIndex]); |
| 138 | new (mBody1Entities + destIndex) Entity(mBody1Entities[srcIndex]); |
| 139 | new (mBody2Entities + destIndex) Entity(mBody2Entities[srcIndex]); |
| 140 | mJoints[destIndex] = mJoints[srcIndex]; |
| 141 | new (mTypes + destIndex) JointType(mTypes[srcIndex]); |
| 142 | new (mPositionCorrectionTechniques + destIndex) JointsPositionCorrectionTechnique(mPositionCorrectionTechniques[srcIndex]); |
| 143 | mIsCollisionEnabled[destIndex] = mIsCollisionEnabled[srcIndex]; |
| 144 | mIsAlreadyInIsland[destIndex] = mIsAlreadyInIsland[srcIndex]; |
| 145 | |
| 146 | // Destroy the source component |
| 147 | destroyComponent(srcIndex); |
| 148 | |
| 149 | assert(!mMapEntityToComponentIndex.containsKey(entity)); |
| 150 | |
| 151 | // Update the entity to component index mapping |
| 152 | mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity, destIndex)); |
| 153 | |
| 154 | assert(mMapEntityToComponentIndex[mJointEntities[destIndex]] == destIndex); |
| 155 | } |
| 156 | |
| 157 | // Swap two components in the array |
| 158 | void JointComponents::swapComponents(uint32 index1, uint32 index2) { |
nothing calls this directly
no test coverage detected