| 142 | } |
| 143 | |
| 144 | PoolIndex PruningPool::removeObject(PrunerHandle h) |
| 145 | { |
| 146 | PX_ASSERT(mNbObjects); |
| 147 | |
| 148 | // remove the object and its AABB by provided PrunerHandle and update mHandleToIndex and mIndexToHandle mappings |
| 149 | const PoolIndex indexOfRemovedObject = mHandleToIndex[h]; // retrieve object's index from handle |
| 150 | |
| 151 | const PoolIndex indexOfLastObject = --mNbObjects; // swap the object at last index with index |
| 152 | if(indexOfLastObject!=indexOfRemovedObject) |
| 153 | { |
| 154 | // PT: move last object's data to recycled spot (from removed object) |
| 155 | |
| 156 | // PT: the last object has moved so we need to handle the mappings for this object |
| 157 | // PT: TODO: investigate where this double-mapping comes from. Should not be needed... |
| 158 | |
| 159 | // PT: these 3 arrays are "parallel" |
| 160 | const PrunerHandle handleOfLastObject = mIndexToHandle[indexOfLastObject]; |
| 161 | mWorldBoxes [indexOfRemovedObject] = mWorldBoxes [indexOfLastObject]; |
| 162 | mObjects [indexOfRemovedObject] = mObjects [indexOfLastObject]; |
| 163 | mIndexToHandle [indexOfRemovedObject] = handleOfLastObject; |
| 164 | |
| 165 | mHandleToIndex[handleOfLastObject] = indexOfRemovedObject; |
| 166 | } |
| 167 | |
| 168 | // mHandleToIndex also stores the freelist for removed handles (in place of holes formed by removed handles) |
| 169 | mHandleToIndex[h] = mFirstRecycledHandle; // update linked list of available recycled handles |
| 170 | mFirstRecycledHandle = h; // update the list head |
| 171 | |
| 172 | return indexOfLastObject; |
| 173 | } |
| 174 | |
| 175 | void PruningPool::shiftOrigin(const PxVec3& shift) |
| 176 | { |
no outgoing calls
no test coverage detected