From c3ef4b7f7b21960a1938c70121ee1b8f18ed090d Mon Sep 17 00:00:00 2001
From: Cinder <cinder@sdf.org>
Date: Sun, 10 May 2015 20:27:42 -0600
Subject: [PATCH] You don't need to null check goddamn getChild() calls

---
 indra/newview/llpanelface.cpp | 1252 +++++++++++++++------------------
 1 file changed, 559 insertions(+), 693 deletions(-)

diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 9467113151..4adba0f519 100755
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -124,7 +124,7 @@ F32		LLPanelFace::getCurrentShinyOffsetV()		{ return getChild<LLUICtrl>("shinyOf
 // Methods
 //
 
-BOOL	LLPanelFace::postBuild()
+BOOL LLPanelFace::postBuild()
 {
 	childSetCommitCallback("combobox shininess",&LLPanelFace::onCommitShiny,this);
 	childSetCommitCallback("combobox bumpiness",&LLPanelFace::onCommitBump,this);
@@ -156,121 +156,84 @@ BOOL	LLPanelFace::postBuild()
 	setMouseOpaque(FALSE);
 
 	mTextureCtrl = getChild<LLTextureCtrl>("texture control");
-	if(mTextureCtrl)
-	{
-		mTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" )));
-		mTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitTexture, this, _2) );
-		mTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelTexture, this, _2) );
-		mTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectTexture, this, _2) );
-		mTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
-		mTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
-		mTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
-
-		mTextureCtrl->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-		mTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
-		mTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
-	}
+	mTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" )));
+	mTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitTexture, this, _2) );
+	mTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelTexture, this, _2) );
+	mTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectTexture, this, _2) );
+	mTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
+	mTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
+	mTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
+
+	mTextureCtrl->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+	mTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
+	mTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
 
 	mShinyTextureCtrl = getChild<LLTextureCtrl>("shinytexture control");
-	if(mShinyTextureCtrl)
-	{
-		mShinyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectSpecularTexture" )));
-		mShinyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitSpecularTexture, this, _2) );
-		mShinyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelSpecularTexture, this, _2) );
-		mShinyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectSpecularTexture, this, _2) );
-		mShinyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
+	mShinyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectSpecularTexture" )));
+	mShinyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitSpecularTexture, this, _2) );
+	mShinyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelSpecularTexture, this, _2) );
+	mShinyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectSpecularTexture, this, _2) );
+	mShinyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
 		
-		mShinyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
-		mShinyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
-		mShinyTextureCtrl->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-		mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
-		mShinyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
-	}
+	mShinyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
+	mShinyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
+	mShinyTextureCtrl->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+	mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
+	mShinyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
 
 	mBumpyTextureCtrl = getChild<LLTextureCtrl>("bumpytexture control");
-	if(mBumpyTextureCtrl)
-	{
-		mBumpyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectNormalTexture" )));
-		mBumpyTextureCtrl->setBlankImageAssetID(LLUUID( gSavedSettings.getString( "DefaultBlankNormalTexture" )));
-		mBumpyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitNormalTexture, this, _2) );
-		mBumpyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelNormalTexture, this, _2) );
-		mBumpyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectNormalTexture, this, _2) );
-		mBumpyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
-
-		mBumpyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
-		mBumpyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
-		mBumpyTextureCtrl->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-		mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
-		mBumpyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
-	}
+	mBumpyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectNormalTexture" )));
+	mBumpyTextureCtrl->setBlankImageAssetID(LLUUID( gSavedSettings.getString( "DefaultBlankNormalTexture" )));
+	mBumpyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitNormalTexture, this, _2) );
+	mBumpyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelNormalTexture, this, _2) );
+	mBumpyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectNormalTexture, this, _2) );
+	mBumpyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
+
+	mBumpyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
+	mBumpyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
+	mBumpyTextureCtrl->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+	mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
+	mBumpyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
 
 	mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
-	if(mColorSwatch)
-	{
-		mColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitColor, this, _2));
-		mColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelColor, this, _2));
-		mColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectColor, this, _2));
-		mColorSwatch->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-		mColorSwatch->setCanApplyImmediately(TRUE);
-	}
+	mColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitColor, this, _2));
+	mColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelColor, this, _2));
+	mColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectColor, this, _2));
+	mColorSwatch->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+	mColorSwatch->setCanApplyImmediately(TRUE);
 
 	mShinyColorSwatch = getChild<LLColorSwatchCtrl>("shinycolorswatch");
-	if(mShinyColorSwatch)
-	{
-		mShinyColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitShinyColor, this, _2));
-		mShinyColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelShinyColor, this, _2));
-		mShinyColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectShinyColor, this, _2));
-		mShinyColorSwatch->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-		mShinyColorSwatch->setCanApplyImmediately(TRUE);
-	}
+	mShinyColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitShinyColor, this, _2));
+	mShinyColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelShinyColor, this, _2));
+	mShinyColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectShinyColor, this, _2));
+	mShinyColorSwatch->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+	mShinyColorSwatch->setCanApplyImmediately(TRUE);
 
 	mLabelColorTransp = getChild<LLTextBox>("color trans");
-	if(mLabelColorTransp)
-	{
-		mLabelColorTransp->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-	}
+	mLabelColorTransp->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
 
 	mCtrlColorTransp = getChild<LLSpinCtrl>("ColorTrans");
-	if(mCtrlColorTransp)
-	{
-		mCtrlColorTransp->setCommitCallback(boost::bind(&LLPanelFace::onCommitAlpha, this, _2));
-		mCtrlColorTransp->setPrecision(0);
-		mCtrlColorTransp->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-	}
+	mCtrlColorTransp->setCommitCallback(boost::bind(&LLPanelFace::onCommitAlpha, this, _2));
+	mCtrlColorTransp->setPrecision(0);
+	mCtrlColorTransp->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
 
 	mCheckFullbright = getChild<LLCheckBoxCtrl>("checkbox fullbright");
-	if (mCheckFullbright)
-	{
-		mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright, this);
-	}
+	mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright, this);
 
 	mComboTexGen = getChild<LLComboBox>("combobox texgen");
-	if(mComboTexGen)
-	{
-		mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen, this);
-		mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);	
-	}
+	mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen, this);
+	mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
 
 	mComboMatMedia = getChild<LLComboBox>("combobox matmedia");
-	if(mComboMatMedia)
-	{
-		mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this);
-		mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL);
-	}
+	mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this);
+	mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL);
 
 	mComboMatType = getChild<LLComboBox>("combobox mattype");
-	if(mComboMatType)
-	{
-		mComboMatType->setCommitCallback(LLPanelFace::onCommitMaterialType, this);
-		mComboMatType->selectNthItem(MATTYPE_DIFFUSE);
-	}
+	mComboMatType->setCommitCallback(LLPanelFace::onCommitMaterialType, this);
+	mComboMatType->selectNthItem(MATTYPE_DIFFUSE);
 
 	mCtrlGlow = getChild<LLSpinCtrl>("glow");
-	if(mCtrlGlow)
-	{
-		mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this);
-	}
-	
+	mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this);
 
 	clearCtrls();
 
@@ -308,7 +271,6 @@ LLPanelFace::~LLPanelFace()
 void LLPanelFace::sendTexture()
 {
 	LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("texture control");
-	if(!mTextureCtrl) return;
 	if( !mTextureCtrl->getTentative() )
 	{
 		// we grab the item id first, because we want to do a
@@ -326,7 +288,7 @@ void LLPanelFace::sendBump(U32 bumpiness)
 {	
 	LLTextureCtrl* bumpytexture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
 	if (bumpiness < BUMPY_TEXTURE)
-{	
+	{
 		LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL;	
 		bumpytexture_ctrl->clear();
 		bumpytexture_ctrl->setImageAssetID(LLUUID());		
@@ -353,7 +315,6 @@ void LLPanelFace::sendBump(U32 bumpiness)
 void LLPanelFace::sendTexGen()
 {
 	LLComboBox*	mComboTexGen = getChild<LLComboBox>("combobox texgen");
-	if(!mComboTexGen)return;
 	U8 tex_gen = (U8) mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT;
 	LLSelectMgr::getInstance()->selectionSetTexGen( tex_gen );
 }
@@ -363,7 +324,7 @@ void LLPanelFace::sendShiny(U32 shininess)
 	LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
 
 	if (shininess < SHINY_TEXTURE)
-{
+	{
 		texture_ctrl->clear();
 		texture_ctrl->setImageAssetID(LLUUID());		
 	}
@@ -385,7 +346,6 @@ void LLPanelFace::sendShiny(U32 shininess)
 void LLPanelFace::sendFullbright()
 {
 	LLCheckBoxCtrl*	mCheckFullbright = getChild<LLCheckBoxCtrl>("checkbox fullbright");
-	if(!mCheckFullbright)return;
 	U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0;
 	LLSelectMgr::getInstance()->selectionSetFullbright( fullbright );
 }
@@ -394,7 +354,6 @@ void LLPanelFace::sendColor()
 {
 	
 	LLColorSwatchCtrl*	mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
-	if(!mColorSwatch)return;
 	LLColor4 color = mColorSwatch->get();
 
 	LLSelectMgr::getInstance()->selectionSetColorOnly( color );
@@ -403,7 +362,6 @@ void LLPanelFace::sendColor()
 void LLPanelFace::sendAlpha()
 {	
 	LLSpinCtrl*	mCtrlColorTransp = getChild<LLSpinCtrl>("ColorTrans");
-	if(!mCtrlColorTransp)return;
 	F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f;
 
 	LLSelectMgr::getInstance()->selectionSetAlphaOnly( alpha );
@@ -413,12 +371,8 @@ void LLPanelFace::sendAlpha()
 void LLPanelFace::sendGlow()
 {
 	LLSpinCtrl* mCtrlGlow = getChild<LLSpinCtrl>("glow");
-	llassert(mCtrlGlow);
-	if (mCtrlGlow)
-	{
-		F32 glow = mCtrlGlow->get();
-		LLSelectMgr::getInstance()->selectionSetGlow( glow );
-	}
+	F32 glow = mCtrlGlow->get();
+	LLSelectMgr::getInstance()->selectionSetGlow( glow );
 }
 
 struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
@@ -433,72 +387,56 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
 		LLSpinCtrl*	ctrlTexOffsetS = mPanel->getChild<LLSpinCtrl>("TexOffsetU");
 		LLSpinCtrl*	ctrlTexOffsetT = mPanel->getChild<LLSpinCtrl>("TexOffsetV");
 		LLSpinCtrl*	ctrlTexRotation = mPanel->getChild<LLSpinCtrl>("TexRot");
-		LLComboBox*		comboTexGen = mPanel->getChild<LLComboBox>("combobox texgen");
-		llassert(comboTexGen);
+		LLComboBox*	comboTexGen = mPanel->getChild<LLComboBox>("combobox texgen");
 		llassert(object);
 
-		if (ctrlTexScaleS)
+		valid = !ctrlTexScaleS->getTentative(); // || !checkFlipScaleS->getTentative();
+		if (valid)
 		{
-			valid = !ctrlTexScaleS->getTentative(); // || !checkFlipScaleS->getTentative();
-			if (valid)
+			value = ctrlTexScaleS->get();
+			if (comboTexGen &&
+				comboTexGen->getCurrentIndex() == 1)
 			{
-				value = ctrlTexScaleS->get();
-				if (comboTexGen &&
-				    comboTexGen->getCurrentIndex() == 1)
-				{
-					value *= 0.5f;
-				}
-				object->setTEScaleS( te, value );
+				value *= 0.5f;
 			}
+			object->setTEScaleS( te, value );
 		}
 
-		if (ctrlTexScaleT)
+		valid = !ctrlTexScaleT->getTentative(); // || !checkFlipScaleT->getTentative();
+		if (valid)
 		{
-			valid = !ctrlTexScaleT->getTentative(); // || !checkFlipScaleT->getTentative();
-			if (valid)
+			value = ctrlTexScaleT->get();
+			//if( checkFlipScaleT->get() )
+			//{
+			//	value = -value;
+			//}
+			if (comboTexGen &&
+				comboTexGen->getCurrentIndex() == 1)
 			{
-				value = ctrlTexScaleT->get();
-				//if( checkFlipScaleT->get() )
-				//{
-				//	value = -value;
-				//}
-				if (comboTexGen &&
-				    comboTexGen->getCurrentIndex() == 1)
-				{
-					value *= 0.5f;
-				}
-				object->setTEScaleT( te, value );
+				value *= 0.5f;
 			}
+			object->setTEScaleT( te, value );
 		}
-
-		if (ctrlTexOffsetS)
+		
+		valid = !ctrlTexOffsetS->getTentative();
+		if (valid)
 		{
-			valid = !ctrlTexOffsetS->getTentative();
-			if (valid)
-			{
-				value = ctrlTexOffsetS->get();
-				object->setTEOffsetS( te, value );
-			}
+			value = ctrlTexOffsetS->get();
+			object->setTEOffsetS( te, value );
 		}
 
-		if (ctrlTexOffsetT)
+		valid = !ctrlTexOffsetT->getTentative();
+		if (valid)
 		{
-			valid = !ctrlTexOffsetT->getTentative();
-			if (valid)
-			{
-				value = ctrlTexOffsetT->get();
-				object->setTEOffsetT( te, value );
-			}
+			value = ctrlTexOffsetT->get();
+			object->setTEOffsetT( te, value );
 		}
 
-		if (ctrlTexRotation)
+		valid = !ctrlTexRotation->getTentative();
+		if (valid)
 		{
-			valid = !ctrlTexRotation->getTentative();
-			if (valid)
-			{
-				value = ctrlTexRotation->get() * DEG_TO_RAD;
-				object->setTERotation( te, value );
-			}
+			value = ctrlTexRotation->get() * DEG_TO_RAD;
+			object->setTERotation( te, value );
 		}
 		return true;
 	}
@@ -615,7 +553,7 @@ struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor
 
 void LLPanelFace::sendTextureInfo()
 {
-	if ((bool)childGetValue("checkbox planar align").asBoolean())
+	if (childGetValue("checkbox planar align").asBoolean())
 	{
 		LLFace* last_face = NULL;
 		bool identical_face =false;
@@ -639,12 +577,10 @@ void LLPanelFace::getState()
 }
 
 void LLPanelFace::updateUI()
-{ //set state of UI to match state of texture entry(ies)  (calls setEnabled, setValue, etc, but NOT setVisible)
+{
 	LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
 
-	if( objectp
-		&& objectp->getPCode() == LL_PCODE_VOLUME
-		&& objectp->permModify())
+	if (objectp && objectp->getPCode() == LL_PCODE_VOLUME && objectp->permModify())
 	{
 		BOOL editable = objectp->permModify() && !objectp->isPermanentEnforced();
 
@@ -652,473 +588,427 @@ void LLPanelFace::updateUI()
 		getChildView("button align")->setEnabled(editable);
 		
 		LLComboBox* combobox_matmedia = getChild<LLComboBox>("combobox matmedia");
-		if (combobox_matmedia)
+		if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL)
 		{
-			if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL)
-			{
-				combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL);
-			}
+			combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL);
 		}
-		else
-		{
-			LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL;
-		}
-		getChildView("combobox matmedia")->setEnabled(editable);
-
+		combobox_matmedia->setEnabled(editable);
+		
 		LLComboBox* combobox_mattype = getChild<LLComboBox>("combobox mattype");
-		if (combobox_mattype)
-		{
-			if (combobox_mattype->getCurrentIndex() < MATTYPE_DIFFUSE)
-			{
-				combobox_mattype->selectNthItem(MATTYPE_DIFFUSE);
-			}
-		}
-		else
+		if (combobox_mattype->getCurrentIndex() < MATTYPE_DIFFUSE)
 		{
-			LL_WARNS("Materials") << "failed getChild for 'combobox mattype'" << LL_ENDL;
+			combobox_mattype->selectNthItem(MATTYPE_DIFFUSE);
 		}
-		getChildView("combobox mattype")->setEnabled(editable);
-
+		combobox_mattype->setEnabled(editable);
+		
 		updateVisibility();
-
-		bool identical				= true;	// true because it is anded below
-      bool identical_diffuse	= false;
-      bool identical_norm		= false;
-      bool identical_spec		= false;
-
-		LLTextureCtrl*	texture_ctrl = getChild<LLTextureCtrl>("texture control");
-		LLTextureCtrl*	shinytexture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
-		LLTextureCtrl*	bumpytexture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
+		
+		bool identical			= true;	// true because it is anded below
+		bool identical_diffuse	= false;
+		bool identical_norm		= false;
+		bool identical_spec		= false;
+		
+		LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control");
+		LLTextureCtrl* shinytexture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
+		LLTextureCtrl* bumpytexture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
 		
 		LLUUID id;
 		LLUUID normmap_id;
 		LLUUID specmap_id;
 		
 		// Color swatch
-		{
-			getChildView("color label")->setEnabled(editable);
-		}
-		LLColorSwatchCtrl*	mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
-
-		LLColor4 color					= LLColor4::white;
-		bool		identical_color	= false;
-
-		if(mColorSwatch)
-			{
-			LLSelectedTE::getColor(color, identical_color);
-
-			mColorSwatch->setOriginal(color);
-			mColorSwatch->set(color, TRUE);
-
-			mColorSwatch->setValid(editable);
-			mColorSwatch->setEnabled( editable );
-			mColorSwatch->setCanApplyImmediately( editable );
-		}
-
+		getChildView("color label")->setEnabled(editable);
+		
+		LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
+		
+		LLColor4 color = LLColor4::white;
+		bool identical_color	= false;
+		
+		LLSelectedTE::getColor(color, identical_color);
+		
+		mColorSwatch->setOriginal(color);
+		mColorSwatch->set(color, TRUE);
+		
+		mColorSwatch->setValid(editable);
+		mColorSwatch->setEnabled(editable);
+		mColorSwatch->setCanApplyImmediately(editable);
+		
 		// Color transparency
 		getChildView("color trans")->setEnabled(editable);
-
+		
 		F32 transparency = (1.f - color.mV[VALPHA]) * 100.f;
-		getChild<LLUICtrl>("ColorTrans")->setValue(editable ? transparency : 0);
-		getChildView("ColorTrans")->setEnabled(editable);
-
+		LLUICtrl* noodle = getChild<LLUICtrl>("ColorTrans");
+		noodle->setValue(editable ? transparency : 0);
+		noodle->setEnabled(editable);
+		
 		// Specular map
 		LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec);
 		
 		U8 shiny = 0;
 		bool identical_shiny = false;
-
+		
 		// Shiny
 		LLSelectedTE::getShiny(shiny, identical_shiny);
 		identical = identical && identical_shiny;
-
+		
 		shiny = specmap_id.isNull() ? shiny : SHINY_TEXTURE;
-
+		
 		LLCtrlSelectionInterface* combobox_shininess = childGetSelectionInterface("combobox shininess");
 		if (combobox_shininess)
-				{
+		{
 			combobox_shininess->selectNthItem((S32)shiny);
 		}
-
+		
 		getChildView("label shininess")->setEnabled(editable);
 		getChildView("combobox shininess")->setEnabled(editable);
-
-		getChildView("label glossiness")->setEnabled(editable);			
+		
+		getChildView("label glossiness")->setEnabled(editable);
 		getChildView("glossiness")->setEnabled(editable);
-
+		
 		getChildView("label environment")->setEnabled(editable);
 		getChildView("environment")->setEnabled(editable);
 		getChildView("label shinycolor")->setEnabled(editable);
-					
+		
 		getChild<LLUICtrl>("combobox shininess")->setTentative(!identical_spec);
 		getChild<LLUICtrl>("glossiness")->setTentative(!identical_spec);
-		getChild<LLUICtrl>("environment")->setTentative(!identical_spec);			
+		getChild<LLUICtrl>("environment")->setTentative(!identical_spec);
 		getChild<LLUICtrl>("shinycolorswatch")->setTentative(!identical_spec);
-					
+		
 		LLColorSwatchCtrl*	mShinyColorSwatch = getChild<LLColorSwatchCtrl>("shinycolorswatch");
-		if(mShinyColorSwatch)
-					{
-			mShinyColorSwatch->setValid(editable);
-			mShinyColorSwatch->setEnabled( editable );
-			mShinyColorSwatch->setCanApplyImmediately( editable );
-		}
-
+		mShinyColorSwatch->setValid(editable);
+		mShinyColorSwatch->setEnabled( editable );
+		mShinyColorSwatch->setCanApplyImmediately( editable );
+		
 		U8 bumpy = 0;
 		// Bumpy
-						{
-			bool identical_bumpy = false;
-			LLSelectedTE::getBumpmap(bumpy,identical_bumpy);
-
-			LLUUID norm_map_id = getCurrentNormalMap();
-			LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness");
-
-			bumpy = norm_map_id.isNull() ? bumpy : BUMPY_TEXTURE;
-
-			if (combobox_bumpiness)
-							{
-				combobox_bumpiness->selectNthItem((S32)bumpy);
-							}
-			else
-							{
-				LL_WARNS() << "failed childGetSelectionInterface for 'combobox bumpiness'" << LL_ENDL;
-							}
-
-			getChildView("combobox bumpiness")->setEnabled(editable);
-			getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical_bumpy);
-			getChildView("label bumpiness")->setEnabled(editable);
-						}
-
+		bool identical_bumpy = false;
+		LLSelectedTE::getBumpmap(bumpy,identical_bumpy);
+		
+		LLUUID norm_map_id = getCurrentNormalMap();
+		LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness");
+		
+		bumpy = norm_map_id.isNull() ? bumpy : BUMPY_TEXTURE;
+		if (combobox_bumpiness)
+		{
+			combobox_bumpiness->selectNthItem((S32)bumpy);
+		}
+		else
+		{
+			LL_WARNS() << "failed childGetSelectionInterface for 'combobox bumpiness'" << LL_ENDL;
+		}
+		
+		getChildView("combobox bumpiness")->setEnabled(editable);
+		getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical_bumpy);
+		getChildView("label bumpiness")->setEnabled(editable);
+		
 		// Texture
+		LLSelectedTE::getTexId(id,identical_diffuse);
+		
+		// Normal map
+		LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm);
+		
+		LLGLenum image_format = GL_RGB;
+		bool identical_image_format = false;
+		LLSelectedTE::getImageFormat(image_format, identical_image_format);
+		
+		switch (image_format)
 		{
-			LLSelectedTE::getTexId(id,identical_diffuse);
-
-			// Normal map
-			LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm);
-
-			mIsAlpha = FALSE;
-			LLGLenum image_format = GL_RGB;
-			bool identical_image_format = false;
-			LLSelectedTE::getImageFormat(image_format, identical_image_format);
-            
-         mIsAlpha = FALSE;
-         switch (image_format)
-         {
-               case GL_RGBA:
-               case GL_ALPHA:
-               {
-                  mIsAlpha = TRUE;
-               }
-               break;
-
-               case GL_RGB: break;
-               default:
-               {
-                  LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL;
-					}
-               break;
-				}
-
-			if(LLViewerMedia::textureHasMedia(id))
+			case GL_RGBA:
+			case GL_ALPHA:
+				mIsAlpha = TRUE;
+				break;
+			default:
+				LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL;
+			case GL_RGB:
+				mIsAlpha = FALSE;
+				break;
+		}
+		
+		if(LLViewerMedia::textureHasMedia(id))
+		{
+			getChildView("button align")->setEnabled(editable);
+		}
+		
+		// Diffuse Alpha Mode
+		
+		// Init to the default that is appropriate for the alpha content of the asset
+		//
+		U8 alpha_mode = mIsAlpha ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
+		
+		bool identical_alpha_mode = false;
+		
+		// See if that's been overridden by a material setting for same...
+		//
+		LLSelectedTEMaterial::getCurrentDiffuseAlphaMode(alpha_mode, identical_alpha_mode, mIsAlpha);
+		
+		LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode");
+		if (combobox_alphamode)
+		{
+			//it is invalid to have any alpha mode other than blend if transparency is greater than zero ...
+			// Want masking? Want emissive? Tough! You get BLEND!
+			alpha_mode = (transparency > 0.f) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : alpha_mode;
+			
+			// ... unless there is no alpha channel in the texture, in which case alpha mode MUST be none
+			alpha_mode = mIsAlpha ? alpha_mode : LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
+			combobox_alphamode->selectNthItem(alpha_mode);
+		}
+		else
+		{
+			LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL;
+		}
+		
+		updateAlphaControls();
+		
+		if(texture_ctrl)
+		{
+			if (identical_diffuse)
 			{
-				getChildView("button align")->setEnabled(editable);
+				texture_ctrl->setTentative( FALSE );
+				texture_ctrl->setEnabled( editable );
+				texture_ctrl->setImageAssetID( id );
+				getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f);
+				getChildView("label alphamode")->setEnabled(editable && mIsAlpha);
+				getChildView("maskcutoff")->setEnabled(editable && mIsAlpha);
+				getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha);
 			}
-			
-			// Diffuse Alpha Mode
-
-			// Init to the default that is appropriate for the alpha content of the asset
-			//
-			U8 alpha_mode = mIsAlpha ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
-
-			bool identical_alpha_mode = false;
-
-			// See if that's been overridden by a material setting for same...
-			//
-			LLSelectedTEMaterial::getCurrentDiffuseAlphaMode(alpha_mode, identical_alpha_mode, mIsAlpha);
-
-			LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode");
-			if (combobox_alphamode)
+			else if (id.isNull())
 			{
-				//it is invalid to have any alpha mode other than blend if transparency is greater than zero ... 
-				// Want masking? Want emissive? Tough! You get BLEND!
-				alpha_mode = (transparency > 0.f) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : alpha_mode;
-
-				// ... unless there is no alpha channel in the texture, in which case alpha mode MUST be none
-				alpha_mode = mIsAlpha ? alpha_mode : LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
-
-				combobox_alphamode->selectNthItem(alpha_mode);
+				// None selected
+				texture_ctrl->setTentative( FALSE );
+				texture_ctrl->setEnabled( FALSE );
+				texture_ctrl->setImageAssetID( LLUUID::null );
+				getChildView("combobox alphamode")->setEnabled( FALSE );
+				getChildView("label alphamode")->setEnabled( FALSE );
+				getChildView("maskcutoff")->setEnabled( FALSE);
+				getChildView("label maskcutoff")->setEnabled( FALSE );
 			}
 			else
 			{
-				LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL;
+				// Tentative: multiple selected with different textures
+				texture_ctrl->setTentative( TRUE );
+				texture_ctrl->setEnabled( editable );
+				texture_ctrl->setImageAssetID( id );
+				getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f);
+				getChildView("label alphamode")->setEnabled(editable && mIsAlpha);
+				getChildView("maskcutoff")->setEnabled(editable && mIsAlpha);
+				getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha);
 			}
-
-			updateAlphaControls();
 			
-				if(texture_ctrl)
-				{
-				if (identical_diffuse)
-				{
-					texture_ctrl->setTentative( FALSE );
-					texture_ctrl->setEnabled( editable );
-					texture_ctrl->setImageAssetID( id );
-					getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f);
-					getChildView("label alphamode")->setEnabled(editable && mIsAlpha);
-					getChildView("maskcutoff")->setEnabled(editable && mIsAlpha);
-					getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha);
-				}
-				else if (id.isNull())
-					{
-						// None selected
-						texture_ctrl->setTentative( FALSE );
-						texture_ctrl->setEnabled( FALSE );
-						texture_ctrl->setImageAssetID( LLUUID::null );
-					getChildView("combobox alphamode")->setEnabled( FALSE );
-					getChildView("label alphamode")->setEnabled( FALSE );
-					getChildView("maskcutoff")->setEnabled( FALSE);
-					getChildView("label maskcutoff")->setEnabled( FALSE );
-					}
-					else
-					{
-						// Tentative: multiple selected with different textures
-						texture_ctrl->setTentative( TRUE );
-						texture_ctrl->setEnabled( editable );
-						texture_ctrl->setImageAssetID( id );
-					getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f);
-					getChildView("label alphamode")->setEnabled(editable && mIsAlpha);
-					getChildView("maskcutoff")->setEnabled(editable && mIsAlpha);
-					getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha);
-				}
-			}
-
-			if (shinytexture_ctrl)
-			{
-				shinytexture_ctrl->setTentative( !identical_spec );
-				shinytexture_ctrl->setEnabled( editable );
-				shinytexture_ctrl->setImageAssetID( specmap_id );
-			}
-
-			if (bumpytexture_ctrl)
-			{
-				bumpytexture_ctrl->setTentative( !identical_norm );
-				bumpytexture_ctrl->setEnabled( editable );
-				bumpytexture_ctrl->setImageAssetID( normmap_id );
-			}
-		}
-
-		// planar align
-		bool align_planar = false;
-		bool identical_planar_aligned = false;
-		{
+			shinytexture_ctrl->setTentative( !identical_spec );
+			shinytexture_ctrl->setEnabled( editable );
+			shinytexture_ctrl->setImageAssetID( specmap_id );
+			
+			bumpytexture_ctrl->setTentative( !identical_norm );
+			bumpytexture_ctrl->setEnabled( editable );
+			bumpytexture_ctrl->setImageAssetID( normmap_id );
+			
+			// planar align
+			bool align_planar = false;
+			bool identical_planar_aligned = false;
+			
 			LLCheckBoxCtrl*	cb_planar_align = getChild<LLCheckBoxCtrl>("checkbox planar align");
 			align_planar = (cb_planar_align && cb_planar_align->get());
-
+			
 			bool enabled = (editable && isIdenticalPlanarTexgen());
 			childSetValue("checkbox planar align", align_planar && enabled);
 			childSetEnabled("checkbox planar align", enabled);
-
+			
 			if (align_planar && enabled)
 			{
 				LLFace* last_face = NULL;
 				bool identical_face = false;
 				LLSelectedTE::getFace(last_face, identical_face);
-
+				
 				LLPanelFaceGetIsAlignedTEFunctor get_is_aligend_func(last_face);
 				// this will determine if the texture param controls are tentative:
 				identical_planar_aligned = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&get_is_aligend_func);
 			}
-		}
-		
-		// Needs to be public and before tex scale settings below to properly reflect
-		// behavior when in planar vs default texgen modes in the
-		// NORSPEC-84 et al
-		//
-		LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
-		bool identical_texgen = true;		
-		bool identical_planar_texgen = false;
-
-		{	
+			
+			// Needs to be public and before tex scale settings below to properly reflect
+			// behavior when in planar vs default texgen modes in the
+			// NORSPEC-84 et al
+			LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
+			bool identical_texgen = true;
+			bool identical_planar_texgen = false;
+			
 			LLSelectedTE::getTexGen(selected_texgen, identical_texgen);
 			identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
-		}
-
-		// Texture scale
-		{
+			
+			// Texture scale
 			bool identical_diff_scale_s = false;
 			bool identical_spec_scale_s = false;
 			bool identical_norm_scale_s = false;
-
+			
 			identical = align_planar ? identical_planar_aligned : identical;
-
-			F32 diff_scale_s = 1.f;			
+			
+			F32 diff_scale_s = 1.f;
 			F32 spec_scale_s = 1.f;
 			F32 norm_scale_s = 1.f;
-
-			LLSelectedTE::getScaleS(						diff_scale_s, identical_diff_scale_s);			
-			LLSelectedTEMaterial::getSpecularRepeatX( spec_scale_s, identical_spec_scale_s);
-			LLSelectedTEMaterial::getNormalRepeatX(	norm_scale_s, identical_norm_scale_s);
-
+			
+			LLSelectedTE::getScaleS(diff_scale_s, identical_diff_scale_s);
+			LLSelectedTEMaterial::getSpecularRepeatX(spec_scale_s, identical_spec_scale_s);
+			LLSelectedTEMaterial::getNormalRepeatX(norm_scale_s, identical_norm_scale_s);
+			
 			diff_scale_s = editable ? diff_scale_s : 1.0f;
 			diff_scale_s *= identical_planar_texgen ? 2.0f : 1.0f;
 			
 			norm_scale_s = editable ? norm_scale_s : 1.0f;
 			norm_scale_s *= identical_planar_texgen ? 2.0f : 1.0f;
-
+			
 			spec_scale_s = editable ? spec_scale_s : 1.0f;
 			spec_scale_s *= identical_planar_texgen ? 2.0f : 1.0f;
-
+			
 			getChild<LLUICtrl>("TexScaleU")->setValue(diff_scale_s);
 			getChild<LLUICtrl>("shinyScaleU")->setValue(spec_scale_s);
 			getChild<LLUICtrl>("bumpyScaleU")->setValue(norm_scale_s);
-
+			
 			getChildView("TexScaleU")->setEnabled(editable);
 			getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull());
 			getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull());
