summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llmodel.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2011-08-30 10:38:26 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2011-08-30 10:38:26 -0400
commit83fc9a2c567ed111bb3579e4f0bd78cc84280b43 (patch)
treeab22deb03805bbeb42aff4f9ed05ed6f376b88e9 /indra/llprimitive/llmodel.cpp
parentdabdc89767c93f2ae9b10300eee87f94a79df707 (diff)
parent6f2820bcd7b7ed06fefeca0e2c34c45ef77e4b62 (diff)
merge
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;
}