From 7f934f34f10196d19b27af1e3e3ab8413a2807b3 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 23 Sep 2011 00:55:24 -0500 Subject: [PATCH] Minor renderer updates. --- indra/llprimitive/llmodel.cpp | 61 +++++++++++++++++++++++++++++++++-- indra/llprimitive/llmodel.h | 6 ++-- indra/llrender/llimagegl.cpp | 2 +- indra/newview/llvovolume.cpp | 2 +- indra/newview/pipeline.cpp | 3 +- 5 files changed, 67 insertions(+), 7 deletions(-) diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 37b3d27d1..80a26c0a1 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1929,10 +1929,66 @@ bool LLModel::loadModel(std::istream& is) } -void LLModel::matchMaterialOrder(LLModel* ref) +bool LLModel::isMaterialListSubset( LLModel* ref ) { - llassert(ref->mMaterialList.size() == mMaterialList.size()); + S32 refCnt = ref->mMaterialList.size(); + S32 modelCnt = mMaterialList.size(); + + for (S32 src = 0; src < modelCnt; ++src) + { + bool foundRef = false; + + for (S32 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 ) + { + llinfos<<"Material of model is not a subset of reference."< index_map; //build a map of material slot names to face indexes @@ -1978,6 +2034,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 58975e55b..19c07dd0b 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -180,8 +180,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 mMaterialList; //data used for skin weights diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index e5a782f3f..879a8b690 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1410,7 +1410,7 @@ void LLImageGL::deleteDeadTextures() { LLTexUnit* tex_unit = gGL.getTexUnit(i); - if (tex_unit->getCurrTexture() == tex) + if (tex_unit && tex_unit->getCurrTexture() == tex) { tex_unit->unbind(tex_unit->getCurrType()); stop_glerror(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7115f16b1..9029a8188 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2842,7 +2842,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e bool special_cursor = specialHoverCursor(); for (S32 i = start_face; i < end_face; ++i) { - if (!special_cursor && !pick_transparent && getTE(i)->getColor().mV[3] == 0.f) + if (!special_cursor && !pick_transparent && getTE(i) && getTE(i)->getColor().mV[3] == 0.f) { //don't attempt to pick completely transparent faces unless //pick_transparent is true continue; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7ed337b59..8f8eab62d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3878,6 +3878,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) occlude = FALSE; gGLLastMatrix = NULL; glLoadMatrixd(gGLModelView); + LLGLSLShader::bindNoShader(); doOcclusion(camera); gGLLastMatrix = NULL; glLoadMatrixd(gGLModelView); @@ -9410,7 +9411,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) { //create alpha mask based on depth buffer (grey out if muted) if (LLPipeline::sRenderDeferred) { - GLuint buff = GL_COLOR_ATTACHMENT0_EXT; + GLuint buff = GL_COLOR_ATTACHMENT0; glDrawBuffersARB(1, &buff); }