-
+			
 			BOOL diff_scale_tentative = !(identical && identical_diff_scale_s);
 			BOOL norm_scale_tentative = !(identical && identical_norm_scale_s);
 			BOOL spec_scale_tentative = !(identical && identical_spec_scale_s);
-
-			getChild<LLUICtrl>("TexScaleU")->setTentative(  LLSD(diff_scale_tentative));			
-			getChild<LLUICtrl>("shinyScaleU")->setTentative(LLSD(spec_scale_tentative));			
+			
+			getChild<LLUICtrl>("TexScaleU")->setTentative( LLSD(diff_scale_tentative));
+			getChild<LLUICtrl>("shinyScaleU")->setTentative(LLSD(spec_scale_tentative));
 			getChild<LLUICtrl>("bumpyScaleU")->setTentative(LLSD(norm_scale_tentative));
-		}
-
-		{
-			bool identical_diff_scale_t = false;
-			bool identical_spec_scale_t = false;
-			bool identical_norm_scale_t = false;
-
-			F32 diff_scale_t = 1.f;			
-			F32 spec_scale_t = 1.f;
-			F32 norm_scale_t = 1.f;
-
-			LLSelectedTE::getScaleT(diff_scale_t, identical_diff_scale_t);
-			LLSelectedTEMaterial::getSpecularRepeatY(spec_scale_t, identical_spec_scale_t);
-			LLSelectedTEMaterial::getNormalRepeatY(norm_scale_t, identical_norm_scale_t);
-
-			diff_scale_t = editable ? diff_scale_t : 1.0f;
-			diff_scale_t *= identical_planar_texgen ? 2.0f : 1.0f;
-
-			norm_scale_t = editable ? norm_scale_t : 1.0f;
-			norm_scale_t *= identical_planar_texgen ? 2.0f : 1.0f;
-
-			spec_scale_t = editable ? spec_scale_t : 1.0f;
-			spec_scale_t *= identical_planar_texgen ? 2.0f : 1.0f;
-
-			BOOL diff_scale_tentative = !identical_diff_scale_t;
-			BOOL norm_scale_tentative = !identical_norm_scale_t;
-			BOOL spec_scale_tentative = !identical_spec_scale_t;
-
-			getChildView("TexScaleV")->setEnabled(editable);
-			getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull());
-			getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull());
-
-			getChild<LLUICtrl>("TexScaleV")->setValue(diff_scale_t);
-			getChild<LLUICtrl>("shinyScaleV")->setValue(norm_scale_t);
-			getChild<LLUICtrl>("bumpyScaleV")->setValue(spec_scale_t);
-
-			getChild<LLUICtrl>("TexScaleV")->setTentative(LLSD(diff_scale_tentative));
-			getChild<LLUICtrl>("shinyScaleV")->setTentative(LLSD(norm_scale_tentative));
-			getChild<LLUICtrl>("bumpyScaleV")->setTentative(LLSD(spec_scale_tentative));
-		}
-
-		// Texture offset
-		{
-			bool identical_diff_offset_s = false;
-			bool identical_norm_offset_s = false;
-			bool identical_spec_offset_s = false;
-
-			F32 diff_offset_s = 0.0f;
-			F32 norm_offset_s = 0.0f;
-			F32 spec_offset_s = 0.0f;
-
-			LLSelectedTE::getOffsetS(diff_offset_s, identical_diff_offset_s);
-			LLSelectedTEMaterial::getNormalOffsetX(norm_offset_s, identical_norm_offset_s);
-			LLSelectedTEMaterial::getSpecularOffsetX(spec_offset_s, identical_spec_offset_s);
-
-			BOOL diff_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_diff_offset_s);
-			BOOL norm_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_s);
-			BOOL spec_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_s);
-
-			getChild<LLUICtrl>("TexOffsetU")->setValue(  editable ? diff_offset_s : 0.0f);
-			getChild<LLUICtrl>("bumpyOffsetU")->setValue(editable ? norm_offset_s : 0.0f);
-			getChild<LLUICtrl>("shinyOffsetU")->setValue(editable ? spec_offset_s : 0.0f);
-
-			getChild<LLUICtrl>("TexOffsetU")->setTentative(LLSD(diff_offset_u_tentative));
-			getChild<LLUICtrl>("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative));
-			getChild<LLUICtrl>("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative));
-
-			getChildView("TexOffsetU")->setEnabled(editable);
-			getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull());
-			getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull());
-		}
-
-		{
-			bool identical_diff_offset_t = false;
-			bool identical_norm_offset_t = false;
-			bool identical_spec_offset_t = false;
-
-			F32 diff_offset_t = 0.0f;
-			F32 norm_offset_t = 0.0f;
-			F32 spec_offset_t = 0.0f;
-
-			LLSelectedTE::getOffsetT(diff_offset_t, identical_diff_offset_t);
-			LLSelectedTEMaterial::getNormalOffsetY(norm_offset_t, identical_norm_offset_t);
-			LLSelectedTEMaterial::getSpecularOffsetY(spec_offset_t, identical_spec_offset_t);
 			
-			BOOL diff_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_diff_offset_t);
-			BOOL norm_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_t);
-			BOOL spec_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_t);
-
-			getChild<LLUICtrl>("TexOffsetV")->setValue(  editable ? diff_offset_t : 0.0f);
-			getChild<LLUICtrl>("bumpyOffsetV")->setValue(editable ? norm_offset_t : 0.0f);
-			getChild<LLUICtrl>("shinyOffsetV")->setValue(editable ? spec_offset_t : 0.0f);
-
-			getChild<LLUICtrl>("TexOffsetV")->setTentative(LLSD(diff_offset_v_tentative));
-			getChild<LLUICtrl>("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative));
-			getChild<LLUICtrl>("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative));
-
-			getChildView("TexOffsetV")->setEnabled(editable);
-			getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull());
-			getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull());
-		}
-
-		// Texture rotation
-		{
-			bool identical_diff_rotation = false;
-			bool identical_norm_rotation = false;
-			bool identical_spec_rotation = false;
-
-			F32 diff_rotation = 0.f;
-			F32 norm_rotation = 0.f;
-			F32 spec_rotation = 0.f;
-
-			LLSelectedTE::getRotation(diff_rotation,identical_diff_rotation);
-			LLSelectedTEMaterial::getSpecularRotation(spec_rotation,identical_spec_rotation);
-			LLSelectedTEMaterial::getNormalRotation(norm_rotation,identical_norm_rotation);
-
-			BOOL diff_rot_tentative = !(align_planar ? identical_planar_aligned : identical_diff_rotation);
-			BOOL norm_rot_tentative = !(align_planar ? identical_planar_aligned : identical_norm_rotation);
-			BOOL spec_rot_tentative = !(align_planar ? identical_planar_aligned : identical_spec_rotation);
-
-			F32 diff_rot_deg = diff_rotation * RAD_TO_DEG;
-			F32 norm_rot_deg = norm_rotation * RAD_TO_DEG;
-			F32 spec_rot_deg = spec_rotation * RAD_TO_DEG;
+			{
+				bool identical_diff_scale_t = false;
+				bool identical_spec_scale_t = false;
+				bool identical_norm_scale_t = false;
+				
+				F32 diff_scale_t = 1.f;
+				F32 spec_scale_t = 1.f;
+				F32 norm_scale_t = 1.f;
+				
+				LLSelectedTE::getScaleT(diff_scale_t, identical_diff_scale_t);
+				LLSelectedTEMaterial::getSpecularRepeatY(spec_scale_t, identical_spec_scale_t);
+				LLSelectedTEMaterial::getNormalRepeatY(norm_scale_t, identical_norm_scale_t);
+				
+				diff_scale_t = editable ? diff_scale_t : 1.0f;
+				diff_scale_t *= identical_planar_texgen ? 2.0f : 1.0f;
+				
+				norm_scale_t = editable ? norm_scale_t : 1.0f;
+				norm_scale_t *= identical_planar_texgen ? 2.0f : 1.0f;
+				
+				spec_scale_t = editable ? spec_scale_t : 1.0f;
+				spec_scale_t *= identical_planar_texgen ? 2.0f : 1.0f;
+				
+				BOOL diff_scale_tentative = !identical_diff_scale_t;
+				BOOL norm_scale_tentative = !identical_norm_scale_t;
+				BOOL spec_scale_tentative = !identical_spec_scale_t;
+				
+				getChildView("TexScaleV")->setEnabled(editable);
+				getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull());
+				getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull());
+				
+				getChild<LLUICtrl>("TexScaleV")->setValue(diff_scale_t);
+				getChild<LLUICtrl>("shinyScaleV")->setValue(norm_scale_t);
+				getChild<LLUICtrl>("bumpyScaleV")->setValue(spec_scale_t);
+				
+				getChild<LLUICtrl>("TexScaleV")->setTentative(LLSD(diff_scale_tentative));
+				getChild<LLUICtrl>("shinyScaleV")->setTentative(LLSD(norm_scale_tentative));
+				getChild<LLUICtrl>("bumpyScaleV")->setTentative(LLSD(spec_scale_tentative));
+			}
+			
+			// Texture offset
+			{
+				bool identical_diff_offset_s = false;
+				bool identical_norm_offset_s = false;
+				bool identical_spec_offset_s = false;
+				
+				F32 diff_offset_s = 0.0f;
+				F32 norm_offset_s = 0.0f;
+				F32 spec_offset_s = 0.0f;
+				
+				LLSelectedTE::getOffsetS(diff_offset_s, identical_diff_offset_s);
+				LLSelectedTEMaterial::getNormalOffsetX(norm_offset_s, identical_norm_offset_s);
+				LLSelectedTEMaterial::getSpecularOffsetX(spec_offset_s, identical_spec_offset_s);
+				
+				BOOL diff_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_diff_offset_s);
+				BOOL norm_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_s);
+				BOOL spec_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_s);
+				
+				getChild<LLUICtrl>("TexOffsetU")->setValue(editable ? diff_offset_s : 0.0f);
+				getChild<LLUICtrl>("bumpyOffsetU")->setValue(editable ? norm_offset_s : 0.0f);
+				getChild<LLUICtrl>("shinyOffsetU")->setValue(editable ? spec_offset_s : 0.0f);
+				
+				getChild<LLUICtrl>("TexOffsetU")->setTentative(LLSD(diff_offset_u_tentative));
+				getChild<LLUICtrl>("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative));
+				getChild<LLUICtrl>("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative));
+				
+				getChildView("TexOffsetU")->setEnabled(editable);
+				getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull());
+				getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull());
+			}
+			
+			{
+				bool identical_diff_offset_t = false;
+				bool identical_norm_offset_t = false;
+				bool identical_spec_offset_t = false;
+				
+				F32 diff_offset_t = 0.0f;
+				F32 norm_offset_t = 0.0f;
+				F32 spec_offset_t = 0.0f;
+				
+				LLSelectedTE::getOffsetT(diff_offset_t, identical_diff_offset_t);
+				LLSelectedTEMaterial::getNormalOffsetY(norm_offset_t, identical_norm_offset_t);
+				LLSelectedTEMaterial::getSpecularOffsetY(spec_offset_t, identical_spec_offset_t);
+				
+				BOOL diff_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_diff_offset_t);
+				BOOL norm_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_t);
+				BOOL spec_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_t);
+				
+				getChild<LLUICtrl>("TexOffsetV")->setValue(  editable ? diff_offset_t : 0.0f);
+				getChild<LLUICtrl>("bumpyOffsetV")->setValue(editable ? norm_offset_t : 0.0f);
+				getChild<LLUICtrl>("shinyOffsetV")->setValue(editable ? spec_offset_t : 0.0f);
+				
+				getChild<LLUICtrl>("TexOffsetV")->setTentative(LLSD(diff_offset_v_tentative));
+				getChild<LLUICtrl>("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative));
+				getChild<LLUICtrl>("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative));
+				
+				getChildView("TexOffsetV")->setEnabled(editable);
+				getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull());
+				getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull());
+			}
+			
+			// Texture rotation
+			{
+				bool identical_diff_rotation = false;
+				bool identical_norm_rotation = false;
+				bool identical_spec_rotation = false;
+				
+				F32 diff_rotation = 0.f;
+				F32 norm_rotation = 0.f;
+				F32 spec_rotation = 0.f;
+				
+				LLSelectedTE::getRotation(diff_rotation,identical_diff_rotation);
+				LLSelectedTEMaterial::getSpecularRotation(spec_rotation,identical_spec_rotation);
+				LLSelectedTEMaterial::getNormalRotation(norm_rotation,identical_norm_rotation);
+				
+				BOOL diff_rot_tentative = !(align_planar ? identical_planar_aligned : identical_diff_rotation);
+				BOOL norm_rot_tentative = !(align_planar ? identical_planar_aligned : identical_norm_rotation);
+				BOOL spec_rot_tentative = !(align_planar ? identical_planar_aligned : identical_spec_rotation);
+				
+				F32 diff_rot_deg = diff_rotation * RAD_TO_DEG;
+				F32 norm_rot_deg = norm_rotation * RAD_TO_DEG;
+				F32 spec_rot_deg = spec_rotation * RAD_TO_DEG;
+				
+				getChildView("TexRot")->setEnabled(editable);
+				getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull());
+				getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull());
+				
+				getChild<LLUICtrl>("TexRot")->setTentative(diff_rot_tentative);
+				getChild<LLUICtrl>("shinyRot")->setTentative(LLSD(norm_rot_tentative));
+				getChild<LLUICtrl>("bumpyRot")->setTentative(LLSD(spec_rot_tentative));
+				
+				getChild<LLUICtrl>("TexRot")->setValue(  editable ? diff_rot_deg : 0.0f);
+				getChild<LLUICtrl>("shinyRot")->setValue(editable ? spec_rot_deg : 0.0f);
+				getChild<LLUICtrl>("bumpyRot")->setValue(editable ? norm_rot_deg : 0.0f);
+			}
 			
-			getChildView("TexRot")->setEnabled(editable);
-			getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull());
-			getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull());
-
-			getChild<LLUICtrl>("TexRot")->setTentative(diff_rot_tentative);
-			getChild<LLUICtrl>("shinyRot")->setTentative(LLSD(norm_rot_tentative));
-			getChild<LLUICtrl>("bumpyRot")->setTentative(LLSD(spec_rot_tentative));
-
-			getChild<LLUICtrl>("TexRot")->setValue(  editable ? diff_rot_deg : 0.0f);			
-			getChild<LLUICtrl>("shinyRot")->setValue(editable ? spec_rot_deg : 0.0f);
-			getChild<LLUICtrl>("bumpyRot")->setValue(editable ? norm_rot_deg : 0.0f);
-		}
-
-		{
 			F32 glow = 0.f;
 			bool identical_glow = false;
 			LLSelectedTE::getGlow(glow,identical_glow);
@@ -1126,162 +1016,146 @@ void LLPanelFace::updateUI()
 			getChild<LLUICtrl>("glow")->setTentative(!identical_glow);
 			getChildView("glow")->setEnabled(editable);
 			getChildView("glow label")->setEnabled(editable);
-		}
-
-		{
-			LLCtrlSelectionInterface* combobox_texgen = childGetSelectionInterface("combobox texgen");
-			if (combobox_texgen)
+			
 			{
-				// Maps from enum to combobox entry index
-				combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1);
-			}
-			else
+				LLCtrlSelectionInterface* combobox_texgen = childGetSelectionInterface("combobox texgen");
+				if (combobox_texgen)
 				{
-				LL_WARNS() << "failed childGetSelectionInterface for 'combobox texgen'" << LL_ENDL;
+					// Maps from enum to combobox entry index
+					combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1);
+				}
+				else
+				{
+					LL_WARNS() << "failed childGetSelectionInterface for 'combobox texgen'" << LL_ENDL;
+				}
+				
+				getChildView("combobox texgen")->setEnabled(editable);
+				getChild<LLUICtrl>("combobox texgen")->setTentative(!identical);
+				getChildView("tex gen")->setEnabled(editable);
+				
+				if (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)
+				{
+					// EXP-1507 (change label based on the mapping mode)
+					getChild<LLUICtrl>("rpt")->setValue(getString("string repeats per meter"));
+				}
+				else if (selected_texgen == LLTextureEntry::TEX_GEN_DEFAULT)
+				{
+					getChild<LLUICtrl>("rpt")->setValue(getString("string repeats per face"));
 				}
