Move a component from a source to a destination index in the components array The destination location must contain a constructed object
| 121 | // Move a component from a source to a destination index in the components array |
| 122 | // The destination location must contain a constructed object |
| 123 | void BodyComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) { |
| 124 | |
| 125 | const Entity entity = mBodiesEntities[srcIndex]; |
| 126 | |
| 127 | // Copy the data of the source component to the destination location |
| 128 | new (mBodiesEntities + destIndex) Entity(mBodiesEntities[srcIndex]); |
| 129 | mBodies[destIndex] = mBodies[srcIndex]; |
| 130 | new (mColliders + destIndex) Array<Entity>(mColliders[srcIndex]); |
| 131 | mIsActive[destIndex] = mIsActive[srcIndex]; |
| 132 | mUserData[destIndex] = mUserData[srcIndex]; |
| 133 | mHasSimulationCollider[destIndex] = mHasSimulationCollider[srcIndex]; |
| 134 | |
| 135 | // Destroy the source component |
| 136 | destroyComponent(srcIndex); |
| 137 | |
| 138 | assert(!mMapEntityToComponentIndex.containsKey(entity)); |
| 139 | |
| 140 | // Update the entity to component index mapping |
| 141 | mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity, destIndex)); |
| 142 | |
| 143 | assert(mMapEntityToComponentIndex[mBodiesEntities[destIndex]] == destIndex); |
| 144 | } |
| 145 | |
| 146 | // Swap two components in the array |
| 147 | void BodyComponents::swapComponents(uint32 index1, uint32 index2) { |
nothing calls this directly
no test coverage detected