Changeset 1560 for GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Timestamp:
- 10/03/06 14:11:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp
r1552 r1560 18 18 // Constructor. 19 19 //----------------------------------------------------------------------------- 20 LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh, IndexData *userindexdata) 21 //:dataRetrievalInterface(idfun?idfun:DefaultIndexDataCreator) 22 { 23 // const char *name_of_file; 24 20 LodStripsLibrary::LodStripsLibrary( const LodStripsLibraryData *lodstripsdata, 21 Mesh *geomesh, 22 IndexData *userindexdata) 23 { 25 24 // Sets the current lod. 26 25 mCurrentLod = 0; 27 26 28 // Converts a String to const char *.29 // name_of_file = name.data();30 31 27 // Sets the global mesh. 32 28 mGeoMesh = geomesh; 33 29 34 delete_indexdata=false; 35 dataRetrievalInterface=userindexdata; 36 37 indices_x_submesh = NULL; 38 offsets_x_submesh = NULL; 39 mStripsSubmesh = NULL; 40 submesh_x_strip = NULL; 41 lodFactor=1.0f; 42 current_triangle_count=0; 30 delete_indexdata = false; 31 dataRetrievalInterface = userindexdata; 32 indices_x_submesh = NULL; 33 offsets_x_submesh = NULL; 34 mStripsSubmesh = NULL; 35 submesh_x_strip = NULL; 36 lodFactor = 1.0f; 37 current_triangle_count = 0; 43 38 44 39 // Loads the Level Of Detail file. 45 40 LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh); 46 41 47 GoToLod(0.0f); 48 minFaces = 0; 42 GoToLod(0.0f); 43 44 minFaces = 0; 45 49 46 for (unsigned int strip = 0; strip < mTotalStrips; strip++) 50 minFaces += int(mStrips[strip].size() - 2); 47 { 48 minFaces += int(mStrips[strip].size() - 2); 49 } 51 50 52 51 GoToLod(1.0f); 53 maxFaces = 0; 52 53 maxFaces = 0; 54 54 55 for (unsigned int strip = 0; strip < mTotalStrips; strip++) 55 maxFaces += int(mStrips[strip].size() - 2); 56 { 57 maxFaces += int(mStrips[strip].size() - 2); 58 } 56 59 } 57 60 … … 668 671 void LodStripsLibrary::UpdateDataRetrievalInterface(void) 669 672 { 670 int target_submesh = 0; 671 size_t strip_count = 0; 672 unsigned int ii_submesh = 0; 673 int target_submesh = 0; 674 size_t strip_count = 0; 675 unsigned int ii_submesh = 0; 676 673 677 current_triangle_count = 0; 674 678 675 679 // indices_x_submesh is calculated without degenerates, 676 680 // 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 681 uint32 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount * 2 - 2; 682 683 dataRetrievalInterface->Begin(target_submesh, 684 indices_x_submesh[target_submesh] + numdeg); 685 686 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 687 688 // For each strip. 682 689 for (unsigned int i = 0; i < mTotalStrips; i++, strip_count++) 683 690 { 684 691 if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 685 692 { 686 if (target_submesh==0) 693 if (target_submesh == 0) 694 { 687 695 offsets_x_submesh[target_submesh] = 0; 696 } 688 697 else 689 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 698 { 699 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] 700 + 701 offsets_x_submesh[target_submesh-1]; 702 } 690 703 691 704 mStripsSubmesh[target_submesh] = (int)strip_count; … … 695 708 ii_submesh = 0; 696 709 dataRetrievalInterface->End(); 710 711 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 712 713 dataRetrievalInterface->Begin(target_submesh, 714 indices_x_submesh[target_submesh] + numdeg); 697 715 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; 701 } 702 716 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 717 } 718 703 719 int lastindex = -1; 704 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii_submesh++) 720 721 for ( SmallIntVector::iterator it = mStrips[i].begin(); 722 it != mStrips[i].end(); 723 it++, ii_submesh++) 705 724 { 706 725 // repeat the first index of the strip: degenerate (DEG!) 707 726 // except for the first strip in a mesh 708 if (lastindex==-1 && strip_count>0) 709 { 710 lastindex=*it; 727 if ((lastindex == -1) && (strip_count > 0)) 728 { 729 lastindex = *it; 730 711 731 dataRetrievalInterface->SetIndex(ii_submesh,*it); 712 732 ii_submesh++; 713 733 } 714 lastindex=*it; 734 735 lastindex = *it; 715 736 dataRetrievalInterface->SetIndex(ii_submesh,*it); 716 737 } … … 718 739 // repeat last vertex of the strip: degenerate (DEG!) 719 740 // except for the last strip in a mesh 720 if (strip_count <mGeoMesh->mSubMesh[target_submesh].mStripCount-1)741 if (strip_count < mGeoMesh->mSubMesh[target_submesh].mStripCount-1) 721 742 { 722 743 dataRetrievalInterface->SetIndex(ii_submesh,lastindex); … … 727 748 if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 728 749 { 729 if (target_submesh==0) 750 if (target_submesh == 0) 751 { 730 752 offsets_x_submesh[target_submesh] = 0; 753 } 731 754 else 732 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 733 734 mStripsSubmesh[target_submesh] = (int)strip_count; 735 strip_count = 0; 755 { 756 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] 757 + 758 offsets_x_submesh[target_submesh-1]; 759 } 760 761 mStripsSubmesh[target_submesh] = (int)strip_count; 762 strip_count = 0; 763 736 764 target_submesh++; 737 765 } … … 739 767 dataRetrievalInterface->End(); 740 768 } 769 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp
r1526 r1560 769 769 770 770 // Reserve memory for vert_info array. 771 vinfo.init(m.vertCount()* 10);771 vinfo.init(m.vertCount()*2); 772 772 773 773 if (simplif::will_use_vertex_constraint)
Note: See TracChangeset
for help on using the changeset viewer.