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

Method addComponent

src/components/TransformComponents.cpp:83–99  ·  view source on GitHub ↗

Add a component

Source from the content-addressed store, hash-verified

81
82// Add a component
83void TransformComponents::addComponent(Entity bodyEntity, bool isDisabled, const TransformComponent& component) {
84
85 // Prepare to add new component (allocate memory if necessary and compute insertion index)
86 uint32 index = prepareAddComponent(isDisabled);
87
88 // Insert the new component data
89 new (mBodies + index) Entity(bodyEntity);
90 new (mTransforms + index) Transform(component.transform);
91
92 // Map the entity with the new component lookup index
93 mMapEntityToComponentIndex.add(Pair<Entity, uint32>(bodyEntity, index));
94
95 mNbComponents++;
96
97 assert(mDisabledStartIndex <= mNbComponents);
98 assert(mNbComponents == static_cast<uint32>(mMapEntityToComponentIndex.size()));
99}
100
101// Move a component from a source to a destination index in the components array
102// The destination location must contain a constructed object

Callers

nothing calls this directly

Calls 2

addMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected