| 1355 | } |
| 1356 | |
| 1357 | bool AABBManager::destroyAggregate(BoundsIndex& index_, Bp::FilterGroup::Enum& group_, AggregateHandle aggregateHandle) |
| 1358 | { |
| 1359 | #if PX_CHECKED |
| 1360 | if(aggregateHandle>=mAggregates.size()) |
| 1361 | { |
| 1362 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "AABBManager::destroyAggregate - aggregateId out of bounds\n"); |
| 1363 | return false; |
| 1364 | } |
| 1365 | |
| 1366 | { |
| 1367 | PxU32 firstFreeAggregate = mFirstFreeAggregate; |
| 1368 | while(firstFreeAggregate!=PX_INVALID_U32) |
| 1369 | { |
| 1370 | if(firstFreeAggregate==aggregateHandle) |
| 1371 | { |
| 1372 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "AABBManager::destroyAggregate - aggregate has already been removed\n"); |
| 1373 | return false; |
| 1374 | } |
| 1375 | firstFreeAggregate = PxU32(reinterpret_cast<size_t>(mAggregates[firstFreeAggregate])); |
| 1376 | } |
| 1377 | } |
| 1378 | #endif |
| 1379 | |
| 1380 | Aggregate* aggregate = getAggregateFromHandle(aggregateHandle); |
| 1381 | |
| 1382 | #if PX_CHECKED |
| 1383 | if(aggregate->getNbAggregated()) |
| 1384 | { |
| 1385 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "AABBManager::destroyAggregate - aggregate still has bounds that needs removed\n"); |
| 1386 | return false; |
| 1387 | } |
| 1388 | #endif |
| 1389 | |
| 1390 | const BoundsIndex index = aggregate->mIndex; |
| 1391 | removeAggregateFromDirtyArray(aggregate, mDirtyAggregates); |
| 1392 | |
| 1393 | if(mAddedHandleMap.test(index)) // PT: if object had been added this frame... |
| 1394 | mAddedHandleMap.reset(index); // PT: ...then simply revert the previous operation locally (it hasn't been passed to the BP yet). |
| 1395 | else if(aggregate->getNbAggregated()) // PT: else we need to remove it from the BP if it has been added there. If there's no aggregated |
| 1396 | mRemovedHandleMap.set(index); // PT: shapes then the aggregate has never been added, or already removed. |
| 1397 | |
| 1398 | PX_DELETE(aggregate); |
| 1399 | mAggregates[aggregateHandle] = reinterpret_cast<Aggregate*>(size_t(mFirstFreeAggregate)); |
| 1400 | mFirstFreeAggregate = aggregateHandle; |
| 1401 | |
| 1402 | // PT: TODO: shouldn't it be compared to mUsedSize? |
| 1403 | PX_ASSERT(index < mVolumeData.size()); |
| 1404 | |
| 1405 | index_ = index; |
| 1406 | group_ = mGroups[index]; |
| 1407 | |
| 1408 | #ifdef BP_USE_AGGREGATE_GROUP_TAIL |
| 1409 | releaseAggregateGroup(mGroups[index]); |
| 1410 | #endif |
| 1411 | resetEntry(index); |
| 1412 | |
| 1413 | mPersistentStateChanged = true; |
| 1414 |
no test coverage detected