| 202 | } |
| 203 | |
| 204 | void AABBPruner::removeObjects(const PrunerHandle* handles, PxU32 count) |
| 205 | { |
| 206 | PX_PROFILE_ZONE("SceneQuery.prunerRemoveObjects", mContextID); |
| 207 | |
| 208 | if(!count) |
| 209 | return; |
| 210 | |
| 211 | mUncommittedChanges = true; |
| 212 | |
| 213 | for(PxU32 i=0; i<count; i++) |
| 214 | { |
| 215 | const PrunerHandle h = handles[i]; |
| 216 | // copy the payload before removing it since we need to know the payload to remove it from the bucket pruner |
| 217 | const PrunerPayload removedPayload = mPool.getPayload(h); |
| 218 | const PoolIndex poolIndex = mPool.getIndex(h); // save the pool index for removed object |
| 219 | const PoolIndex poolRelocatedLastIndex = mPool.removeObject(h); // save the lastIndex returned by removeObject |
| 220 | if(mIncrementalRebuild && mAABBTree) |
| 221 | { |
| 222 | mNeedsNewTree = true; |
| 223 | |
| 224 | const TreeNodeIndex treeNodeIndex = mTreeMap[poolIndex]; // already removed from pool but still in tree map |
| 225 | const PrunerPayload swappedPayload = mPool.getObjects()[poolIndex]; |
| 226 | if(treeNodeIndex!=INVALID_NODE_ID) // can be invalid if removed |
| 227 | { |
| 228 | mAABBTree->markNodeForRefit(treeNodeIndex); // mark the spot as blank |
| 229 | mBucketPruner.swapIndex(poolIndex, swappedPayload, poolRelocatedLastIndex); // if swapped index is in bucket pruner |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | PX_ASSERT(treeNodeIndex==INVALID_PRUNERHANDLE); |
| 234 | PxU32 timeStamp; |
| 235 | bool status = mBucketPruner.removeObject(removedPayload, poolIndex, swappedPayload, poolRelocatedLastIndex, timeStamp); |
| 236 | PX_ASSERT(status); |
| 237 | PX_UNUSED(status); |
| 238 | } |
| 239 | |
| 240 | mTreeMap.invalidate(poolIndex, poolRelocatedLastIndex, *mAABBTree); |
| 241 | if(mNewTree) |
| 242 | mNewTreeFixups.pushBack(NewTreeFixup(poolIndex, poolRelocatedLastIndex)); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | if (mPool.getNbActiveObjects()==0) |
| 247 | { |
| 248 | // this is just to make sure we release all the internal data once all the objects are out of the pruner |
| 249 | // since this is the only place we know that and we don't want to keep memory reserved |
| 250 | release(); |
| 251 | |
| 252 | // Pruner API requires a commit before the next query, even if we ended up removing the entire tree here. This |
| 253 | // forces that to happen. |
| 254 | mUncommittedChanges = true; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 259 | /** |
no test coverage detected