Update the broad-phase state of some colliders components
| 157 | |
| 158 | // Update the broad-phase state of some colliders components |
| 159 | void BroadPhaseSystem::updateCollidersComponents(uint32 startIndex, uint32 nbItems) { |
| 160 | |
| 161 | RP3D_PROFILE("BroadPhaseSystem::updateCollidersComponents()", mProfiler); |
| 162 | |
| 163 | assert(nbItems > 0); |
| 164 | assert(startIndex < mCollidersComponents.getNbComponents()); |
| 165 | assert(startIndex + nbItems <= mCollidersComponents.getNbComponents()); |
| 166 | |
| 167 | // For each collider component to update |
| 168 | for (uint32 i = startIndex; i < startIndex + nbItems; i++) { |
| 169 | |
| 170 | const int32 broadPhaseId = mCollidersComponents.mBroadPhaseIds[i]; |
| 171 | if (broadPhaseId != -1) { |
| 172 | |
| 173 | const Entity& bodyEntity = mCollidersComponents.mBodiesEntities[i]; |
| 174 | const Transform& transform = mTransformsComponents.getTransform(bodyEntity); |
| 175 | |
| 176 | // Recompute the world-space AABB of the collision shape |
| 177 | const AABB aabb = mCollidersComponents.mCollisionShapes[i]->computeTransformedAABB(transform * mCollidersComponents.mLocalToBodyTransforms[i]); |
| 178 | |
| 179 | // If the size of the collision shape has been changed by the user, |
| 180 | // we need to reset the broad-phase AABB to its new size |
| 181 | const bool forceReInsert = mCollidersComponents.mHasCollisionShapeChangedSize[i]; |
| 182 | |
| 183 | // Update the broad-phase state of the collider |
| 184 | updateColliderInternal(broadPhaseId, mCollidersComponents.mColliders[i], aabb, forceReInsert); |
| 185 | |
| 186 | mCollidersComponents.mHasCollisionShapeChangedSize[i] = false; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | |
| 192 | // Add a collider in the array of colliders that have moved in the last simulation step |
nothing calls this directly
no test coverage detected