summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2013-08-07 13:35:08 -0700
committerGraham Linden <graham@lindenlab.com>2013-08-07 13:35:08 -0700
commitf3952f9a8dc368c991d9aaac174bfee5a0dd90e9 (patch)
tree98d8e289b73e75e73eafde30373d13120e917144
parentbfe2377a9a3061094e3c1fa10bb0afed06cac709 (diff)
NORSPEC-329 fix mangling of diffuse alpha mode by material edits when only one face really has alpha
-rwxr-xr-xindra/newview/llpanelface.h15
-rwxr-xr-xindra/newview/llviewerobject.cpp24
-rwxr-xr-xindra/newview/llviewerobject.h2
3 files changed, 40 insertions, 1 deletions
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index 834ad9e14c..06a45644d0 100755
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -255,7 +255,20 @@ private:
// Determine correct alpha mode for current diffuse texture
// (i.e. does it have an alpha channel that makes alpha mode useful)
//
- U8 default_alpha_mode = (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
+ // _panel->isAlpha() "lies" when one face has alpha and the rest do not (NORSPEC-329)
+ // need to get per-face answer to this question for sane alpha mode retention on updates.
+ //
+ U8 default_alpha_mode = object->isImageAlphaBlended(face) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
+
+ if (!current_material.isNull())
+ {
+ default_alpha_mode = current_material->getDiffuseAlphaMode();
+ }
+
+ // Insure we don't inherit the default of blend by accident...
+ // this will be stomped by a legit request to change the alpha mode by the apply() below
+ //
+ new_material->setDiffuseAlphaMode(default_alpha_mode);
// Do "It"!
//
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index f29a00e4c4..0070240803 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -4517,6 +4517,30 @@ LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const
}
+bool LLViewerObject::isImageAlphaBlended(const U8 te) const
+{
+ LLViewerTexture* image = getTEImage(te);
+ LLGLenum format = image ? image->getPrimaryFormat() : GL_RGB;
+ switch (format)
+ {
+ case GL_RGBA:
+ case GL_ALPHA:
+ {
+ return true;
+ }
+ break;
+
+ case GL_RGB: break;
+ default:
+ {
+ llwarns << "Unexpected tex format in LLViewerObject::isImageAlphaBlended...returning no alpha." << llendl;
+ }
+ break;
+ }
+
+ return false;
+}
+
LLViewerTexture *LLViewerObject::getTENormalMap(const U8 face) const
{
// llassert(mTEImages);
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index ea0d55cda5..16f1f403d3 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -339,6 +339,8 @@ public:
LLViewerTexture *getTENormalMap(const U8 te) const;
LLViewerTexture *getTESpecularMap(const U8 te) const;
+ bool isImageAlphaBlended(const U8 te) const;
+
void fitFaceTexture(const U8 face);
void sendTEUpdate() const; // Sends packed representation of all texture entry information