diff options
Diffstat (limited to 'indra/llprimitive')
-rw-r--r-- | indra/llprimitive/CMakeLists.txt | 10 | ||||
-rw-r--r-- | indra/llprimitive/llmodel.cpp | 62 | ||||
-rw-r--r-- | indra/llprimitive/llmodel.h | 6 |
3 files changed, 69 insertions, 9 deletions
diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 97e1ebde47..7d0e313ff3 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -59,9 +59,9 @@ add_library (llprimitive ${llprimitive_SOURCE_FILES}) #add unit tests if (LL_TESTS) - INCLUDE(LLAddBuildTest) - SET(llprimitive_TEST_SOURCE_FILES - llmediaentry.cpp - ) - LL_ADD_PROJECT_UNIT_TESTS(llprimitive "${llprimitive_TEST_SOURCE_FILES}") + INCLUDE(LLAddBuildTest) + SET(llprimitive_TEST_SOURCE_FILES + llmediaentry.cpp + ) + LL_ADD_PROJECT_UNIT_TESTS(llprimitive "${llprimitive_TEST_SOURCE_FILES}") endif (LL_TESTS) diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index d8e4d4a173..6e4bb7ec97 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1903,14 +1903,71 @@ bool LLModel::loadModel(std::istream& is) } -void LLModel::matchMaterialOrder(LLModel* ref) +bool LLModel::isMaterialListSubset( LLModel* ref ) { - llassert(ref->mMaterialList.size() == mMaterialList.size()); + int refCnt = ref->mMaterialList.size(); + int modelCnt = mMaterialList.size(); + + for (U32 src = 0; src < modelCnt; ++src) + { + bool foundRef = false; + + for (U32 dst = 0; dst < refCnt; ++dst) + { + //llinfos<<mMaterialList[src]<<" "<<ref->mMaterialList[dst]<<llendl; + foundRef = mMaterialList[src] == ref->mMaterialList[dst]; + + if ( foundRef ) + { + break; + } + } + if (!foundRef) + { + return false; + } + } + + return true; +} + +bool LLModel::needToAddFaces( LLModel* ref, int& refFaceCnt, int& modelFaceCnt ) +{ + bool changed = false; + if ( refFaceCnt< modelFaceCnt ) + { + refFaceCnt += modelFaceCnt - refFaceCnt; + changed = true; + } + else + if ( modelFaceCnt < refFaceCnt ) + { + modelFaceCnt += refFaceCnt - modelFaceCnt; + changed = true; + } + + return changed; +} +bool LLModel::matchMaterialOrder(LLModel* ref, int& refFaceCnt, int& modelFaceCnt ) +{ + //Is this a subset? + //LODs cannot currently add new materials, e.g. + //1. ref = a,b,c lod1 = d,e => This is not permitted + //2. ref = a,b,c lod1 = c => This would be permitted + + bool isASubset = isMaterialListSubset( ref ); + if ( !isASubset ) + { + llinfos<<"Material of model is not a subset of reference."<<llendl; + return false; + } + std::map<std::string, U32> index_map; //build a map of material slot names to face indexes bool reorder = false; + std::set<std::string> base_mat; std::set<std::string> cur_mat; @@ -1952,6 +2009,7 @@ void LLModel::matchMaterialOrder(LLModel* ref) //override material list with reference model ordering mMaterialList = ref->mMaterialList; + return true; } diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 9a7b9fa271..1cf528fd9f 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -176,8 +176,10 @@ public: //reorder face list based on mMaterialList in this and reference so //order matches that of reference (material ordering touchup) - void matchMaterialOrder(LLModel* reference); - + bool matchMaterialOrder(LLModel* ref, int& refFaceCnt, int& modelFaceCnt ); + bool isMaterialListSubset( LLModel* ref ); + bool needToAddFaces( LLModel* ref, int& refFaceCnt, int& modelFaceCnt ); + std::vector<std::string> mMaterialList; //data used for skin weights |