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

Method moveComponentToIndex

src/components/TransformComponents.cpp:103–120  ·  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

101// Move a component from a source to a destination index in the components array
102// The destination location must contain a constructed object
103void TransformComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) {
104
105 const Entity entity = mBodies[srcIndex];
106
107 // Copy the data of the source component to the destination location
108 new (mBodies + destIndex) Entity(mBodies[srcIndex]);
109 new (mTransforms + destIndex) Transform(mTransforms[srcIndex]);
110
111 // Destroy the source component
112 destroyComponent(srcIndex);
113
114 assert(!mMapEntityToComponentIndex.containsKey(entity));
115
116 // Update the entity to component index mapping
117 mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity, destIndex));
118
119 assert(mMapEntityToComponentIndex[mBodies[destIndex]] == destIndex);
120}
121
122// Swap two components in the array
123void TransformComponents::swapComponents(uint32 index1, uint32 index2) {

Callers

nothing calls this directly

Calls 2

containsKeyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected