diff options
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rwxr-xr-x | indra/newview/llvovolume.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 66ee386874..008ef792e0 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2040,19 +2040,32 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { - S32 res = 0; - - if (pMaterialParams && getTEImage(te) && 3 == getTEImage(te)->getComponents() && pMaterialParams->getDiffuseAlphaMode()) - { - LLViewerObject::setTEMaterialID(te, LLMaterialID::null); - res = LLViewerObject::setTEMaterialParams(te, NULL); - } - else + LLMaterialPtr pMaterial = const_cast<LLMaterialPtr&>(pMaterialParams); + + if(pMaterialParams) { - res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); + LLViewerTexture* image = getTEImage(te); + LLGLenum image_format = image ? image->getPrimaryFormat() : GL_RGB; + LLMaterialPtr current_material = getTEMaterialParams(te); + + U8 new_diffuse_alpha_mode = pMaterialParams->getDiffuseAlphaMode(); + + if(new_diffuse_alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + { + new_diffuse_alpha_mode = (GL_RGB == image_format || 0 == image_format ? LLMaterial::DIFFUSE_ALPHA_MODE_NONE : new_diffuse_alpha_mode); + } + + if(pMaterialParams->getDiffuseAlphaMode() != new_diffuse_alpha_mode) { + //create new material + pMaterial = new LLMaterial(pMaterialParams->asLLSD()); + pMaterial->setDiffuseAlphaMode(new_diffuse_alpha_mode); + LLMaterialMgr::getInstance()->put(getID(),te,*pMaterial); + } } - LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterialParams) ? pMaterialParams->asLLSD() : LLSD("null")) << " res " << res + S32 res = LLViewerObject::setTEMaterialParams(te, pMaterial); + + LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterial) ? pMaterial->asLLSD() : LLSD("null")) << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast<LLVOVolume*>(this), te) ? " selected" : " not selected" ) << LL_ENDL; setChanged(ALL_CHANGED); |