-
-			getChildView("combobox texgen")->setEnabled(editable);
-			getChild<LLUICtrl>("combobox texgen")->setTentative(!identical);
-			getChildView("tex gen")->setEnabled(editable);
-
-			if (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)
-			{
-				// EXP-1507 (change label based on the mapping mode)
-				getChild<LLUICtrl>("rpt")->setValue(getString("string repeats per meter"));
-			}
-			else
-			if (selected_texgen == LLTextureEntry::TEX_GEN_DEFAULT)
-			{
-				getChild<LLUICtrl>("rpt")->setValue(getString("string repeats per face"));
-			}
 			}
-
-		{
+			
 			U8 fullbright_flag = 0;
 			bool identical_fullbright = false;
 			
 			LLSelectedTE::getFullbright(fullbright_flag,identical_fullbright);
-
+			
 			getChild<LLUICtrl>("checkbox fullbright")->setValue(fullbright_flag != 0);
 			getChildView("checkbox fullbright")->setEnabled(editable);
 			getChild<LLUICtrl>("checkbox fullbright")->setTentative(!identical_fullbright);
-		}
-		
-		// Repeats per meter
-		{
-			F32 repeats_diff = 1.f;
-			F32 repeats_norm = 1.f;
-			F32 repeats_spec = 1.f;
-
-			bool identical_diff_repeats = false;
-			bool identical_norm_repeats = false;
-			bool identical_spec_repeats = false;
-
-			LLSelectedTE::getMaxDiffuseRepeats(repeats_diff, identical_diff_repeats);
-			LLSelectedTEMaterial::getMaxNormalRepeats(repeats_norm, identical_norm_repeats);
-			LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats);			
-
-			LLComboBox*	mComboTexGen = getChild<LLComboBox>("combobox texgen");
-			if (mComboTexGen)
-		{
+			
+			// Repeats per meter
+			{
+				F32 repeats_diff = 1.f;
+				F32 repeats_norm = 1.f;
+				F32 repeats_spec = 1.f;
+				
+				bool identical_diff_repeats = false;
+				bool identical_norm_repeats = false;
+				bool identical_spec_repeats = false;
+				
+				LLSelectedTE::getMaxDiffuseRepeats(repeats_diff, identical_diff_repeats);
+				LLSelectedTEMaterial::getMaxNormalRepeats(repeats_norm, identical_norm_repeats);
+				LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats);
+				
+				LLComboBox*	mComboTexGen = getChild<LLComboBox>("combobox texgen");
 				S32 index = mComboTexGen ? mComboTexGen->getCurrentIndex() : 0;
 				BOOL enabled = editable && (index != 1);
 				BOOL identical_repeats = true;
 				F32  repeats = 1.0f;
-
+				
 				U32 material_type = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? combobox_mattype->getCurrentIndex() : MATTYPE_DIFFUSE;
-
+				
 				LLSelectMgr::getInstance()->setTextureChannel(LLRender::eTexIndex(material_type));
-
+				
 				switch (material_type)
-			{
+				{
 					default:
 					case MATTYPE_DIFFUSE:
-				{
 						enabled = editable && !id.isNull();
 						identical_repeats = identical_diff_repeats;
 						repeats = repeats_diff;
-				}
-					break;
-
+						break;
+						
 					case MATTYPE_SPECULAR:
-			{
 						enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull()));
 						identical_repeats = identical_spec_repeats;
 						repeats = repeats_spec;
-			}
-					break;
-
+						break;
+						
 					case MATTYPE_NORMAL:
-			{
 						enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull()));
 						identical_repeats = identical_norm_repeats;
 						repeats = repeats_norm;
-					}
-					break;
+						break;
 				}
-
+				
 				BOOL repeats_tentative = !identical_repeats;
-
 				getChildView("rptctrl")->setEnabled(identical_planar_texgen ? FALSE : enabled);
 				getChild<LLUICtrl>("rptctrl")->setValue(editable ? repeats : 1.0f);
 				getChild<LLUICtrl>("rptctrl")->setTentative(LLSD(repeats_tentative));
 			}
-		}
-
-		// Materials
-		{
+			
+			// Materials
 			LLMaterialPtr material;
 			LLSelectedTEMaterial::getCurrent(material, identical);
-
+			
 			if (material && editable)
 			{
-				LL_DEBUGS("Materials: OnMatererialsLoaded:") << material->asLLSD() << LL_ENDL;
-
+				LL_DEBUGS("Materials") << " OnMatererialsLoaded: " << material->asLLSD() << LL_ENDL;
+				
 				// Alpha
-				LLCtrlSelectionInterface* combobox_alphamode =
-					childGetSelectionInterface("combobox alphamode");
+				LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode");
 				if (combobox_alphamode)
 				{
 					U32 alpha_mode = material->getDiffuseAlphaMode();
-
+					
 					if (transparency > 0.f)
-					{ //it is invalid to have any alpha mode other than blend if transparency is greater than zero ... 
+					{ //it is invalid to have any alpha mode other than blend if transparency is greater than zero ...
 						alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND;
 					}
-
+					
 					if (!mIsAlpha)
 					{ // ... unless there is no alpha channel in the texture, in which case alpha mode MUST ebe none
 						alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
-				}
-
+					}
+					
 					combobox_alphamode->selectNthItem(alpha_mode);
-			}
-			else
-			{
+				}
+				else
+				{
 					LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL;
-			}
+				}
 				getChild<LLUICtrl>("maskcutoff")->setValue(material->getAlphaMaskCutoff());
 				updateAlphaControls();
-
+				
 				identical_planar_texgen = isIdenticalPlanarTexgen();
-
+				
 				// Shiny (specular)
 				F32 offset_x, offset_y, repeat_x, repeat_y, rot;
 				LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
 				texture_ctrl->setImageAssetID(material->getSpecularID());
-
+				
 				if (!material->getSpecularID().isNull() && (shiny == SHINY_TEXTURE))
-			{
+				{
 					material->getSpecularOffset(offset_x,offset_y);
 					material->getSpecularRepeat(repeat_x,repeat_y);
-
+					
 					if (identical_planar_texgen)
-			{
+					{
 						repeat_x *= 2.0f;
 						repeat_y *= 2.0f;
-			}
-
+					}
+					
 					rot = material->getSpecularRotation();
 					getChild<LLUICtrl>("shinyScaleU")->setValue(repeat_x);
 					getChild<LLUICtrl>("shinyScaleV")->setValue(repeat_y);
@@ -1290,10 +1164,10 @@ void LLPanelFace::updateUI()
 					getChild<LLUICtrl>("shinyOffsetV")->setValue(offset_y);
 					getChild<LLUICtrl>("glossiness")->setValue(material->getSpecularLightExponent());
 					getChild<LLUICtrl>("environment")->setValue(material->getEnvironmentIntensity());
-
+					
 					updateShinyControls(!material->getSpecularID().isNull(), true);
-		}
-
+				}
+				
 				// Assert desired colorswatch color to match material AFTER updateShinyControls
 				// to avoid getting overwritten with the default on some UI state changes.
 				//
@@ -1302,92 +1176,90 @@ void LLPanelFace::updateUI()
 					getChild<LLColorSwatchCtrl>("shinycolorswatch")->setOriginal(material->getSpecularLightColor());
 					getChild<LLColorSwatchCtrl>("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE);
 				}
-
+				
 				// Bumpy (normal)
 				texture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
 				texture_ctrl->setImageAssetID(material->getNormalID());
-
+				
 				if (!material->getNormalID().isNull())
 				{
 					material->getNormalOffset(offset_x,offset_y);
 					material->getNormalRepeat(repeat_x,repeat_y);
-
+					
 					if (identical_planar_texgen)
 					{
 						repeat_x *= 2.0f;
 						repeat_y *= 2.0f;
 					}
-			
+					
 					rot = material->getNormalRotation();
 					getChild<LLUICtrl>("bumpyScaleU")->setValue(repeat_x);
 					getChild<LLUICtrl>("bumpyScaleV")->setValue(repeat_y);
 					getChild<LLUICtrl>("bumpyRot")->setValue(rot*RAD_TO_DEG);
 					getChild<LLUICtrl>("bumpyOffsetU")->setValue(offset_x);
 					getChild<LLUICtrl>("bumpyOffsetV")->setValue(offset_y);
-
+					
 					updateBumpyControls(!material->getNormalID().isNull(), true);
 				}
 			}
