diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2011-08-30 10:38:26 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2011-08-30 10:38:26 -0400 |
commit | 83fc9a2c567ed111bb3579e4f0bd78cc84280b43 (patch) | |
tree | ab22deb03805bbeb42aff4f9ed05ed6f376b88e9 /indra/llprimitive/llmodel.cpp | |
parent | dabdc89767c93f2ae9b10300eee87f94a79df707 (diff) | |
parent | 6f2820bcd7b7ed06fefeca0e2c34c45ef77e4b62 (diff) |
merge
Diffstat (limited to 'indra/llprimitive/llmodel.cpp')
-rw-r--r-- | indra/llprimitive/llmodel.cpp | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index d8e4d4a173..d13e6b662c 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1903,14 +1903,70 @@ 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 ) + { + 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 +2008,7 @@ void LLModel::matchMaterialOrder(LLModel* ref) //override material list with reference model ordering mMaterialList = ref->mMaterialList; + return true; } |