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

Method setIsEntityDisabled

src/components/Components.cpp:159–194  ·  view source on GitHub ↗

Notify if a given entity is disabled (sleeping) or not

Source from the content-addressed store, hash-verified

157
158// Notify if a given entity is disabled (sleeping) or not
159void Components::setIsEntityDisabled(Entity entity, bool isDisabled) {
160
161 const uint32 index = mMapEntityToComponentIndex[entity];
162
163 // If the component was disabled and is not disabled anymore
164 if (!isDisabled && index >= mDisabledStartIndex) {
165
166 assert(mDisabledStartIndex < mNbComponents);
167
168 // If the disabled component is not the first disabled component
169 if (mDisabledStartIndex != index) {
170
171 // Swap the first disabled component with the one we need to enable it
172 swapComponents(index, mDisabledStartIndex);
173 }
174
175 mDisabledStartIndex++;
176 }
177 // If the component was enabled and must now be disabled
178 else if (isDisabled && index < mDisabledStartIndex) {
179
180 assert(mDisabledStartIndex > 0);
181
182 // If the enabled component is not the only enabled component
183 if (index != mDisabledStartIndex - 1) {
184
185 // Swap the last enabled component with the one we need to disable
186 swapComponents(index, mDisabledStartIndex - 1);
187 }
188
189 mDisabledStartIndex--;
190 }
191
192 assert(mDisabledStartIndex <= mNbComponents);
193 assert(mNbComponents == static_cast<uint32>(mMapEntityToComponentIndex.size()));
194}

Callers 2

setBodyDisabledMethod · 0.80
setJointDisabledMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected