summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llmodel.cpp
diff options
context:
space:
mode:
authorprep linden <prep@lindenlab.com>2011-08-30 09:32:16 -0400
committerprep linden <prep@lindenlab.com>2011-08-30 09:32:16 -0400
commit71ac45a28b238bac4ac0cf43ee85f04589ffa116 (patch)
treeab256f9fa290d1af3415323f70e38984fa1dbb1d /indra/llprimitive/llmodel.cpp
parent2e4dcca9e2049aa4a8c29820937b6a956d75e5d8 (diff)
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
Diffstat (limited to 'indra/llprimitive/llmodel.cpp')
-rw-r--r--indra/llprimitive/llmodel.cpp61
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;
}