void TriangleBatch::Stripify( TriangleBatch& pNewBatch ) { #if GD_PLATFORM == GD_PLATFORM_WIN32 GD_ASSERT( mIndices ); PrimitiveGroup* strip; UInt16 numGroups; SetCacheSize(CACHESIZE_GEFORCE1_2); SetStitchStrips(true); SetMinStripSize(0); SetListsOnly(false); // Stripify! GenerateStrips( mIndices, mIndicesCount, &strip, &numGroups ); GD_ASSERT( numGroups == 1 ); // Copy the result in our triangle batch. pNewBatch.Allocate( TriangleStrip, strip->numIndices ); memcpy( pNewBatch.GetIndices(), strip->indices, strip->numIndices*sizeof(UInt16) ); //GD_DELETE_ARRAY(strip); #else debugBreak(); #endif }
void nvStripWrap(std::vector<Primitive> & faces, std::vector<U16> & indices, S32 cacheSize) { // set stripper parameters...we'll just set some default ones SetCacheSize(cacheSize); SetStitchStrips(true); // engine can handle this, so let it SetListsOnly(false); // engine can handle this, so let it SetMinStripSize(0); // engine can handle this, so let it // main strip loop... U32 start, end, i; std::vector<Primitive> someStrips; std::vector<Primitive> retStrips; std::vector<U16> someIndices; std::vector<U16> retIndices; for (start = 0; start<faces.size(); start=end) { for (end=start; end<faces.size() && faces[start].type==faces[end].type; end++) ; // copy start to end faces into new list -- this is so we end up doing less copying // down the road (when we are doing the look ahead simulation) someStrips.clear(); someIndices.clear(); for (i=start;i<end;i++) { someIndices.push_back(indices[faces[i].firstElement + 0]); someIndices.push_back(indices[faces[i].firstElement + 1]); someIndices.push_back(indices[faces[i].firstElement + 2]); } U32 matIndex = faces[start].type ^ (Primitive::Triangles|Primitive::Strip); nvMakeStrips(someStrips,someIndices,cacheSize,matIndex); // now move strips and indices into larger list S32 startStrips = retStrips.size(); retStrips.resize(startStrips+someStrips.size()); S32 startIndices = retIndices.size(); retIndices.resize(startIndices+someIndices.size()); memcpy(&retStrips[startStrips],&someStrips[0],someStrips.size()*sizeof(Primitive)); memcpy(&retIndices[startIndices],&someIndices[0],someIndices.size()*sizeof(U16)); // now adjust start of new strips for (i=startStrips; i<retStrips.size(); i++) retStrips[i].firstElement += startIndices; } indices = retIndices; faces = retStrips; }
void xrStripify (xr_vector<u16> &indices, xr_vector<u16> &perturb, int iCacheSize, int iMinStripLength) { SetCacheSize (iCacheSize); SetMinStripSize (iMinStripLength); SetListsOnly (true); // Generate strips xr_vector<PrimitiveGroup> PGROUP; GenerateStrips (&*indices.begin(),(u32)indices.size(),PGROUP); R_ASSERT (PGROUP.size()==1); R_ASSERT (PGROUP[0].type==PT_LIST); if (indices.size()!=PGROUP[0].numIndices) throw "Stripify failed."; // Remap indices xr_vector<PrimitiveGroup> xPGROUP; RemapIndices (PGROUP,u16(perturb.size()),xPGROUP); R_ASSERT (xPGROUP.size()==1); R_ASSERT (xPGROUP[0].type==PT_LIST); // Build perturberation table for(u32 index = 0; index < PGROUP[0].numIndices; index++) { u16 oldIndex = PGROUP[0].indices [index]; int newIndex = xPGROUP[0].indices [index]; R_ASSERT(oldIndex<(int)perturb.size()); R_ASSERT(newIndex<(int)perturb.size()); perturb[newIndex] = oldIndex; } // Copy indices Memory.mem_copy (&*indices.begin(),xPGROUP[0].indices,(u32)indices.size()*sizeof(u16)); // Release memory xPGROUP.clear (); PGROUP.clear (); }