Ignore:
Timestamp:
10/02/06 19:09:48 (18 years ago)
Author:
gumbau
Message:

Fixed degenerates in LodStripsFixed?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r1541 r1552  
    281281        } 
    282282 
     283/*      // debug! 
     284        FILE *f = fopen("lodstrips_lodinfo.txt","wt"); 
     285        fprintf(f,"mCurrentLOD: %d",mCurrentLod); 
     286        fprintf(f,"mLods: %d",mLods); 
     287        for (int i=0; i<mTotalStrips; i++) 
     288        { 
     289                fprintf(f,"\nstrip: %d - ",i); 
     290                for (int j=0; j<mStrips[i].size(); j++) 
     291                { 
     292                        int ind = mStrips[i][j]; 
     293                        fprintf(f,"%d ",ind); 
     294                } 
     295        } 
     296        fclose(f);*/ 
     297 
    283298        UpdateDataRetrievalInterface(); 
    284299//      return  return_value; 
     
    456471                mStripsChanges[i]       =       0; 
    457472        } 
     473 
    458474//      dataRetrievalInterface->End(); 
    459475 
     
    525541                        indexBegin      =       geoSubMesh->mStrip[strip]; 
    526542 
    527                         //      If the strips is not the first. 
    528                          
    529 /*                      if (strip != 0) 
    530                         { 
     543                        //      If the strips is not the first. (DEG!) 
     544                        if (strip != 0) 
    531545                                indexBegin++; 
    532                         } 
    533 */                       
    534546 
    535547                        //      If is the final strip 
     
    544556                                indexEnd        = geoSubMesh->mStrip[strip + 1]; 
    545557 
    546                                 //      Remove degenerated 
    547 //                              indexEnd--; 
     558                                //      Remove degenerated (DEG!) 
     559                                indexEnd--; 
    548560                        } 
    549561                         
     
    656668void LodStripsLibrary::UpdateDataRetrievalInterface(void) 
    657669{ 
    658         unsigned        int     ii      =       0; 
    659          
    660         int     counter = 0; 
    661670        int     target_submesh  = 0; 
    662671        size_t  strip_count     = 0; 
    663         unsigned int ii_submesh = 0; 
    664  
    665         dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh]); 
    666  
    667 //      dataRetrievalInterface->SetCurrentSubmesh(target_submesh); 
    668  
    669         for (unsigned   int     i       =       0;      i < mTotalStrips;       i++,    strip_count++) 
     672        unsigned int ii_submesh = 0;     
     673        current_triangle_count = 0; 
     674 
     675        // indices_x_submesh is calculated without degenerates,  
     676        // we must add the degenerate indices added here 
     677        uint32 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 
     678 
     679        dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh] + numdeg); 
     680        current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 
     681 
     682        for (unsigned int i = 0; i < mTotalStrips; i++, strip_count++) 
    670683        { 
    671684                if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
    672685                { 
    673 //                      indices_x_submesh[target_submesh] = counter; 
    674  
    675686                        if (target_submesh==0) 
    676687                                offsets_x_submesh[target_submesh] = 0; 
     
    678689                                offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 
    679690 
    680                         counter =       0; 
    681691                        mStripsSubmesh[target_submesh]  =       (int)strip_count; 
    682692                        strip_count     =       0; 
     
    684694                        target_submesh++; 
    685695                        ii_submesh = 0; 
    686 //                      dataRetrievalInterface->SetCurrentSubmesh(target_submesh); 
    687696                        dataRetrievalInterface->End(); 
    688                         dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh]); 
     697                         
     698                        numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 
     699                        dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh] + numdeg); 
     700                        current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 
    689701                } 
    690702                 
    691703                int lastindex = -1; 
    692                 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii++, ii_submesh++) 
     704                for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii_submesh++) 
    693705                { 
    694 /*                      // repeat the first index of the strip: degenerate 
    695                         if (lastindex==-1) 
     706                        // repeat the first index of the strip: degenerate (DEG!) 
     707                        // except for the first strip in a mesh 
     708                        if (lastindex==-1 && strip_count>0) 
    696709                        { 
    697710                                lastindex=*it; 
    698                                 dataRetrievalInterface->SetIndex(ii,*it);                                
    699                                 counter++; 
    700                                 ii++; 
    701                         }*/ 
     711                                dataRetrievalInterface->SetIndex(ii_submesh,*it);                                
     712                                ii_submesh++; 
     713                        } 
    702714                        lastindex=*it; 
    703715                        dataRetrievalInterface->SetIndex(ii_submesh,*it); 
    704                         counter++; 
    705716                } 
    706717 
    707 /*              // last repeat last vertex of the strip: degenerate 
    708                 dataRetrievalInterface->SetIndex(ii,lastindex); 
    709                 counter++; 
    710                 ii++;*/ 
    711  
    712 //              dataRetrievalInterface->SetNumValidIndices(ii); 
     718                // repeat last vertex of the strip: degenerate (DEG!) 
     719                // except for the last strip in a mesh 
     720                if (strip_count<mGeoMesh->mSubMesh[target_submesh].mStripCount-1) 
     721                { 
     722                        dataRetrievalInterface->SetIndex(ii_submesh,lastindex); 
     723                        ii_submesh++; 
     724                } 
    713725        } 
    714726 
    715727        if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
    716728        { 
    717 //              indices_x_submesh[target_submesh] = counter; 
    718729                if (target_submesh==0) 
    719730                        offsets_x_submesh[target_submesh] = 0; 
     
    721732                        offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 
    722733 
    723                 counter = 0; 
    724734                mStripsSubmesh[target_submesh] = (int)strip_count; 
    725735                strip_count = 0; 
    726736                target_submesh++; 
    727 //              dataRetrievalInterface->SetCurrentSubmesh(target_submesh); 
    728737        } 
    729738 
Note: See TracChangeset for help on using the changeset viewer.