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

Method moveComponentToIndex

src/components/FixedJointComponents.cpp:170–200  ·  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

168// Move a component from a source to a destination index in the components array
169// The destination location must contain a constructed object
170void FixedJointComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) {
171
172 const Entity entity = mJointEntities[srcIndex];
173
174 // Copy the data of the source component to the destination location
175 new (mJointEntities + destIndex) Entity(mJointEntities[srcIndex]);
176 mJoints[destIndex] = mJoints[srcIndex];
177 new (mLocalAnchorPointBody1 + destIndex) Vector3(mLocalAnchorPointBody1[srcIndex]);
178 new (mLocalAnchorPointBody2 + destIndex) Vector3(mLocalAnchorPointBody2[srcIndex]);
179 new (mR1World + destIndex) Vector3(mR1World[srcIndex]);
180 new (mR2World + destIndex) Vector3(mR2World[srcIndex]);
181 new (mI1 + destIndex) Matrix3x3(mI1[srcIndex]);
182 new (mI2 + destIndex) Matrix3x3(mI2[srcIndex]);
183 new (mImpulseTranslation + destIndex) Vector3(mImpulseTranslation[srcIndex]);
184 new (mImpulseRotation + destIndex) Vector3(mImpulseRotation[srcIndex]);
185 new (mInverseMassMatrixTranslation + destIndex) Matrix3x3(mInverseMassMatrixTranslation[srcIndex]);
186 new (mInverseMassMatrixRotation + destIndex) Matrix3x3(mInverseMassMatrixRotation[srcIndex]);
187 new (mBiasTranslation + destIndex) Vector3(mBiasTranslation[srcIndex]);
188 new (mBiasRotation + destIndex) Vector3(mBiasRotation[srcIndex]);
189 new (mInitOrientationDifferenceInv + destIndex) Quaternion(mInitOrientationDifferenceInv[srcIndex]);
190
191 // Destroy the source component
192 destroyComponent(srcIndex);
193
194 assert(!mMapEntityToComponentIndex.containsKey(entity));
195
196 // Update the entity to component index mapping
197 mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity, destIndex));
198
199 assert(mMapEntityToComponentIndex[mJointEntities[destIndex]] == destIndex);
200}
201
202// Swap two components in the array
203void FixedJointComponents::swapComponents(uint32 index1, uint32 index2) {

Callers

nothing calls this directly

Calls 2

containsKeyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected