| 688 | Vector<DepthSortList::Poly> gWorkListJunkBin(256, __FILE__, __LINE__ ); |
| 689 | |
| 690 | void DepthSortList::depthPartition(const Point3F * sourceVerts, U32 numVerts, Vector<Poly> & partition, Vector<Point3F> & partitionVerts) |
| 691 | { |
| 692 | // create the depth partition of the passed poly |
| 693 | // a depth partition is a partition of the poly on the |
| 694 | // x-z plane so that each sub-poly in the partition can be |
| 695 | // mapped onto exactly one plane in the depth list (i.e., |
| 696 | // those polys found in mPolyIndexList... the ones that are |
| 697 | // depth sorted). The plane the sub-polys are mapped onto |
| 698 | // is the plane of the closest facing poly. |
| 699 | // |
| 700 | // y-coord of input polys are ignored, and are remapped |
| 701 | // on output to put the output polys on the |
| 702 | // corresponding planes. |
| 703 | |
| 704 | // This routine is confusing because there are three lists of polys. |
| 705 | // |
| 706 | // The source list (passed in as a single poly, but becomes a list as |
| 707 | // it is split up) comprises the poly to be partitioned. Verts for sourcePoly |
| 708 | // are held in sourceVerts when passed to this routine, but immediately copied |
| 709 | // to mVertexList (and indices are added for each vert to mIndexList). |
| 710 | // |
| 711 | // The scraps list is generated from the source poly (it contains the outside |
| 712 | // piece of each cut that is made). Indices for polys in the scraps list are |
| 713 | // found in mIndexList and verts are found in mVerts list. Note that the depthPartition |
| 714 | // routine will add verts and indices to the member lists, but not polys. |
| 715 | // |
| 716 | // Finally, the partition list is the end result -- the depth partition. These |
| 717 | // polys are not indexed polys. The vertexStart field indexes directly into partitionVerts |
| 718 | // array. |
| 719 | |
| 720 | if (mBase<0) |
| 721 | // begin the depth sort |
| 722 | sortByYExtents(); |
| 723 | |
| 724 | // apply cookie cutter to these polys |
| 725 | Vector<Poly> * sourceList = &gWorkListA; |
| 726 | sourceList->clear(); |
| 727 | |
| 728 | // add source poly for to passed verts |
| 729 | sourceList->increment(); |
| 730 | sourceList->last().vertexStart = mIndexList.size(); |
| 731 | sourceList->last().vertexCount = numVerts; |
| 732 | |
| 733 | // add verts of source poly to mVertexList and mIndexList |
| 734 | mVertexList.setSize(mVertexList.size()+numVerts); |
| 735 | mIndexList.setSize(mIndexList.size()+numVerts); |
| 736 | for (S32 v=0; v<numVerts; v++) |
| 737 | { |
| 738 | mVertexList[mVertexList.size()-numVerts+v].point = sourceVerts[v]; |
| 739 | mIndexList[mIndexList.size()-numVerts+v] = mVertexList.size()-numVerts+v; |
| 740 | } |
| 741 | |
| 742 | // put scraps from cookie cutter in this list |
| 743 | Vector<Poly> * scraps = &gWorkListB; |
| 744 | scraps->clear(); |
| 745 | |
| 746 | gWorkListJunkBin.clear(); |
| 747 | |