Remove a collider from the body To remove a collider, you need to specify its pointer * @param collider The pointer of the collider you want to remove */
| 164 | * @param collider The pointer of the collider you want to remove |
| 165 | */ |
| 166 | void Body::removeCollider(Collider* collider) { |
| 167 | |
| 168 | RP3D_LOG(mWorld.mConfig.worldName, Logger::Level::Information, Logger::Category::Body, |
| 169 | "Body " + std::to_string(mEntity.id) + ": Collider " + std::to_string(collider->getBroadPhaseId()) + " removed from body", __FILE__, __LINE__); |
| 170 | |
| 171 | // Remove the collider from the broad-phase |
| 172 | if (collider->getBroadPhaseId() != -1) { |
| 173 | mWorld.mCollisionDetection.removeCollider(collider); |
| 174 | } |
| 175 | |
| 176 | mWorld.mBodyComponents.removeColliderFromBody(mEntity, collider->getEntity()); |
| 177 | |
| 178 | // Unassign the collider from the collision shape |
| 179 | collider->getCollisionShape()->removeCollider(collider); |
| 180 | |
| 181 | // Remove the collider component |
| 182 | mWorld.mCollidersComponents.removeComponent(collider->getEntity()); |
| 183 | |
| 184 | // Destroy the entity |
| 185 | mWorld.mEntityManager.destroyEntity(collider->getEntity()); |
| 186 | |
| 187 | // Call the constructor of the collider |
| 188 | collider->~Collider(); |
| 189 | |
| 190 | // Update whether the body still has a simulation collider |
| 191 | if (mWorld.mBodyComponents.getHasSimulationCollider(mEntity)) { |
| 192 | updateHasSimulationCollider(); |
| 193 | } |
| 194 | |
| 195 | // Release allocated memory for the collider |
| 196 | mWorld.mMemoryManager.release(MemoryManager::AllocationType::Pool, collider, sizeof(Collider)); |
| 197 | } |
| 198 | |
| 199 | // Remove all the colliders |
| 200 | void Body::removeAllColliders() { |
no test coverage detected