| 387 | } |
| 388 | |
| 389 | void ClippedPolyList::triangulate() |
| 390 | { |
| 391 | PROFILE_SCOPE( ClippedPolyList_Triangulate ); |
| 392 | |
| 393 | // Copy the source lists to our temp list and clear |
| 394 | // the originals which will recieve the results. |
| 395 | mTempPolyList.set( mPolyList.address(), mPolyList.size() ); |
| 396 | mTempIndexList.set( mIndexList.address(), mIndexList.size() ); |
| 397 | mPolyList.clear(); |
| 398 | mIndexList.clear(); |
| 399 | |
| 400 | U32 j, numTriangles; |
| 401 | |
| 402 | // |
| 403 | PolyListIterator polyIter = mTempPolyList.begin(); |
| 404 | for ( ; polyIter != mTempPolyList.end(); polyIter++ ) |
| 405 | { |
| 406 | const Poly &poly = *polyIter; |
| 407 | |
| 408 | // How many triangles in this poly? |
| 409 | numTriangles = poly.vertexCount - 2; |
| 410 | |
| 411 | // Build out the triangles. |
| 412 | for ( j = 0; j < numTriangles; j++ ) |
| 413 | { |
| 414 | mPolyList.increment(); |
| 415 | |
| 416 | Poly &triangle = mPolyList.last(); |
| 417 | triangle = poly; |
| 418 | triangle.vertexCount = 3; |
| 419 | triangle.vertexStart = mIndexList.size(); |
| 420 | |
| 421 | mIndexList.push_back( mTempIndexList[ poly.vertexStart ] ); |
| 422 | mIndexList.push_back( mTempIndexList[ poly.vertexStart + 1 + j ] ); |
| 423 | mIndexList.push_back( mTempIndexList[ poly.vertexStart + 2 + j ] ); |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | void ClippedPolyList::generateNormals() |
| 429 | { |