aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpolymesh.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llpolymesh.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llpolymesh.cpp')
-rw-r--r--linden/indra/newview/llpolymesh.cpp82
1 files changed, 37 insertions, 45 deletions
diff --git a/linden/indra/newview/llpolymesh.cpp b/linden/indra/newview/llpolymesh.cpp
index d703129..d74beeb 100644
--- a/linden/indra/newview/llpolymesh.cpp
+++ b/linden/indra/newview/llpolymesh.cpp
@@ -90,7 +90,8 @@ LLPolyMeshSharedData::LLPolyMeshSharedData()
90LLPolyMeshSharedData::~LLPolyMeshSharedData() 90LLPolyMeshSharedData::~LLPolyMeshSharedData()
91{ 91{
92 freeMeshData(); 92 freeMeshData();
93 mMorphData.deleteAllData(); 93 for_each(mMorphData.begin(), mMorphData.end(), DeletePointer());
94 mMorphData.clear();
94} 95}
95 96
96//----------------------------------------------------------------------------- 97//-----------------------------------------------------------------------------
@@ -604,7 +605,7 @@ BOOL LLPolyMeshSharedData::loadMesh( const char *fileName )
604 continue; 605 continue;
605 } 606 }
606 607
607 mMorphData.addData(morph_data); 608 mMorphData.insert(morph_data);
608 } 609 }
609 610
610 S32 numRemaps; 611 S32 numRemaps;
@@ -759,11 +760,11 @@ LLPolyMesh *LLPolyMesh::getMesh(const LLString &name, LLPolyMesh* reference_mesh
759 //------------------------------------------------------------------------- 760 //-------------------------------------------------------------------------
760 // search for an existing mesh by this name 761 // search for an existing mesh by this name
761 //------------------------------------------------------------------------- 762 //-------------------------------------------------------------------------
762 LLPolyMeshSharedData **meshSharedData = sGlobalSharedMeshList.getValue(name); 763 LLPolyMeshSharedData* meshSharedData = get_if_there(sGlobalSharedMeshList, name, (LLPolyMeshSharedData*)NULL);
763 if (meshSharedData) 764 if (meshSharedData)
764 { 765 {
765// llinfos << "Polymesh " << name << " found in global mesh table." << llendl; 766// llinfos << "Polymesh " << name << " found in global mesh table." << llendl;
766 LLPolyMesh *poly_mesh = new LLPolyMesh(*meshSharedData, reference_mesh); 767 LLPolyMesh *poly_mesh = new LLPolyMesh(meshSharedData, reference_mesh);
767 return poly_mesh; 768 return poly_mesh;
768 } 769 }
769 770
@@ -787,7 +788,7 @@ LLPolyMesh *LLPolyMesh::getMesh(const LLString &name, LLPolyMesh* reference_mesh
787 LLPolyMesh *poly_mesh = new LLPolyMesh(mesh_data, reference_mesh); 788 LLPolyMesh *poly_mesh = new LLPolyMesh(mesh_data, reference_mesh);
788 789
789// llinfos << "Polymesh " << name << " added to global mesh table." << llendl; 790// llinfos << "Polymesh " << name << " added to global mesh table." << llendl;
790 sGlobalSharedMeshList.addToTail(name, poly_mesh->mSharedData); 791 sGlobalSharedMeshList[name] = poly_mesh->mSharedData;
791 792
792 return poly_mesh; 793 return poly_mesh;
793} 794}
@@ -797,21 +798,9 @@ LLPolyMesh *LLPolyMesh::getMesh(const LLString &name, LLPolyMesh* reference_mesh
797//----------------------------------------------------------------------------- 798//-----------------------------------------------------------------------------
798void LLPolyMesh::freeAllMeshes() 799void LLPolyMesh::freeAllMeshes()
799{ 800{
800 U32 i;
801
802 // delete each item in the global lists 801 // delete each item in the global lists
803 for (i=0; i<sGlobalSharedMeshList.length(); i++) 802 for_each(sGlobalSharedMeshList.begin(), sGlobalSharedMeshList.end(), DeletePairedPointer());
804 { 803 sGlobalSharedMeshList.clear();
805 // returns a pointer to the value, which is the pointer
806 // to the mesh
807 LLPolyMeshSharedData **shared_mesh_pp = sGlobalSharedMeshList.getValueAt(i);
808
809 // delete the mesh
810 delete *shared_mesh_pp;
811 }
812
813 // empty the lists
814 sGlobalSharedMeshList.removeAll();
815} 804}
816 805
817LLPolyMeshSharedData *LLPolyMesh::getSharedData() const 806LLPolyMeshSharedData *LLPolyMesh::getSharedData() const
@@ -830,7 +819,7 @@ void LLPolyMesh::dumpDiagInfo()
830 U32 total_faces = 0; 819 U32 total_faces = 0;
831 U32 total_kb = 0; 820 U32 total_kb = 0;
832 821
833 char buf[1024]; /*Flawfinder: ignore*/ 822 std::string buf;
834 823
835 llinfos << "-----------------------------------------------------" << llendl; 824 llinfos << "-----------------------------------------------------" << llendl;
836 llinfos << " Global PolyMesh Table (DEBUG only)" << llendl; 825 llinfos << " Global PolyMesh Table (DEBUG only)" << llendl;
@@ -838,18 +827,17 @@ void LLPolyMesh::dumpDiagInfo()
838 llinfos << "-----------------------------------------------------" << llendl; 827 llinfos << "-----------------------------------------------------" << llendl;
839 828
840 // print each loaded mesh, and it's memory usage 829 // print each loaded mesh, and it's memory usage
841 for (U32 i=0; i<sGlobalSharedMeshList.length(); i++) 830 for(LLPolyMeshSharedDataTable::iterator iter = sGlobalSharedMeshList.begin();
831 iter != sGlobalSharedMeshList.end(); ++iter)
842 { 832 {
843 std::string *mesh_name_p = sGlobalSharedMeshList.getIndexAt(i); 833 const std::string& mesh_name = iter->first;
844 834 LLPolyMeshSharedData* mesh = iter->second;
845 LLPolyMeshSharedData **mesh_pp = sGlobalSharedMeshList.getValueAt(i);
846 LLPolyMeshSharedData &mesh = **mesh_pp;
847 835
848 S32 num_verts = mesh.mNumVertices; 836 S32 num_verts = mesh->mNumVertices;
849 S32 num_faces = mesh.mNumFaces; 837 S32 num_faces = mesh->mNumFaces;
850 U32 num_kb = mesh.getNumKB(); 838 U32 num_kb = mesh->getNumKB();
851 839
852 snprintf(buf, sizeof(buf), "%8d %8d %8d %s", num_verts, num_faces, num_kb, mesh_name_p->c_str()); /* Flawfinder: ignore */ 840 buf = llformat("%8d %8d %8d %s", num_verts, num_faces, num_kb, mesh_name.c_str());
853 llinfos << buf << llendl; 841 llinfos << buf << llendl;
854 842
855 total_verts += num_verts; 843 total_verts += num_verts;
@@ -858,7 +846,7 @@ void LLPolyMesh::dumpDiagInfo()
858 } 846 }
859 847
860 llinfos << "-----------------------------------------------------" << llendl; 848 llinfos << "-----------------------------------------------------" << llendl;
861 snprintf(buf, sizeof(buf), "%8d %8d %8d TOTAL", total_verts, total_faces, total_kb ); /* Flawfinder: ignore */ 849 buf = llformat("%8d %8d %8d TOTAL", total_verts, total_faces, total_kb );
862 llinfos << buf << llendl; 850 llinfos << buf << llendl;
863 llinfos << "-----------------------------------------------------" << llendl; 851 llinfos << "-----------------------------------------------------" << llendl;
864} 852}
@@ -943,11 +931,12 @@ void LLPolyMesh::initializeForMorph()
943//----------------------------------------------------------------------------- 931//-----------------------------------------------------------------------------
944LLPolyMorphData* LLPolyMesh::getMorphData(const char *morph_name) 932LLPolyMorphData* LLPolyMesh::getMorphData(const char *morph_name)
945{ 933{
946 if (!mSharedData) return NULL; 934 if (!mSharedData)
947 for (LLPolyMorphData *morph_data = mSharedData->mMorphData.getFirstData(); 935 return NULL;
948 morph_data; 936 for (LLPolyMeshSharedData::morphdata_list_t::iterator iter = mSharedData->mMorphData.begin();
949 morph_data = mSharedData->mMorphData.getNextData()) 937 iter != mSharedData->mMorphData.end(); ++iter)
950 { 938 {
939 LLPolyMorphData *morph_data = *iter;
951 if (!strcmp(morph_data->getName(), morph_name)) 940 if (!strcmp(morph_data->getName(), morph_name))
952 { 941 {
953 return morph_data; 942 return morph_data;
@@ -959,22 +948,25 @@ LLPolyMorphData* LLPolyMesh::getMorphData(const char *morph_name)
959//----------------------------------------------------------------------------- 948//-----------------------------------------------------------------------------
960// removeMorphData() 949// removeMorphData()
961//----------------------------------------------------------------------------- 950//-----------------------------------------------------------------------------
962void LLPolyMesh::removeMorphData(LLPolyMorphData *morph_target) 951// // erasing but not deleting seems bad, but fortunately we don't actually use this...
963{ 952// void LLPolyMesh::removeMorphData(LLPolyMorphData *morph_target)
964 if (!mSharedData) return; 953// {
965 954// if (!mSharedData)
966 mSharedData->mMorphData.removeData(morph_target); 955// return;
967} 956// mSharedData->mMorphData.erase(morph_target);
957// }
968 958
969//----------------------------------------------------------------------------- 959//-----------------------------------------------------------------------------
970// deleteAllMorphData() 960// deleteAllMorphData()
971//----------------------------------------------------------------------------- 961//-----------------------------------------------------------------------------
972void LLPolyMesh::deleteAllMorphData() 962// void LLPolyMesh::deleteAllMorphData()
973{ 963// {
974 if (!mSharedData) return; 964// if (!mSharedData)
965// return;
975 966
976 mSharedData->mMorphData.deleteAllData(); 967// for_each(mSharedData->mMorphData.begin(), mSharedData->mMorphData.end(), DeletePointer());
977} 968// mSharedData->mMorphData.clear();
969// }
978 970
979//----------------------------------------------------------------------------- 971//-----------------------------------------------------------------------------
980// getWritableWeights() 972// getWritableWeights()