| 316 | } |
| 317 | |
| 318 | void ClippedPolyList::cullUnusedVerts() |
| 319 | { |
| 320 | PROFILE_SCOPE( ClippedPolyList_CullUnusedVerts ); |
| 321 | |
| 322 | U32 i = 0; |
| 323 | U32 k, n, numDeleted; |
| 324 | bool result; |
| 325 | |
| 326 | IndexListIterator iNextIter; |
| 327 | VertexListIterator nextVIter; |
| 328 | VertexListIterator vIter; |
| 329 | |
| 330 | for ( vIter = mVertexList.begin(); vIter != mVertexList.end(); vIter++, i++ ) |
| 331 | { |
| 332 | // Is this vertex used? |
| 333 | iNextIter = T3D::find( mIndexList.begin(), mIndexList.end(), i ); |
| 334 | if ( iNextIter != mIndexList.end() ) |
| 335 | continue; |
| 336 | |
| 337 | // If not, find the next used vertex. |
| 338 | |
| 339 | // i is an unused vertex |
| 340 | // k is a used vertex |
| 341 | // delete the vertices from i to j - 1 |
| 342 | k = 0; |
| 343 | n = i + 1; |
| 344 | result = false; |
| 345 | numDeleted = 0; |
| 346 | |
| 347 | for ( nextVIter = vIter + 1; nextVIter != mVertexList.end(); nextVIter++, n++ ) |
| 348 | { |
| 349 | iNextIter = T3D::find( mIndexList.begin(), mIndexList.end(), n ); |
| 350 | |
| 351 | // If we found a used vertex |
| 352 | // grab its index for later use |
| 353 | // and set our result bool. |
| 354 | if ( (*iNextIter) == n ) |
| 355 | { |
| 356 | k = n; |
| 357 | result = true; |
| 358 | break; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | // All the remaining verts are unused. |
| 363 | if ( !result ) |
| 364 | { |
| 365 | mVertexList.setSize( i ); |
| 366 | mNormalList.setSize( i ); |
| 367 | break; |
| 368 | } |
| 369 | |
| 370 | // Erase unused verts. |
| 371 | numDeleted = (k-1) - i + 1; |
| 372 | mVertexList.erase( i, numDeleted ); |
| 373 | mNormalList.erase( i, numDeleted ); |
| 374 | |
| 375 | // Find any references to vertices after those deleted |
no test coverage detected