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

Method moveComponentToIndex

src/components/JointComponents.cpp:132–155  ·  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

130// Move a component from a source to a destination index in the components array
131// The destination location must contain a constructed object
132void 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
158void JointComponents::swapComponents(uint32 index1, uint32 index2) {

Callers

nothing calls this directly

Calls 2

containsKeyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected