From 5f03e197f4cfb43de93dc42b16b54beafccd376a Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 25 Jan 2013 17:54:38 -0500 Subject: Trying to set materials up for rendering! Yay! --- indra/newview/llselectmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c3c37141ed..ff4c120623 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1927,7 +1927,7 @@ void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) llassert(mMediaData.isMap()); const LLTextureEntry *texture_entry = object->getTE(te); if (!mMediaData.isMap() || - (NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY)) + ((NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY))) { // skip adding/updating media } -- cgit v1.3 From 1751c965ba1ffd1a89a3b94542624e70cbde1060 Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Tue, 29 Jan 2013 21:19:58 -0600 Subject: Editing interface for normal and specular maps and other parameters. --- indra/newview/llpanelface.cpp | 430 +++++++++++++++++++-- indra/newview/llpanelface.h | 12 + indra/newview/llselectmgr.cpp | 32 ++ indra/newview/llselectmgr.h | 2 + .../skins/default/xui/en/panel_tools_texture.xml | 136 ++++++- 5 files changed, 579 insertions(+), 33 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 51bda4141d..f0daa96e19 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -46,6 +46,7 @@ #include "lldrawpoolbump.h" #include "llface.h" #include "lllineeditor.h" +#include "llmaterialmgr.h" #include "llmediaentry.h" #include "llnotificationsutil.h" #include "llresmgr.h" @@ -59,6 +60,7 @@ #include "llviewercontrol.h" #include "llviewermedia.h" #include "llviewerobject.h" +#include "llviewerregion.h" #include "llviewerstats.h" #include "llvovolume.h" #include "lluictrlfactory.h" @@ -75,6 +77,7 @@ const S32 MATTYPE_DIFFUSE = 0; // Diffuse material texture const S32 MATTYPE_NORMAL = 1; // Normal map const S32 MATTYPE_SPECULAR = 2; // Specular map const S32 ALPHAMODE_NONE = 0; // No alpha mask applied +const S32 ALPHAMODE_BLEND = 1; // Alpha blending mode const S32 ALPHAMODE_MASK = 2; // Alpha masking mode const S32 BUMPY_TEXTURE = 18; // use supplied normal map const S32 SHINY_TEXTURE = 4; // use supplied specular map @@ -95,11 +98,27 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("checkbox planar align",&LLPanelFace::onCommitPlanarAlign, this); childSetCommitCallback("TexOffsetU",LLPanelFace::onCommitTextureInfo, this); childSetCommitCallback("TexOffsetV",LLPanelFace::onCommitTextureInfo, this); + childSetCommitCallback("bumpyScaleU",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("bumpyScaleV",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("bumpyRot",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("bumpyOffsetU",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("bumpyOffsetV",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("shinyScaleU",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("shinyScaleV",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("shinyRot",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("shinyOffsetU",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("shinyOffsetV",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("environment",&LLPanelFace::onCommitMaterial, this); + childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterial, this); childSetAction("button align",&LLPanelFace::onClickAutoFix,this); LLRect rect = this->getRect(); LLTextureCtrl* mTextureCtrl; + LLTextureCtrl* mShinyTextureCtrl; + LLTextureCtrl* mBumpyTextureCtrl; LLColorSwatchCtrl* mColorSwatch; + LLColorSwatchCtrl* mShinyColorSwatch; LLComboBox* mComboTexGen; LLComboBox* mComboMatMedia; @@ -129,6 +148,36 @@ BOOL LLPanelFace::postBuild() mTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); } + mShinyTextureCtrl = getChild("shinytexture control"); + 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->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2)); + mShinyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1)); + mShinyTextureCtrl->setFollowsTop(); + mShinyTextureCtrl->setFollowsLeft(); + mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mShinyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + } + + mBumpyTextureCtrl = getChild("bumpytexture control"); + 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->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2)); + mBumpyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1)); + mBumpyTextureCtrl->setFollowsTop(); + mBumpyTextureCtrl->setFollowsLeft(); + mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mBumpyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + } + mColorSwatch = getChild("colorswatch"); if(mColorSwatch) { @@ -140,6 +189,15 @@ BOOL LLPanelFace::postBuild() mColorSwatch->setCanApplyImmediately(TRUE); } + mShinyColorSwatch = getChild("shinycolorswatch"); + if(mShinyColorSwatch) + { + mShinyColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitShinyColor, this, _2)); + mShinyColorSwatch->setFollowsTop(); + mShinyColorSwatch->setFollowsLeft(); + mShinyColorSwatch->setCanApplyImmediately(TRUE); + } + mLabelColorTransp = getChild("color trans"); if(mLabelColorTransp) { @@ -196,7 +254,10 @@ BOOL LLPanelFace::postBuild() } LLPanelFace::LLPanelFace() -: LLPanel() +: LLPanel(), + mMaterialID(LLMaterialID::null), + mMaterial(LLMaterialPtr()), + mIsAlpha(FALSE) { } @@ -563,6 +624,8 @@ void LLPanelFace::getState() bool identical; LLTextureCtrl* texture_ctrl = getChild("texture control"); + LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); + LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); // Texture { @@ -597,39 +660,46 @@ void LLPanelFace::getState() } func; identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); - BOOL is_alpha = FALSE; - struct f2 : public LLSelectedTEGetFunctor + mIsAlpha = FALSE; + LLGLenum image_format; + struct f2 : public LLSelectedTEGetFunctor { - BOOL get(LLViewerObject* object, S32 te_index) + LLGLenum get(LLViewerObject* object, S32 te_index) { - BOOL is_alpha = FALSE; + LLGLenum image_format; LLViewerTexture* image = object->getTEImage(te_index); - if (image) is_alpha = image->getIsAlphaMask(); - return is_alpha; + if (image) image_format = image->getPrimaryFormat(); + return image_format; } } func2; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, is_alpha ); + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + mIsAlpha = image_format != GL_RGB; if(LLViewerMedia::textureHasMedia(id)) { getChildView("button align")->setEnabled(editable); } - if (!is_alpha) { - // Selected texture has no alpha, force alpha mode None + // Default alpha mode to None if texture has no alpha, or Alpha Blending if present + // Will be overridden later if a material is present for this face + S32 default_alpha = ALPHAMODE_NONE; + if (mIsAlpha) + { + default_alpha = ALPHAMODE_BLEND; + } LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); if (combobox_alphamode) { - combobox_alphamode->selectNthItem(ALPHAMODE_NONE); + combobox_alphamode->selectNthItem(default_alpha); } else { llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } - onCommitAlphaMode(getChild("combobox alpha"),this); + onCommitAlphaMode(getChild("combobox alphamode"),this); } if (identical) @@ -640,10 +710,16 @@ void LLPanelFace::getState() texture_ctrl->setTentative( FALSE ); texture_ctrl->setEnabled( editable ); texture_ctrl->setImageAssetID( id ); - getChildView("combobox alphamode")->setEnabled(editable && is_alpha); - getChildView("label alphamode")->setEnabled(editable && is_alpha); - getChildView("maskcutoff")->setEnabled(editable && is_alpha); - getChildView("label maskcutoff")->setEnabled(editable && is_alpha); + shinytexture_ctrl->setTentative( FALSE ); + shinytexture_ctrl->setEnabled( editable ); + shinytexture_ctrl->setImageAssetID( id ); + bumpytexture_ctrl->setTentative( FALSE ); + bumpytexture_ctrl->setEnabled( editable ); + bumpytexture_ctrl->setImageAssetID( id ); + getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha); + getChildView("label alphamode")->setEnabled(editable && mIsAlpha); + getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); + getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha); } } else @@ -656,6 +732,12 @@ void LLPanelFace::getState() texture_ctrl->setTentative( FALSE ); texture_ctrl->setEnabled( FALSE ); texture_ctrl->setImageAssetID( LLUUID::null ); + shinytexture_ctrl->setTentative( FALSE ); + shinytexture_ctrl->setEnabled( FALSE ); + shinytexture_ctrl->setImageAssetID( LLUUID::null ); + bumpytexture_ctrl->setTentative( FALSE ); + bumpytexture_ctrl->setEnabled( FALSE ); + bumpytexture_ctrl->setImageAssetID( LLUUID::null ); getChildView("combobox alphamode")->setEnabled( FALSE ); getChildView("label alphamode")->setEnabled( FALSE ); getChildView("maskcutoff")->setEnabled( FALSE); @@ -667,10 +749,16 @@ void LLPanelFace::getState() texture_ctrl->setTentative( TRUE ); texture_ctrl->setEnabled( editable ); texture_ctrl->setImageAssetID( id ); - getChildView("combobox alphamode")->setEnabled(editable && is_alpha); - getChildView("label alphamode")->setEnabled(editable && is_alpha); - getChildView("maskcutoff")->setEnabled(editable && is_alpha); - getChildView("label maskcutoff")->setEnabled(editable && is_alpha); + shinytexture_ctrl->setTentative( TRUE ); + shinytexture_ctrl->setEnabled( editable ); + shinytexture_ctrl->setImageAssetID( id ); + bumpytexture_ctrl->setTentative( TRUE ); + bumpytexture_ctrl->setEnabled( editable ); + bumpytexture_ctrl->setImageAssetID( id ); + getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha); + getChildView("label alphamode")->setEnabled(editable && mIsAlpha); + getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); + getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha); } } } @@ -729,6 +817,12 @@ void LLPanelFace::getState() getChild("TexScaleU")->setValue(editable ? scale_s : 0); getChild("TexScaleU")->setTentative(LLSD((BOOL)(!identical))); getChildView("TexScaleU")->setEnabled(editable); + getChild("shinyScaleU")->setValue(editable ? scale_s : 0); + getChild("shinyScaleU")->setTentative(LLSD((BOOL)(!identical))); + getChildView("shinyScaleU")->setEnabled(FALSE); + getChild("bumpyScaleU")->setValue(editable ? scale_s : 0); + getChild("bumpyScaleU")->setTentative(LLSD((BOOL)(!identical))); + getChildView("bumpyScaleU")->setEnabled(FALSE); } { @@ -746,6 +840,12 @@ void LLPanelFace::getState() getChild("TexScaleV")->setValue(editable ? scale_t : 0); getChild("TexScaleV")->setTentative(LLSD((BOOL)(!identical))); getChildView("TexScaleV")->setEnabled(editable); + getChild("shinyScaleV")->setValue(editable ? scale_t : 0); + getChild("shinyScaleV")->setTentative(LLSD((BOOL)(!identical))); + getChildView("shinyScaleV")->setEnabled(FALSE); + getChild("bumpyScaleV")->setValue(editable ? scale_t : 0); + getChild("bumpyScaleV")->setTentative(LLSD((BOOL)(!identical))); + getChildView("bumpyScaleV")->setEnabled(FALSE); } // Texture offset @@ -764,6 +864,12 @@ void LLPanelFace::getState() getChild("TexOffsetU")->setValue(editable ? offset_s : 0); getChild("TexOffsetU")->setTentative(!identical); getChildView("TexOffsetU")->setEnabled(editable); + getChild("shinyOffsetU")->setValue(editable ? offset_s : 0); + getChild("shinyOffsetU")->setTentative(!identical); + getChildView("shinyOffsetU")->setEnabled(FALSE); + getChild("bumpyOffsetU")->setValue(editable ? offset_s : 0); + getChild("bumpyOffsetU")->setTentative(!identical); + getChildView("bumpyOffsetU")->setEnabled(FALSE); } { @@ -780,6 +886,12 @@ void LLPanelFace::getState() getChild("TexOffsetV")->setValue(editable ? offset_t : 0); getChild("TexOffsetV")->setTentative(!identical); getChildView("TexOffsetV")->setEnabled(editable); + getChild("shinyOffsetV")->setValue(editable ? offset_t : 0); + getChild("shinyOffsetV")->setTentative(!identical); + getChildView("shinyOffsetV")->setEnabled(FALSE); + getChild("bumpyOffsetV")->setValue(editable ? offset_t : 0); + getChild("bumpyOffsetV")->setTentative(!identical); + getChildView("bumpyOffsetV")->setEnabled(FALSE); } // Texture rotation @@ -797,6 +909,12 @@ void LLPanelFace::getState() getChild("TexRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); getChild("TexRot")->setTentative(!identical); getChildView("TexRot")->setEnabled(editable); + getChild("shinyRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); + getChild("shinyRot")->setTentative(!identical); + getChildView("shinyRot")->setEnabled(FALSE); + getChild("bumpyRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); + getChild("bumpyRot")->setTentative(!identical); + getChildView("bumpyRot")->setEnabled(FALSE); } // Color swatch @@ -852,7 +970,7 @@ void LLPanelFace::getState() } - // Bump + // Shiny { F32 shinyf = 0.f; struct f9 : public LLSelectedTEGetFunctor @@ -887,6 +1005,7 @@ void LLPanelFace::getState() getChildView("label shinycolor")->setEnabled(editable); } + // Bumpy { F32 bumpf = 0.f; struct f10 : public LLSelectedTEGetFunctor @@ -941,6 +1060,10 @@ void LLPanelFace::getState() { getChild("TexScaleU")->setValue(2.0f * getChild("TexScaleU")->getValue().asReal() ); getChild("TexScaleV")->setValue(2.0f * getChild("TexScaleV")->getValue().asReal() ); + getChild("shinyScaleU")->setValue(2.0f * getChild("TexScaleU")->getValue().asReal() ); + getChild("shinyScaleV")->setValue(2.0f * getChild("TexScaleV")->getValue().asReal() ); + getChild("bumpyScaleU")->setValue(2.0f * getChild("TexScaleU")->getValue().asReal() ); + getChild("bumpyScaleV")->setValue(2.0f * getChild("TexScaleV")->getValue().asReal() ); // EXP-1507 (change label based on the mapping mode) getChild("rpt")->setValue(getString("string repeats per meter")); @@ -1000,6 +1123,29 @@ void LLPanelFace::getState() } } + // Materials + { + mMaterialID = LLMaterialID::null; + //mMaterial = LLMaterialPtr(); + struct f1 : public LLSelectedTEGetFunctor + { + LLMaterialID get(LLViewerObject* object, S32 te_index) + { + LLMaterialID material_id; + + return object->getTE(te_index)->getMaterialID(); + } + } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterialID ); + llinfos << "Material ID returned: '" + << mMaterialID.asString() << "', isNull? " + << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; + if (!mMaterialID.isNull() && editable) + { + LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); + } + } + // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); calcp->setVar(LLCalc::TEX_U_SCALE, childGetValue("TexScaleU").asReal()); @@ -1041,6 +1187,8 @@ void LLPanelFace::getState() //getChildView("has media")->setEnabled(FALSE); //getChildView("media info set")->setEnabled(FALSE); + onCommitMaterialsMedia(NULL,this); + // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); calcp->clearVar(LLCalc::TEX_U_SCALE); @@ -1059,6 +1207,126 @@ void LLPanelFace::refresh() getState(); } +void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) +{ + llinfos << "Material loaded: " << material_id.asString() + << ", LLSD: " << material->asLLSD() << llendl; + mMaterial = material; + getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); + getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); + getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); + getChild("glossiness")->setValue((F32)(material->getSpecularLightExponent())/255.0); + getChild("environment")->setValue((F32)(material->getEnvironmentIntensity())/255.0); + LLCtrlSelectionInterface* combobox_alphamode = + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) + { + combobox_alphamode->selectNthItem(material->getDiffuseAlphaMode()); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; + } + onCommitAlphaMode(getChild("combobox alphamode"),this); + LLComboBox* comboMaterialType = getChild("combobox mattype"); + F32 offset_x, offset_y, repeat_x, repeat_y, rot; + if ((comboMaterialType->getCurrentIndex() == MATTYPE_SPECULAR) && + !material->getSpecularID().isNull()) + { + material->getSpecularOffset(offset_x,offset_y); + material->getSpecularRepeat(repeat_x,repeat_y); + rot = material->getSpecularRotation(); + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); + texture_ctrl->setImageAssetID(material->getSpecularID()); + LLCtrlSelectionInterface* combobox_shininess = + childGetSelectionInterface("combobox shininess"); + if (combobox_shininess) + { + combobox_shininess->selectNthItem(SHINY_TEXTURE); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox shininess'" << llendl; + } + getChild("shinyScaleU")->setValue(repeat_x); + getChild("shinyScaleV")->setValue(repeat_y); + getChild("shinyRot")->setValue(rot); + getChild("shinyOffsetU")->setValue(offset_x); + getChild("shinyOffsetV")->setValue(offset_y); + } + if ((comboMaterialType->getCurrentIndex() == MATTYPE_NORMAL) && + !material->getNormalID().isNull()) + { + material->getNormalOffset(offset_x,offset_y); + material->getNormalRepeat(repeat_x,repeat_y); + rot = material->getNormalRotation(); + LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(material->getNormalID()); + LLCtrlSelectionInterface* combobox_bumpiness = + childGetSelectionInterface("combobox bumpiness"); + if (combobox_bumpiness) + { + combobox_bumpiness->selectNthItem(BUMPY_TEXTURE); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox bumpiness'" << llendl; + } + getChild("bumpyScaleU")->setValue(repeat_x); + getChild("bumpyScaleV")->setValue(repeat_y); + getChild("bumpyRot")->setValue(rot); + getChild("bumpyOffsetU")->setValue(offset_x); + getChild("bumpyOffsetV")->setValue(offset_y); + } +} + +void LLPanelFace::updateMaterial() +{ + LLComboBox* comboAlphaMode = getChild("combobox alphamode"); + LLComboBox* comboBumpiness = getChild("combobox bumpiness"); + LLComboBox* comboShininess = getChild("combobox shininess"); + if (!comboAlphaMode || !comboBumpiness || !comboShininess) + { + return; + } + if ((mIsAlpha && (comboAlphaMode->getCurrentIndex() != ALPHAMODE_BLEND)) + || (comboBumpiness->getCurrentIndex() != BUMPY_TEXTURE) + || (comboShininess->getCurrentIndex() != SHINY_TEXTURE)) + { + // The user's specified something that needs a material. + if (!mMaterial) + { + mMaterial = LLMaterialPtr(new LLMaterial()); + } + mMaterial->setNormalID(getChild("bumpytexture control")->getImageAssetID()); + mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), + getChild("bumpyOffsetV")->getValue().asReal()); + mMaterial->setNormalRepeat(getChild("bumpyScaleU")->getValue().asReal(), + getChild("bumpyScaleV")->getValue().asReal()); + mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()); + mMaterial->setSpecularID(getChild("shinytexture control")->getImageAssetID()); + mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), + getChild("shinyOffsetV")->getValue().asReal()); + mMaterial->setSpecularRepeat(getChild("shinyScaleU")->getValue().asReal(), + getChild("shinyScaleV")->getValue().asReal()); + mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()); + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent((U8)(255*getChild("glossiness")->getValue().asReal())); + mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + } + else + { + // The user has specified settings that don't need a material. + if (mMaterial) + { + mMaterial.reset(); + } + } + LLSelectMgr::getInstance()->selectionSetMaterial( *mMaterial ); +} + // // Static functions // @@ -1075,6 +1343,11 @@ void LLPanelFace::onCommitColor(const LLSD& data) sendColor(); } +void LLPanelFace::onCommitShinyColor(const LLSD& data) +{ + updateMaterial(); +} + void LLPanelFace::onCommitAlpha(const LLSD& data) { sendAlpha(); @@ -1095,27 +1368,33 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* comboMaterialsMedia = self->getChild("combobox matmedia"); - if (!comboMaterialsMedia) + // Get material info so we can use it later + if (self->mMaterial) { - return; + self->onMaterialLoaded(self->mMaterialID,self->mMaterial); } - U32 materials_media = comboMaterialsMedia->getCurrentIndex(); + LLComboBox* comboMaterialsMedia = self->getChild("combobox matmedia"); LLComboBox* comboMaterialType = self->getChild("combobox mattype"); - if (!comboMaterialType) + if (!comboMaterialType || !comboMaterialsMedia) { return; } + U32 materials_media = comboMaterialsMedia->getCurrentIndex(); U32 material_type = comboMaterialType->getCurrentIndex(); - bool show_media = (materials_media == MATMEDIA_MEDIA); - bool show_texture = (!show_media) && (material_type == MATTYPE_DIFFUSE); - bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR); + bool show_media = (materials_media == MATMEDIA_MEDIA) && comboMaterialsMedia->getEnabled(); + bool show_texture = (!show_media) && (material_type == MATTYPE_DIFFUSE) && comboMaterialsMedia->getEnabled(); + bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && comboMaterialsMedia->getEnabled(); + bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && comboMaterialsMedia->getEnabled(); self->getChildView("combobox mattype")->setVisible(!show_media); + self->getChildView("rptctrl")->setVisible(!show_media); + + // Media controls self->getChildView("media_info")->setVisible(show_media); self->getChildView("add_media")->setVisible(show_media); self->getChildView("delete_media")->setVisible(show_media); 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); @@ -1125,6 +1404,13 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { onCommitAlphaMode(ctrl, userdata); } + self->getChildView("TexScaleU")->setVisible(show_texture); + self->getChildView("TexScaleV")->setVisible(show_texture); + self->getChildView("TexRot")->setVisible(show_texture); + self->getChildView("TexOffsetU")->setVisible(show_texture); + self->getChildView("TexOffsetV")->setVisible(show_texture); + + // Specular map controls self->getChildView("shinytexture control")->setVisible(show_shininess); self->getChildView("combobox shininess")->setVisible(show_shininess); self->getChildView("label shininess")->setVisible(show_shininess); @@ -1138,9 +1424,50 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { onCommitShiny(ctrl, userdata); } + self->getChildView("shinyScaleU")->setVisible(show_shininess); + self->getChildView("shinyScaleV")->setVisible(show_shininess); + self->getChildView("shinyRot")->setVisible(show_shininess); + self->getChildView("shinyOffsetU")->setVisible(show_shininess); + self->getChildView("shinyOffsetV")->setVisible(show_shininess); + + // Normal map controls self->getChildView("bumpytexture control")->setVisible(show_bumpiness); self->getChildView("combobox bumpiness")->setVisible(show_bumpiness); self->getChildView("label bumpiness")->setVisible(show_bumpiness); + self->getChildView("bumpyScaleU")->setVisible(show_bumpiness); + self->getChildView("bumpyScaleV")->setVisible(show_bumpiness); + self->getChildView("bumpyRot")->setVisible(show_bumpiness); + self->getChildView("bumpyOffsetU")->setVisible(show_bumpiness); + self->getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + + // Enable texture scale/rotation/offset parameters if there's one + // present to set for + bool texParmsEnable = show_texture; + if (self->mMaterial) + { + texParmsEnable = texParmsEnable || + (!self->mMaterial->getNormalID().isNull() && show_bumpiness) || + (!self->mMaterial->getSpecularID().isNull() && show_shininess); + } + self->getChildView("tex gen")->setEnabled(texParmsEnable); + self->getChildView("combobox texgen")->setEnabled(texParmsEnable); + self->getChildView("rptctrl")->setEnabled(texParmsEnable); + self->getChildView("TexScaleU")->setEnabled(texParmsEnable); + self->getChildView("TexScaleV")->setEnabled(texParmsEnable); + self->getChildView("TexRot")->setEnabled(texParmsEnable); + self->getChildView("TexOffsetU")->setEnabled(texParmsEnable); + self->getChildView("TexOffsetV")->setEnabled(texParmsEnable); + self->getChildView("shinyScaleU")->setEnabled(texParmsEnable); + self->getChildView("shinyScaleV")->setEnabled(texParmsEnable); + self->getChildView("shinyRot")->setEnabled(texParmsEnable); + self->getChildView("shinyOffsetU")->setEnabled(texParmsEnable); + self->getChildView("shinyOffsetV")->setEnabled(texParmsEnable); + self->getChildView("bumpyScaleU")->setEnabled(texParmsEnable); + self->getChildView("bumpyScaleV")->setEnabled(texParmsEnable); + self->getChildView("bumpyRot")->setEnabled(texParmsEnable); + self->getChildView("bumpyOffsetU")->setEnabled(texParmsEnable); + self->getChildView("bumpyOffsetV")->setEnabled(texParmsEnable); + self->getChildView("checkbox planar align")->setEnabled(texParmsEnable); } // static @@ -1196,6 +1523,7 @@ void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking self->getChildView("label maskcutoff")->setVisible(show_alphactrls); self->getChildView("maskcutoff")->setVisible(show_alphactrls); + self->updateMaterial(); } // static @@ -1247,6 +1575,28 @@ void LLPanelFace::onSelectTexture(const LLSD& data) sendTexture(); } +void LLPanelFace::onCommitMaterialTexture( const LLSD& data ) +{ + updateMaterial(); +} + +void LLPanelFace::onCancelMaterialTexture(const LLSD& data) +{ + // not sure what to do here other than + updateMaterial(); +} + +void LLPanelFace::onSelectMaterialTexture(const LLSD& data) +{ + updateMaterial(); +} + +//static +void LLPanelFace::onCommitMaterial(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + self->updateMaterial(); +} // static void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata ) @@ -1339,7 +1689,25 @@ void LLPanelFace::onCommitPlanarAlign(LLUICtrl* ctrl, void* userdata) void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) { - LLTextureCtrl* texture_ctrl = getChild("texture control"); + LLComboBox* combo_mattype = getChild("combobox mattype"); + if (!combo_mattype) + { + return; + } + U32 mattype = combo_mattype->getCurrentIndex(); + std::string which_control="texture control"; + switch (mattype) + { + case MATTYPE_SPECULAR: + which_control = "shinytexture_control"; + break; + case MATTYPE_NORMAL: + which_control = "bumpytexture_control"; + break; + // no default needed + } + + LLTextureCtrl* texture_ctrl = getChild(which_control); if (texture_ctrl) { LLUUID obj_owner_id; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 56b4034a2d..c6322d59b2 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -29,6 +29,7 @@ #include "v4color.h" #include "llpanel.h" +#include "llmaterial.h" class LLButton; class LLCheckBoxCtrl; @@ -42,6 +43,7 @@ class LLTextureCtrl; class LLUICtrl; class LLViewerObject; class LLFloater; +class LLMaterialID; class LLPanelFace : public LLPanel { @@ -74,12 +76,19 @@ protected: void onCommitTexture(const LLSD& data); void onCancelTexture(const LLSD& data); void onSelectTexture(const LLSD& data); + void onCommitMaterialTexture(const LLSD& data); + void onCancelMaterialTexture(const LLSD& data); + void onSelectMaterialTexture(const LLSD& data); void onCommitColor(const LLSD& data); + void onCommitShinyColor(const LLSD& data); void onCommitAlpha(const LLSD& data); void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); + void onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material); + void updateMaterial(); static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); static void onCommitBump( LLUICtrl* ctrl, void* userdata); @@ -103,6 +112,9 @@ private: */ void onTextureSelectionChanged(LLInventoryItem* itemp); + LLMaterialID mMaterialID; + LLMaterialPtr mMaterial; + BOOL mIsAlpha; }; #endif diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c3c37141ed..9f9e39527f 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -63,6 +63,7 @@ #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llinventorymodel.h" +#include "llmaterialmgr.h" #include "llmenugl.h" #include "llmeshrepository.h" #include "llmutelist.h" @@ -2009,6 +2010,37 @@ void LLSelectMgr::selectionSetGlow(F32 glow) mSelectedObjects->applyToObjects( &func2 ); } +void LLSelectMgr::selectionSetMaterial(LLMaterial& material) +{ + struct f1 : public LLSelectedTEFunctor + { + LLMaterial mMaterial; + f1(LLMaterial material) : mMaterial(material) {}; + bool apply(LLViewerObject* object, S32 face) + { + if (object->permModify()) + { + LLMaterialMgr::getInstance()->put(object->getID(),face,mMaterial); + } + return true; + } + } func1(material); + mSelectedObjects->applyToTEs( &func1 ); + + struct f2 : public LLSelectedObjectFunctor + { + virtual bool apply(LLViewerObject* object) + { + if (object->permModify()) + { + object->sendTEUpdate(); + } + return true; + } + } func2; + mSelectedObjects->applyToObjects( &func2 ); +} + //----------------------------------------------------------------------------- // findObjectPermissions() diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index ecbb20df1b..f1da18dcc3 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -43,6 +43,7 @@ #include "llpermissions.h" #include "llcontrol.h" #include "llviewerobject.h" // LLObjectSelection::getSelectedTEValue template +#include "llmaterial.h" #include #include @@ -537,6 +538,7 @@ public: void selectionSetClickAction(U8 action); void selectionSetIncludeInSearch(bool include_in_search); void selectionSetGlow(const F32 glow); + void selectionSetMaterial(LLMaterial& material); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); void selectionSetObjectName(const std::string& name); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index 21cbf9673d..8382ad69d1 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -200,10 +200,12 @@ Mask cutoff + + + + + + + + + + + + Date: Thu, 31 Jan 2013 00:36:23 -0600 Subject: Control reorganization and bugfixes. --- indra/newview/llpanelface.cpp | 215 ++++++++++++++++++++++++++---------------- indra/newview/llpanelface.h | 2 + indra/newview/llselectmgr.cpp | 1 + 3 files changed, 139 insertions(+), 79 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 024265b377..4f61d5bbb6 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -699,7 +699,7 @@ void LLPanelFace::getState() { llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } - onCommitAlphaMode(getChild("combobox alphamode"),this); + updateAlphaControls(getChild("combobox alphamode"),this); } if (identical) @@ -712,10 +712,10 @@ void LLPanelFace::getState() texture_ctrl->setImageAssetID( id ); shinytexture_ctrl->setTentative( FALSE ); shinytexture_ctrl->setEnabled( editable ); - shinytexture_ctrl->setImageAssetID( id ); + shinytexture_ctrl->setImageAssetID( LLUUID::null ); bumpytexture_ctrl->setTentative( FALSE ); bumpytexture_ctrl->setEnabled( editable ); - bumpytexture_ctrl->setImageAssetID( id ); + bumpytexture_ctrl->setImageAssetID( LLUUID::null ); getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha); getChildView("label alphamode")->setEnabled(editable && mIsAlpha); getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); @@ -751,10 +751,10 @@ void LLPanelFace::getState() texture_ctrl->setImageAssetID( id ); shinytexture_ctrl->setTentative( TRUE ); shinytexture_ctrl->setEnabled( editable ); - shinytexture_ctrl->setImageAssetID( id ); + shinytexture_ctrl->setImageAssetID( LLUUID::null ); bumpytexture_ctrl->setTentative( TRUE ); bumpytexture_ctrl->setEnabled( editable ); - bumpytexture_ctrl->setImageAssetID( id ); + bumpytexture_ctrl->setImageAssetID( LLUUID::null ); getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha); getChildView("label alphamode")->setEnabled(editable && mIsAlpha); getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); @@ -1091,11 +1091,6 @@ void LLPanelFace::getState() getChild("checkbox fullbright")->setTentative(!identical); } - // Repeats per meter label - { - getChildView("rpt")->setEnabled(editable); - } - // Repeats per meter { F32 repeats = 1.f; @@ -1126,7 +1121,7 @@ void LLPanelFace::getState() // Materials { mMaterialID = LLMaterialID::null; - //mMaterial = LLMaterialPtr(); + mMaterial.reset(); struct f1 : public LLSelectedTEGetFunctor { LLMaterialID get(LLViewerObject* object, S32 te_index) @@ -1142,6 +1137,7 @@ void LLPanelFace::getState() << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; if (!mMaterialID.isNull() && editable) { + llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); } } @@ -1209,14 +1205,25 @@ void LLPanelFace::refresh() void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) { - llinfos << "Material loaded: " << material_id.asString() - << ", LLSD: " << material->asLLSD() << llendl; mMaterial = material; - getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); - getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); - getChild("glossiness")->setValue((F32)(material->getSpecularLightExponent())/255.0); - getChild("environment")->setValue((F32)(material->getEnvironmentIntensity())/255.0); +#if 0 + static LLMaterialID old_material_id = LLMaterialID::null; + if (material_id == old_material_id) + { + llinfos << "Material ID " << material_id.asString() + << " unchanged, not updating" << llendl; + return; + } + else + { + llinfos << "Material ID changed, old " << old_material_id.asString() + << ", new " << material_id.asString() + << ", updating controls: " << material->asLLSD() + << llendl; + } + old_material_id = material_id; +#endif + // Alpha LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); if (combobox_alphamode) @@ -1227,17 +1234,18 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate { llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } - onCommitAlphaMode(getChild("combobox alphamode"),this); - LLComboBox* comboMaterialType = getChild("combobox mattype"); + getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); + updateAlphaControls(getChild("combobox alphamode"),this); + + // Shiny (specular) F32 offset_x, offset_y, repeat_x, repeat_y, rot; - if ((comboMaterialType->getCurrentIndex() == MATTYPE_SPECULAR) && - !material->getSpecularID().isNull()) + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); + texture_ctrl->setImageAssetID(material->getSpecularID()); + if (!material->getSpecularID().isNull()) { material->getSpecularOffset(offset_x,offset_y); material->getSpecularRepeat(repeat_x,repeat_y); rot = material->getSpecularRotation(); - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - texture_ctrl->setImageAssetID(material->getSpecularID()); LLCtrlSelectionInterface* combobox_shininess = childGetSelectionInterface("combobox shininess"); if (combobox_shininess) @@ -1253,15 +1261,20 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate getChild("shinyRot")->setValue(rot); getChild("shinyOffsetU")->setValue(offset_x); getChild("shinyOffsetV")->setValue(offset_y); + getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); + getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); + getChild("glossiness")->setValue((F32)(material->getSpecularLightExponent())/255.0); + getChild("environment")->setValue((F32)(material->getEnvironmentIntensity())/255.0); } - if ((comboMaterialType->getCurrentIndex() == MATTYPE_NORMAL) && - !material->getNormalID().isNull()) + + // Bumpy (normal) + texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(material->getNormalID()); + if (!material->getNormalID().isNull()) { material->getNormalOffset(offset_x,offset_y); material->getNormalRepeat(repeat_x,repeat_y); rot = material->getNormalRotation(); - LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(material->getNormalID()); LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness"); if (combobox_bumpiness) @@ -1289,42 +1302,69 @@ void LLPanelFace::updateMaterial() { return; } - if ((mIsAlpha && (comboAlphaMode->getCurrentIndex() != ALPHAMODE_BLEND)) - || (comboBumpiness->getCurrentIndex() != BUMPY_TEXTURE) - || (comboShininess->getCurrentIndex() != SHINY_TEXTURE)) + U32 alpha_mode = comboAlphaMode->getCurrentIndex(); + U32 bumpiness = comboBumpiness->getCurrentIndex(); + U32 shininess = comboShininess->getCurrentIndex(); + if ((mIsAlpha && (alpha_mode != ALPHAMODE_BLEND)) + || (bumpiness == BUMPY_TEXTURE) + || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. if (!mMaterial) { mMaterial = LLMaterialPtr(new LLMaterial()); } - mMaterial->setNormalID(getChild("bumpytexture control")->getImageAssetID()); - mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), - getChild("bumpyOffsetV")->getValue().asReal()); - mMaterial->setNormalRepeat(getChild("bumpyScaleU")->getValue().asReal(), - getChild("bumpyScaleV")->getValue().asReal()); - mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()); - mMaterial->setSpecularID(getChild("shinytexture control")->getImageAssetID()); - mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), - getChild("shinyOffsetV")->getValue().asReal()); - mMaterial->setSpecularRepeat(getChild("shinyScaleU")->getValue().asReal(), - getChild("shinyScaleV")->getValue().asReal()); - mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()); + if (bumpiness == BUMPY_TEXTURE) + { + mMaterial->setNormalID(getChild("bumpytexture control")->getImageAssetID()); + mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), + getChild("bumpyOffsetV")->getValue().asReal()); + mMaterial->setNormalRepeat(getChild("bumpyScaleU")->getValue().asReal(), + getChild("bumpyScaleV")->getValue().asReal()); + mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()); + } + else + { + mMaterial->setNormalID(LLUUID()); + mMaterial->setNormalOffset(0.0f,0.0f); + mMaterial->setNormalRepeat(1.0f,1.0f); + mMaterial->setNormalRotation(0.0f); + } + if (shininess == SHINY_TEXTURE) + { + mMaterial->setSpecularID(getChild("shinytexture control")->getImageAssetID()); + mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), + getChild("shinyOffsetV")->getValue().asReal()); + mMaterial->setSpecularRepeat(getChild("shinyScaleU")->getValue().asReal(), + getChild("shinyScaleV")->getValue().asReal()); + mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()); + } + else + { + mMaterial->setSpecularID(LLUUID()); + mMaterial->setSpecularOffset(0.0f,0.0f); + mMaterial->setSpecularRepeat(1.0f,1.0f); + mMaterial->setSpecularRotation(0.0f); + } mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); mMaterial->setSpecularLightExponent((U8)(255*getChild("glossiness")->getValue().asReal())); mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + llinfos << "Updating material: " << mMaterial->asLLSD() << llendl; + LLSelectMgr::getInstance()->selectionSetMaterial( *mMaterial ); } else { // The user has specified settings that don't need a material. - if (mMaterial) + if (mMaterial || !mMaterialID.isNull()) { + llinfos << "Resetting material entry" << llendl; mMaterial.reset(); + mMaterialID = LLMaterialID::null; + // Delete existing material entry... } } - LLSelectMgr::getInstance()->selectionSetMaterial( *mMaterial ); } // @@ -1345,7 +1385,8 @@ void LLPanelFace::onCommitColor(const LLSD& data) void LLPanelFace::onCommitShinyColor(const LLSD& data) { - updateMaterial(); + llinfos << "updating material" << llendl; + //updateMaterial(); } void LLPanelFace::onCommitAlpha(const LLSD& data) @@ -1368,23 +1409,21 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - // Get material info so we can use it later - if (self->mMaterial) - { - self->onMaterialLoaded(self->mMaterialID,self->mMaterial); - } - LLComboBox* comboMaterialsMedia = self->getChild("combobox matmedia"); - LLComboBox* comboMaterialType = self->getChild("combobox mattype"); - if (!comboMaterialType || !comboMaterialsMedia) + LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); + LLComboBox* combo_shininess = self->getChild("combobox shininess"); + LLComboBox* combo_bumpiness = self->getChild("combobox bumpiness"); + if (!combo_mattype || !combo_matmedia || !combo_shininess || !combo_bumpiness) { + llwarns << "Combo box not found...exiting." << llendl; return; } - U32 materials_media = comboMaterialsMedia->getCurrentIndex(); - U32 material_type = comboMaterialType->getCurrentIndex(); - bool show_media = (materials_media == MATMEDIA_MEDIA) && comboMaterialsMedia->getEnabled(); - bool show_texture = (!show_media) && (material_type == MATTYPE_DIFFUSE) && comboMaterialsMedia->getEnabled(); - bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && comboMaterialsMedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && comboMaterialsMedia->getEnabled(); + 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_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); @@ -1402,7 +1441,7 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) self->getChildView("maskcutoff")->setVisible(false); if (show_texture) { - onCommitAlphaMode(ctrl, userdata); + updateAlphaControls(ctrl, userdata); } self->getChildView("TexScaleU")->setVisible(show_texture); self->getChildView("TexScaleV")->setVisible(show_texture); @@ -1422,7 +1461,7 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) self->getChildView("shinycolorswatch")->setVisible(false); if (show_shininess) { - onCommitShiny(ctrl, userdata); + updateShinyControls(ctrl, userdata); } self->getChildView("shinyScaleU")->setVisible(show_shininess); self->getChildView("shinyScaleV")->setVisible(show_shininess); @@ -1442,13 +1481,9 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) // Enable texture scale/rotation/offset parameters if there's one // present to set for - bool texParmsEnable = show_texture; - if (self->mMaterial) - { - texParmsEnable = texParmsEnable || - (!self->mMaterial->getNormalID().isNull() && show_bumpiness) || - (!self->mMaterial->getSpecularID().isNull() && show_shininess); - } + bool texParmsEnable = show_texture || + (show_shininess && (combo_shininess->getCurrentIndex() == SHINY_TEXTURE)) || + (show_bumpiness && (combo_bumpiness->getCurrentIndex() == BUMPY_TEXTURE)); self->getChildView("tex gen")->setEnabled(texParmsEnable); self->getChildView("combobox texgen")->setEnabled(texParmsEnable); self->getChildView("rptctrl")->setEnabled(texParmsEnable); @@ -1491,8 +1526,9 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) } // static -void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata) { + llinfos << "Entered." << llendl; LLPanelFace* self = (LLPanelFace*) userdata; LLComboBox* comboShiny = self->getChild("combobox shininess"); if (!comboShiny) @@ -1507,12 +1543,21 @@ void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) self->getChildView("environment")->setVisible(show_shinyctrls); self->getChildView("label shinycolor")->setVisible(show_shinyctrls); self->getChildView("shinycolorswatch")->setVisible(show_shinyctrls); +} + +// static +void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; self->sendShiny(); + llinfos << "updating material" << llendl; + //self->updateMaterial(); } // static -void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) { + llinfos << "Entered." << llendl; LLPanelFace* self = (LLPanelFace*) userdata; LLComboBox* comboAlphaMode = self->getChild("combobox alphamode"); if (!comboAlphaMode) @@ -1523,7 +1568,15 @@ void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking self->getChildView("label maskcutoff")->setVisible(show_alphactrls); self->getChildView("maskcutoff")->setVisible(show_alphactrls); - self->updateMaterial(); +} + +// static +void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + self->updateAlphaControls(ctrl,userdata); + llinfos << "updating material" << llendl; + //self->updateMaterial(); } // static @@ -1577,25 +1630,29 @@ void LLPanelFace::onSelectTexture(const LLSD& data) void LLPanelFace::onCommitMaterialTexture( const LLSD& data ) { - updateMaterial(); + llinfos << "updating material" << llendl; + //updateMaterial(); } void LLPanelFace::onCancelMaterialTexture(const LLSD& data) { // not sure what to do here other than - updateMaterial(); + llinfos << "updating material" << llendl; + //updateMaterial(); } void LLPanelFace::onSelectMaterialTexture(const LLSD& data) { - updateMaterial(); + llinfos << "updating material" << llendl; + //updateMaterial(); } //static void LLPanelFace::onCommitMaterial(LLUICtrl* ctrl, void* userdata) { - LLPanelFace* self = (LLPanelFace*) userdata; - self->updateMaterial(); + llinfos << "updating material" << llendl; + //LLPanelFace* self = (LLPanelFace*) userdata; + //self->updateMaterial(); } // static @@ -1699,10 +1756,10 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) switch (mattype) { case MATTYPE_SPECULAR: - which_control = "shinytexture_control"; + which_control = "shinytexture control"; break; case MATTYPE_NORMAL: - which_control = "bumpytexture_control"; + which_control = "bumpytexture control"; break; // no default needed } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index c6322d59b2..62aa632821 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -93,7 +93,9 @@ protected: static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); + static void updateShinyControls( LLUICtrl* ctrl, void* userdata); static void onCommitShiny( LLUICtrl* ctrl, void* userdata); + static void updateAlphaControls( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); static void onCommitGlow( LLUICtrl* ctrl, void *userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 9f9e39527f..6f855ad30d 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2020,6 +2020,7 @@ void LLSelectMgr::selectionSetMaterial(LLMaterial& material) { if (object->permModify()) { + llinfos << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial.asLLSD() << llendl; LLMaterialMgr::getInstance()->put(object->getID(),face,mMaterial); } return true; -- cgit v1.3 From 3422f75cf749df10c7bb7711b9a7fa870655818f Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Wed, 6 Feb 2013 21:38:05 -0600 Subject: Tell the renderer to use the updated material immediately on editing it. --- indra/newview/llpanelface.cpp | 2 +- indra/newview/llselectmgr.cpp | 11 ++++++----- indra/newview/llselectmgr.h | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 7b3bbf8b3b..7e9fe212dd 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1352,7 +1352,7 @@ void LLPanelFace::updateMaterial() mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); llinfos << "Updating material: " << mMaterial->asLLSD() << llendl; - LLSelectMgr::getInstance()->selectionSetMaterial( *mMaterial ); + LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); // We've sent an update. Need to hold off on any more until // the sim acknowledges this one. diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c93cecdd5d..9f343f465c 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2010,18 +2010,19 @@ void LLSelectMgr::selectionSetGlow(F32 glow) mSelectedObjects->applyToObjects( &func2 ); } -void LLSelectMgr::selectionSetMaterial(LLMaterial& material) +void LLSelectMgr::selectionSetMaterial(LLMaterialPtr material) { struct f1 : public LLSelectedTEFunctor { - LLMaterial mMaterial; - f1(LLMaterial material) : mMaterial(material) {}; + LLMaterialPtr mMaterial; + f1(LLMaterialPtr material) : mMaterial(material) {}; bool apply(LLViewerObject* object, S32 face) { if (object->permModify()) { - llinfos << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial.asLLSD() << llendl; - LLMaterialMgr::getInstance()->put(object->getID(),face,mMaterial); + llinfos << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << llendl; + LLMaterialMgr::getInstance()->put(object->getID(),face,*mMaterial); + object->setTEMaterialParams(face,mMaterial); } return true; } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f1da18dcc3..2eae5b94c9 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -48,6 +48,7 @@ #include #include #include +#include // boost::make_shared class LLMessageSystem; class LLViewerTexture; @@ -538,7 +539,7 @@ public: void selectionSetClickAction(U8 action); void selectionSetIncludeInSearch(bool include_in_search); void selectionSetGlow(const F32 glow); - void selectionSetMaterial(LLMaterial& material); + void selectionSetMaterial(LLMaterialPtr material); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); void selectionSetObjectName(const std::string& name); -- cgit v1.3 From fa7dd433088963a101252884f35fda8094f4a76b Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Wed, 27 Feb 2013 19:27:46 -0600 Subject: Wire up LLMaterialMgr::remove() to edit panel. --- indra/newview/llpanelface.cpp | 4 ++-- indra/newview/llselectmgr.cpp | 33 ++++++++++++++++++++++++++++++++- indra/newview/llselectmgr.h | 1 + 3 files changed, 35 insertions(+), 3 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 5c4c2693f8..ca161a8654 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1368,10 +1368,10 @@ void LLPanelFace::updateMaterial() mMaterial.reset(); mMaterialID = LLMaterialID::null; // Delete existing material entry... - + LLSelectMgr::getInstance()->selectionRemoveMaterial(); // Hold off any further updates till this one's // acknowledged. - //mUpdateInFlight = true; + mUpdateInFlight = true; } } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 91d737ee95..94cfdb9f53 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2017,7 +2017,7 @@ void LLSelectMgr::selectionSetMaterial(LLMaterialPtr material) { if (object->permModify()) { - llinfos << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << llendl; + LL_INFOS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << LL_ENDL; LLMaterialMgr::getInstance()->put(object->getID(),face,*mMaterial); object->setTEMaterialParams(face,mMaterial); } @@ -2040,6 +2040,37 @@ void LLSelectMgr::selectionSetMaterial(LLMaterialPtr material) mSelectedObjects->applyToObjects( &func2 ); } +void LLSelectMgr::selectionRemoveMaterial() +{ + struct f1 : public LLSelectedTEFunctor + { + bool apply(LLViewerObject* object, S32 face) + { + if (object->permModify()) + { + LL_INFOS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; + LLMaterialMgr::getInstance()->remove(object->getID(),face); + //object->setTEMaterialParams(face,LLMaterial::null); + } + return true; + } + } func1; + mSelectedObjects->applyToTEs( &func1 ); + + struct f2 : public LLSelectedObjectFunctor + { + virtual bool apply(LLViewerObject* object) + { + if (object->permModify()) + { + object->sendTEUpdate(); + } + return true; + } + } func2; + mSelectedObjects->applyToObjects( &func2 ); +} + //----------------------------------------------------------------------------- // findObjectPermissions() diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 65f3ea96e3..9d187f6272 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -543,6 +543,7 @@ public: void selectionSetIncludeInSearch(bool include_in_search); void selectionSetGlow(const F32 glow); void selectionSetMaterial(LLMaterialPtr material); + void selectionRemoveMaterial(); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); void selectionSetObjectName(const std::string& name); -- cgit v1.3 From 2eaf35b946630ab6b8635e74d5e7f2188c179e4b Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Thu, 28 Feb 2013 07:44:45 -0600 Subject: Clear face's material ID internally when removing the material. --- indra/newview/llselectmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 94cfdb9f53..4623d32cff 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2050,7 +2050,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_INFOS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - //object->setTEMaterialParams(face,LLMaterial::null); + object->setTEMaterialID(face,LLMaterialID::null); } return true; } -- cgit v1.3 From 8b24857f6ae7f4d719697f17e664f095a8aa2753 Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Sat, 9 Mar 2013 16:11:55 -0600 Subject: Dynamically add and remove "Use texture" normal/specular setting. --- indra/newview/llpanelface.cpp | 216 +++++++++++++------------ indra/newview/llpanelface.h | 1 + indra/newview/llselectmgr.cpp | 4 +- indra/newview/skins/default/xui/en/strings.xml | 1 + 4 files changed, 115 insertions(+), 107 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index ca161a8654..b205997615 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -56,6 +56,7 @@ #include "lltexturectrl.h" #include "lltextureentry.h" #include "lltooldraganddrop.h" +#include "lltrans.h" #include "llui.h" #include "llviewercontrol.h" #include "llviewermedia.h" @@ -82,6 +83,12 @@ const S32 ALPHAMODE_MASK = 2; // Alpha masking mode const S32 BUMPY_TEXTURE = 18; // use supplied normal map const S32 SHINY_TEXTURE = 4; // use supplied specular map +// +// "Use texture" label for normal/specular type comboboxes +// Filled in at initialization from translated strings +// +std::string USE_TEXTURE; + // // Methods // @@ -257,10 +264,9 @@ LLPanelFace::LLPanelFace() : LLPanel(), mMaterialID(LLMaterialID::null), mMaterial(LLMaterialPtr()), - mIsAlpha(false), - mUpdateInFlight(false), - mUpdatePending(false) + mIsAlpha(false) { + USE_TEXTURE = LLTrans::getString("use_texture"); } @@ -291,7 +297,13 @@ void LLPanelFace::sendBump() { LLComboBox* mComboBumpiness = getChild("combobox bumpiness"); if(!mComboBumpiness)return; - U8 bump = (U8) mComboBumpiness->getCurrentIndex() & TEM_BUMP_MASK; + U32 bumpiness = mComboBumpiness->getCurrentIndex(); + if (bumpiness < BUMPY_TEXTURE) + { + LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(LLUUID()); + } + U8 bump = (U8) bumpiness & TEM_BUMP_MASK; LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); } @@ -307,7 +319,13 @@ void LLPanelFace::sendShiny() { LLComboBox* mComboShininess = getChild("combobox shininess"); if(!mComboShininess)return; - U8 shiny = (U8) mComboShininess->getCurrentIndex() & TEM_SHINY_MASK; + U32 shininess = mComboShininess->getCurrentIndex(); + if (shininess < SHINY_TEXTURE) + { + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); + texture_ctrl->setImageAssetID(LLUUID()); + } + U8 shiny = (U8) shininess & TEM_SHINY_MASK; LLSelectMgr::getInstance()->selectionSetShiny( shiny ); } @@ -1142,13 +1160,6 @@ void LLPanelFace::getState() llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); } - if (mUpdatePending && !mUpdateInFlight) - { - // One or more updates are pending, and the - // previous one has been acknowledged. Send - // the pending updates. - updateMaterial(); - } } // Set variable values for numeric expressions @@ -1215,8 +1226,6 @@ void LLPanelFace::refresh() void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) { mMaterial = material; - // We've gotten a materials update, so the sim's ready for another. - mUpdateInFlight = false; // Alpha LLCtrlSelectionInterface* combobox_alphamode = @@ -1236,21 +1245,12 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate F32 offset_x, offset_y, repeat_x, repeat_y, rot; LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); texture_ctrl->setImageAssetID(material->getSpecularID()); + LLComboBox* combobox_shininess = getChild("combobox shininess"); if (!material->getSpecularID().isNull()) { material->getSpecularOffset(offset_x,offset_y); material->getSpecularRepeat(repeat_x,repeat_y); rot = material->getSpecularRotation(); - LLCtrlSelectionInterface* combobox_shininess = - childGetSelectionInterface("combobox shininess"); - if (combobox_shininess) - { - combobox_shininess->selectNthItem(SHINY_TEXTURE); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox shininess'" << llendl; - } getChild("shinyScaleU")->setValue(repeat_x); getChild("shinyScaleV")->setValue(repeat_y); getChild("shinyRot")->setValue(rot); @@ -1261,41 +1261,29 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate getChild("glossiness")->setValue((F32)(material->getSpecularLightExponent())/255.0); getChild("environment")->setValue((F32)(material->getEnvironmentIntensity())/255.0); } + updateShinyControls(combobox_shininess,this); // Bumpy (normal) texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); + LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); if (!material->getNormalID().isNull()) { material->getNormalOffset(offset_x,offset_y); material->getNormalRepeat(repeat_x,repeat_y); rot = material->getNormalRotation(); - LLCtrlSelectionInterface* combobox_bumpiness = - childGetSelectionInterface("combobox bumpiness"); - if (combobox_bumpiness) - { - combobox_bumpiness->selectNthItem(BUMPY_TEXTURE); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox bumpiness'" << llendl; - } getChild("bumpyScaleU")->setValue(repeat_x); getChild("bumpyScaleV")->setValue(repeat_y); getChild("bumpyRot")->setValue(rot); getChild("bumpyOffsetU")->setValue(offset_x); getChild("bumpyOffsetV")->setValue(offset_y); } + updateBumpyControls(combobox_bumpiness,this); } void LLPanelFace::updateMaterial() { - LL_WARNS("Materials") << LL_ENDL; - if (mUpdateInFlight) - { - LL_WARNS("Materials") << "Attempt to update material while a previous update is pending ignored." << LL_ENDL; - return; - } + LL_WARNS("Materials") << "Entered." << LL_ENDL; LLComboBox* comboAlphaMode = getChild("combobox alphamode"); LLComboBox* comboBumpiness = getChild("combobox bumpiness"); LLComboBox* comboShininess = getChild("combobox shininess"); @@ -1317,6 +1305,7 @@ void LLPanelFace::updateMaterial() } if (bumpiness == BUMPY_TEXTURE) { + LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; mMaterial->setNormalID(getChild("bumpytexture control")->getImageAssetID()); mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), getChild("bumpyOffsetV")->getValue().asReal()); @@ -1326,6 +1315,7 @@ void LLPanelFace::updateMaterial() } else { + LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; mMaterial->setNormalID(LLUUID()); mMaterial->setNormalOffset(0.0f,0.0f); mMaterial->setNormalRepeat(1.0f,1.0f); @@ -1333,6 +1323,7 @@ void LLPanelFace::updateMaterial() } if (shininess == SHINY_TEXTURE) { + LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; mMaterial->setSpecularID(getChild("shinytexture control")->getImageAssetID()); mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), getChild("shinyOffsetV")->getValue().asReal()); @@ -1342,6 +1333,7 @@ void LLPanelFace::updateMaterial() } else { + LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; mMaterial->setSpecularID(LLUUID()); mMaterial->setSpecularOffset(0.0f,0.0f); mMaterial->setSpecularRepeat(1.0f,1.0f); @@ -1354,10 +1346,6 @@ void LLPanelFace::updateMaterial() mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); - - // We've sent an update. Need to hold off on any more until - // the sim acknowledges this one. - mUpdateInFlight = true; } else { @@ -1369,14 +1357,8 @@ void LLPanelFace::updateMaterial() mMaterialID = LLMaterialID::null; // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); - // Hold off any further updates till this one's - // acknowledged. - mUpdateInFlight = true; } } - - // We've taken care of the update, so clear the update pending flag. - mUpdatePending = false; } // @@ -1397,14 +1379,7 @@ void LLPanelFace::onCommitColor(const LLSD& data) void LLPanelFace::onCommitShinyColor(const LLSD& data) { - if (!mUpdateInFlight) - { - updateMaterial(); - } - else - { - mUpdatePending = true; - } + updateMaterial(); } void LLPanelFace::onCommitAlpha(const LLSD& data) @@ -1488,6 +1463,10 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) self->getChildView("shinyOffsetV")->setVisible(show_shininess); // Normal map controls + if (show_bumpiness) + { + updateBumpyControls(ctrl, userdata); + } self->getChildView("bumpytexture control")->setVisible(show_bumpiness); self->getChildView("combobox bumpiness")->setVisible(show_bumpiness); self->getChildView("label bumpiness")->setVisible(show_bumpiness); @@ -1547,13 +1526,39 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; + LLTextureCtrl* texture_ctrl = self->getChild("shinytexture control"); + LLUUID shiny_texture_ID = texture_ctrl->getImageAssetID(); + LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; LLComboBox* comboShiny = self->getChild("combobox shininess"); if (!comboShiny) { return; } + if (!shiny_texture_ID.isNull()) + { + if (!comboShiny->itemExists(USE_TEXTURE)) + { + comboShiny->add(USE_TEXTURE); + } + comboShiny->setSimple(USE_TEXTURE); + } + else + { + if (comboShiny->itemExists(USE_TEXTURE)) + { + // HACK: This depends on adding the "Use texture" + // item at the end of a list of known length. + comboShiny->remove(SHINY_TEXTURE); + } + } + LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); + U32 materials_media = combo_matmedia->getCurrentIndex(); + U32 material_type = combo_mattype->getCurrentIndex(); + bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); + bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); - bool show_shinyctrls = (shiny_value == SHINY_TEXTURE); // Use texture + bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture self->getChildView("label glossiness")->setVisible(show_shinyctrls); self->getChildView("glossiness")->setVisible(show_shinyctrls); self->getChildView("label environment")->setVisible(show_shinyctrls); @@ -1563,20 +1568,44 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata) } // static -void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - self->sendShiny(); - if (!self->mUpdateInFlight) + LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); + LL_DEBUGS("Materials") << "Bumpy texture selected: " << bumpy_texture_ID << LL_ENDL; + LLComboBox* comboBumpy = self->getChild("combobox bumpiness"); + if (!comboBumpy) { - self->updateMaterial(); + return; + } + if (!bumpy_texture_ID.isNull()) + { + if (!comboBumpy->itemExists(USE_TEXTURE)) + { + comboBumpy->add(USE_TEXTURE); + } + comboBumpy->setSimple(USE_TEXTURE); } else { - self->mUpdatePending = true; + if (comboBumpy->itemExists(USE_TEXTURE)) + { + // HACK: This depends on adding the "Use texture" + // item at the end of a list of known length. + comboBumpy->remove(BUMPY_TEXTURE); + } } } +// static +void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + self->sendShiny(); + self->updateMaterial(); +} + // static void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) { @@ -1597,14 +1626,7 @@ void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; updateAlphaControls(ctrl,userdata); - if (!self->mUpdateInFlight) - { - self->updateMaterial(); - } - else - { - self->mUpdatePending = true; - } + self->updateMaterial(); } // static @@ -1658,55 +1680,39 @@ void LLPanelFace::onSelectTexture(const LLSD& data) void LLPanelFace::onCommitMaterialTexture( const LLSD& data ) { - LL_DEBUGS("Materials") << data << "\n" << (mUpdateInFlight ? "In Flight" : "Now Pending" ) << LL_ENDL; - if (!mUpdateInFlight) - { - updateMaterial(); - } - else - { - mUpdatePending = true; - } + LL_DEBUGS("Materials") << data << LL_ENDL; + updateMaterial(); + LLComboBox* combo_shiny = getChild("combobox shininess"); + updateShinyControls(combo_shiny,this); + LLComboBox* combo_bumpy = getChild("combobox bumpiness"); + updateBumpyControls(combo_bumpy,this); } void LLPanelFace::onCancelMaterialTexture(const LLSD& data) { // not sure what to do here other than - if (!mUpdateInFlight) - { - updateMaterial(); - } - else - { - mUpdatePending = true; - } + updateMaterial(); + LLComboBox* combo_shiny = getChild("combobox shininess"); + updateShinyControls(combo_shiny,this); + LLComboBox* combo_bumpy = getChild("combobox bumpiness"); + updateBumpyControls(combo_bumpy,this); } void LLPanelFace::onSelectMaterialTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; - if (!mUpdateInFlight) - { - updateMaterial(); - } - else - { - mUpdatePending = true; - } + updateMaterial(); + LLComboBox* combo_shiny = getChild("combobox shininess"); + updateShinyControls(combo_shiny,this); + LLComboBox* combo_bumpy = getChild("combobox bumpiness"); + updateBumpyControls(combo_bumpy,this); } //static void LLPanelFace::onCommitMaterial(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - if (!self->mUpdateInFlight) - { - self->updateMaterial(); - } - else - { - self->mUpdatePending = true; - } + self->updateMaterial(); } // static diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index e83a03b0ae..a99b4e772f 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -94,6 +94,7 @@ protected: static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); static void updateShinyControls( LLUICtrl* ctrl, void* userdata); + static void updateBumpyControls( LLUICtrl* ctrl, void* userdata); static void onCommitShiny( LLUICtrl* ctrl, void* userdata); static void updateAlphaControls( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 4623d32cff..5089570319 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2017,7 +2017,7 @@ void LLSelectMgr::selectionSetMaterial(LLMaterialPtr material) { if (object->permModify()) { - LL_INFOS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << LL_ENDL; + LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << LL_ENDL; LLMaterialMgr::getInstance()->put(object->getID(),face,*mMaterial); object->setTEMaterialParams(face,mMaterial); } @@ -2048,7 +2048,7 @@ void LLSelectMgr::selectionRemoveMaterial() { if (object->permModify()) { - LL_INFOS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; + LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); object->setTEMaterialID(face,LLMaterialID::null); } diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 4383b98592..b78f555c9b 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -371,6 +371,7 @@ Please try logging in again in a minute. Multiple + Use texture Loading... -- cgit v1.3 From 6a417acd63d576271a8b752e42a79156dd8bdc27 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 10 Apr 2013 10:23:03 -0700 Subject: NORSPEC-92 More UI fixes --- indra/newview/llpanelface.cpp | 27 ++++++++++++++++++++++----- indra/newview/llselectmgr.cpp | 4 +--- indra/newview/llselectmgr.h | 2 ++ indra/newview/llvoavatar.cpp | 2 -- 4 files changed, 25 insertions(+), 10 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9af4bed918..b404fbb9d5 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1780,7 +1780,7 @@ void LLPanelFace::updateMaterial() mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); - if (bumpiness == BUMPY_TEXTURE) + if (!norm_map_id.isNull()) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; mMaterial->setNormalID(norm_map_id); @@ -1810,7 +1810,7 @@ void LLPanelFace::updateMaterial() LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); - if (shininess == SHINY_TEXTURE) + if (!spec_map_id.isNull()) { LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; mMaterial->setSpecularID(spec_map_id); @@ -1850,7 +1850,24 @@ void LLPanelFace::updateMaterial() } LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; - LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); + + LLMaterialPtr material_to_set = mMaterial; + + // If we're editing a single face and not the entire material for an object, + // we need to clone the material so that our changes to the material's settings + // don't automatically propagate to the non-selected faces + // NORSPEC-92 + // + LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); + LLSelectNode* node = sel->getFirstNode(); + if (node) + { + if (node->getTESelectMask() != TE_SELECT_MASK_ALL) + { + material_to_set = new LLMaterial(*mMaterial); + } + } + LLSelectMgr::getInstance()->selectionSetMaterial( material_to_set ); } else { @@ -2030,7 +2047,7 @@ void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) LLComboBox* combo_bumpy = self->getChild("combobox bumpiness"); // Need 'true' here to insure that the 'Use Texture' choice is removed - // when we select something other than a spec texture + // when we select something other than a normmap texture // updateBumpyControls(combo_bumpy,self, true); self->updateMaterial(); @@ -2084,7 +2101,7 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool mess_ bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); - bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture + bool show_shinyctrls = (shiny_value != 0) && show_shininess; // Use texture self->getChildView("label glossiness")->setVisible(show_shinyctrls); self->getChildView("glossiness")->setVisible(show_shinyctrls); self->getChildView("label environment")->setVisible(show_shinyctrls); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 5089570319..4f58d09db3 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -104,7 +104,6 @@ const F32 SILHOUETTE_UPDATE_THRESHOLD_SQUARED = 0.02f; const S32 MAX_ACTION_QUEUE_SIZE = 20; const S32 MAX_SILS_PER_FRAME = 50; const S32 MAX_OBJECTS_PER_PACKET = 254; -const S32 TE_SELECT_MASK_ALL = 0xFFFFFFFF; // // Globals @@ -1181,7 +1180,6 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 & if (mGridMode == GRID_MODE_LOCAL && mSelectedObjects->getObjectCount()) { //LLViewerObject* root = getSelectedParentObject(mSelectedObjects->getFirstObject()); - LLBBox bbox = mSavedSelectionBBox; mGridOrigin = mSavedSelectionBBox.getCenterAgent(); mGridScale = mSavedSelectionBBox.getExtentLocal() * 0.5f; @@ -1200,7 +1198,7 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 & { mGridRotation = first_grid_object->getRenderRotation(); LLVector3 first_grid_obj_pos = first_grid_object->getRenderPosition(); - + (void)first_grid_obj_pos; LLVector4a min_extents(F32_MAX); LLVector4a max_extents(-F32_MAX); BOOL grid_changed = FALSE; diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 9d187f6272..1991b5581b 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -123,6 +123,8 @@ typedef enum e_selection_type SELECT_TYPE_HUD }ESelectType; +const S32 TE_SELECT_MASK_ALL = 0xFFFFFFFF; + // Contains information about a selected object, particularly which TEs are selected. class LLSelectNode { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 9d16c28e2f..f861f49296 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4336,7 +4336,6 @@ U32 LLVOAvatar::renderTransparent(BOOL first_pass) gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } -#if !LL_DARWIN if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender) { if (LLPipeline::sImpostorRender) @@ -4363,7 +4362,6 @@ U32 LLVOAvatar::renderTransparent(BOOL first_pass) gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } } -#endif return num_indices; } -- cgit v1.3 From f356d7eb9fd730f5f6f5a29fb0706e20876ad3bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 11 May 2013 19:58:56 -0700 Subject: Fix many issues with selection misapplication and rendering not matching applied materials --- indra/llprimitive/llprimitive.cpp | 18 ++ indra/llprimitive/llprimitive.h | 2 + indra/llprimitive/lltextureentry.cpp | 25 +- indra/llprimitive/lltextureentry.h | 6 + indra/newview/llmaterialmgr.cpp | 61 ++++ indra/newview/llmaterialmgr.h | 24 ++ indra/newview/llpanelface.cpp | 318 +++++++++------------ indra/newview/llpanelface.h | 2 +- indra/newview/llselectmgr.cpp | 5 + indra/newview/llviewerobject.cpp | 78 ++--- indra/newview/llviewerobject.h | 2 +- indra/newview/llvovolume.cpp | 47 +-- indra/newview/llvovolume.h | 2 +- .../skins/default/xui/en/panel_tools_texture.xml | 8 +- 14 files changed, 338 insertions(+), 260 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index e5905c3a3b..2fa77177f5 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -374,6 +374,24 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index b1f8090416..47a21beaaf 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -361,6 +361,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -386,6 +387,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 53816266eb..1d581da897 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -67,12 +67,16 @@ LLTextureEntry::LLTextureEntry() LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -536,23 +540,20 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + } - return TEM_CHANGE_NONE; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mMaterial != pMaterialParams) - { - mMaterial = pMaterialParams; - return TEM_CHANGE_TEXTURE; - } - return TEM_CHANGE_NONE; + + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; } void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..5cc76cfe82 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -100,6 +100,10 @@ public: void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } + // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); S32 setColor(const LLColor4 &color); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..e41a46038f 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -216,6 +216,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -300,6 +345,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 39be5cab29..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,8 +44,12 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; + const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); + typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); @@ -78,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9c40ff06cc..837b8687e8 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1562,36 +1562,108 @@ void LLPanelFace::getState() // Materials { - mMaterialID = LLMaterialID::null; - mMaterial = NULL; + struct f1 : public LLSelectedTEGetFunctor + { + LLMaterialPtr get(LLViewerObject* object, S32 te_index) + { + return object->getTE(te_index)->getMaterialParams(); + } + } func; - struct f1 : public LLSelectedTEGetFunctor + LLMaterialPtr material; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterial ); + + if (mMaterial && editable) { - LLMaterialID get(LLViewerObject* object, S32 te_index) + LL_DEBUGS("Materials: OnMatererialsLoaded:") << material->asLLSD() << LL_ENDL; + + // Alpha + LLCtrlSelectionInterface* combobox_alphamode = + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - LLMaterialID material_id; + combobox_alphamode->selectNthItem(mMaterial->getDiffuseAlphaMode()); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; + } + getChild("maskcutoff")->setValue(mMaterial->getAlphaMaskCutoff()); + updateAlphaControls(getChild("combobox alphamode"),this); + + LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; + bool identical_texgen = true; + bool identical_planar_texgen = false; - return object->getTE(te_index)->getMaterialID(); + struct f44 : public LLSelectedTEGetFunctor + { + 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("shinytexture control"); + texture_ctrl->setImageAssetID(material->getSpecularID()); + LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->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("shinyScaleU")->setValue(repeat_x); + getChild("shinyScaleV")->setValue(repeat_y); + getChild("shinyRot")->setValue(rot*RAD_TO_DEG); + getChild("shinyOffsetU")->setValue(offset_x); + getChild("shinyOffsetV")->setValue(offset_y); + getChild("glossiness")->setValue(mMaterial->getSpecularLightExponent()); + getChild("environment")->setValue(mMaterial->getEnvironmentIntensity()); } - } func; + updateShinyControls(combobox_shininess,this, !mMaterial->getSpecularID().isNull(), true); - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) + // Assert desired colorswatch color to match material AFTER updateShinyControls + // to avoid getting overwritten with the default on some UI state changes. + // + if (!material->getSpecularID().isNull()) { - mMaterialID = node->getObject()->getTE(selected_te)->getMaterialID(); + getChild("shinycolorswatch")->setOriginal(mMaterial->getSpecularLightColor()); + getChild("shinycolorswatch")->set(mMaterial->getSpecularLightColor(),TRUE); } - } - llinfos << "Material ID returned: '" << mMaterialID.asString() << "', isNull? " << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; + // Bumpy (normal) + texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(mMaterial->getNormalID()); + LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!mMaterial->getNormalID().isNull()) + { + mMaterial->getNormalOffset(offset_x,offset_y); + mMaterial->getNormalRepeat(repeat_x,repeat_y); - if (!mMaterialID.isNull() && editable) - { - llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; - LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = material->getNormalRotation(); + getChild("bumpyScaleU")->setValue(repeat_x); + getChild("bumpyScaleV")->setValue(repeat_y); + getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); + getChild("bumpyOffsetU")->setValue(offset_x); + getChild("bumpyOffsetV")->setValue(offset_y); + } + updateBumpyControls(combobox_bumpiness,this, !mMaterial->getNormalID().isNull(), true); } } @@ -1658,104 +1730,6 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) -{ //laying out UI based on material parameters (calls setVisible on various components) - LL_DEBUGS("Materials") << "material id " << material_id.asString() << " data " << material->asLLSD() << LL_ENDL; - - //make a local copy of the material for editing - // (prevents local edits from overwriting client state on shared materials) - mMaterial = new LLMaterial(*material); - mMaterialID = material_id; - - // Alpha - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); - if (combobox_alphamode) - { - combobox_alphamode->selectNthItem(material->getDiffuseAlphaMode()); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; - } - getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("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 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("shinytexture control"); - texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("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("shinyScaleU")->setValue(repeat_x); - getChild("shinyScaleV")->setValue(repeat_y); - getChild("shinyRot")->setValue(rot*RAD_TO_DEG); - getChild("shinyOffsetU")->setValue(offset_x); - getChild("shinyOffsetV")->setValue(offset_y); - getChild("glossiness")->setValue(material->getSpecularLightExponent()); - getChild("environment")->setValue(material->getEnvironmentIntensity()); - } - updateShinyControls(combobox_shininess,this, !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. - // - if (!material->getSpecularID().isNull()) - { - getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); - getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); - } - - // Bumpy (normal) - texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("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("bumpyScaleU")->setValue(repeat_x); - getChild("bumpyScaleV")->setValue(repeat_y); - getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); - getChild("bumpyOffsetU")->setValue(offset_x); - getChild("bumpyOffsetV")->setValue(offset_y); - } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); -} - void LLPanelFace::updateMaterial() { // assign current state of UI to material definition for submit to sim LL_DEBUGS("Materials") << "Entered." << LL_ENDL; @@ -1781,53 +1755,38 @@ 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 = false; - if (!mMaterial) + + // Create new or clone material + // + if (mMaterial.isNull()) { - new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); + new_material = true; } - - LLMaterialPtr material_to_set = mMaterial; - - bool subselection = false; - - // If we're editing a single face and not the entire material for an object, - // we need to clone the material so that our changes to the material's settings - // don't automatically propagate to the non-selected faces - // NORSPEC-92 - // - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) + else { - if (node->getTESelectMask() != TE_SELECT_MASK_ALL) - { - llinfos << "Cloning material to apply to subselection." << llendl; - material_to_set = new LLMaterial(mMaterial->asLLSD()); - subselection = true; - } - else - { - llinfos << "Apply material change to whole selection." << llendl; - } + mMaterial = LLMaterialPtr(new LLMaterial(mMaterial->asLLSD())); } - llassert(!material_to_set.isNull()); + llassert_always(mMaterial); - material_to_set->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - material_to_set->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(norm_map_id); + mMaterial->setNormalID(norm_map_id); F32 bumpy_scale_u = getChild("bumpyScaleU")->getValue().asReal(); F32 bumpy_scale_v = getChild("bumpyScaleV")->getValue().asReal(); @@ -1838,18 +1797,18 @@ void LLPanelFace::updateMaterial() bumpy_scale_v *= 0.5f; } - material_to_set->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), + mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), getChild("bumpyOffsetV")->getValue().asReal()); - material_to_set->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); - material_to_set->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); + mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); } else { LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(LLUUID()); - material_to_set->setNormalOffset(0.0f,0.0f); - material_to_set->setNormalRepeat(1.0f,1.0f); - material_to_set->setNormalRotation(0.0f); + mMaterial->setNormalID(LLUUID()); + mMaterial->setNormalOffset(0.0f,0.0f); + mMaterial->setNormalRepeat(1.0f,1.0f); + mMaterial->setNormalRotation(0.0f); } LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); @@ -1857,8 +1816,8 @@ void LLPanelFace::updateMaterial() if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(spec_map_id); - material_to_set->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), + mMaterial->setSpecularID(spec_map_id); + mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), getChild("shinyOffsetV")->getValue().asReal()); F32 shiny_scale_u = getChild("shinyScaleU")->getValue().asReal(); @@ -1870,55 +1829,42 @@ void LLPanelFace::updateMaterial() shiny_scale_v *= 0.5f; } - material_to_set->setSpecularRepeat(shiny_scale_u, shiny_scale_v); - material_to_set->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setSpecularRepeat(shiny_scale_u, shiny_scale_v); + mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); //override shininess to 0.2f if this is a new material if (!new_material) { - material_to_set->setSpecularLightColor(getChild("shinycolorswatch")->get()); - material_to_set->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); - material_to_set->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); + mMaterial->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); } } else { LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(LLUUID()); - material_to_set->setSpecularOffset(0.0f,0.0f); - material_to_set->setSpecularRepeat(1.0f,1.0f); - material_to_set->setSpecularRotation(0.0f); - material_to_set->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); - material_to_set->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - material_to_set->setEnvironmentIntensity(0); + mMaterial->setSpecularID(LLUUID()); + mMaterial->setSpecularOffset(0.0f,0.0f); + mMaterial->setSpecularRepeat(1.0f,1.0f); + mMaterial->setSpecularRotation(0.0f); + mMaterial->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); + mMaterial->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + mMaterial->setEnvironmentIntensity(0); } - LL_DEBUGS("Materials") << "Updating material: " << material_to_set->asLLSD() << LL_ENDL; - + LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; - if (node && node->getObject() && node->getObject()->permModify() && subselection) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) - { - LLMaterialMgr::getInstance()->put(node->getObject()->getID(),selected_te,*material_to_set); - node->getObject()->getTE(selected_te)->setMaterialParams(material_to_set); - node->getObject()->sendTEUpdate(); - } - } - else - { - LLSelectMgr::getInstance()->selectionSetMaterial( material_to_set ); - } + LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); } else { // The user has specified settings that don't need a material. - if (mMaterial || !mMaterialID.isNull()) + //if (mMaterial || !mMaterialID.isNull()) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; mMaterial = NULL; mMaterialID = LLMaterialID::null; + // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 7fbeef223b..401dbd1e94 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -87,7 +87,7 @@ protected: void onCommitAlpha(const LLSD& data); void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material); + void updateMaterial(); static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 5a65623b91..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -815,6 +815,7 @@ void LLSelectMgr::addAsFamily(std::vector& objects, BOOL add_to if (objectp->getNumTEs() > 0) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else { @@ -872,10 +873,12 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab else if (face == SELECT_ALL_TES) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else if (0 <= face && face < SELECT_MAX_TES) { nodep->selectTE(face, TRUE); + objectp->setTESelected(face, true); } else { @@ -1095,6 +1098,7 @@ LLObjectSelectionHandle LLSelectMgr::selectHighlightedObjects() // flag this object as selected objectp->setSelected(TRUE); + objectp->setAllTESelected(true); mSelectedObjects->mSelectType = getSelectTypeForObject(objectp); @@ -1318,6 +1322,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) if (nodep->isTESelected(te)) { nodep->selectTE(te, FALSE); + objectp->setTESelected(te, false); } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 2965d968a3..548fb236d6 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -530,6 +530,17 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) } } +void LLViewerObject::setSelected(BOOL sel) +{ + mUserSelected = sel; + resetRot(); + + if (!sel) + { + setAllTESelected(false); + } +} + // This method returns true if the object is over land owned by the // agent. bool LLViewerObject::isReturnable() @@ -4116,14 +4127,8 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, LLViewerTexture *image) { mat->setNormalID(uuid); } - - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } } - mTENormalMaps[te] = image; + changeTENormalMap(te,image); return retval; } @@ -4144,14 +4149,9 @@ S32 LLViewerObject::setTESpecularMapCore(const U8 te, LLViewerTexture *image) if (mat) { mat->setSpecularID(uuid); - } - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); } } - mTESpecularMaps[te] = image; + changeTESpecularMap(te, image); return retval; } @@ -4171,6 +4171,11 @@ void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTENormalMaps[index] = new_image ; } @@ -4180,6 +4185,11 @@ void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTESpecularMaps[index] = new_image ; } @@ -4375,18 +4385,21 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; } - else if (pMaterialID != tep->getMaterialID()) + //else if (pMaterialID != tep->getMaterialID()) { LL_DEBUGS("Material") << "Changing texture entry for te " << (S32)te << ", object " << mID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); } return retval; } @@ -4398,22 +4411,23 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri if (!tep) { llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; + return 0; } - else if (pMaterialParams != tep->getMaterialParams()) + + retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); + LL_DEBUGS("Material") << "Changing material params for te " << (S32)te + << ", object " << mID + << " (" << retval << ")" + << LL_ENDL; + setTENormalMap(te, tep->getMaterialParams()->getNormalID()); + setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + + setChanged(TEXTURE); + if (mDrawable.notNull()) { - retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("Material") << "Changing material params for te " << (S32)te - << ", object " << mID - << " (" << retval << ")" - << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } + return retval; } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ba23ad97b0..bcb74a8d1f 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -211,7 +211,7 @@ public: LLViewerRegion* getRegion() const { return mRegionp; } BOOL isSelected() const { return mUserSelected; } - virtual void setSelected(BOOL sel) { mUserSelected = sel; resetRot();} + virtual void setSelected(BOOL sel); const LLUUID &getID() const { return mID; } U32 getLocalID() const { return mLocalID; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 941892a597..df014513ad 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,33 +1973,34 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) +void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; - for (U8 i = 0; i < getNumTEs(); i++) + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; + LLTextureEntry* texture_entry = getTE(te); + if (texture_entry && (texture_entry->getMaterialID().isNull() || (texture_entry->getMaterialID() == pMaterialID))) { - if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) - { - setTEMaterialParams(i, pMaterialParams); - } + setTEMaterialParams(te, pMaterialParams); } } S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); - LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res - << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) - << LL_ENDL; - if (res) - { - LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); - gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; - } - return res; + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res + << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) + << LL_ENDL; + + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); } + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; +} S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { @@ -2007,13 +2008,13 @@ S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialPa LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; - if (res) + setChanged(TEXTURE); + if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; } - - return res; + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index d1bfefdc70..a5f933c319 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,7 +187,7 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); + void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index b6fc48212a..a5425062ec 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -644,8 +644,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="bumpyRot" width="265" /> @@ -707,8 +707,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="shinyRot" width="265" /> -- cgit v1.3 From 5ac9d9cb05f22099bea8c9312f5e0b234430022a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 12 May 2013 16:10:31 +0200 Subject: LLMaterialMgr::get() doesn't handle a callback request for LLMaterialID::null --- indra/llprimitive/lltextureentry.cpp | 7 ++----- indra/newview/llmaterialmgr.cpp | 1 + indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 23 +++++++++++++---------- indra/newview/llvovolume.cpp | 18 ++++++++++-------- 5 files changed, 27 insertions(+), 24 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 8365c9d7b6..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -550,12 +550,9 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) mMaterialUpdatePending = false; mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; } - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + return TEM_CHANGE_NONE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..f217ff160e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -116,6 +116,7 @@ void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) LLMaterialMgr::LLMaterialMgr() { + mMaterials.insert(std::pair(LLMaterialID::null, LLMaterialPtr(NULL))); gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..e80ad6976e 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face,LLMaterialID::null); + object->setTEMaterialParams(face, NULL); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index d56df96c44..4e233d479a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,15 +4393,18 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - } - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) + if (retval) { - gPipeline.markTextured(mDrawable); + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } } + } return retval; } @@ -4420,11 +4423,11 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri << ", object " << mID << " (" << retval << ")" << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + setTENormalMap(te, (pMaterialParams) ? pMaterialParams->getNormalID() : LLUUID::null); + setTESpecularMap(te, (pMaterialParams) ? pMaterialParams->getSpecularID() : LLUUID::null); setChanged(TEXTURE); - if (mDrawable.notNull()) + if (mDrawable.notNull()) { gPipeline.markTextured(mDrawable); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 734ac2afc8..8e811527eb 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,21 +1991,23 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); - setChanged(TEXTURE); - if (!mDrawable.isNull()) + if (res) { - gPipeline.markTextured(mDrawable); + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); + } + mFaceMappingChanged = TRUE; } - mFaceMappingChanged = TRUE; - return TEM_CHANGE_TEXTURE; + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res + LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterialParams) ? pMaterialParams->asLLSD() : LLSD("null")) << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; setChanged(TEXTURE); -- cgit v1.3 From d9e8ee7cfd323872145c23e4032989f9b7770f55 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 13 May 2013 13:02:53 -0700 Subject: NORSPEC-178 NORSPEC-179 NORSPEC-180 made enable/disable handling more consistent and increased max range on repeats per meter --- indra/llprimitive/lltextureentry.cpp | 21 +- indra/newview/llmaterialmgr.cpp | 61 ++++++ indra/newview/llmaterialmgr.h | 22 ++ indra/newview/llpanelface.cpp | 241 +++++++++------------ indra/newview/llpanelface.h | 52 +++-- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 17 +- indra/newview/llvovolume.cpp | 8 +- .../skins/default/xui/en/panel_tools_texture.xml | 2 +- 9 files changed, 244 insertions(+), 182 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..ca57f1edbd 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,28 +539,21 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) + if (mMaterialID != pMaterialID) { - if (mSelected) + mMaterialID = pMaterialID; + + } + if (mMaterialID.isNull()) { - mMaterialUpdatePending = true; - mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + setMaterialParams(NULL); } - - mMaterialUpdatePending = false; - mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } - return TEM_CHANGE_NONE; -} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mSelected) - { - mMaterialUpdatePending = true; - } + mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index f217ff160e..59e5d05736 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,6 +217,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -301,6 +346,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index a6a7a5d1d7..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,9 +44,11 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -80,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index d108a260bc..b2f76e2114 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -596,6 +596,11 @@ void LLPanelFace::sendTextureInfo() } void LLPanelFace::getState() +{ + updateUI(); +} + +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(); @@ -636,12 +641,12 @@ void LLPanelFace::getState() } getChildView("combobox mattype")->setEnabled(editable); - onCommitMaterialsMedia(NULL, this); + updateVisibility(); bool identical; - bool identical_diffuse; - bool identical_norm; - bool identical_spec; + bool identical_diffuse; + bool identical_norm; + bool identical_spec; LLTextureCtrl* texture_ctrl = getChild("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); @@ -798,7 +803,7 @@ void LLPanelFace::getState() llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } - updateAlphaControls(getChild("combobox alphamode"),this); + updateAlphaControls(); } if(texture_ctrl && !texture_ctrl->isPickerShown()) @@ -1587,7 +1592,7 @@ void LLPanelFace::getState() llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("combobox alphamode"),this); + updateAlphaControls(); LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; bool identical_texgen = true; @@ -1607,7 +1612,7 @@ void LLPanelFace::getState() F32 offset_x, offset_y, repeat_x, repeat_y, rot; LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->getSpecularID().isNull()) { material->getSpecularOffset(offset_x,offset_y); @@ -1628,7 +1633,7 @@ void LLPanelFace::getState() getChild("glossiness")->setValue(material->getSpecularLightExponent()); getChild("environment")->setValue(material->getEnvironmentIntensity()); } - updateShinyControls(combobox_shininess,this, !material->getSpecularID().isNull(), true); + 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. @@ -1642,7 +1647,7 @@ void LLPanelFace::getState() // Bumpy (normal) texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!material->getNormalID().isNull()) { material->getNormalOffset(offset_x,offset_y); @@ -1661,7 +1666,7 @@ void LLPanelFace::getState() getChild("bumpyOffsetU")->setValue(offset_x); getChild("bumpyOffsetV")->setValue(offset_y); } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); + updateBumpyControls(!material->getNormalID().isNull(), true); } } @@ -1702,12 +1707,11 @@ void LLPanelFace::getState() 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); - onCommitMaterialsMedia(NULL,this); + updateVisibility(); // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); @@ -1904,10 +1908,16 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); - LLComboBox* combo_mattype = self->getChild("combobox mattype"); - LLComboBox* combo_shininess = self->getChild("combobox shininess"); - LLComboBox* combo_bumpiness = self->getChild("combobox bumpiness"); + self->updateUI(); +} + +// static +void LLPanelFace::updateVisibility() +{ + LLComboBox* combo_matmedia = getChild("combobox matmedia"); + LLComboBox* combo_mattype = getChild("combobox mattype"); + LLComboBox* combo_shininess = getChild("combobox shininess"); + LLComboBox* combo_bumpiness = getChild("combobox bumpiness"); if (!combo_mattype || !combo_matmedia || !combo_shininess || !combo_bumpiness) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; @@ -1919,93 +1929,66 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) 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(true); + getChildView("combobox mattype")->setVisible(!show_media); + getChildView("rptctrl")->setVisible(true); // Media controls - self->getChildView("media_info")->setVisible(show_media); - self->getChildView("add_media")->setVisible(show_media); - self->getChildView("delete_media")->setVisible(show_media); - self->getChildView("button align")->setVisible(show_media); + getChildView("media_info")->setVisible(show_media); + getChildView("add_media")->setVisible(show_media); + getChildView("delete_media")->setVisible(show_media); + getChildView("button align")->setVisible(show_media); // Diffuse texture controls - 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); + getChildView("texture control")->setVisible(show_texture && !show_media); + getChildView("label alphamode")->setVisible(show_texture && !show_media); + getChildView("combobox alphamode")->setVisible(show_texture && !show_media); + getChildView("label maskcutoff")->setVisible(false); + getChildView("maskcutoff")->setVisible(false); if (show_texture && !show_media) { - updateAlphaControls(ctrl, userdata); + updateAlphaControls(); } - self->getChildView("TexScaleU")->setVisible(show_texture); - self->getChildView("TexScaleV")->setVisible(show_texture); - self->getChildView("TexRot")->setVisible(show_texture); - self->getChildView("TexOffsetU")->setVisible(show_texture); - self->getChildView("TexOffsetV")->setVisible(show_texture); + getChildView("TexScaleU")->setVisible(show_texture); + getChildView("TexScaleV")->setVisible(show_texture); + getChildView("TexRot")->setVisible(show_texture); + getChildView("TexOffsetU")->setVisible(show_texture); + getChildView("TexOffsetV")->setVisible(show_texture); // Specular map controls - self->getChildView("shinytexture control")->setVisible(show_shininess); - self->getChildView("combobox shininess")->setVisible(show_shininess); - self->getChildView("label shininess")->setVisible(show_shininess); - self->getChildView("label glossiness")->setVisible(false); - self->getChildView("glossiness")->setVisible(false); - self->getChildView("label environment")->setVisible(false); - self->getChildView("environment")->setVisible(false); - self->getChildView("label shinycolor")->setVisible(false); - self->getChildView("shinycolorswatch")->setVisible(false); + getChildView("shinytexture control")->setVisible(show_shininess); + getChildView("combobox shininess")->setVisible(show_shininess); + getChildView("label shininess")->setVisible(show_shininess); + getChildView("label glossiness")->setVisible(false); + getChildView("glossiness")->setVisible(false); + getChildView("label environment")->setVisible(false); + getChildView("environment")->setVisible(false); + getChildView("label shinycolor")->setVisible(false); + getChildView("shinycolorswatch")->setVisible(false); if (show_shininess) { - updateShinyControls(ctrl, userdata); + updateShinyControls(); } - self->getChildView("shinyScaleU")->setVisible(show_shininess); - self->getChildView("shinyScaleV")->setVisible(show_shininess); - self->getChildView("shinyRot")->setVisible(show_shininess); - self->getChildView("shinyOffsetU")->setVisible(show_shininess); - self->getChildView("shinyOffsetV")->setVisible(show_shininess); + getChildView("shinyScaleU")->setVisible(show_shininess); + getChildView("shinyScaleV")->setVisible(show_shininess); + getChildView("shinyRot")->setVisible(show_shininess); + getChildView("shinyOffsetU")->setVisible(show_shininess); + getChildView("shinyOffsetV")->setVisible(show_shininess); // Normal map controls if (show_bumpiness) { - updateBumpyControls(ctrl, userdata); + updateBumpyControls(); } - self->getChildView("bumpytexture control")->setVisible(show_bumpiness); - self->getChildView("combobox bumpiness")->setVisible(show_bumpiness); - self->getChildView("label bumpiness")->setVisible(show_bumpiness); - self->getChildView("bumpyScaleU")->setVisible(show_bumpiness); - self->getChildView("bumpyScaleV")->setVisible(show_bumpiness); - self->getChildView("bumpyRot")->setVisible(show_bumpiness); - self->getChildView("bumpyOffsetU")->setVisible(show_bumpiness); - self->getChildView("bumpyOffsetV")->setVisible(show_bumpiness); - - // Enable texture scale/rotation/offset parameters if there's one - // present to set for - bool texParmsEnable = show_texture || - (show_shininess && (combo_shininess->getCurrentIndex() == SHINY_TEXTURE)) || - (show_bumpiness && (combo_bumpiness->getCurrentIndex() == BUMPY_TEXTURE)); - self->getChildView("tex gen")->setEnabled(texParmsEnable); - self->getChildView("combobox texgen")->setEnabled(texParmsEnable); - self->getChildView("rptctrl")->setEnabled(texParmsEnable); - self->getChildView("TexScaleU")->setEnabled(texParmsEnable); - self->getChildView("TexScaleV")->setEnabled(texParmsEnable); - self->getChildView("TexRot")->setEnabled(texParmsEnable); - self->getChildView("TexOffsetU")->setEnabled(texParmsEnable); - self->getChildView("TexOffsetV")->setEnabled(texParmsEnable); - self->getChildView("shinyScaleU")->setEnabled(texParmsEnable); - self->getChildView("shinyScaleV")->setEnabled(texParmsEnable); - self->getChildView("shinyRot")->setEnabled(texParmsEnable); - self->getChildView("shinyOffsetU")->setEnabled(texParmsEnable); - self->getChildView("shinyOffsetV")->setEnabled(texParmsEnable); - self->getChildView("bumpyScaleU")->setEnabled(texParmsEnable); - self->getChildView("bumpyScaleV")->setEnabled(texParmsEnable); - self->getChildView("bumpyRot")->setEnabled(texParmsEnable); - self->getChildView("bumpyOffsetU")->setEnabled(texParmsEnable); - self->getChildView("bumpyOffsetV")->setEnabled(texParmsEnable); - self->getChildView("checkbox planar align")->setEnabled(texParmsEnable); - - // Needed to handle transitions to/from media mode - // NORSPEC-84 - updateAlphaControls(ctrl,userdata); + getChildView("bumpytexture control")->setVisible(show_bumpiness); + getChildView("combobox bumpiness")->setVisible(show_bumpiness); + getChildView("label bumpiness")->setVisible(show_bumpiness); + getChildView("bumpyScaleU")->setVisible(show_bumpiness); + getChildView("bumpyScaleV")->setVisible(show_bumpiness); + getChildView("bumpyRot")->setVisible(show_bumpiness); + getChildView("bumpyOffsetU")->setVisible(show_bumpiness); + getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + + } // static @@ -2016,7 +1999,7 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) // like the texture ctrls for diffuse/norm/spec so that they are correct // when switching modes // - self->getState(); + self->updateUI(); } // static @@ -2024,10 +2007,7 @@ void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->sendBump(); - - LLComboBox* combo_bumpy = self->getChild("combobox bumpiness"); - - updateBumpyControls(combo_bumpy,self, false, true); + self->updateBumpyControls(false, true); self->updateMaterial(); } @@ -2039,13 +2019,12 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) } // static -void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_shiny_combobox) +void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_shiny_combobox) { - LLPanelFace* self = (LLPanelFace*) userdata; - LLTextureCtrl* texture_ctrl = self->getChild("shinytexture control"); + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); LLUUID shiny_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; - LLComboBox* comboShiny = self->getChild("combobox shininess"); + LLComboBox* comboShiny = getChild("combobox shininess"); if(mess_with_shiny_combobox) { @@ -2061,15 +2040,15 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_se // NORSPEC-94: Set default specular color to white // - LLColorSwatchCtrl* mShinyColorSwatch = self->getChild("shinycolorswatch"); + LLColorSwatchCtrl* mShinyColorSwatch = getChild("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("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - self->getChild("environment")->setValue(0); + getChild("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + getChild("environment")->setValue(0); } comboShiny->setSimple(USE_TEXTURE); } @@ -2084,30 +2063,29 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_se } } - LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); - LLComboBox* combo_mattype = self->getChild("combobox mattype"); + LLComboBox* combo_matmedia = getChild("combobox matmedia"); + LLComboBox* combo_mattype = getChild("combobox mattype"); U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = combo_mattype->getCurrentIndex(); bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture - self->getChildView("label glossiness")->setVisible(show_shinyctrls); - self->getChildView("glossiness")->setVisible(show_shinyctrls); - self->getChildView("label environment")->setVisible(show_shinyctrls); - self->getChildView("environment")->setVisible(show_shinyctrls); - self->getChildView("label shinycolor")->setVisible(show_shinyctrls); - self->getChildView("shinycolorswatch")->setVisible(show_shinyctrls); + getChildView("label glossiness")->setVisible(show_shinyctrls); + getChildView("glossiness")->setVisible(show_shinyctrls); + getChildView("label environment")->setVisible(show_shinyctrls); + getChildView("environment")->setVisible(show_shinyctrls); + getChildView("label shinycolor")->setVisible(show_shinyctrls); + getChildView("shinycolorswatch")->setVisible(show_shinyctrls); } // static -void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_combobox) +void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_combobox) { - LLPanelFace* self = (LLPanelFace*) userdata; - LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLTextureCtrl* texture_ctrl = getChild("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; - LLComboBox* comboBumpy = self->getChild("combobox bumpiness"); + LLComboBox* comboBumpy = getChild("combobox bumpiness"); if (!comboBumpy) { return; @@ -2115,7 +2093,7 @@ void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_se if (mess_with_combobox) { - LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLTextureCtrl* texture_ctrl = getChild("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; @@ -2144,19 +2122,17 @@ void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->sendShiny(); - LLComboBox* combo_shiny = self->getChild("combobox shininess"); // 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, false, true); + self->updateShinyControls(false, true); self->updateMaterial(); } // static -void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::updateAlphaControls() { - LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* comboAlphaMode = self->getChild("combobox alphamode"); + LLComboBox* comboAlphaMode = getChild("combobox alphamode"); if (!comboAlphaMode) { return; @@ -2164,14 +2140,14 @@ void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) U32 alpha_value = comboAlphaMode->getCurrentIndex(); bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking - LLComboBox* combobox_matmedia = self->getChild("combobox matmedia"); + LLComboBox* combobox_matmedia = getChild("combobox matmedia"); U32 mat_media = MATMEDIA_MATERIAL; if (combobox_matmedia) { mat_media = combobox_matmedia->getCurrentIndex(); } - LLComboBox* combobox_mattype = self->getChild("combobox mattype"); + LLComboBox* combobox_mattype = getChild("combobox mattype"); U32 mat_type = MATTYPE_DIFFUSE; if (combobox_mattype) { @@ -2181,15 +2157,15 @@ void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) show_alphactrls = show_alphactrls && (mat_media == MATMEDIA_MATERIAL); show_alphactrls = show_alphactrls && (mat_type == MATTYPE_DIFFUSE); - self->getChildView("label maskcutoff")->setVisible(show_alphactrls); - self->getChildView("maskcutoff")->setVisible(show_alphactrls); + getChildView("label maskcutoff")->setVisible(show_alphactrls); + getChildView("maskcutoff")->setVisible(show_alphactrls); } // static void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - updateAlphaControls(ctrl,userdata); + self->updateAlphaControls(); self->updateMaterial(); } @@ -2245,46 +2221,40 @@ void LLPanelFace::onSelectTexture(const LLSD& data) void LLPanelFace::onCommitSpecularTexture( const LLSD& data ) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, true, true); + updateShinyControls(true, true); updateMaterial(); } void LLPanelFace::onCommitNormalTexture( const LLSD& data ) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy, this, true, true); + updateBumpyControls(true, true); updateMaterial(); } void LLPanelFace::onCancelSpecularTexture(const LLSD& data) { updateMaterial(); - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, false, true); + updateShinyControls(false, true); } void LLPanelFace::onCancelNormalTexture(const LLSD& data) { updateMaterial(); - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy,this, false, true); + updateBumpyControls(false, true); } void LLPanelFace::onSelectSpecularTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; updateMaterial(); - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, true, true); + updateShinyControls(true, true); } void LLPanelFace::onSelectNormalTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy,this, true, true); + updateBumpyControls(true, true); updateMaterial(); } @@ -2310,9 +2280,10 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) gFocusMgr.setKeyboardFocus( NULL ); - //F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get(); - F32 repeats_per_meter = (F32)self->getChild("rptctrl")->getValue().asReal();//self->mCtrlRepeatsPerMeter->get(); + LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); F32 obj_scale_s = 1.0f; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 4e97295b84..88f32e45f8 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -67,7 +67,7 @@ protected: void sendTexGen(); // applies and sends bump map void sendShiny(); // applies and sends shininess void sendFullbright(); // applies and sends full bright - void sendGlow(); + void sendGlow(); void sendMedia(); // this function is to return TRUE if the drag should succeed. @@ -88,29 +88,49 @@ protected: void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void updateMaterial(); - - static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); - static void onCommitBump( LLUICtrl* ctrl, void* userdata); + // Make UI reflect state of currently selected material (refresh) + // and UI mode (e.g. editing normal map v diffuse map) + // + void updateUI(); + + // Callback funcs for individual controls + // + static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); + static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); - static void updateShinyControls( LLUICtrl* ctrl, void* userdata, bool is_setting_texture = false, bool mess_with_combobox = false); - static void updateBumpyControls( LLUICtrl* ctrl, void* userdata, bool is_setting_texture = false, bool mess_with_combobox = false); - static void onCommitShiny( LLUICtrl* ctrl, void* userdata); - static void updateAlphaControls( LLUICtrl* ctrl, void* userdata); + static void onCommitShiny( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); - static void onCommitGlow( LLUICtrl* ctrl, void *userdata); - static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); - + static void onCommitGlow( LLUICtrl* ctrl, void *userdata); + static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); static void onClickAutoFix(void*); - static F32 valueGlow(LLViewerObject* object, S32 face); + + static F32 valueGlow(LLViewerObject* object, S32 face); private: + // Update visibility of controls to match current UI mode + // (e.g. materials vs media editing) + // + // Do NOT call updateUI from within this function. + // + void updateVisibility(); + + // Make material reflect current state of UI (apply edit) + // + void updateMaterial(); + + // Update vis and enabling of specific subsets of controls based on material params + // (e.g. hide the spec controls if no spec texture is applied) + // + void updateShinyControls(bool is_setting_texture = false, bool mess_with_combobox = false); + void updateBumpyControls(bool is_setting_texture = false, bool mess_with_combobox = false); + void updateAlphaControls(); + /* * Checks whether the selected texture from the LLFloaterTexturePicker can be applied to the currently selected object. * If agent selects texture which is not allowed to be applied for the currently selected object, diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index e80ad6976e..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialParams(face, NULL); + object->setTEMaterialID(face,LLMaterialID::null); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4e233d479a..f8bc6ef4d3 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,18 +4393,15 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - if (retval) + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) { - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } - } return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8e811527eb..1021615255 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,17 +1991,15 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - if (res) - { - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); setChanged(TEXTURE); if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); } mFaceMappingChanged = TRUE; - } - return res; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index a5425062ec..5be3ca9d9f 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -567,7 +567,7 @@ layout="topleft" label_width="205" left="10" - max_val="10" + max_val="100" min_val="0.1" name="rptctrl" width="265" /> -- cgit v1.3 From ad09e2111cd980117ae937b79155ef6c24e4567c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 14 May 2013 21:14:46 +0200 Subject: NORSPEC-102 & Co Reloaded --- indra/llprimitive/lltextureentry.cpp | 21 ++++++++----- indra/newview/llmaterialmgr.cpp | 61 ------------------------------------ indra/newview/llmaterialmgr.h | 22 ------------- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 17 +++++----- indra/newview/llvovolume.cpp | 8 +++-- 6 files changed, 30 insertions(+), 101 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index ca57f1edbd..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,21 +539,28 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { - mMaterialID = pMaterialID; - - } - if (mMaterialID.isNull()) + if (mSelected) { - setMaterialParams(NULL); + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; } + + mMaterialUpdatePending = false; + mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } + return TEM_CHANGE_NONE; +} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 59e5d05736..f217ff160e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,51 +217,6 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } -boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) -{ - boost::signals2::connection connection; - - material_map_t::const_iterator itMaterial = mMaterials.find(material_id); - if (itMaterial != mMaterials.end()) - { - LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; - get_callback_te_t signal; - signal.connect(cb); - signal(material_id, itMaterial->second, te); - connection = boost::signals2::connection(); - } - else - { - if (!isGetPending(region_id, material_id)) - { - get_queue_t::iterator itQueue = mGetQueue.find(region_id); - if (mGetQueue.end() == itQueue) - { - LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); - itQueue = ret.first; - } - LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; - itQueue->second.insert(material_id); - markGetPending(region_id, material_id); - } - - TEMaterialPair te_mat_pair; - te_mat_pair.te = te; - te_mat_pair.materialID = material_id; - - get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); - if (itCallback == mGetTECallbacks.end()) - { - std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); - itCallback = ret.first; - } - connection = itCallback->second->connect(cb); - } - - return connection; -} - bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -346,22 +301,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } - TEMaterialPair te_mat_pair; - te_mat_pair.materialID = material_id; - - U32 i = 0; - while (i < LLTEContents::MAX_TES) - { - te_mat_pair.te = i++; - get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); - if (itCallbackTE != mGetTECallbacks.end()) - { - (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); - delete itCallbackTE->second; - mGetTECallbacks.erase(itCallbackTE); - } - } - return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 922b16f1cf..a6a7a5d1d7 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,11 +44,9 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; - typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); - boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -82,26 +80,6 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; - // struct for TE-specific material ID query - struct TEMaterialPair - { - U32 te; - LLMaterialID materialID; - }; - - // needed for std::map compliance only - // - friend inline bool operator<( - const struct LLMaterialMgr::TEMaterialPair& lhs, - const struct LLMaterialMgr::TEMaterialPair& rhs) - { - return (lhs.materialID < rhs.materialID) ? TRUE : - (lhs.te < rhs.te) ? TRUE : FALSE; - } - - typedef std::map get_callback_te_map_t; - get_callback_te_map_t mGetTECallbacks; - typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..e80ad6976e 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face,LLMaterialID::null); + object->setTEMaterialParams(face, NULL); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f8bc6ef4d3..4e233d479a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,15 +4393,18 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - } - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) + if (retval) { - gPipeline.markTextured(mDrawable); + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } } + } return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 1021615255..8e811527eb 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,15 +1991,17 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + if (res) + { + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); setChanged(TEXTURE); if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); } mFaceMappingChanged = TRUE; - return TEM_CHANGE_TEXTURE; + } + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) -- cgit v1.3 From a37bff8bf1add5afe154b25156d7ebe38ff9af31 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 14 May 2013 15:26:43 -0700 Subject: NORSPEC-103 reflect normal/spec UVs in face edit overlay display --- indra/newview/llface.cpp | 4 +- indra/newview/llpanelface.cpp | 19 ++++++++- indra/newview/llselectmgr.cpp | 77 ++++++++++++++++++++++++++++----- indra/newview/llselectmgr.h | 8 +++- indra/newview/llviewershadermgr.cpp | 25 +++++++++++ indra/newview/llviewershadermgr.h | 3 ++ indra/newview/pipeline.cpp | 85 ++++++++++++++++++++++++++++++++++--- indra/newview/pipeline.h | 7 +++ 8 files changed, 207 insertions(+), 21 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 007ad1f8d9..eb78d42c35 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -582,7 +582,9 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) } else { - mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); + // cheaters sometimes prosper... + // + mVertexBuffer->setBuffer(mVertexBuffer->getTypeMask()); mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); } diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9d0b9d0cac..f8c05bd007 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1646,6 +1646,18 @@ void LLPanelFace::updateUI() getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); } + // Update sel manager as to which channel we're editing so it can reflect the correct overlay UI + // NORSPEC-103 + LLRender::eTexIndex channel_to_edit = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? (LLRender::eTexIndex)combobox_mattype->getCurrentIndex() : LLRender::DIFFUSE_MAP; + + if ( ((channel_to_edit == LLRender::NORMAL_MAP) && material->getNormalID().isNull()) + ||((channel_to_edit == LLRender::SPECULAR_MAP) && material->getSpecularID().isNull())) + { + channel_to_edit = LLRender::DIFFUSE_MAP; + } + + LLSelectMgr::getInstance()->setTextureChannel(channel_to_edit); + // Bumpy (normal) texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); @@ -1670,7 +1682,10 @@ void LLPanelFace::updateUI() } updateBumpyControls(!material->getNormalID().isNull(), true); } - + else + { + LLSelectMgr::getInstance()->setTextureChannel(LLRender::DIFFUSE_MAP); + } } // Set variable values for numeric expressions @@ -1856,7 +1871,7 @@ void LLPanelFace::updateMaterial() } LL_DEBUGS("Materials") << "Updating material: " << material->asLLSD() << LL_ENDL; - + LLSelectMgr::getInstance()->selectionSetMaterial( material ); } else diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..7c9c935a1b 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -188,6 +188,7 @@ LLSelectMgr::LLSelectMgr() mDebugSelectMgr(LLCachedControl(gSavedSettings, "DebugSelectMgr", FALSE)) { mTEMode = FALSE; + mTextureChannel = LLRender::DIFFUSE_MAP; mLastCameraPos.clearVec(); sHighlightThickness = gSavedSettings.getF32("SelectionHighlightThickness"); @@ -236,6 +237,8 @@ void LLSelectMgr::clearSelections() mHighlightedObjects->deleteAllNodes(); mRectSelectedObjects.clear(); mGridObjects.deleteAllNodes(); + + LLPipeline::setRenderHighlightTextureChannel(LLRender::DIFFUSE_MAP); } void LLSelectMgr::update() @@ -844,6 +847,10 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab // check to see if object is already in list LLSelectNode *nodep = mSelectedObjects->findNode(objectp); + // Reset (in anticipation of being set to an appropriate value by panel refresh, if they're up) + // + setTextureChannel(LLRender::DIFFUSE_MAP); + // if not in list, add it if (!nodep) { @@ -4467,7 +4474,8 @@ void LLSelectMgr::saveSelectedObjectTransform(EActionType action_type) struct f : public LLSelectedNodeFunctor { EActionType mActionType; - f(EActionType a) : mActionType(a) {} + LLSelectMgr* mManager; + f(EActionType a, LLSelectMgr* p) : mActionType(a), mManager(p) {} virtual bool apply(LLSelectNode* selectNode) { LLViewerObject* object = selectNode->getObject(); @@ -4514,10 +4522,10 @@ void LLSelectMgr::saveSelectedObjectTransform(EActionType action_type) } selectNode->mSavedScale = object->getScale(); - selectNode->saveTextureScaleRatios(); + selectNode->saveTextureScaleRatios(mManager->mTextureChannel); return true; } - } func(action_type); + } func(action_type, this); getSelection()->applyToNodes(&func); mSavedSelectionBBox = getBBoxOfSelection(); @@ -5828,23 +5836,72 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures) } } -void LLSelectNode::saveTextureScaleRatios() +void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { mTextureScaleRatios.clear(); if (mObject.notNull()) { + + LLVector3 scale = mObject->getScale(); + for (U8 i = 0; i < mObject->getNumTEs(); i++) { - F32 s,t; + F32 s = 1.0f; + F32 t = 1.0f; + + LLVector3 v; + const LLTextureEntry* tep = mObject->getTE(i); - tep->getScale(&s,&t); - U32 s_axis = 0; - U32 t_axis = 0; + if (!tep) + continue; + + LLMaterialPtr mat = tep->getMaterialParams(); + U32 s_axis = VX; + U32 t_axis = VY; LLPrimitive::getTESTAxes(i, &s_axis, &t_axis); - LLVector3 v; - LLVector3 scale = mObject->getScale(); + switch(index_to_query) + { + case LLRender::DIFFUSE_MAP: + { + tep->getScale(&s,&t); + } + break; + + case LLRender::NORMAL_MAP: + { + if (mat) + { + mat->getNormalRepeat(s, t); + } + else + { + tep->getScale(&s,&t); + } + + } + break; + + case LLRender::SPECULAR_MAP: + { + if (mat) + { + mat->getSpecularRepeat(s, t); + } + else + { + tep->getScale(&s,&t); + } + } + break; + + default: + // should never be. + // + llassert_always(false); + break; + } if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) { diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 1991b5581b..f9b97cebdd 100755 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -147,7 +147,7 @@ public: // *NOTE: invalidate stored textures and colors when # faces change void saveColors(); void saveTextures(const uuid_vec_t& textures); - void saveTextureScaleRatios(); + void saveTextureScaleRatios(LLRender::eTexIndex index_to_query); BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const; @@ -514,6 +514,11 @@ public: void saveSelectedObjectColors(); void saveSelectedObjectTextures(); + // Sets which texture channel to query for scale and rot of display + // and depends on UI state of LLPanelFace when editing + void setTextureChannel(LLRender::eTexIndex texIndex) { mTextureChannel = texIndex; } + LLRender::eTexIndex getTextureChannel() { return mTextureChannel; } + void selectionUpdatePhysics(BOOL use_physics); void selectionUpdateTemporary(BOOL is_temporary); void selectionUpdatePhantom(BOOL is_ghost); @@ -777,6 +782,7 @@ private: EGridMode mGridMode; BOOL mTEMode; // render te + LLRender::eTexIndex mTextureChannel; // diff, norm, or spec, depending on UI editing mode LLVector3d mSelectionCenterGlobal; LLBBox mSelectionBBox; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index fce06b9e13..022ddb69ce 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -143,6 +143,9 @@ LLGLSLShader gUnderWaterProgram; //interface shaders LLGLSLShader gHighlightProgram; +LLGLSLShader gHighlightNormalProgram; +LLGLSLShader gHighlightSpecularProgram; + LLGLSLShader gPathfindingProgram; LLGLSLShader gPathfindingNoNormalsProgram; @@ -752,6 +755,8 @@ void LLViewerShaderMgr::unloadShaders() gAvatarEyeballProgram.unload(); gAvatarPickProgram.unload(); gHighlightProgram.unload(); + gHighlightNormalProgram.unload(); + gHighlightSpecularProgram.unload(); gWLSkyProgram.unload(); gWLCloudProgram.unload(); @@ -2703,6 +2708,26 @@ BOOL LLViewerShaderMgr::loadShadersInterface() success = gHighlightProgram.createShader(NULL, NULL); } + if (success) + { + gHighlightNormalProgram.mName = "Highlight Normals Shader"; + gHighlightNormalProgram.mShaderFiles.clear(); + gHighlightNormalProgram.mShaderFiles.push_back(make_pair("interface/highlightNormV.glsl", GL_VERTEX_SHADER_ARB)); + gHighlightNormalProgram.mShaderFiles.push_back(make_pair("interface/highlightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gHighlightNormalProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gHighlightNormalProgram.createShader(NULL, NULL); + } + + if (success) + { + gHighlightSpecularProgram.mName = "Highlight Spec Shader"; + gHighlightSpecularProgram.mShaderFiles.clear(); + gHighlightSpecularProgram.mShaderFiles.push_back(make_pair("interface/highlightSpecV.glsl", GL_VERTEX_SHADER_ARB)); + gHighlightSpecularProgram.mShaderFiles.push_back(make_pair("interface/highlightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gHighlightSpecularProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gHighlightSpecularProgram.createShader(NULL, NULL); + } + if (success) { gUIProgram.mName = "UI Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 5ef5d2234c..a24427a7bb 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -301,6 +301,9 @@ extern LLGLSLShader gGlowExtractProgram; //interface shaders extern LLGLSLShader gHighlightProgram; +extern LLGLSLShader gHighlightNormalProgram; +extern LLGLSLShader gHighlightSpecularProgram; + extern LLGLSLShader gPathfindingProgram; extern LLGLSLShader gPathfindingNoNormalsProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f4b445c2eb..bcbd752550 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -354,6 +354,7 @@ BOOL LLPipeline::sRenderParticleBeacons = FALSE; BOOL LLPipeline::sRenderSoundBeacons = FALSE; BOOL LLPipeline::sRenderBeacons = FALSE; BOOL LLPipeline::sRenderHighlight = TRUE; +LLRender::eTexIndex LLPipeline::sRenderHighlightTextureChannel = LLRender::DIFFUSE_MAP; BOOL LLPipeline::sForceOldBakedUpload = FALSE; S32 LLPipeline::sUseOcclusion = 0; BOOL LLPipeline::sDelayVBUpdate = TRUE; @@ -3843,7 +3844,9 @@ void LLPipeline::postSort(LLCamera& camera) if (!sShadowRender) { mSelectedFaces.clear(); - + + LLPipeline::setRenderHighlightTextureChannel(LLSelectMgr::getInstance()->getTextureChannel()); + // Draw face highlights for selected faces. if (LLSelectMgr::getInstance()->getTEMode()) { @@ -4066,13 +4069,14 @@ void LLPipeline::renderHighlights() gGL.diffuseColor4f(1,1,1,0.5f); } - if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && !mFaceSelectImagep) + { + mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT); + } + + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::DIFFUSE_MAP)) { // Make sure the selection image gets downloaded and decoded - if (!mFaceSelectImagep) - { - mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT); - } mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); U32 count = mSelectedFaces.size(); @@ -4088,7 +4092,7 @@ void LLPipeline::renderHighlights() facep->renderSelected(mFaceSelectImagep, color); } } - + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) { // Paint 'em red! @@ -4110,6 +4114,67 @@ void LLPipeline::renderHighlights() { gHighlightProgram.unbind(); } + + + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::NORMAL_MAP)) + { + color.setVec(1.0f, 0.5f, 0.5f, 0.5f); + if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + { + gHighlightNormalProgram.bind(); + gGL.diffuseColor4f(1,1,1,0.5f); + } + + mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); + + U32 count = mSelectedFaces.size(); + for (U32 i = 0; i < count; i++) + { + LLFace *facep = mSelectedFaces[i]; + if (!facep || facep->getDrawable()->isDead()) + { + llerrs << "Bad face on selection" << llendl; + return; + } + + facep->renderSelected(mFaceSelectImagep, color); + } + + if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + { + gHighlightNormalProgram.unbind(); + } + } + + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::SPECULAR_MAP)) + { + color.setVec(0.0f, 0.3f, 1.0f, 0.8f); + if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + { + gHighlightSpecularProgram.bind(); + gGL.diffuseColor4f(1,1,1,0.5f); + } + + mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); + + U32 count = mSelectedFaces.size(); + for (U32 i = 0; i < count; i++) + { + LLFace *facep = mSelectedFaces[i]; + if (!facep || facep->getDrawable()->isDead()) + { + llerrs << "Bad face on selection" << llendl; + return; + } + + facep->renderSelected(mFaceSelectImagep, color); + } + + if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + { + gHighlightSpecularProgram.unbind(); + } + } } //debug use @@ -6727,6 +6792,12 @@ BOOL LLPipeline::getRenderHighlights(void*) return sRenderHighlight; } +// static +void LLPipeline::setRenderHighlightTextureChannel(LLRender::eTexIndex channel) +{ + sRenderHighlightTextureChannel = channel; +} + LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end, BOOL pick_transparent, S32* face_hit, diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 9b7d1d642c..4aee8f14d6 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -394,6 +394,7 @@ public: static void setRenderHighlights(BOOL val); static void toggleRenderHighlights(void* data); static BOOL getRenderHighlights(void* data); + static void setRenderHighlightTextureChannel(LLRender::eTexIndex channel); // sets which UV setup to display in highlight overlay static void updateRenderBump(); static void updateRenderDeferred(); @@ -401,6 +402,8 @@ public: static void throttleNewMemoryAllocation(BOOL disable); + + void addDebugBlip(const LLVector3& position, const LLColor4& color); void hidePermanentObjects( std::vector& restoreList ); @@ -847,6 +850,10 @@ public: static BOOL sRenderBeacons; static BOOL sRenderHighlight; + // Determines which set of UVs to use in highlight display + // + static LLRender::eTexIndex sRenderHighlightTextureChannel; + //debug use static U32 sCurRenderPoolType ; -- cgit v1.3 From d187ee8e59787f15b5be1b1d811e0345aa05e8bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 21 May 2013 16:51:36 -0700 Subject: NORSPEC-96 slight refrain, make Stretch Textures apply to norm/spec maps in planar texgen mode --- indra/newview/llselectmgr.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index e42d29f7e3..15e5f9f740 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2507,8 +2507,42 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) // Apply new scale to face if (planar) { - object->setTEScale(te_num, 1.f/object_scale.mV[s_axis]*scale_ratio.mV[s_axis], - 1.f/object_scale.mV[t_axis]*scale_ratio.mV[t_axis]); + F32 scale_s = scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 scale_t = scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + + switch (mTextureChannel) + { + case LLRender::DIFFUSE_MAP: + { + object->setTEScale(te_num, scale_s, scale_t); + } + break; + + case LLRender::NORMAL_MAP: + { + LLTextureEntry* tep = object->getTE(te_num); + if (tep && !tep->getMaterialParams().isNull()) + { + LLMaterialPtr p = tep->getMaterialParams(); + p->setNormalRepeat(scale_s * 0.5f, scale_t * 0.5f); + } + } + break; + + case LLRender::SPECULAR_MAP: + { + LLTextureEntry* tep = object->getTE(te_num); + if (tep && !tep->getMaterialParams().isNull()) + { + LLMaterialPtr p = tep->getMaterialParams(); + p->setSpecularRepeat(scale_s * 0.5f, scale_t * 0.5f); + } + } + break; + default: + break; + } + } else { -- cgit v1.3 From 8b7a4c503c1a64480cdd411012cae94880bf143f Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 21 May 2013 17:09:04 -0700 Subject: NORSPEC-96 tweak fix to follow clone/modify/re-apply pattern from build tool to avoid changing objects sharing a material --- indra/newview/llselectmgr.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 15e5f9f740..1bb12e495d 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2523,8 +2523,10 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) LLTextureEntry* tep = object->getTE(te_num); if (tep && !tep->getMaterialParams().isNull()) { - LLMaterialPtr p = tep->getMaterialParams(); + LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setNormalRepeat(scale_s * 0.5f, scale_t * 0.5f); + selectionSetMaterial( p ); } } break; @@ -2534,8 +2536,10 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) LLTextureEntry* tep = object->getTE(te_num); if (tep && !tep->getMaterialParams().isNull()) { - LLMaterialPtr p = tep->getMaterialParams(); + LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setSpecularRepeat(scale_s * 0.5f, scale_t * 0.5f); + selectionSetMaterial( p ); } } break; -- cgit v1.3 From 66e53759679910e2c3720cda92ba6e917c66d12c Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 24 May 2013 15:07:23 -0700 Subject: NORSPEC-96 NORSPEC-189 another attempt at planar stretch across all 3 channels and make the materials CB use a UUID instead of this pointer for safety --- indra/newview/llmaterialmgr.cpp | 4 - indra/newview/llmaterialmgr.h | 6 -- indra/newview/llselectmgr.cpp | 163 ++++++++++++++++++---------------------- indra/newview/llselectmgr.h | 2 +- indra/newview/llvovolume.cpp | 33 +++----- indra/newview/llvovolume.h | 5 +- 6 files changed, 90 insertions(+), 123 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 5c0173c7a7..fdc1dfd749 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,7 +217,6 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } -#if USE_TE_SPECIFIC_REGISTRATION boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) { boost::signals2::connection connection; @@ -262,7 +261,6 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const return connection; } -#endif bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { @@ -343,7 +341,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL if (isGetPending(region_id, material_id)) { - #if USE_TE_SPECIFIC_REGISTRATION TEMaterialPair te_mat_pair; te_mat_pair.materialID = material_id; @@ -359,7 +356,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetTECallbacks.erase(itCallbackTE); } } - #endif get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); if (itCallback != mGetCallbacks.end()) diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 8a2a9be255..e317a791ad 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -31,8 +31,6 @@ #include "llmaterialid.h" #include "llsingleton.h" -#define USE_TE_SPECIFIC_REGISTRATION 1 - class LLViewerRegion; class LLMaterialMgr : public LLSingleton @@ -49,10 +47,8 @@ public: const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); -#if USE_TE_SPECIFIC_REGISTRATION typedef boost::signals2::signal get_callback_te_t; boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); -#endif typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -86,7 +82,6 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; -#if USE_TE_SPECIFIC_REGISTRATION // struct for TE-specific material ID query class TEMaterialPair { @@ -115,7 +110,6 @@ protected: typedef boost::unordered_map get_callback_te_map_t; get_callback_te_map_t mGetTECallbacks; -#endif typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 1bb12e495d..372dfb0f0c 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2501,57 +2501,41 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) continue; } - LLVector3 scale_ratio = selectNode->mTextureScaleRatios[te_num]; LLVector3 object_scale = object->getScale(); + LLVector3 diffuse_scale_ratio = selectNode->mTextureScaleRatios[LLRender::DIFFUSE_MAP][te_num]; + LLVector3 normal_scale_ratio = selectNode->mTextureScaleRatios[LLRender::NORMAL_MAP][te_num]; + LLVector3 specular_scale_ratio = selectNode->mTextureScaleRatios[LLRender::SPECULAR_MAP][te_num]; // Apply new scale to face if (planar) { - F32 scale_s = scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; - F32 scale_t = scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + F32 diffuse_scale_s = diffuse_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 diffuse_scale_t = diffuse_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; - switch (mTextureChannel) + F32 normal_scale_s = normal_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 normal_scale_t = normal_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + + F32 specular_scale_s = specular_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 specular_scale_t = specular_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + + + object->setTEScale(te_num, diffuse_scale_s, diffuse_scale_t); + + LLTextureEntry* tep = object->getTE(te_num); + + if (tep && !tep->getMaterialParams().isNull()) { - case LLRender::DIFFUSE_MAP: - { - object->setTEScale(te_num, scale_s, scale_t); - } - break; - - case LLRender::NORMAL_MAP: - { - LLTextureEntry* tep = object->getTE(te_num); - if (tep && !tep->getMaterialParams().isNull()) - { - LLMaterialPtr orig = tep->getMaterialParams(); - LLMaterialPtr p = new LLMaterial(orig->asLLSD()); - p->setNormalRepeat(scale_s * 0.5f, scale_t * 0.5f); - selectionSetMaterial( p ); - } - } - break; - - case LLRender::SPECULAR_MAP: - { - LLTextureEntry* tep = object->getTE(te_num); - if (tep && !tep->getMaterialParams().isNull()) - { - LLMaterialPtr orig = tep->getMaterialParams(); - LLMaterialPtr p = new LLMaterial(orig->asLLSD()); - p->setSpecularRepeat(scale_s * 0.5f, scale_t * 0.5f); - selectionSetMaterial( p ); - } - } - break; - default: - break; + LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); + p->setNormalRepeat(normal_scale_s, normal_scale_t); + p->setSpecularRepeat(specular_scale_s, specular_scale_t); + selectionSetMaterial( p ); } - } else { - object->setTEScale(te_num, scale_ratio.mV[s_axis]*object_scale.mV[s_axis], - scale_ratio.mV[t_axis]*object_scale.mV[t_axis]); + object->setTEScale(te_num, diffuse_scale_ratio.mV[s_axis]*object_scale.mV[s_axis], + diffuse_scale_ratio.mV[t_axis]*object_scale.mV[t_axis]); } send = send_to_sim; } @@ -5876,7 +5860,10 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures) void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { - mTextureScaleRatios.clear(); + mTextureScaleRatios[LLRender::DIFFUSE_MAP].clear(); + mTextureScaleRatios[LLRender::NORMAL_MAP].clear(); + mTextureScaleRatios[LLRender::SPECULAR_MAP].clear(); + if (mObject.notNull()) { @@ -5884,9 +5871,15 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) for (U8 i = 0; i < mObject->getNumTEs(); i++) { - F32 s = 1.0f; - F32 t = 1.0f; + F32 diffuse_s = 1.0f; + F32 diffuse_t = 1.0f; + F32 normal_s = 1.0f; + F32 normal_t = 1.0f; + + F32 specular_s = 1.0f; + F32 specular_t = 1.0f; + LLVector3 v; const LLTextureEntry* tep = mObject->getTE(i); @@ -5899,60 +5892,54 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) U32 t_axis = VY; LLPrimitive::getTESTAxes(i, &s_axis, &t_axis); - switch(index_to_query) + tep->getScale(&diffuse_s,&diffuse_t); + + if (mat) { - case LLRender::DIFFUSE_MAP: - { - tep->getScale(&s,&t); - } - break; - - case LLRender::NORMAL_MAP: - { - if (mat) - { - mat->getNormalRepeat(s, t); - } - else - { - tep->getScale(&s,&t); - } - - } - break; - - case LLRender::SPECULAR_MAP: - { - if (mat) - { - mat->getSpecularRepeat(s, t); - } - else - { - tep->getScale(&s,&t); - } - } - break; - - default: - // should never be. - // - llassert_always(false); - break; + mat->getNormalRepeat(normal_s, normal_t); + } + else + { + tep->getScale(&normal_s,&normal_t); } - if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) + if (mat) { - v.mV[s_axis] = s*scale.mV[s_axis]; - v.mV[t_axis] = t*scale.mV[t_axis]; + mat->getSpecularRepeat(specular_s, specular_t); } else { - v.mV[s_axis] = s/scale.mV[s_axis]; - v.mV[t_axis] = t/scale.mV[t_axis]; + tep->getScale(&specular_s,&specular_t); } - mTextureScaleRatios.push_back(v); + if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) + { + v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; + mTextureScaleRatios[LLRender::DIFFUSE_MAP].push_back(v); + + v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; + mTextureScaleRatios[LLRender::NORMAL_MAP].push_back(v); + + v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; + mTextureScaleRatios[LLRender::SPECULAR_MAP].push_back(v); + } + else + { + v.mV[s_axis] = diffuse_s/scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t/scale.mV[t_axis]; + mTextureScaleRatios[LLRender::DIFFUSE_MAP].push_back(v); + + v.mV[s_axis] = normal_s/scale.mV[s_axis]; + v.mV[t_axis] = normal_t/scale.mV[t_axis]; + mTextureScaleRatios[LLRender::NORMAL_MAP].push_back(v); + + v.mV[s_axis] = specular_s/scale.mV[s_axis]; + v.mV[t_axis] = specular_t/scale.mV[t_axis]; + mTextureScaleRatios[LLRender::SPECULAR_MAP].push_back(v); + } } } } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f9b97cebdd..a750d8ce72 100755 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -183,7 +183,7 @@ public: U64 mCreationDate; std::vector mSavedColors; uuid_vec_t mSavedTextures; - std::vector mTextureScaleRatios; + std::vector mTextureScaleRatios[LLRender::NUM_TEXTURE_CHANNELS]; std::vector mSilhouetteVertices; // array of vertices to render silhouette of object std::vector mSilhouetteNormals; // array of normals to render silhouette of object BOOL mSilhouetteExists; // need to generate silhouette? diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 5663d474bd..7ce0343022 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,27 +1973,19 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallbackTE(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) +void LLVOVolume::setTEMaterialParamsCallbackTE(const LLUUID& objectID, const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; - if (te >= getNumTEs()) - return; - - LLTextureEntry* texture_entry = getTE(te); - if (texture_entry && (texture_entry->getMaterialID() == pMaterialID)) + LLVOVolume* pVol = (LLVOVolume*)gObjectList.findObject(objectID); + if (pVol && pVol->getVolume()) { - setTEMaterialParams(te, pMaterialParams); - } -} + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; + if (te >= pVol->getNumTEs()) + return; -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) -{ - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; - for (U8 i = 0; i < getNumTEs(); i++) - { - if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) + LLTextureEntry* texture_entry = pVol->getTE(te); + if (texture_entry && (texture_entry->getMaterialID() == pMaterialID)) { - setTEMaterialParams(i, pMaterialParams); + pVol->setTEMaterialParams(te, pMaterialParams); } } } @@ -2008,11 +2000,8 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; if (res) { -#if USE_TE_SPECIFIC_REGISTRATION - LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallbackTE, this, _1, _2, _3)); -#else - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); -#endif + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallbackTE, getID(), _1, _2, _3)); + setChanged(TEXTURE); if (!mDrawable.isNull()) { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 52539ab8d5..56c552ab9f 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,8 +187,9 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); - void setTEMaterialParamsCallbackTE(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); + + static void setTEMaterialParamsCallbackTE(const LLUUID& objectID, const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); + /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); -- cgit v1.3 From 8d4594cd11b290562510bda7c09e3b3eec192ba6 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 29 May 2013 19:10:53 -0700 Subject: NORSPEC-96 diff/norm/spec tex scale ratio rodeo, yo --- indra/newview/llselectmgr.cpp | 85 ++++++++++++++++--------------------------- indra/newview/llselectmgr.h | 2 +- 2 files changed, 32 insertions(+), 55 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 372dfb0f0c..37c11bd027 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2502,9 +2502,12 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) } LLVector3 object_scale = object->getScale(); - LLVector3 diffuse_scale_ratio = selectNode->mTextureScaleRatios[LLRender::DIFFUSE_MAP][te_num]; - LLVector3 normal_scale_ratio = selectNode->mTextureScaleRatios[LLRender::NORMAL_MAP][te_num]; - LLVector3 specular_scale_ratio = selectNode->mTextureScaleRatios[LLRender::SPECULAR_MAP][te_num]; + LLVector3 diffuse_scale_ratio = selectNode->mTextureScaleRatios[te_num]; + + // We like these to track together. NORSPEC-96 + // + LLVector3 normal_scale_ratio = diffuse_scale_ratio; + LLVector3 specular_scale_ratio = diffuse_scale_ratio; // Apply new scale to face if (planar) @@ -2518,7 +2521,6 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) F32 specular_scale_s = specular_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; F32 specular_scale_t = specular_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; - object->setTEScale(te_num, diffuse_scale_s, diffuse_scale_t); LLTextureEntry* tep = object->getTE(te_num); @@ -2534,8 +2536,28 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) } else { - object->setTEScale(te_num, diffuse_scale_ratio.mV[s_axis]*object_scale.mV[s_axis], - diffuse_scale_ratio.mV[t_axis]*object_scale.mV[t_axis]); + + F32 diffuse_scale_s = diffuse_scale_ratio.mV[s_axis]*object_scale.mV[s_axis]; + F32 diffuse_scale_t = diffuse_scale_ratio.mV[t_axis]*object_scale.mV[t_axis]; + + F32 normal_scale_s = normal_scale_ratio.mV[s_axis]*object_scale.mV[s_axis]; + F32 normal_scale_t = normal_scale_ratio.mV[t_axis]*object_scale.mV[t_axis]; + + F32 specular_scale_s = specular_scale_ratio.mV[s_axis]*object_scale.mV[s_axis]; + F32 specular_scale_t = specular_scale_ratio.mV[t_axis]*object_scale.mV[t_axis]; + + object->setTEScale(te_num, diffuse_scale_s,diffuse_scale_t); + + LLTextureEntry* tep = object->getTE(te_num); + + if (tep && !tep->getMaterialParams().isNull()) + { + LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); + p->setNormalRepeat(normal_scale_s, normal_scale_t); + p->setSpecularRepeat(specular_scale_s, specular_scale_t); + selectionSetMaterial( p ); + } } send = send_to_sim; } @@ -5860,9 +5882,7 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures) void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { - mTextureScaleRatios[LLRender::DIFFUSE_MAP].clear(); - mTextureScaleRatios[LLRender::NORMAL_MAP].clear(); - mTextureScaleRatios[LLRender::SPECULAR_MAP].clear(); + mTextureScaleRatios.clear(); if (mObject.notNull()) { @@ -5874,71 +5894,28 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) F32 diffuse_s = 1.0f; F32 diffuse_t = 1.0f; - F32 normal_s = 1.0f; - F32 normal_t = 1.0f; - - F32 specular_s = 1.0f; - F32 specular_t = 1.0f; - LLVector3 v; - const LLTextureEntry* tep = mObject->getTE(i); if (!tep) continue; - LLMaterialPtr mat = tep->getMaterialParams(); - U32 s_axis = VX; U32 t_axis = VY; LLPrimitive::getTESTAxes(i, &s_axis, &t_axis); tep->getScale(&diffuse_s,&diffuse_t); - if (mat) - { - mat->getNormalRepeat(normal_s, normal_t); - } - else - { - tep->getScale(&normal_s,&normal_t); - } - - if (mat) - { - mat->getSpecularRepeat(specular_s, specular_t); - } - else - { - tep->getScale(&specular_s,&specular_t); - } - if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) { v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; - mTextureScaleRatios[LLRender::DIFFUSE_MAP].push_back(v); - - v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; - v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; - mTextureScaleRatios[LLRender::NORMAL_MAP].push_back(v); - - v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; - v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; - mTextureScaleRatios[LLRender::SPECULAR_MAP].push_back(v); + mTextureScaleRatios.push_back(v); } else { v.mV[s_axis] = diffuse_s/scale.mV[s_axis]; v.mV[t_axis] = diffuse_t/scale.mV[t_axis]; - mTextureScaleRatios[LLRender::DIFFUSE_MAP].push_back(v); - - v.mV[s_axis] = normal_s/scale.mV[s_axis]; - v.mV[t_axis] = normal_t/scale.mV[t_axis]; - mTextureScaleRatios[LLRender::NORMAL_MAP].push_back(v); - - v.mV[s_axis] = specular_s/scale.mV[s_axis]; - v.mV[t_axis] = specular_t/scale.mV[t_axis]; - mTextureScaleRatios[LLRender::SPECULAR_MAP].push_back(v); + mTextureScaleRatios.push_back(v); } } } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index a750d8ce72..f9b97cebdd 100755 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -183,7 +183,7 @@ public: U64 mCreationDate; std::vector mSavedColors; uuid_vec_t mSavedTextures; - std::vector mTextureScaleRatios[LLRender::NUM_TEXTURE_CHANNELS]; + std::vector mTextureScaleRatios; std::vector mSilhouetteVertices; // array of vertices to render silhouette of object std::vector mSilhouetteNormals; // array of normals to render silhouette of object BOOL mSilhouetteExists; // need to generate silhouette? -- cgit v1.3 From 7e4e59470f36ae7a0e01b8d2613af4c8fb6b0101 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 08:58:15 -0700 Subject: NORSPEC-233 WIP for individual material param edits across hetero object selections --- indra/llprimitive/llmaterial.h | 28 +- indra/llprimitive/lltextureentry.h | 8 +- indra/newview/llpanelface.cpp | 1427 ++++++++++++++++-------------------- indra/newview/llpanelface.h | 290 +++++++- indra/newview/llselectmgr.cpp | 27 +- indra/newview/llselectmgr.h | 8 +- 6 files changed, 974 insertions(+), 814 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index b265732adc..9f52a3f6c1 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -69,19 +69,43 @@ public: const LLUUID& getNormalID() const { return mNormalID; } void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + F32 getNormalOffsetX() const { return mNormalOffsetX; } + F32 getNormalOffsetY() const { return mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void setNormalOffsetX(F32 offset_x) { mNormalOffsetX = offset_x; } + void setNormalOffsetY(F32 offset_y) { mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + F32 getNormalRepeatX() const { return mNormalRepeatX; } + F32 getNormalRepeatY() const { return mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } - F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRepeatX(F32 repeat_x) { mNormalRepeatX = repeat_x; } + void setNormalRepeatY(F32 repeat_y) { mNormalRepeatY = repeat_y; } + + F32 getNormalRotation() const { return mNormalRotation; } void setNormalRotation(F32 rot) { mNormalRotation = rot; } const LLUUID& getSpecularID() const { return mSpecularID; } void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + F32 getSpecularOffsetX() const { return mSpecularOffsetX; } + F32 getSpecularOffsetY() const { return mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void setSpecularOffsetX(F32 offset_x) { mSpecularOffsetX = offset_x; } + void setSpecularOffsetY(F32 offset_y) { mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + F32 getSpecularRepeatX() const { return mSpecularRepeatX; } + F32 getSpecularRepeatY() const { return mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } - F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRepeatX(F32 repeat_x) { mSpecularRepeatX = repeat_x; } + void setSpecularRepeatY(F32 repeat_y) { mSpecularRepeatY = repeat_y; } + + F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 5cc76cfe82..59364cb913 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,7 +133,13 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } + void getScaleS(F32 *s) const { *s = mScaleS; } + void getScaleT(F32 *t) const { *t = mScaleT; } + void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } + F32 getOffsetS() const { return mOffsetS; } + F32 getOffsetT() const { return mOffsetT; } + F32 getRotation() const { return mRotation; } void getRotation(F32 *theta) const { *theta = mRotation; } @@ -144,7 +150,7 @@ public: U8 getBumpShinyFullbright() const { return mBump; } U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; } - U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } + LLTextureEntry::e_texgen getTexGen() const { return LLTextureEntry::e_texgen(mMediaFlags & TEM_TEX_GEN_MASK); } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 01ed6e84b8..a26b9ed237 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -89,6 +89,27 @@ const S32 SHINY_TEXTURE = 4; // use supplied specular map // std::string USE_TEXTURE; +// Things the UI provides... +// +LLUUID LLPanelFace::getCurrentNormalMap() { return getChild("bumpytexture control")->getImageAssetID(); } +LLUUID LLPanelFace::getCurrentSpecularMap() { return getChild("shinytexture control")->getImageAssetID(); } +U32 LLPanelFace::getCurrentShininess() { return getChild("combobox shininess")->getCurrentIndex(); } +U32 LLPanelFace::getCurrentBumpiness() { return getChild("combobox bumpiness")->getCurrentIndex(); } +U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild("combobox alphamode")->getCurrentIndex(); } +U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild("maskcutoff")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild("environment")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild("glossiness")->getValue().asInteger(); } +F32 LLPanelFace::getCurrentBumpyRot() { return getChild("bumpyRot")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleU() { return getChild("bumpyScaleU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleV() { return getChild("bumpyScaleV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetU() { return getChild("bumpyOffsetU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetV() { return getChild("bumpyOffsetV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyRot() { return getChild("shinyRot")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleU() { return getChild("shinyScaleU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleV() { return getChild("shinyScaleV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetU() { return getChild("shinyOffsetU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetV() { return getChild("shinyOffsetV")->getValue().asReal(); } + // // Methods // @@ -105,19 +126,21 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("checkbox planar align",&LLPanelFace::onCommitPlanarAlign, this); childSetCommitCallback("TexOffsetU",LLPanelFace::onCommitTextureInfo, this); childSetCommitCallback("TexOffsetV",LLPanelFace::onCommitTextureInfo, this); - childSetCommitCallback("bumpyScaleU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyScaleV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyRot",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyOffsetU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyOffsetV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyScaleU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyScaleV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyRot",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyOffsetU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyOffsetV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("environment",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterial, this); + + childSetCommitCallback("bumpyScaleU",&LLPanelFace::onCommitMaterialBumpyScaleX, this); + childSetCommitCallback("bumpyScaleV",&LLPanelFace::onCommitMaterialBumpyScaleY, this); + childSetCommitCallback("bumpyRot",&LLPanelFace::onCommitMaterialBumpyRot, this); + childSetCommitCallback("bumpyOffsetU",&LLPanelFace::onCommitMaterialBumpyOffsetX, this); + childSetCommitCallback("bumpyOffsetV",&LLPanelFace::onCommitMaterialBumpyOffsetY, this); + childSetCommitCallback("shinyScaleU",&LLPanelFace::onCommitMaterialShinyScaleX, this); + childSetCommitCallback("shinyScaleV",&LLPanelFace::onCommitMaterialShinyScaleY, this); + childSetCommitCallback("shinyRot",&LLPanelFace::onCommitMaterialShinyRot, this); + childSetCommitCallback("shinyOffsetU",&LLPanelFace::onCommitMaterialShinyOffsetX, this); + childSetCommitCallback("shinyOffsetV",&LLPanelFace::onCommitMaterialShinyOffsetY, this); + childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this); + childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this); + childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this); + childSetAction("button align",&LLPanelFace::onClickAutoFix,this); LLTextureCtrl* mTextureCtrl; @@ -293,10 +316,11 @@ void LLPanelFace::sendTexture() void LLPanelFace::sendBump(U32 bumpiness) { + LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); + if (bumpiness < BUMPY_TEXTURE) { - LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; - LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); + LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; bumpytexture_ctrl->clear(); bumpytexture_ctrl->setImageAssetID(LLUUID()); } @@ -305,7 +329,7 @@ void LLPanelFace::sendBump(U32 bumpiness) LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); updateBumpyControls(bumpiness == BUMPY_TEXTURE, true); - updateMaterial(); + LLSelectedTEMaterial::setNormalID(this, bumpytexture_ctrl->getImageAssetID()); } void LLPanelFace::sendTexGen() @@ -328,9 +352,8 @@ void LLPanelFace::sendShiny(U32 shininess) U8 shiny = (U8) shininess & TEM_SHINY_MASK; LLSelectMgr::getInstance()->selectionSetShiny( shiny ); } - updateShinyControls(!texture_ctrl->getImageAssetID().isNull(), true); - updateMaterial(); + LLSelectedTEMaterial::setSpecularID(this, texture_ctrl->getImageAssetID()); } void LLPanelFace::sendFullbright() @@ -568,16 +591,9 @@ void LLPanelFace::sendTextureInfo() { if ((bool)childGetValue("checkbox planar align").asBoolean()) { - struct f1 : public LLSelectedTEGetFunctor - { - LLFace* get(LLViewerObject* object, S32 te) - { - return (object->mDrawable) ? object->mDrawable->getFace(te): NULL; - } - } get_last_face_func; - LLFace* last_face; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_last_face_func, last_face); - + LLFace* last_face = NULL; + bool identical_face =false; + LLSelectedTE::getFace(last_face, identical_face); LLPanelFaceSetAlignedTEFunctor setfunc(this, last_face); LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc); } @@ -639,12 +655,12 @@ void LLPanelFace::updateUI() updateVisibility(); - bool identical; - bool identical_diffuse; - bool identical_norm; - bool identical_spec; + 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("texture control"); + LLTextureCtrl* texture_ctrl = getChild("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); @@ -657,18 +673,14 @@ void LLPanelFace::updateUI() getChildView("color label")->setEnabled(editable); } LLColorSwatchCtrl* mColorSwatch = getChild("colorswatch"); - LLColor4 color = LLColor4::white; + + LLColor4 color = LLColor4::white; + bool identical_color = false; + if(mColorSwatch) { - struct f7 : public LLSelectedTEGetFunctor - { - LLColor4 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getColor(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, color ); - + LLSelectedTE::getColor(color, identical_color); + mColorSwatch->setOriginal(color); mColorSwatch->set(color, TRUE); @@ -689,42 +701,19 @@ void LLPanelFace::updateUI() } // Specular map - struct spec_get : public LLSelectedTEGetFunctor - { - LLUUID get(LLViewerObject* object, S32 te_index) - { - LLUUID id; - - LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); - - if (mat) - { - id = mat->getSpecularID(); - } - - return id; - } - } spec_get_func; - identical_spec = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &spec_get_func, specmap_id ); - + LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); + U8 shiny = 0; + bool identical_shiny = false; // Shiny { - struct f9 : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return (U8)(object->getTE(face)->getShiny()); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shiny ); - - LLCtrlSelectionInterface* combobox_shininess = - childGetSelectionInterface("combobox shininess"); + 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); @@ -733,17 +722,22 @@ void LLPanelFace::updateUI() { llwarns << "failed childGetSelectionInterface for 'combobox shininess'" << llendl; } - getChildView("combobox shininess")->setEnabled(editable); - getChild("combobox shininess")->setTentative(!identical); + + getChildView("label shininess")->setEnabled(editable); + getChildView("combobox shininess")->setEnabled(editable); + + getChildView("label glossiness")->setEnabled(editable); getChildView("glossiness")->setEnabled(editable); - getChild("glossiness")->setTentative(!identical); - getChildView("label glossiness")->setEnabled(editable); - getChildView("environment")->setEnabled(editable); - getChild("environment")->setTentative(!identical); + getChildView("label environment")->setEnabled(editable); - getChild("shinycolorswatch")->setTentative(!identical); + getChildView("environment")->setEnabled(editable); getChildView("label shinycolor")->setEnabled(editable); + + getChild("combobox shininess")->setTentative(!identical); + getChild("glossiness")->setTentative(!identical); + getChild("environment")->setTentative(!identical); + getChild("shinycolorswatch")->setTentative(!identical); } LLColorSwatchCtrl* mShinyColorSwatch = getChild("shinycolorswatch"); @@ -757,17 +751,11 @@ void LLPanelFace::updateUI() U8 bumpy = 0; // Bumpy - { - struct f10 : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getBumpmap(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpy ); + { + U8 bumpy; + LLSelectedTE::getBumpmap(bumpy,identical); - LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); + LLUUID norm_map_id = getCurrentNormalMap(); LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness"); if (combobox_bumpiness) @@ -785,72 +773,18 @@ void LLPanelFace::updateUI() // Texture { - struct f1 : public LLSelectedTEGetFunctor - { - LLUUID get(LLViewerObject* object, S32 te_index) - { - LLUUID id; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) id = image->getID(); - - if (!id.isNull() && LLViewerMedia::textureHasMedia(id)) - { - LLTextureEntry *te = object->getTE(te_index); - if (te) - { - LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL ; - if(!tex) - { - tex = LLViewerFetchedTexture::sDefaultImagep; - } - if (tex) - { - id = tex->getID(); - } - } - } - return id; - } - } func; - identical_diffuse = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); + LLSelectedTE::getTexId(id,identical_diffuse); // Normal map - struct norm_get : public LLSelectedTEGetFunctor - { - LLUUID get(LLViewerObject* object, S32 te_index) - { - LLUUID id; - - LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); - - if (mat) - { - id = mat->getNormalID(); - } - - return id; - } - } norm_get_func; - identical_norm = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &norm_get_func, normmap_id ); - + LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm); + if (bumpy != BUMPY_TEXTURE) normmap_id = LLUUID::null; mIsAlpha = FALSE; LLGLenum image_format; - struct f2 : public LLSelectedTEGetFunctor - { - LLGLenum get(LLViewerObject* object, S32 te_index) - { - LLGLenum image_format = GL_RGB; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) image_format = image->getPrimaryFormat(); - return image_format; - } - } func2; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + bool identical_image_format = false; + LLSelectedTE::getImageFormat(image_format, identical_image_format); mIsAlpha = FALSE; switch (image_format) @@ -876,53 +810,27 @@ void LLPanelFace::updateUI() } // Diffuse Alpha Mode - struct alpha_get : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 te_index) - { - U8 ret = 1; - - LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); + U8 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + bool identical_alpha_mode = false; + LLSelectedTEMaterial::getDiffuseAlphaMode(alpha_mode, identical_alpha_mode); - if (mat) - { - ret = mat->getDiffuseAlphaMode(); - } - - return ret; - } - } alpha_get_func; - - U8 alpha_mode = 1; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &alpha_get_func, alpha_mode); - + LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); + //it is invalid to have any alpha mode other than blend if transparency is greater than zero ... + alpha_mode = (transparency > 0.f) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : alpha_mode; - if (combobox_alphamode) - { - - if (transparency > 0.f) - { //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 - { - llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; - } + // ... unless there is no alpha channel in the texture, in which case alpha mode MUST ebe none + alpha_mode = mIsAlpha ? alpha_mode : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; - updateAlphaControls(); + combobox_alphamode->selectNthItem(alpha_mode); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } + + updateAlphaControls(); if(texture_ctrl && !texture_ctrl->isPickerShown()) { @@ -1010,34 +918,20 @@ void LLPanelFace::updateUI() // planar align bool align_planar = false; bool identical_planar_aligned = false; - bool is_planar = false; { LLCheckBoxCtrl* cb_planar_align = getChild("checkbox planar align"); align_planar = (cb_planar_align && cb_planar_align->get()); - struct f1 : public LLSelectedTEGetFunctor - { - bool get(LLViewerObject* object, S32 face) - { - return (object->getTE(face)->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR); - } - } func; - - bool texgens_identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, is_planar ); - bool enabled = (editable && texgens_identical && is_planar); + + bool enabled = (editable && isIdenticalPlanarTexgen()); childSetValue("checkbox planar align", align_planar && enabled); childSetEnabled("checkbox planar align", enabled); if (align_planar && enabled) { - struct f2 : public LLSelectedTEGetFunctor - { - LLFace* get(LLViewerObject* object, S32 te) - { - return (object->mDrawable) ? object->mDrawable->getFace(te): NULL; - } - } get_te_face_func; - LLFace* last_face; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_te_face_func, last_face); + 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); @@ -1052,386 +946,214 @@ void LLPanelFace::updateUI() bool identical_texgen = true; bool identical_planar_texgen = false; - { - struct f11 : public LLSelectedTEGetFunctor - { - 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 ); + { + LLSelectedTE::getTexGen(selected_texgen, identical_texgen); identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); } // Texture scale { - F32 scale_s = 1.f; - struct f2 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mScaleS; - } - } func; + bool identical_diff_scale_s = false; + bool identical_spec_scale_s = false; + bool identical_norm_scale_s = false; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_s ); identical = align_planar ? identical_planar_aligned : identical; - F32 scale_u = editable ? scale_s : 0; - scale_u *= identical_planar_texgen ? 2.0f : 1.0f; + F32 diff_scale_s = 1.f; + F32 spec_scale_s = 1.f; + F32 norm_scale_s = 1.f; - getChild("TexScaleU")->setValue(scale_u); - getChild("TexScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("TexScaleU")->setEnabled(editable); - - scale_s = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + LLSelectedTE::getOffsetS( 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); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularRepeat(s, t); - } - return s; - } - } shiny_func; + diff_scale_s = editable ? diff_scale_s : 1.0f; + diff_scale_s *= identical_planar_texgen ? 2.0f : 1.0f; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_s ); - identical = align_planar ? identical_planar_aligned : identical; - - F32 scale_s_value = editable ? scale_s : 0; - scale_s_value *= 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; - getChild("shinyScaleU")->setValue(scale_s_value); - getChild("shinyScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + spec_scale_s = editable ? spec_scale_s : 1.0f; + spec_scale_s *= identical_planar_texgen ? 2.0f : 1.0f; - scale_s = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + getChild("TexScaleU")->setValue(diff_scale_s); + getChild("shinyScaleU")->setValue(spec_scale_s); + getChild("bumpyScaleU")->setValue(norm_scale_s); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalRepeat(s, t); - } - return s; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_s ); - identical = align_planar ? identical_planar_aligned : identical; + getChildView("TexScaleU")->setEnabled(editable); + getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); - scale_s_value = editable ? scale_s : 0; - scale_s_value *= identical_planar_texgen ? 2.0f : 1.0f; + 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("bumpyScaleU")->setValue(scale_s_value); - getChild("bumpyScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); + getChild("TexScaleU")->setTentative( LLSD(diff_scale_tentative)); + getChild("shinyScaleU")->setTentative(LLSD(spec_scale_tentative)); + getChild("bumpyScaleU")->setTentative(LLSD(norm_scale_tentative)); } { - F32 scale_t = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mScaleT; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_t ); - identical = align_planar ? identical_planar_aligned : identical; + bool identical_diff_scale_t = false; + bool identical_spec_scale_t = false; + bool identical_norm_scale_t = false; - F32 scale_t_value = editable ? scale_t : 0; - scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f; + F32 diff_scale_t = 1.f; + F32 spec_scale_t = 1.f; + F32 norm_scale_t = 1.f; - getChild("TexScaleV")->setValue(scale_t_value); - getChild("TexScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("TexScaleV")->setEnabled(editable); - - scale_t = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + LLSelectedTE::getOffsetT(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); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularRepeat(s, t); - } - return t; - } - } shiny_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_t ); - identical = align_planar ? identical_planar_aligned : identical; + diff_scale_t = editable ? diff_scale_t : 1.0f; + diff_scale_t *= identical_planar_texgen ? 2.0f : 1.0f; - scale_t_value = editable ? scale_t : 0; - scale_t_value *= 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; - getChild("shinyScaleV")->setValue(scale_t_value); - getChild("shinyScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + spec_scale_t = editable ? spec_scale_t : 1.0f; + spec_scale_t *= identical_planar_texgen ? 2.0f : 1.0f; - scale_t = 1.f; - struct f5 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + BOOL diff_scale_tentative = !(identical && identical_diff_scale_t); + BOOL norm_scale_tentative = !(identical && identical_norm_scale_t); + BOOL spec_scale_tentative = !(identical && identical_spec_scale_t); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalRepeat(s, t); - } - return t; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_t ); - identical = align_planar ? identical_planar_aligned : identical; + getChildView("TexScaleV")->setEnabled(editable); + getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); - scale_t_value = editable ? scale_t : 0.0f; - scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f; + getChild("TexScaleV")->setValue(diff_scale_t); + getChild("shinyScaleV")->setValue(norm_scale_t); + getChild("bumpyScaleV")->setValue(spec_scale_t); - getChild("bumpyScaleV")->setValue(scale_t_value); - getChild("bumpyScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); - + getChild("TexScaleV")->setTentative(LLSD(diff_scale_tentative)); + getChild("shinyScaleV")->setTentative(LLSD(norm_scale_tentative)); + getChild("bumpyScaleV")->setTentative(LLSD(spec_scale_tentative)); } // Texture offset { - getChildView("tex offset")->setEnabled(editable); - F32 offset_s = 0.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mOffsetS; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_s ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("TexOffsetU")->setValue(editable ? offset_s : 0); - getChild("TexOffsetU")->setTentative(!identical); - getChildView("TexOffsetU")->setEnabled(editable); + bool identical_diff_offset_s = false; + bool identical_norm_offset_s = false; + bool identical_spec_offset_s = false; - offset_s = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + F32 diff_offset_s = 0.0f; + F32 norm_offset_s = 0.0f; + F32 spec_offset_s = 0.0f; - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularOffset(s, t); - } - return s; - } - } shiny_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, offset_s ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("shinyOffsetU")->setValue(editable ? offset_s : 0); - getChild("shinyOffsetU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); + 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); - offset_s = 1.f; - struct f5 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + 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); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalOffset(s, t); - } - return s; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, offset_s ); - identical = align_planar ? identical_planar_aligned : identical; + getChild("TexOffsetU")->setValue( editable ? diff_offset_s : 0.0f); + getChild("bumpyOffsetU")->setValue(editable ? norm_offset_s : 0.0f); + getChild("shinyOffsetU")->setValue(editable ? spec_offset_s : 0.0f); + + getChild("TexOffsetU")->setTentative(LLSD(diff_offset_u_tentative)); + getChild("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative)); + getChild("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative)); - getChild("bumpyOffsetU")->setValue(editable ? offset_s : 0); - getChild("bumpyOffsetU")->setTentative(LLSD((BOOL)(!identical))); + getChildView("TexOffsetU")->setEnabled(editable); + getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); } { - F32 offset_t = 0.f; - struct f5 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mOffsetT; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_t ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("TexOffsetV")->setValue(editable ? offset_t : 0); - getChild("TexOffsetV")->setTentative(!identical); - getChildView("TexOffsetV")->setEnabled(editable); - - - offset_t = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + bool identical_diff_offset_t = false; + bool identical_norm_offset_t = false; + bool identical_spec_offset_t = false; - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularOffset(s, t); - } - return t; - } - } shiny_func; + 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); - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, offset_t ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("shinyOffsetV")->setValue(editable ? offset_t : 0); - getChild("shinyOffsetV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); + 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); - offset_t = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + getChild("TexOffsetV")->setValue( editable ? diff_offset_t : 0.0f); + getChild("bumpyOffsetV")->setValue(editable ? norm_offset_t : 0.0f); + getChild("shinyOffsetV")->setValue(editable ? spec_offset_t : 0.0f); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalOffset(s, t); - } - return t; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, offset_t ); - identical = align_planar ? identical_planar_aligned : identical; + getChild("TexOffsetV")->setTentative(LLSD(diff_offset_v_tentative)); + getChild("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative)); + getChild("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative)); - getChild("bumpyOffsetV")->setValue(editable ? offset_t : 0); - getChild("bumpyOffsetV")->setTentative(LLSD((BOOL)(!identical))); + getChildView("TexOffsetV")->setEnabled(editable); + getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); } // Texture rotation { - F32 rotation = 0.f; - struct f6 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mRotation; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, rotation ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("TexRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); - getChild("TexRot")->setTentative(!identical); - getChildView("TexRot")->setEnabled(editable); + 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; - - rotation = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 ret = 0.f; + LLSelectedTE::getRotation(diff_rotation,identical_diff_rotation); + LLSelectedTEMaterial::getSpecularRotation(spec_rotation,identical_spec_rotation); + LLSelectedTEMaterial::getNormalRotation(norm_rotation,identical_norm_rotation); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - ret = mat->getSpecularRotation(); - } - return ret; - } - } shiny_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, rotation ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("shinyRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); - getChild("shinyRot")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); + 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); - rotation = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 ret = 0.f; + 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; - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - ret = mat->getNormalRotation(); - } - return ret; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, rotation ); - identical = align_planar ? identical_planar_aligned : identical; - - F32 normal_rot_deg = rotation * RAD_TO_DEG; - getChild("bumpyRot")->setValue(editable ? normal_rot_deg : 0.0f); - getChild("bumpyRot")->setTentative(LLSD((BOOL)(!identical))); + getChildView("TexRot")->setEnabled(editable); + getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); + + getChild("TexRot")->setTentative(diff_rot_tentative); + getChild("shinyRot")->setTentative(LLSD(norm_rot_tentative)); + getChild("bumpyRot")->setTentative(LLSD(spec_rot_tentative)); + + getChild("TexRot")->setValue( editable ? diff_rot_deg : 0.0f); + getChild("shinyRot")->setValue(editable ? spec_rot_deg : 0.0f); + getChild("bumpyRot")->setValue(editable ? norm_rot_deg : 0.0f); } { F32 glow = 0.f; - struct f8 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getGlow(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, glow ); + bool identical_glow = false; + + LLSelectedTE::getGlow(glow,identical_glow); + + identical = identical && identical_glow; getChild("glow")->setValue(glow); getChildView("glow")->setEnabled(editable); getChild("glow")->setTentative(!identical); getChildView("glow label")->setEnabled(editable); - } - - { - LLCtrlSelectionInterface* combobox_texgen = - childGetSelectionInterface("combobox texgen"); + LLCtrlSelectionInterface* combobox_texgen = childGetSelectionInterface("combobox texgen"); if (combobox_texgen) { - combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1); // Maps from enum to combobox entry index + // Maps from enum to combobox entry index + combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1); } else { llwarns << "failed childGetSelectionInterface for 'combobox texgen'" << llendl; } + getChildView("combobox texgen")->setEnabled(editable); getChild("combobox texgen")->setTentative(!identical); getChildView("tex gen")->setEnabled(editable); @@ -1450,14 +1172,11 @@ void LLPanelFace::updateUI() { U8 fullbright_flag = 0; - struct f12 : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getFullbright(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, fullbright_flag ); + bool identical_fullbright = false; + + LLSelectedTE::getFullbright(fullbright_flag,identical_fullbright); + + identical = identical && identical_fullbright; getChild("checkbox fullbright")->setValue((S32)(fullbright_flag != 0)); getChildView("checkbox fullbright")->setEnabled(editable); @@ -1470,65 +1189,13 @@ void LLPanelFace::updateUI() F32 repeats_norm = 1.f; F32 repeats_spec = 1.f; - struct f13 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - U32 s_axis = VX; - U32 t_axis = VY; - // BUG: Only repeats along S axis - // BUG: Only works for boxes. - LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); - F32 repeats_s = object->getTE(face)->mScaleS / object->getScale().mV[s_axis]; - F32 repeats_t = object->getTE(face)->mScaleT / object->getScale().mV[t_axis]; - return llmax(repeats_s, repeats_t); - } - - } func_diff; - bool identical_diff_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_diff, repeats_diff ); - - struct f14 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - U32 s_axis = VX; - U32 t_axis = VY; - F32 repeats_s = 1.0f; - F32 repeats_t = 1.0f; - if (mat) - { - mat->getNormalRepeat(repeats_s, repeats_t); - repeats_s /= object->getScale().mV[s_axis]; - repeats_t /= object->getScale().mV[t_axis]; - } - return llmax(repeats_s, repeats_t); - } - - } func_norm; - BOOL identical_norm_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_norm, repeats_norm ); + bool identical_diff_repeats = false; + bool identical_norm_repeats = false; + bool identical_spec_repeats = false; - struct f15 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - U32 s_axis = VX; - U32 t_axis = VY; - F32 repeats_s = 1.0f; - F32 repeats_t = 1.0f; - if (mat) - { - mat->getSpecularRepeat(repeats_s, repeats_t); - repeats_s /= object->getScale().mV[s_axis]; - repeats_t /= object->getScale().mV[t_axis]; - } - return llmax(repeats_s, repeats_t); - } - - } func_spec; - BOOL identical_spec_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_spec, repeats_spec ); - + LLSelectedTE::getMaxDiffuseRepeats(repeats_spec, identical_spec_repeats); + LLSelectedTEMaterial::getMaxNormalRepeats(repeats_spec, identical_spec_repeats); + LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats); LLComboBox* mComboTexGen = getChild("combobox texgen"); if (mComboTexGen) @@ -1575,16 +1242,8 @@ void LLPanelFace::updateUI() // Materials { - struct f1 : public LLSelectedTEGetFunctor - { - LLMaterialPtr get(LLViewerObject* object, S32 te_index) - { - return object->getTE(te_index)->getMaterialParams(); - } - } func; - LLMaterialPtr material; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material ); + LLSelectedTEMaterial::getCurrent(material, identical); if (material && editable) { @@ -1616,19 +1275,7 @@ void LLPanelFace::updateUI() getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); updateAlphaControls(); - 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 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)); + identical_planar_texgen = isIdenticalPlanarTexgen(); // Shiny (specular) F32 offset_x, offset_y, repeat_x, repeat_y, rot; @@ -1771,143 +1418,75 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::updateMaterial() -{ // assign current state of UI to material definition for submit to sim - LL_DEBUGS("Materials") << "Entered." << LL_ENDL; - LLComboBox* comboAlphaMode = getChild("combobox alphamode"); - LLComboBox* comboBumpiness = getChild("combobox bumpiness"); - LLComboBox* comboShininess = getChild("combobox shininess"); - if (!comboAlphaMode || !comboBumpiness || !comboShininess) - { +/* +void LLPanelFace::updateMaterialParams(LLMaterialEditFunctorBase* edit_func) +{ + if (!edit_func) return; - } - U32 alpha_mode = comboAlphaMode->getCurrentIndex(); - U32 bumpiness = comboBumpiness->getCurrentIndex(); - U32 shininess = comboShininess->getCurrentIndex(); - - LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; - struct f45 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); - bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - - bool is_default_blend_mode = mIsAlpha ? (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) - : (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - - LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); - LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); - if ( !is_default_blend_mode - || !norm_map_id.isNull() - || !spec_map_id.isNull()) + struct LLSelectedTEEditMaterial : public LLSelectedTEMaterialFunctor { - // This should match getState() - struct f1 : public LLSelectedTEGetFunctor + LLSelectedTEEditMaterial(LLPanelFace* panel, LLMaterialEditFunctorBase* edit) : _panel(panel), _edit(edit) {}; + virtual ~LLSelectedTEEditMaterial() {}; + virtual LLMaterialPtr apply(LLViewerObject* object, S32 face, LLTextureEntry* tep, LLMaterialPtr& current_material) { - LLMaterialPtr get(LLViewerObject* object, S32 te_index) + if (_edit) { - return object->getTE(te_index)->getMaterialParams(); - } - } func; - LLMaterialPtr cur_material; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, cur_material); - - bool new_material = cur_material.isNull(); - - LLMaterialPtr material( (!new_material) ? new LLMaterial(cur_material->asLLSD()) : new LLMaterial()); - llassert_always(material); - - material->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - material->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); - - if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE)) - { - LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material->setNormalID(norm_map_id); + // Yesterday's news... + // + //U32 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); + //LLUUID old_normal_map_id = _panel->getCurrentNormalMap(); + //LLUUID old_spec_map_id = _panel->getCurrentSpecularMap(); + //bool was_default_blend_mode = (current_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + //bool was_need_material = !was_default_blend_mode || !old_normal_map_id.isNull() || !old_spec_map_id.isNull(); - F32 bumpy_scale_u = getChild("bumpyScaleU")->getValue().asReal(); - F32 bumpy_scale_v = getChild("bumpyScaleV")->getValue().asReal(); + LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); + llassert_always(new_material); - if (identical_planar_texgen) - { - bumpy_scale_u *= 0.5f; - bumpy_scale_v *= 0.5f; - } + // Do "It"! + // + _edit->apply(new_material); - material->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), - getChild("bumpyOffsetV")->getValue().asReal()); - material->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); - F32 normal_rot_rads = getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD; - material->setNormalRotation(normal_rot_rads); - } - else - { - LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material->setNormalID(LLUUID()); - material->setNormalOffset(0.0f,0.0f); - material->setNormalRepeat(1.0f,1.0f); - material->setNormalRotation(0.0f); - } - - + U32 new_alpha_mode = new_material->getDiffuseAlphaMode(); + LLUUID new_normal_map_id = new_material->getNormalID(); + LLUUID new_spec_map_id = new_material->getSpecularID(); - if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE)) - { - LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; - material->setSpecularID(spec_map_id); - material->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), - getChild("shinyOffsetV")->getValue().asReal()); + bool is_default_blend_mode = (new_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); - F32 shiny_scale_u = getChild("shinyScaleU")->getValue().asReal(); - F32 shiny_scale_v = getChild("shinyScaleV")->getValue().asReal(); + if (!current_material.isNull() && !is_need_material) + { + LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; + LLMaterialMgr::getInstance()->remove(object->getID(),face); + } + else + { + // Replicate old init behavior + // + if (current_material.isNull()) + { + U8 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); + U8 current_alpha_mask_cutoff = _panel->getCurrentAlphaMaskCutoff(); - if (identical_planar_texgen) - { - shiny_scale_u *= 0.5f; - shiny_scale_v *= 0.5f; - } + new_material->setDiffuseAlphaMode(current_alpha_mode); + new_material->setAlphaMaskCutoff(current_alpha_mask_cutoff); + } - material->setSpecularRepeat(shiny_scale_u, shiny_scale_v); - material->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << new_material->asLLSD() << LL_ENDL; + LLMaterialMgr::getInstance()->put(object->getID(),face,*new_material); + } - //override shininess to 0.2f if this is a new material - if (!new_material) - { - material->setSpecularLightColor(getChild("shinycolorswatch")->get()); - material->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); - material->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); + object->setTEMaterialParams(face, new_material); + return new_material; } + return NULL; } - else - { - LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; - material->setSpecularID(LLUUID()); - material->setSpecularOffset(0.0f,0.0f); - material->setSpecularRepeat(1.0f,1.0f); - material->setSpecularRotation(0.0f); - material->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); - material->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - material->setEnvironmentIntensity(0); - } - - LL_DEBUGS("Materials") << "Updating material: " << material->asLLSD() << LL_ENDL; - - LLSelectMgr::getInstance()->selectionSetMaterial( material ); - } - else - { - // The user has specified settings that don't need a material. - LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; - - // Delete existing material entry... - LLSelectMgr::getInstance()->selectionRemoveMaterial(); - } + LLMaterialEditFunctorBase* _edit; + LLPanelFace* _panel; + } editor(this, edit_func); + LLSelectMgr::getInstance()->selectionSetMaterialParams(&editor); } +*/ // // Static functions @@ -1927,7 +1506,7 @@ void LLPanelFace::onCommitColor(const LLSD& data) void LLPanelFace::onCommitShinyColor(const LLSD& data) { - updateMaterial(); + LLSelectedTEMaterial::setSpecularLightColor(this, getChild("shinycolorswatch")->get()); } void LLPanelFace::onCommitAlpha(const LLSD& data) @@ -2216,7 +1795,7 @@ void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->updateAlphaControls(); - self->updateMaterial(); + LLSelectedTEMaterial::setDiffuseAlphaMode(self,self->getCurrentDiffuseAlphaMode()); } // static @@ -2268,18 +1847,8 @@ void LLPanelFace::onSelectTexture(const LLSD& data) sendTexture(); LLGLenum image_format; - struct f2 : public LLSelectedTEGetFunctor - { - LLGLenum get(LLViewerObject* object, S32 te_index) - { - LLGLenum image_format = GL_RGB; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) image_format = image->getPrimaryFormat(); - return image_format; - } - } func2; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + bool identical_image_format = false; + LLSelectedTE::getImageFormat(image_format, identical_image_format); LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); @@ -2306,8 +1875,7 @@ void LLPanelFace::onSelectTexture(const LLSD& data) combobox_alphamode->selectNthItem(alpha_mode); } - - updateMaterial(); + LLSelectedTEMaterial::setDiffuseAlphaMode(this, getCurrentDiffuseAlphaMode()); } void LLPanelFace::onCommitSpecularTexture( const LLSD& data ) @@ -2324,17 +1892,9 @@ void LLPanelFace::onCommitNormalTexture( const LLSD& data ) void LLPanelFace::onCancelSpecularTexture(const LLSD& data) { - - U8 shiny = 0; - struct get_shiny : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return (U8)(object->getTE(face)->getShiny()); - } - } func; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shiny ); - + U8 shiny = 0; + bool identical_shiny = false; + LLSelectedTE::getShiny(shiny, identical_shiny); LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); shiny = spec_map_id.isNull() ? shiny : SHINY_TEXTURE; sendShiny(shiny); @@ -2342,16 +1902,9 @@ void LLPanelFace::onCancelSpecularTexture(const LLSD& data) void LLPanelFace::onCancelNormalTexture(const LLSD& data) { - U8 bumpy = 0; - struct get_bumpy : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return (U8)(object->getTE(face)->getBumpmap()); - } - - } func; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpy ); + U8 bumpy = 0; + bool identical_bumpy = false; + LLSelectedTE::getBumpmap(bumpy, identical_bumpy); sendBump(bumpy); } @@ -2368,10 +1921,126 @@ void LLPanelFace::onSelectNormalTexture(const LLSD& data) } //static -void LLPanelFace::onCommitMaterial(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyOffsetX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setNormalOffsetX(self,self->getCurrentBumpyOffsetU()); +} + +//static +void LLPanelFace::onCommitMaterialBumpyOffsetY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setNormalOffsetY(self,self->getCurrentBumpyOffsetV()); +} + +//static +void LLPanelFace::onCommitMaterialShinyOffsetX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularOffsetX(self,self->getCurrentShinyOffsetU()); +} + +//static +void LLPanelFace::onCommitMaterialShinyOffsetY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularOffsetY(self,self->getCurrentShinyOffsetV()); +} + +//static +void LLPanelFace::onCommitMaterialBumpyScaleX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 bumpy_scale_u = self->getCurrentBumpyScaleU(); + if (self->isIdenticalPlanarTexgen()) + { + bumpy_scale_u *= 0.5f; + } + LLSelectedTEMaterial::setNormalRepeatX(self,bumpy_scale_u); +} + +//static +void LLPanelFace::onCommitMaterialBumpyScaleY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 bumpy_scale_v = self->getCurrentBumpyScaleV(); + if (self->isIdenticalPlanarTexgen()) + { + bumpy_scale_v *= 0.5f; + } + LLSelectedTEMaterial::setNormalRepeatY(self,bumpy_scale_v); +} + +//static +void LLPanelFace::onCommitMaterialShinyScaleX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 shiny_scale_u = self->getCurrentShinyScaleU(); + if (self->isIdenticalPlanarTexgen()) + { + shiny_scale_u *= 0.5f; + } + LLSelectedTEMaterial::setSpecularRepeatX(self,shiny_scale_u); +} + +//static +void LLPanelFace::onCommitMaterialShinyScaleY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 shiny_scale_v = self->getCurrentShinyScaleV(); + if (self->isIdenticalPlanarTexgen()) + { + shiny_scale_v *= 0.5f; + } + LLSelectedTEMaterial::setSpecularRepeatY(self,shiny_scale_v); +} + +//static +void LLPanelFace::onCommitMaterialBumpyRot(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setNormalRotation(self,self->getCurrentBumpyRot()); +} + +//static +void LLPanelFace::onCommitMaterialShinyRot(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularRotation(self,self->getCurrentShinyRot()); +} + +//static +void LLPanelFace::onCommitMaterialGloss(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularLightExponent(self,self->getCurrentGlossiness()); +} + +//static +void LLPanelFace::onCommitMaterialEnv(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setEnvironmentIntensity(self,self->getCurrentEnvIntensity()); +} + +//static +void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - self->updateMaterial(); + LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff()); } // static @@ -2387,44 +2056,21 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); - F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); - - LLComboBox* combo_mattype = self->getChild("combobox mattype"); + U32 material_type = combo_mattype->getCurrentIndex(); + F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); - F32 obj_scale_s = 1.0f; - F32 obj_scale_t = 1.0f; - - U32 material_type = combo_mattype->getCurrentIndex(); + F32 obj_scale_s = 1.0f; + F32 obj_scale_t = 1.0f; - struct f_objscale_s : public LLSelectedTEGetFunctor - { - 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 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 ); - + bool identical_scale_s = false; + bool identical_scale_t = false; + + LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s); + LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t); + switch (material_type) { case MATTYPE_DIFFUSE: @@ -2437,9 +2083,12 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { LLUICtrl* bumpy_scale_u = self->getChild("bumpyScaleU"); LLUICtrl* bumpy_scale_v = self->getChild("bumpyScaleV"); + bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); - self->updateMaterial(); + + LLSelectedTEMaterial::setNormalRepeatX(self,obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setNormalRepeatY(self,obj_scale_t * repeats_per_meter); } break; @@ -2447,9 +2096,12 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { LLUICtrl* shiny_scale_u = self->getChild("shinyScaleU"); LLUICtrl* shiny_scale_v = self->getChild("shinyScaleV"); + shiny_scale_u->setValue(obj_scale_s * repeats_per_meter); shiny_scale_v->setValue(obj_scale_t * repeats_per_meter); - self->updateMaterial(); + + LLSelectedTEMaterial::setSpecularRepeatX(self,obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setSpecularRepeatY(self,obj_scale_t * repeats_per_meter); } break; @@ -2580,3 +2232,180 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) } } +bool LLPanelFace::isIdenticalPlanarTexgen() +{ + LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; + bool identical_texgen = false; + LLSelectedTE::getTexGen(selected_texgen, identical_texgen); + return (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); +} + +void LLPanelFace::LLSelectedTE::getFace(LLFace*& face_to_return, bool& identical_face) +{ + struct LLSelectedTEGetFace : public LLSelectedTEGetFunctor + { + LLFace* get(LLViewerObject* object, S32 te) + { + return (object->mDrawable) ? object->mDrawable->getFace(te): NULL; + } + } get_te_face_func; + identical_face = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_te_face_func, face_to_return); +} + +void LLPanelFace::LLSelectedTE::getImageFormat(LLGLenum& image_format_to_return, bool& identical_face) +{ + struct LLSelectedTEGetImageFormat : public LLSelectedTEGetFunctor + { + LLGLenum get(LLViewerObject* object, S32 te_index) + { + LLViewerTexture* image = object->getTEImage(te_index); + return image ? image->getPrimaryFormat() : GL_RGB; + } + } get_glenum; + identical_face = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_glenum, image_format_to_return); +} + +void LLPanelFace::LLSelectedTE::getTexId(LLUUID& id, bool& identical) +{ + struct LLSelectedTEGetTexId : public LLSelectedTEGetFunctor + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + LLUUID id; + LLViewerTexture* image = object->getTEImage(te_index); + if (image) + { + id = image->getID(); + } + + if (!id.isNull() && LLViewerMedia::textureHasMedia(id)) + { + LLTextureEntry *te = object->getTE(te_index); + if (te) + { + LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL; + if(!tex) + { + tex = LLViewerFetchedTexture::sDefaultImagep; + } + if (tex) + { + id = tex->getID(); + } + } + } + return id; + } + } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); +} + +void LLPanelFace::LLSelectedTEMaterial::getCurrent(LLMaterialPtr& material_ptr, bool& identical_material) +{ + struct MaterialFunctor : public LLSelectedTEGetFunctor + { + LLMaterialPtr get(LLViewerObject* object, S32 te_index) + { + return object->getTE(te_index)->getMaterialParams(); + } + } func; + identical_material = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material_ptr); +} + +void LLPanelFace::LLSelectedTEMaterial::getMaxSpecularRepeats(F32& repeats, bool& identical) +{ + struct LLSelectedTEGetMaxSpecRepeats : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + U32 s_axis = VX; + U32 t_axis = VY; + F32 repeats_s = 1.0f; + F32 repeats_t = 1.0f; + if (mat) + { + mat->getSpecularRepeat(repeats_s, repeats_t); + repeats_s /= object->getScale().mV[s_axis]; + repeats_t /= object->getScale().mV[t_axis]; + } + return llmax(repeats_s, repeats_t); + } + + } max_spec_repeats_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_spec_repeats_func, repeats); +} + +void LLPanelFace::LLSelectedTEMaterial::getMaxNormalRepeats(F32& repeats, bool& identical) +{ + struct LLSelectedTEGetMaxNormRepeats : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + U32 s_axis = VX; + U32 t_axis = VY; + F32 repeats_s = 1.0f; + F32 repeats_t = 1.0f; + if (mat) + { + mat->getNormalRepeat(repeats_s, repeats_t); + repeats_s /= object->getScale().mV[s_axis]; + repeats_t /= object->getScale().mV[t_axis]; + } + return llmax(repeats_s, repeats_t); + } + + } max_norm_repeats_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_norm_repeats_func, repeats); +} + +void LLPanelFace::LLSelectedTE::getObjectScaleS(F32& scale_s, bool& identical) +{ + struct LLSelectedTEGetObjectScaleS : public LLSelectedTEGetFunctor + { + 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; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_s_func, scale_s ); +} + +void LLPanelFace::LLSelectedTE::getObjectScaleT(F32& scale_t, bool& identical) +{ + struct LLSelectedTEGetObjectScaleS : public LLSelectedTEGetFunctor + { + 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; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_t_func, scale_t ); +} + +void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identical) +{ + struct LLSelectedTEGetMaxDiffuseRepeats : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + U32 s_axis = VX; + U32 t_axis = VY; + LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); + F32 repeats_s = object->getTE(face)->mScaleS / object->getScale().mV[s_axis]; + F32 repeats_t = object->getTE(face)->mScaleT / object->getScale().mV[t_axis]; + return llmax(repeats_s, repeats_t); + } + + } max_diff_repeats_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_diff_repeats_func, repeats ); +} \ No newline at end of file diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index f64564c9a0..b93e214326 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -30,6 +30,9 @@ #include "v4color.h" #include "llpanel.h" #include "llmaterial.h" +#include "llmaterialmgr.h" +#include "lltextureentry.h" +#include "llselectmgr.h" class LLButton; class LLCheckBoxCtrl; @@ -45,6 +48,48 @@ class LLViewerObject; class LLFloater; class LLMaterialID; +// Represents an edit for use in replicating the op across one or more materials in the selection set. +// +// The apply function optionally performs the edit which it implements +// as a functor taking Data that calls member func MaterialFunc taking SetValueType +// on an instance of the LLMaterial class. +// +// boost who? +// +template< + typename DataType, + typename SetValueType, + void (LLMaterial::*MaterialEditFunc)(SetValueType data) > +class LLMaterialEditFunctor +{ +public: + LLMaterialEditFunctor(const DataType& data) : _data(data) {} + virtual ~LLMaterialEditFunctor() {} + virtual void apply(LLMaterialPtr& material) { (material->*(MaterialEditFunc))(_data); } + DataType _data; +}; + +template< + typename DataType, + DataType (LLMaterial::*MaterialGetFunc)() > +class LLMaterialGetFunctor +{ +public: + LLMaterialGetFunctor() : {} + virtual DataType get(LLMaterialPtr& material) { return (material->*(MaterialGetFunc)); } +}; + +template< + typename DataType, + DataType (LLTextureEntry::*TEGetFunc)() > +class LLTEGetFunctor +{ +public: + LLTEGetFunctor() : _data(data) {} + virtual DataType get(LLTextureEntry* entry) { return (entry*(TEGetFunc)); } + DataType _data; +}; + class LLPanelFace : public LLPanel { public: @@ -93,10 +138,31 @@ protected: // void updateUI(); + // Convenience func to determine if all faces in selection have + // identical planar texgen settings during edits + // + bool isIdenticalPlanarTexgen(); + // Callback funcs for individual controls // static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); + + static void onCommitMaterialBumpyScaleX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyScaleY( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyRot( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyOffsetX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyOffsetY( LLUICtrl* ctrl, void* userdata); + + static void onCommitMaterialShinyScaleX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyScaleY( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyRot( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyOffsetX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyOffsetY( LLUICtrl* ctrl, void* userdata); + + static void onCommitMaterialGloss( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialEnv( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialMaskCutoff( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); static void onCommitBump( LLUICtrl* ctrl, void* userdata); @@ -113,6 +179,29 @@ protected: private: + bool isAlpha() { return mIsAlpha; } + + // Convenience funcs to keep the visual flack to a minimum + // + LLUUID getCurrentNormalMap(); + LLUUID getCurrentSpecularMap(); + U32 getCurrentShininess(); + U32 getCurrentBumpiness(); + U8 getCurrentDiffuseAlphaMode(); + U8 getCurrentAlphaMaskCutoff(); + U8 getCurrentEnvIntensity(); + U8 getCurrentGlossiness(); + F32 getCurrentBumpyRot(); + F32 getCurrentBumpyScaleU(); + F32 getCurrentBumpyScaleV(); + F32 getCurrentBumpyOffsetU(); + F32 getCurrentBumpyOffsetV(); + F32 getCurrentShinyRot(); + F32 getCurrentShinyScaleU(); + F32 getCurrentShinyScaleV(); + F32 getCurrentShinyOffsetU(); + F32 getCurrentShinyOffsetV(); + // Update visibility of controls to match current UI mode // (e.g. materials vs media editing) // @@ -120,10 +209,106 @@ private: // void updateVisibility(); - // Make material reflect current state of UI (apply edit) + // Make material(s) reflect current state of UI (apply edit) // void updateMaterial(); + // Hey look everyone, a type-safe alternative to copy and paste! :) + // + + // Update material parameters by applying 'edit_func' to selected TEs + // + template< + typename DataType, + typename SetValueType, + void (LLMaterial::*MaterialEditFunc)(SetValueType data) > + static void edit(LLPanelFace* p, DataType data) + { + LLMaterialEditFunctor< DataType, SetValueType, MaterialEditFunc > edit(data); + struct LLSelectedTEEditMaterial : public LLSelectedTEMaterialFunctor + { + LLSelectedTEEditMaterial(LLPanelFace* panel, LLMaterialEditFunctor< DataType, SetValueType, MaterialEditFunc >* editp) : _panel(panel), _edit(editp) {} + virtual ~LLSelectedTEEditMaterial() {}; + virtual LLMaterialPtr apply(LLViewerObject* object, S32 face, LLTextureEntry* tep, LLMaterialPtr& current_material) + { + if (_edit) + { + LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); + llassert_always(new_material); + + // Do "It"! + // + _edit->apply(new_material); + + U32 new_alpha_mode = new_material->getDiffuseAlphaMode(); + LLUUID new_normal_map_id = new_material->getNormalID(); + LLUUID new_spec_map_id = new_material->getSpecularID(); + + bool is_default_blend_mode = (new_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); + + if (!current_material.isNull() && !is_need_material) + { + LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; + LLMaterialMgr::getInstance()->remove(object->getID(),face); + } + else + { + // Replicate old init behavior + // + if (current_material.isNull()) + { + U8 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); + U8 current_alpha_mask_cutoff = _panel->getCurrentAlphaMaskCutoff(); + + new_material->setDiffuseAlphaMode(current_alpha_mode); + new_material->setAlphaMaskCutoff(current_alpha_mask_cutoff); + } + + LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << new_material->asLLSD() << LL_ENDL; + LLMaterialMgr::getInstance()->put(object->getID(),face,*new_material); + } + + object->setTEMaterialParams(face, new_material); + return new_material; + } + return NULL; + } + LLMaterialEditFunctor< DataType, SetValueType, MaterialEditFunc >* _edit; + LLPanelFace* _panel; + } editor(p, &edit); + LLSelectMgr::getInstance()->selectionSetMaterialParams(&editor); + } + + template< + typename DataType, + typename ReturnType, + ReturnType (LLMaterial::* const MaterialGetFunc)() const > + static void getTEMaterialValue(DataType& data_to_return, bool& identical) + { + struct GetTEMaterialVal : public LLSelectedTEGetFunctor + { + DataType get(LLViewerObject* object, S32 face) { return (object && object->getTE(face)) ? ((object->getTE(face)->getMaterialParams()->*(MaterialGetFunc))()) : DataType(); } + } GetFunc; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &GetFunc, data_to_return); + } + + template< + typename DataType, + typename ReturnType, // some kids just have to different... + ReturnType (LLTextureEntry::* const TEGetFunc)() const > + static void getTEValue(DataType& data_to_return, bool& identical) + { + struct GetTEVal : public LLSelectedTEGetFunctor + { + DataType get(LLViewerObject* object, S32 face) { + LLTextureEntry* tep = object ? object->getTE(face) : NULL; + return tep ? ((tep->*(TEGetFunc))()) : DataType(); + } + } GetTEValFunc; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &GetTEValFunc, data_to_return ); + } + // Update vis and enabling of specific subsets of controls based on material params // (e.g. hide the spec controls if no spec texture is applied) // @@ -152,6 +337,107 @@ private: */ bool mUpdateInFlight; bool mUpdatePending; + + #if defined(DEF_GET_MAT_STATE) + #undef DEF_GET_MAT_STATE + #endif + + #if defined(DEF_GET_TE_STATE) + #undef DEF_GET_TE_STATE + #endif + + // Accessors for selected TE material state + // + #define DEF_GET_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ + static void MaterialMemberFunc(DataType& data, bool& identical) \ + { \ + getTEMaterialValue< DataType, ReturnType, &LLMaterial::##MaterialMemberFunc >(data, identical); \ + } + + // Mutators for selected TE material + // + #define DEF_EDIT_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ + static void MaterialMemberFunc(LLPanelFace* p,DataType data) \ + { \ + edit< DataType, ReturnType, &LLMaterial::##MaterialMemberFunc >(p,data); \ + } + + + // Accessors for selected TE state proper (legacy settings etc) + // + #define DEF_GET_TE_STATE(DataType,ReturnType,TexEntryMemberFunc) \ + static void TexEntryMemberFunc(DataType& data, bool& identical) \ + { \ + getTEValue< DataType, ReturnType, &LLTextureEntry::##TexEntryMemberFunc >(data, identical); \ + } + + class LLSelectedTEMaterial + { + public: + static void getCurrent(LLMaterialPtr& material_ptr, bool& identical_material); + static void getMaxSpecularRepeats(F32& repeats, bool& identical); + static void getMaxNormalRepeats(F32& repeats, bool& identical); + + DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getNormalID) + DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getSpecularID) + DEF_GET_MAT_STATE(U8,U8,getDiffuseAlphaMode) + + DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatX) + DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatY) + DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetX) + DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetY) + DEF_GET_MAT_STATE(F32,F32,getSpecularRotation) + + DEF_GET_MAT_STATE(F32,F32,getNormalRepeatX) + DEF_GET_MAT_STATE(F32,F32,getNormalRepeatY) + DEF_GET_MAT_STATE(F32,F32,getNormalOffsetX) + DEF_GET_MAT_STATE(F32,F32,getNormalOffsetY) + DEF_GET_MAT_STATE(F32,F32,getNormalRotation) + + DEF_EDIT_MAT_STATE(U8,U8,setDiffuseAlphaMode); + DEF_EDIT_MAT_STATE(U8,U8,setAlphaMaskCutoff); + + DEF_EDIT_MAT_STATE(F32,F32,setNormalOffsetX); + DEF_EDIT_MAT_STATE(F32,F32,setNormalOffsetY); + DEF_EDIT_MAT_STATE(F32,F32,setNormalRepeatX); + DEF_EDIT_MAT_STATE(F32,F32,setNormalRepeatY); + DEF_EDIT_MAT_STATE(F32,F32,setNormalRotation); + + DEF_EDIT_MAT_STATE(F32,F32,setSpecularOffsetX); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularOffsetY); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularRepeatX); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularRepeatY); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularRotation); + + DEF_EDIT_MAT_STATE(U8,U8,setEnvironmentIntensity); + DEF_EDIT_MAT_STATE(U8,U8,setSpecularLightExponent); + + DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setNormalID); + DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setSpecularID); + DEF_EDIT_MAT_STATE(LLColor4U, const LLColor4U&,setSpecularLightColor); + }; + + class LLSelectedTE + { + public: + + static void getFace(LLFace*& face_to_return, bool& identical_face); + static void getImageFormat(LLGLenum& image_format_to_return, bool& identical_face); + static void getTexId(LLUUID& id, bool& identical); + static void getObjectScaleS(F32& scale_s, bool& identical); + static void getObjectScaleT(F32& scale_t, bool& identical); + static void getMaxDiffuseRepeats(F32& repeats, bool& identical); + + DEF_GET_TE_STATE(U8,U8,getBumpmap) + DEF_GET_TE_STATE(U8,U8,getShiny) + DEF_GET_TE_STATE(U8,U8,getFullbright) + DEF_GET_TE_STATE(F32,F32,getRotation) + DEF_GET_TE_STATE(F32,F32,getOffsetS) + DEF_GET_TE_STATE(F32,F32,getOffsetT) + DEF_GET_TE_STATE(F32,F32,getGlow) + DEF_GET_TE_STATE(LLTextureEntry::e_texgen,LLTextureEntry::e_texgen,getTexGen) + DEF_GET_TE_STATE(LLColor4,const LLColor4&,getColor) + }; }; #endif diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 37c11bd027..0cbdbe16a3 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2016,23 +2016,29 @@ void LLSelectMgr::selectionSetGlow(F32 glow) mSelectedObjects->applyToObjects( &func2 ); } -void LLSelectMgr::selectionSetMaterial(LLMaterialPtr material) +void LLSelectMgr::selectionSetMaterialParams(LLSelectedTEMaterialFunctor* material_func) { struct f1 : public LLSelectedTEFunctor { LLMaterialPtr mMaterial; - f1(LLMaterialPtr material) : mMaterial(material) {}; + f1(LLSelectedTEMaterialFunctor* material_func) : _material_func(material_func) {} + bool apply(LLViewerObject* object, S32 face) { - if (object->permModify()) + if (object && object->permModify() && _material_func) { - LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << LL_ENDL; - LLMaterialMgr::getInstance()->put(object->getID(),face,*mMaterial); - object->setTEMaterialParams(face,mMaterial); + LLTextureEntry* tep = object->getTE(face); + if (tep) + { + LLMaterialPtr current_material = tep->getMaterialParams(); + _material_func->apply(object, face, tep, current_material); + } } return true; } - } func1(material); + + LLSelectedTEMaterialFunctor* _material_func; + } func1(material_func); mSelectedObjects->applyToTEs( &func1 ); struct f2 : public LLSelectedObjectFunctor @@ -2531,7 +2537,8 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setNormalRepeat(normal_scale_s, normal_scale_t); p->setSpecularRepeat(specular_scale_s, specular_scale_t); - selectionSetMaterial( p ); + + LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p); } } else @@ -2553,10 +2560,12 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) if (tep && !tep->getMaterialParams().isNull()) { LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setNormalRepeat(normal_scale_s, normal_scale_t); p->setSpecularRepeat(specular_scale_s, specular_scale_t); - selectionSetMaterial( p ); + + LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p); } } send = send_to_sim; diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f9b97cebdd..d4b736640c 100755 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -85,6 +85,12 @@ struct LLSelectedTEFunctor virtual bool apply(LLViewerObject* object, S32 face) = 0; }; +struct LLSelectedTEMaterialFunctor +{ + virtual ~LLSelectedTEMaterialFunctor() {}; + virtual LLMaterialPtr apply(LLViewerObject* object, S32 face, LLTextureEntry* tep, LLMaterialPtr& current_material) = 0; +}; + template struct LLSelectedTEGetFunctor { virtual ~LLSelectedTEGetFunctor() {}; @@ -549,7 +555,7 @@ public: void selectionSetClickAction(U8 action); void selectionSetIncludeInSearch(bool include_in_search); void selectionSetGlow(const F32 glow); - void selectionSetMaterial(LLMaterialPtr material); + void selectionSetMaterialParams(LLSelectedTEMaterialFunctor* material_func); void selectionRemoveMaterial(); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); -- cgit v1.3