+			
+			
+			// Set variable values for numeric expressions
+			LLCalc* calcp = LLCalc::getInstance();
+			calcp->setVar(LLCalc::TEX_U_SCALE, childGetValue("TexScaleU").asReal());
+			calcp->setVar(LLCalc::TEX_V_SCALE, childGetValue("TexScaleV").asReal());
+			calcp->setVar(LLCalc::TEX_U_OFFSET, childGetValue("TexOffsetU").asReal());
+			calcp->setVar(LLCalc::TEX_V_OFFSET, childGetValue("TexOffsetV").asReal());
+			calcp->setVar(LLCalc::TEX_ROTATION, childGetValue("TexRot").asReal());
+			calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal());
+			calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal());
 		}
-
-		// Set variable values for numeric expressions
-		LLCalc* calcp = LLCalc::getInstance();
-		calcp->setVar(LLCalc::TEX_U_SCALE, childGetValue("TexScaleU").asReal());
-		calcp->setVar(LLCalc::TEX_V_SCALE, childGetValue("TexScaleV").asReal());
-		calcp->setVar(LLCalc::TEX_U_OFFSET, childGetValue("TexOffsetU").asReal());
-		calcp->setVar(LLCalc::TEX_V_OFFSET, childGetValue("TexOffsetV").asReal());
-		calcp->setVar(LLCalc::TEX_ROTATION, childGetValue("TexRot").asReal());
-		calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal());
-		calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal());
-	}
-	else
-	{
-		// Disable all UICtrls
-		clearCtrls();
-
-		// Disable non-UICtrls
-		LLTextureCtrl*	texture_ctrl = getChild<LLTextureCtrl>("texture control"); 
-		if(texture_ctrl)
-		{
-			texture_ctrl->setImageAssetID( LLUUID::null );
-			texture_ctrl->setEnabled( FALSE );  // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl.
-// 			texture_ctrl->setValid(FALSE);
-		}
-		LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
-		if(mColorSwatch)
+		else
 		{
-			mColorSwatch->setEnabled( FALSE );			
-			mColorSwatch->setFallbackImage(LLUI::getUIImage("locked_image.j2c") );
-			mColorSwatch->setValid(FALSE);
+			// Disable all UICtrls
+			clearCtrls();
+			
+			// Disable non-UICtrls
+			LLTextureCtrl*	texture_ctrl = getChild<LLTextureCtrl>("texture control");
+			if(texture_ctrl)
+			{
+				texture_ctrl->setImageAssetID( LLUUID::null );
+				texture_ctrl->setEnabled( FALSE );  // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl.
+			}
+			LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
+			if(mColorSwatch)
+			{
+				mColorSwatch->setEnabled( FALSE );
+				mColorSwatch->setFallbackImage(LLUI::getUIImage("locked_image.j2c") );
+				mColorSwatch->setValid(FALSE);
+			}
+			getChildView("color trans")->setEnabled(FALSE);
+			getChildView("rpt")->setEnabled(FALSE);
+			getChildView("tex offset")->setEnabled(FALSE);
+			getChildView("tex gen")->setEnabled(FALSE);
+			getChildView("label shininess")->setEnabled(FALSE);
+			getChildView("label bumpiness")->setEnabled(FALSE);
+			getChildView("button align")->setEnabled(FALSE);
+			//getChildView("has media")->setEnabled(FALSE);
+			//getChildView("media info set")->setEnabled(FALSE);
+			
+			updateVisibility();
+			
+			// Set variable values for numeric expressions
+			LLCalc* calcp = LLCalc::getInstance();
+			calcp->clearVar(LLCalc::TEX_U_SCALE);
+			calcp->clearVar(LLCalc::TEX_V_SCALE);
+			calcp->clearVar(LLCalc::TEX_U_OFFSET);
+			calcp->clearVar(LLCalc::TEX_V_OFFSET);
+			calcp->clearVar(LLCalc::TEX_ROTATION);
+			calcp->clearVar(LLCalc::TEX_TRANSPARENCY);
+			calcp->clearVar(LLCalc::TEX_GLOW);
 		}
-		getChildView("color trans")->setEnabled(FALSE);
-		getChildView("rpt")->setEnabled(FALSE);
-		getChildView("tex offset")->setEnabled(FALSE);
-		getChildView("tex gen")->setEnabled(FALSE);
-		getChildView("label shininess")->setEnabled(FALSE);
-		getChildView("label bumpiness")->setEnabled(FALSE);
-		getChildView("button align")->setEnabled(FALSE);
-		//getChildView("has media")->setEnabled(FALSE);
-		//getChildView("media info set")->setEnabled(FALSE);
-		
-		updateVisibility();
-
-		// Set variable values for numeric expressions
-		LLCalc* calcp = LLCalc::getInstance();
-		calcp->clearVar(LLCalc::TEX_U_SCALE);
-		calcp->clearVar(LLCalc::TEX_V_SCALE);
-		calcp->clearVar(LLCalc::TEX_U_OFFSET);
-		calcp->clearVar(LLCalc::TEX_V_OFFSET);
-		calcp->clearVar(LLCalc::TEX_ROTATION);
-		calcp->clearVar(LLCalc::TEX_TRANSPARENCY);
-		calcp->clearVar(LLCalc::TEX_GLOW);		
 	}
 }
 
-
 void LLPanelFace::refresh()
 {
-	LL_DEBUGS("Materials") << LL_ENDL;
 	getState();
 }
 
@@ -1398,7 +1270,7 @@ void LLPanelFace::refresh()
 // static
 F32 LLPanelFace::valueGlow(LLViewerObject* object, S32 face)
 {
-	return (F32)(object->getTE(face)->getGlow());
+	return object->getTE(face)->getGlow();
 }
 
 
@@ -1456,13 +1328,7 @@ void LLPanelFace::updateVisibility()
 {	
 	LLComboBox* combo_matmedia = getChild<LLComboBox>("combobox matmedia");
 	LLComboBox* combo_mattype = getChild<LLComboBox>("combobox mattype");
-	LLComboBox* combo_shininess = getChild<LLComboBox>("combobox shininess");
-	LLComboBox* combo_bumpiness = getChild<LLComboBox>("combobox bumpiness");
-	if (!combo_mattype || !combo_matmedia || !combo_shininess || !combo_bumpiness)
-	{
-		LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL;
-		return;
-	}
+
 	U32 materials_media = combo_matmedia->getCurrentIndex();
 	U32 material_type = combo_mattype->getCurrentIndex();
 	bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled();
-- 
GitLab