summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelface.cpp')
-rwxr-xr-x[-rw-r--r--]indra/newview/llpanelface.cpp405
1 files changed, 238 insertions, 167 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 032d066c48..b3b4932b65 100644..100755
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -120,7 +120,6 @@ BOOL LLPanelFace::postBuild()
childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterial, this);
childSetAction("button align",&LLPanelFace::onClickAutoFix,this);
- LLRect rect = this->getRect();
LLTextureCtrl* mTextureCtrl;
LLTextureCtrl* mShinyTextureCtrl;
LLTextureCtrl* mBumpyTextureCtrl;
@@ -159,9 +158,9 @@ BOOL LLPanelFace::postBuild()
if(mShinyTextureCtrl)
{
mShinyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" )));
- mShinyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitMaterialTexture, this, _2) );
- mShinyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelMaterialTexture, this, _2) );
- mShinyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectMaterialTexture, this, _2) );
+ 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->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
mShinyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
mShinyTextureCtrl->setFollowsTop();
@@ -174,9 +173,9 @@ BOOL LLPanelFace::postBuild()
if(mBumpyTextureCtrl)
{
mBumpyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" )));
- mBumpyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitMaterialTexture, this, _2) );
- mBumpyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelMaterialTexture, this, _2) );
- mBumpyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectMaterialTexture, this, _2) );
+ 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->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
mBumpyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
mBumpyTextureCtrl->setFollowsTop();
@@ -262,6 +261,7 @@ BOOL LLPanelFace::postBuild()
LLPanelFace::LLPanelFace()
: LLPanel(),
+ mMaterialID(LLMaterialID::null),
mMaterial(LLMaterialPtr()),
mIsAlpha(false)
{
@@ -299,18 +299,18 @@ void LLPanelFace::sendBump()
U32 bumpiness = mComboBumpiness->getCurrentIndex();
if (bumpiness < BUMPY_TEXTURE)
{
- LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
- //texture_ctrl->setImageAssetID(LLUUID());
- texture_ctrl->clear();
+ LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL;
+ LLTextureCtrl* bumpytexture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
+ bumpytexture_ctrl->clear();
LLSD dummy_data;
- onSelectMaterialTexture(dummy_data);
+ onSelectNormalTexture(dummy_data);
}
U8 bump = (U8) bumpiness & TEM_BUMP_MASK;
LLSelectMgr::getInstance()->selectionSetBumpmap( bump );
//refresh material state (in case this change impacts material params)
LLSD dummy_data;
- onCommitMaterialTexture(dummy_data);
+ onCommitNormalTexture(dummy_data);
}
void LLPanelFace::sendTexGen()
@@ -333,6 +333,10 @@ void LLPanelFace::sendShiny()
}
U8 shiny = (U8) shininess & TEM_SHINY_MASK;
LLSelectMgr::getInstance()->selectionSetShiny( shiny );
+
+ //refresh material state (in case this change impacts material params)
+ LLSD dummy_data;
+ onCommitSpecularTexture(dummy_data);
}
void LLPanelFace::sendFullbright()
@@ -396,10 +400,6 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
if (valid)
{
value = ctrlTexScaleS->get();
- //if( checkFlipScaleS->get() )
- //{
- // value = -value;
- //}
if (comboTexGen &&
comboTexGen->getCurrentIndex() == 1)
{
@@ -634,20 +634,11 @@ void LLPanelFace::getState()
}
else
{
- llwarns << "failed getChild for 'combobox mattype'" << llendl;
+ LL_WARNS("Materials") << "failed getChild for 'combobox mattype'" << LL_ENDL;
}
getChildView("combobox mattype")->setEnabled(editable);
onCommitMaterialsMedia(NULL, this);
-
- //if ( LLMediaEngine::getInstance()->getMediaRenderer () )
- // if ( LLMediaEngine::getInstance()->getMediaRenderer ()->isLoaded () )
- // {
- //
- // //mLabelTexAutoFix->setEnabled ( editable );
- //
- // //mBtnAutoFix->setEnabled ( editable );
- // }
bool identical;
bool identical_diffuse;
@@ -812,7 +803,7 @@ void LLPanelFace::getState()
updateAlphaControls(getChild<LLComboBox>("combobox alphamode"),this);
}
- if(texture_ctrl)
+ if(texture_ctrl && !texture_ctrl->isPickerShown())
{
if (identical_diffuse)
{
@@ -848,7 +839,7 @@ void LLPanelFace::getState()
}
}
- if (shinytexture_ctrl)
+ if (shinytexture_ctrl && !shinytexture_ctrl->isPickerShown())
{
if (identical_spec)
{
@@ -870,7 +861,7 @@ void LLPanelFace::getState()
}
}
- if (bumpytexture_ctrl)
+ if (bumpytexture_ctrl && !bumpytexture_ctrl->isPickerShown())
{
if (identical_norm)
{
@@ -1310,6 +1301,7 @@ void LLPanelFace::getState()
mColorSwatch->setEnabled( editable );
mColorSwatch->setCanApplyImmediately( editable );
}
+
// Color transparency
{
getChildView("color trans")->setEnabled(editable);
@@ -1376,14 +1368,10 @@ void LLPanelFace::getState()
getChild<LLUICtrl>("shinycolorswatch")->setTentative(!identical);
getChildView("label shinycolor")->setEnabled(editable);
}
- // NORSPEC-94: Set default specular color to white (will get
- // overwritten from material when loaded)
+
LLColorSwatchCtrl* mShinyColorSwatch = getChild<LLColorSwatchCtrl>("shinycolorswatch");
- color = LLColor4::white;
if(mShinyColorSwatch)
{
- mShinyColorSwatch->setOriginal(color);
- mShinyColorSwatch->set(color, TRUE);
mShinyColorSwatch->setValid(editable);
mShinyColorSwatch->setEnabled( editable );
mShinyColorSwatch->setCanApplyImmediately( editable );
@@ -1565,8 +1553,8 @@ void LLPanelFace::getState()
}
break;
}
-
- getChildView("rptctrl")->setEnabled(enabled);
+
+ getChildView("rptctrl")->setEnabled(identical_planar_texgen ? FALSE : enabled);
getChild<LLUICtrl>("rptctrl")->setValue(editable ? repeats : 1.0f);
getChild<LLUICtrl>("rptctrl")->setTentative(!identical);
}
@@ -1578,20 +1566,106 @@ void LLPanelFace::getState()
{
LLMaterialPtr get(LLViewerObject* object, S32 te_index)
{
- LLMaterialID material_id;
-
return object->getTE(te_index)->getMaterialParams();
}
} func;
LLMaterialPtr material;
- identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material );
-
- mMaterial = (material) ? new LLMaterial(*material) : NULL;
+ identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterial );
+
if (mMaterial && editable)
{
- onMaterialLoaded(mMaterial);
+ LL_DEBUGS("Materials: OnMatererialsLoaded:") << material->asLLSD() << LL_ENDL;
+
+ // Alpha
+ LLCtrlSelectionInterface* combobox_alphamode =
+ childGetSelectionInterface("combobox alphamode");
+ if (combobox_alphamode)
+ {
+ combobox_alphamode->selectNthItem(mMaterial->getDiffuseAlphaMode());
+ }
+ else
+ {
+ llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl;
+ }
+ getChild<LLUICtrl>("maskcutoff")->setValue(mMaterial->getAlphaMaskCutoff());
+ updateAlphaControls(getChild<LLComboBox>("combobox alphamode"),this);
+
+ LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
+ bool identical_texgen = true;
+ bool identical_planar_texgen = false;
+
+ struct f44 : public LLSelectedTEGetFunctor<LLTextureEntry::e_texgen>
+ {
+ LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face)
+ {
+ return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen());
+ }
+ } func;
+ identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen );
+ identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
+
+ // Shiny (specular)
+ F32 offset_x, offset_y, repeat_x, repeat_y, rot;
+ LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
+ texture_ctrl->setImageAssetID(mMaterial->getSpecularID());
+ LLComboBox* combobox_shininess = getChild<LLComboBox>("combobox shininess");
+ if (!mMaterial->getSpecularID().isNull())
+ {
+ mMaterial->getSpecularOffset(offset_x,offset_y);
+ mMaterial->getSpecularRepeat(repeat_x,repeat_y);
+
+ if (identical_planar_texgen)
+ {
+ repeat_x *= 2.0f;
+ repeat_y *= 2.0f;
+ }
+
+ rot = mMaterial->getSpecularRotation();
+ getChild<LLUICtrl>("shinyScaleU")->setValue(repeat_x);
+ getChild<LLUICtrl>("shinyScaleV")->setValue(repeat_y);
+ getChild<LLUICtrl>("shinyRot")->setValue(rot*RAD_TO_DEG);
+ getChild<LLUICtrl>("shinyOffsetU")->setValue(offset_x);
+ getChild<LLUICtrl>("shinyOffsetV")->setValue(offset_y);
+ getChild<LLUICtrl>("glossiness")->setValue(mMaterial->getSpecularLightExponent());
+ getChild<LLUICtrl>("environment")->setValue(mMaterial->getEnvironmentIntensity());
+ }
+ updateShinyControls(combobox_shininess,this, !mMaterial->getSpecularID().isNull(), true);
+
+ // Assert desired colorswatch color to match material AFTER updateShinyControls
+ // to avoid getting overwritten with the default on some UI state changes.
+ //
+ if (!mMaterial->getSpecularID().isNull())
+ {
+ getChild<LLColorSwatchCtrl>("shinycolorswatch")->setOriginal(mMaterial->getSpecularLightColor());
+ getChild<LLColorSwatchCtrl>("shinycolorswatch")->set(mMaterial->getSpecularLightColor(),TRUE);
+ }
+
+ // Bumpy (normal)
+ texture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
+ texture_ctrl->setImageAssetID(mMaterial->getNormalID());
+ LLComboBox* combobox_bumpiness = getChild<LLComboBox>("combobox bumpiness");
+ if (!mMaterial->getNormalID().isNull())
+ {
+ mMaterial->getNormalOffset(offset_x,offset_y);
+ mMaterial->getNormalRepeat(repeat_x,repeat_y);
+
+ if (identical_planar_texgen)
+ {
+ repeat_x *= 2.0f;
+ repeat_y *= 2.0f;
+ }
+
+ rot = mMaterial->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(combobox_bumpiness,this, !mMaterial->getNormalID().isNull(), true);
}
+
}
// Set variable values for numeric expressions
@@ -1652,93 +1726,10 @@ void LLPanelFace::getState()
void LLPanelFace::refresh()
{
+ LL_DEBUGS("Materials") << LL_ENDL;
getState();
}
-void LLPanelFace::onMaterialLoaded(const LLMaterialPtr material)
-{ //laying out UI based on material parameters (calls setVisible on various components)
- // Alpha
- LLCtrlSelectionInterface* combobox_alphamode =
- childGetSelectionInterface("combobox alphamode");
- if (combobox_alphamode)
- {
- combobox_alphamode->selectNthItem(material->getDiffuseAlphaMode());
- }
- else
- {
- llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl;
- }
- getChild<LLUICtrl>("maskcutoff")->setValue(material->getAlphaMaskCutoff());
- updateAlphaControls(getChild<LLComboBox>("combobox alphamode"),this);
-
- LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
- bool identical_texgen = true;
- bool identical_planar_texgen = false;
-
- struct f44 : public LLSelectedTEGetFunctor<LLTextureEntry::e_texgen>
- {
- LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face)
- {
- return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen());
- }
- } func;
- identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen );
- identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
-
- // Shiny (specular)
- F32 offset_x, offset_y, repeat_x, repeat_y, rot;
- LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
- texture_ctrl->setImageAssetID(material->getSpecularID());
- LLComboBox* combobox_shininess = getChild<LLComboBox>("combobox shininess");
- if (!material->getSpecularID().isNull())
- {
- 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);
- getChild<LLUICtrl>("shinyRot")->setValue(rot*RAD_TO_DEG);
- getChild<LLUICtrl>("shinyOffsetU")->setValue(offset_x);
- getChild<LLUICtrl>("shinyOffsetV")->setValue(offset_y);
- getChild<LLColorSwatchCtrl>("shinycolorswatch")->setOriginal(material->getSpecularLightColor());
- getChild<LLColorSwatchCtrl>("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE);
- getChild<LLUICtrl>("glossiness")->setValue((F32)(material->getSpecularLightExponent())/255.0);
- getChild<LLUICtrl>("environment")->setValue((F32)(material->getEnvironmentIntensity())/255.0);
- }
- updateShinyControls(combobox_shininess,this, true);
-
- // Bumpy (normal)
- texture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
- texture_ctrl->setImageAssetID(material->getNormalID());
- LLComboBox* combobox_bumpiness = getChild<LLComboBox>("combobox bumpiness");
- 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(combobox_bumpiness,this, true);
-}
-
void LLPanelFace::updateMaterial()
{ // assign current state of UI to material definition for submit to sim
LL_DEBUGS("Materials") << "Entered." << LL_ENDL;
@@ -1764,19 +1755,35 @@ void LLPanelFace::updateMaterial()
bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen );
bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
- if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND))
+ bool is_default_blend_mode = mIsAlpha ? (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)
+ : (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
+
+ if ( !is_default_blend_mode
|| (bumpiness == BUMPY_TEXTURE)
|| (shininess == SHINY_TEXTURE))
{
// The user's specified something that needs a material.
- bool new_material = !mMaterial;
+ bool new_material = false;
+
+ // Create new or clone material
+ //
+ if (mMaterial.isNull())
+ {
+ mMaterial = LLMaterialPtr(new LLMaterial());
+ new_material = true;
+ }
+ else
+ {
+ mMaterial = LLMaterialPtr(new LLMaterial(mMaterial->asLLSD()));
+ }
+
+ llassert_always(mMaterial);
- mMaterial = LLMaterialPtr(new LLMaterial());
mMaterial->setDiffuseAlphaMode(getChild<LLComboBox>("combobox alphamode")->getCurrentIndex());
mMaterial->setAlphaMaskCutoff((U8)(getChild<LLUICtrl>("maskcutoff")->getValue().asInteger()));
LLUUID norm_map_id = getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID();
- if (bumpiness == BUMPY_TEXTURE)
+ if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE))
{
LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL;
mMaterial->setNormalID(norm_map_id);
@@ -1806,7 +1813,7 @@ void LLPanelFace::updateMaterial()
LLUUID spec_map_id = getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID();
- if (shininess == SHINY_TEXTURE)
+ if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE))
{
LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL;
mMaterial->setSpecularID(spec_map_id);
@@ -1829,8 +1836,8 @@ void LLPanelFace::updateMaterial()
if (!new_material)
{
mMaterial->setSpecularLightColor(getChild<LLColorSwatchCtrl>("shinycolorswatch")->get());
- mMaterial->setSpecularLightExponent((U8)(255*getChild<LLUICtrl>("glossiness")->getValue().asReal()));
- mMaterial->setEnvironmentIntensity((U8)(255*getChild<LLUICtrl>("environment")->getValue().asReal()));
+ mMaterial->setSpecularLightExponent(getChild<LLUICtrl>("glossiness")->getValue().asInteger());
+ mMaterial->setEnvironmentIntensity(getChild<LLUICtrl>("environment")->getValue().asInteger());
}
}
else
@@ -1846,15 +1853,18 @@ void LLPanelFace::updateMaterial()
}
LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL;
+
LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial );
}
else
{
// The user has specified settings that don't need a material.
- if (mMaterial)
+ //if (mMaterial || !mMaterialID.isNull())
{
LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL;
mMaterial = NULL;
+ mMaterialID = LLMaterialID::null;
+
// Delete existing material entry...
LLSelectMgr::getInstance()->selectionRemoveMaterial();
}
@@ -1908,17 +1918,17 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata)
LLComboBox* combo_bumpiness = self->getChild<LLComboBox>("combobox bumpiness");
if (!combo_mattype || !combo_matmedia || !combo_shininess || !combo_bumpiness)
{
- llwarns << "Combo box not found...exiting." << llendl;
+ 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();
- bool show_texture = (!show_media) && (material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled();
+ bool show_texture = (show_media || ((material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled()));
bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled();
bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled();
self->getChildView("combobox mattype")->setVisible(!show_media);
- self->getChildView("rptctrl")->setVisible(!show_media);
+ self->getChildView("rptctrl")->setVisible(true);
// Media controls
self->getChildView("media_info")->setVisible(show_media);
@@ -1927,12 +1937,12 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata)
self->getChildView("button align")->setVisible(show_media);
// Diffuse texture controls
- self->getChildView("texture control")->setVisible(show_texture);
- self->getChildView("label alphamode")->setVisible(show_texture);
- self->getChildView("combobox alphamode")->setVisible(show_texture);
+ self->getChildView("texture control")->setVisible(show_texture && !show_media);
+ self->getChildView("label alphamode")->setVisible(show_texture && !show_media);
+ self->getChildView("combobox alphamode")->setVisible(show_texture && !show_media);
self->getChildView("label maskcutoff")->setVisible(false);
self->getChildView("maskcutoff")->setVisible(false);
- if (show_texture)
+ if (show_texture && !show_media)
{
updateAlphaControls(ctrl, userdata);
}
@@ -2024,10 +2034,8 @@ void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata)
self->sendBump();
LLComboBox* combo_bumpy = self->getChild<LLComboBox>("combobox bumpiness");
- // Need 'true' here to insure that the 'Use Texture' choice is removed
- // when we select something other than a spec texture
- //
- updateBumpyControls(combo_bumpy,self, true);
+
+ updateBumpyControls(combo_bumpy,self, false, true);
self->updateMaterial();
}
@@ -2039,7 +2047,7 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata)
}
// static
-void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool mess_with_shiny_combobox)
+void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_shiny_combobox)
{
LLPanelFace* self = (LLPanelFace*) userdata;
LLTextureCtrl* texture_ctrl = self->getChild<LLTextureCtrl>("shinytexture control");
@@ -2053,11 +2061,23 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool mess_
{
return;
}
- if (!shiny_texture_ID.isNull())
+ if (!shiny_texture_ID.isNull() && is_setting_texture)
{
if (!comboShiny->itemExists(USE_TEXTURE))
{
comboShiny->add(USE_TEXTURE);
+
+ // NORSPEC-94: Set default specular color to white
+ //
+ LLColorSwatchCtrl* mShinyColorSwatch = self->getChild<LLColorSwatchCtrl>("shinycolorswatch");
+ if(mShinyColorSwatch)
+ {
+ LL_DEBUGS("Materials") << "Resetting specular color to default of white" << LL_ENDL;
+ mShinyColorSwatch->setOriginal(LLColor4::white);
+ mShinyColorSwatch->set(LLColor4::white, TRUE);
+ }
+ self->getChild<LLUICtrl>("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT);
+ self->getChild<LLUICtrl>("environment")->setValue(0);
}
comboShiny->setSimple(USE_TEXTURE);
}
@@ -2089,12 +2109,12 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool mess_
}
// static
-void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool mess_with_combobox)
+void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_combobox)
{
LLPanelFace* self = (LLPanelFace*) userdata;
LLTextureCtrl* texture_ctrl = self->getChild<LLTextureCtrl>("bumpytexture control");
LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID();
- LL_DEBUGS("Materials") << "Bumpy texture selected: " << bumpy_texture_ID << LL_ENDL;
+ LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL;
LLComboBox* comboBumpy = self->getChild<LLComboBox>("combobox bumpiness");
if (!comboBumpy)
{
@@ -2103,7 +2123,11 @@ void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool mess_
if (mess_with_combobox)
{
- if (!bumpy_texture_ID.isNull())
+ LLTextureCtrl* texture_ctrl = self->getChild<LLTextureCtrl>("bumpytexture control");
+ LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID();
+ LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL;
+
+ if (!bumpy_texture_ID.isNull() && is_setting_texture)
{
if (!comboBumpy->itemExists(USE_TEXTURE))
{
@@ -2132,7 +2156,7 @@ void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata)
// Need 'true' here to insure that the 'Use Texture' choice is removed
// when we select something other than a spec texture
//
- updateShinyControls(combo_shiny,self, true);
+ updateShinyControls(combo_shiny,self, false, true);
self->updateMaterial();
}
@@ -2226,34 +2250,50 @@ void LLPanelFace::onSelectTexture(const LLSD& data)
sendTexture();
}
-void LLPanelFace::onCommitMaterialTexture( const LLSD& data )
+void LLPanelFace::onCommitSpecularTexture( const LLSD& data )
{
LL_DEBUGS("Materials") << data << LL_ENDL;
- updateMaterial();
LLComboBox* combo_shiny = getChild<LLComboBox>("combobox shininess");
- updateShinyControls(combo_shiny,this, true);
+ updateShinyControls(combo_shiny,this, true, true);
+ updateMaterial();
+}
+
+void LLPanelFace::onCommitNormalTexture( const LLSD& data )
+{
+ LL_DEBUGS("Materials") << data << LL_ENDL;
LLComboBox* combo_bumpy = getChild<LLComboBox>("combobox bumpiness");
- updateBumpyControls(combo_bumpy,this, true);
+ updateBumpyControls(combo_bumpy, this, true, true);
+ updateMaterial();
}
-void LLPanelFace::onCancelMaterialTexture(const LLSD& data)
+void LLPanelFace::onCancelSpecularTexture(const LLSD& data)
{
- // not sure what to do here other than
updateMaterial();
LLComboBox* combo_shiny = getChild<LLComboBox>("combobox shininess");
- updateShinyControls(combo_shiny,this, true);
+ updateShinyControls(combo_shiny,this, false, true);
+}
+
+void LLPanelFace::onCancelNormalTexture(const LLSD& data)
+{
+ updateMaterial();
LLComboBox* combo_bumpy = getChild<LLComboBox>("combobox bumpiness");
- updateBumpyControls(combo_bumpy,this, true);
+ updateBumpyControls(combo_bumpy,this, false, true);
}
-void LLPanelFace::onSelectMaterialTexture(const LLSD& data)
+void LLPanelFace::onSelectSpecularTexture(const LLSD& data)
{
LL_DEBUGS("Materials") << data << LL_ENDL;
updateMaterial();
LLComboBox* combo_shiny = getChild<LLComboBox>("combobox shininess");
- updateShinyControls(combo_shiny,this, true);
+ updateShinyControls(combo_shiny,this, true, true);
+}
+
+void LLPanelFace::onSelectNormalTexture(const LLSD& data)
+{
+ LL_DEBUGS("Materials") << data << LL_ENDL;
LLComboBox* combo_bumpy = getChild<LLComboBox>("combobox bumpiness");
- updateBumpyControls(combo_bumpy,this, true);
+ updateBumpyControls(combo_bumpy,this, true, true);
+ updateMaterial();
}
//static
@@ -2283,8 +2323,38 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata)
LLComboBox* combo_mattype = self->getChild<LLComboBox>("combobox mattype");
+ F32 obj_scale_s = 1.0f;
+ F32 obj_scale_t = 1.0f;
+
U32 material_type = combo_mattype->getCurrentIndex();
+ struct f_objscale_s : public LLSelectedTEGetFunctor<F32>
+ {
+ F32 get(LLViewerObject* object, S32 face)
+ {
+ U32 s_axis = VX;
+ U32 t_axis = VY;
+ LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
+ return object->getScale().mV[s_axis];
+ }
+
+ } scale_s_func;
+
+ struct f_objscale_t : public LLSelectedTEGetFunctor<F32>
+ {
+ F32 get(LLViewerObject* object, S32 face)
+ {
+ U32 s_axis = VX;
+ U32 t_axis = VY;
+ LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
+ return object->getScale().mV[t_axis];
+ }
+
+ } scale_t_func;
+
+ LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_s_func, obj_scale_s );
+ LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_t_func, obj_scale_t );
+
switch (material_type)
{
case MATTYPE_DIFFUSE:
@@ -2297,8 +2367,8 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata)
{
LLUICtrl* bumpy_scale_u = self->getChild<LLUICtrl>("bumpyScaleU");
LLUICtrl* bumpy_scale_v = self->getChild<LLUICtrl>("bumpyScaleV");
- bumpy_scale_u->setValue(bumpy_scale_u->getValue().asReal() * repeats_per_meter);
- bumpy_scale_v->setValue(bumpy_scale_v->getValue().asReal() * repeats_per_meter);
+ bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter);
+ bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter);
self->updateMaterial();
}
break;
@@ -2307,8 +2377,8 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata)
{
LLUICtrl* shiny_scale_u = self->getChild<LLUICtrl>("shinyScaleU");
LLUICtrl* shiny_scale_v = self->getChild<LLUICtrl>("shinyScaleV");
- shiny_scale_u->setValue(shiny_scale_u->getValue().asReal() * repeats_per_meter);
- shiny_scale_v->setValue(shiny_scale_v->getValue().asReal() * repeats_per_meter);
+ shiny_scale_u->setValue(obj_scale_s * repeats_per_meter);
+ shiny_scale_v->setValue(obj_scale_t * repeats_per_meter);
self->updateMaterial();
}
break;
@@ -2390,6 +2460,7 @@ void LLPanelFace::onCommitPlanarAlign(LLUICtrl* ctrl, void* userdata)
void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp)
{
+ LL_DEBUGS("Materials") << "item asset " << itemp->getAssetUUID() << LL_ENDL;
LLComboBox* combo_mattype = getChild<LLComboBox>("combobox mattype");
if (!combo_mattype)
{
@@ -2407,7 +2478,7 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp)
break;
// no default needed
}
-
+ LL_DEBUGS("Materials") << "control " << which_control << LL_ENDL;
LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(which_control);
if (texture_ctrl)
{