| 1333 | |
| 1334 | PX_COMPILE_TIME_ASSERT(sizeof(BpHandle)==sizeof(float)); |
| 1335 | void BoxManager::prepareData(RadixSortBuffered& /*rs*/, ABP_Object* PX_RESTRICT objects, PxU32 objectsCapacity, ABP_MM& memoryManager) |
| 1336 | { |
| 1337 | PX_UNUSED(objectsCapacity); |
| 1338 | |
| 1339 | // PT: mNbUpdated = number of objects in the updated buffer, could have been updated this frame or previous frame |
| 1340 | const PxU32 size = mNbUpdated; |
| 1341 | if(!size) |
| 1342 | { |
| 1343 | if(mNbRemovedSleeping) |
| 1344 | { |
| 1345 | // PT: benchmark for this codepath: MBP.RemoveHalfSleeping |
| 1346 | purgeRemovedFromSleeping(objects, objectsCapacity); |
| 1347 | } |
| 1348 | return; |
| 1349 | } |
| 1350 | |
| 1351 | PX_ASSERT(mAABBManagerBounds); |
| 1352 | PX_ASSERT(mAABBManagerDistances); |
| 1353 | PX_ASSERT(mInToOut_Updated); |
| 1354 | |
| 1355 | // Prepare new/updated objects |
| 1356 | const ABP_Index* PX_RESTRICT remap = mInToOut_Updated; |
| 1357 | const PxBounds3* PX_RESTRICT bounds = mAABBManagerBounds; |
| 1358 | const float* PX_RESTRICT distances = mAABBManagerDistances; |
| 1359 | |
| 1360 | float* PX_RESTRICT keys = NULL; |
| 1361 | |
| 1362 | // newOrUpdatedIDs: *userIDs* of objects that have been added or updated this frame. |
| 1363 | // sleepingIndices: *indices* (not userIDs) of non-updated objects within mInToOut_Updated |
| 1364 | PxU32* tempBuffer = NULL; |
| 1365 | PxU32* newOrUpdatedIDs = tempBuffer; |
| 1366 | PxU32* sleepingIndices = tempBuffer; |
| 1367 | |
| 1368 | // PT: mNbUpdated / mInToOut_Updated contains: |
| 1369 | // 1) objects added this frame (from addObject(s)) |
| 1370 | // 2) objects updated this frame (from updateObject(s)) |
| 1371 | // 3) objects updated the frame before, not updated this frame, i.e. they are now "sleeping" |
| 1372 | // 4) objects updated the frame before, then removed (from removeObject(s)) |
| 1373 | // |
| 1374 | // We split the current array into separate groups: |
| 1375 | // - 1) & 2) go to "temp", count is "nbUpdated" |
| 1376 | // - 3) go to "temp2", count is "nbSleeping" |
| 1377 | // - 4) are filtered out. No special processing is needed because the updated data is always parsed/recreated here anyway. |
| 1378 | // So if we don't actively add removed objects to the new buffers, they get removed as a side-effect. |
| 1379 | |
| 1380 | PxU32 nbUpdated = 0; // PT: number of objects updated this frame |
| 1381 | PxU32 nbSleeping = 0; |
| 1382 | PxU32 nbRemoved = 0; // PT: number of removed objects that were previously located in the udpated array |
| 1383 | |
| 1384 | // PT: TODO: could we do the work within mInToOut_Updated? |
| 1385 | // - updated objects have invalidated bounds so we don't need to preserve their order |
| 1386 | // - we need to preserve the order of sleeping objects to avoid re-sorting them |
| 1387 | // - we cannot use MTF since it breaks the order |
| 1388 | // - parse backward and move sleeping objects to the back? but then we might have to move the sleeping boxes at the same time |
| 1389 | |
| 1390 | for(PxU32 i=0;i<size;i++) |
| 1391 | { |
| 1392 | PX_ASSERT(i<mMaxNbUpdated); |
no test coverage detected