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 ColliderComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) { |
| 171 | |
| 172 | const Entity colliderEntity = mCollidersEntities[srcIndex]; |
| 173 | |
| 174 | // Copy the data of the source component to the destination location |
| 175 | new (mCollidersEntities + destIndex) Entity(mCollidersEntities[srcIndex]); |
| 176 | new (mBodiesEntities + destIndex) Entity(mBodiesEntities[srcIndex]); |
| 177 | mColliders[destIndex] = mColliders[srcIndex]; |
| 178 | new (mBroadPhaseIds + destIndex) int32(mBroadPhaseIds[srcIndex]); |
| 179 | new (mLocalToBodyTransforms + destIndex) Transform(mLocalToBodyTransforms[srcIndex]); |
| 180 | mCollisionShapes[destIndex] = mCollisionShapes[srcIndex]; |
| 181 | new (mCollisionCategoryBits + destIndex) unsigned short(mCollisionCategoryBits[srcIndex]); |
| 182 | new (mCollideWithMaskBits + destIndex) unsigned short(mCollideWithMaskBits[srcIndex]); |
| 183 | new (mLocalToWorldTransforms + destIndex) Transform(mLocalToWorldTransforms[srcIndex]); |
| 184 | new (mOverlappingPairs + destIndex) Array<uint64>(mOverlappingPairs[srcIndex]); |
| 185 | mHasCollisionShapeChangedSize[destIndex] = mHasCollisionShapeChangedSize[srcIndex]; |
| 186 | mIsTrigger[destIndex] = mIsTrigger[srcIndex]; |
| 187 | mIsSimulationCollider[destIndex] = mIsSimulationCollider[srcIndex]; |
| 188 | mIsWorldQueryCollider[destIndex] = mIsWorldQueryCollider[srcIndex]; |
| 189 | mMaterials[destIndex] = mMaterials[srcIndex]; |
| 190 | |
| 191 | // Destroy the source component |
| 192 | destroyComponent(srcIndex); |
| 193 | |
| 194 | assert(!mMapEntityToComponentIndex.containsKey(colliderEntity)); |
| 195 | |
| 196 | // Update the entity to component index mapping |
| 197 | mMapEntityToComponentIndex.add(Pair<Entity, uint32>(colliderEntity, destIndex)); |
| 198 | |
| 199 | assert(mMapEntityToComponentIndex[mCollidersEntities[destIndex]] == destIndex); |
| 200 | } |
| 201 | |
| 202 | // Swap two components in the array |
| 203 | void ColliderComponents::swapComponents(uint32 index1, uint32 index2) { |
nothing calls this directly
no test coverage detected