From 71ac45a28b238bac4ac0cf43ee85f04589ffa116 Mon Sep 17 00:00:00 2001 From: prep linden Date: Tue, 30 Aug 2011 09:32:16 -0400 Subject: Handling of material mismatches - lod materials are required to be a subset of the high lod, introduced addEmptyFace() for when parity does not exist between model material counts --- indra/llprimitive/llmodel.cpp | 61 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') 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[dst]<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 index_map; //build a map of material slot names to face indexes bool reorder = false; + std::set base_mat; std::set cur_mat; @@ -1952,6 +2008,7 @@ void LLModel::matchMaterialOrder(LLModel* ref) //override material list with reference model ordering mMaterialList = ref->mMaterialList; + return true; } -- cgit v1.2.3