summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelface.cpp
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2019-08-13 21:59:37 +0300
committerAndreyL ProductEngine <alihatskiy@productengine.com>2019-08-13 21:59:37 +0300
commitcdcdc4b3e377061930866d8ad439871615ca3390 (patch)
tree0a472a95f684915e33fa84a533869bb10ea54e16 /indra/newview/llpanelface.cpp
parentb045831843ba81b54c46cc0b944c4481fec9f222 (diff)
parent823cef92ed9f22943888172f35b88f1a8efa0d8b (diff)
Merged in lindenlab/viewer-bear
Diffstat (limited to 'indra/newview/llpanelface.cpp')
-rw-r--r--indra/newview/llpanelface.cpp155
1 files changed, 138 insertions, 17 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 392bacb8d9..8b31c5aa90 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -82,6 +82,8 @@ 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
+BOOST_STATIC_ASSERT(MATTYPE_DIFFUSE == LLRender::DIFFUSE_MAP && MATTYPE_NORMAL == LLRender::NORMAL_MAP && MATTYPE_SPECULAR == LLRender::SPECULAR_MAP);
+
//
// "Use texture" label for normal/specular type comboboxes
// Filled in at initialization from translated strings
@@ -154,6 +156,7 @@ BOOL LLPanelFace::postBuild()
childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this);
childSetAction("button align",&LLPanelFace::onClickAutoFix,this);
+ childSetAction("button align textures", &LLPanelFace::onAlignTexture, this);
LLTextureCtrl* mTextureCtrl;
LLTextureCtrl* mShinyTextureCtrl;
@@ -439,11 +442,28 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
{
BOOL valid;
F32 value;
- LLSpinCtrl* ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>("TexScaleU");
- LLSpinCtrl* ctrlTexScaleT = mPanel->getChild<LLSpinCtrl>("TexScaleV");
- LLSpinCtrl* ctrlTexOffsetS = mPanel->getChild<LLSpinCtrl>("TexOffsetU");
- LLSpinCtrl* ctrlTexOffsetT = mPanel->getChild<LLSpinCtrl>("TexOffsetV");
- LLSpinCtrl* ctrlTexRotation = mPanel->getChild<LLSpinCtrl>("TexRot");
+
+ LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type");
+ std::string prefix;
+ switch (radio_mat_type->getSelectedIndex())
+ {
+ case MATTYPE_DIFFUSE:
+ prefix = "Tex";
+ break;
+ case MATTYPE_NORMAL:
+ prefix = "bumpy";
+ break;
+ case MATTYPE_SPECULAR:
+ prefix = "shiny";
+ break;
+ }
+
+ LLSpinCtrl * ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleU");
+ LLSpinCtrl * ctrlTexScaleT = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleV");
+ LLSpinCtrl * ctrlTexOffsetS = mPanel->getChild<LLSpinCtrl>(prefix + "OffsetU");
+ LLSpinCtrl * ctrlTexOffsetT = mPanel->getChild<LLSpinCtrl>(prefix + "OffsetV");
+ LLSpinCtrl * ctrlTexRotation = mPanel->getChild<LLSpinCtrl>(prefix + "Rot");
+
LLComboBox* comboTexGen = mPanel->getChild<LLComboBox>("combobox texgen");
LLCheckBoxCtrl* cb_planar_align = mPanel->getChild<LLCheckBoxCtrl>("checkbox planar align");
bool align_planar = (cb_planar_align && cb_planar_align->get());
@@ -466,8 +486,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
if (align_planar)
{
- LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, value, te);
- LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, value, te);
+ LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, value, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, value, te, object->getID());
}
}
}
@@ -491,8 +511,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
if (align_planar)
{
- LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, value, te);
- LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, value, te);
+ LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, value, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, value, te, object->getID());
}
}
}
@@ -507,8 +527,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
if (align_planar)
{
- LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, value, te);
- LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, value, te);
+ LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, value, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, value, te, object->getID());
}
}
}
@@ -523,8 +543,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
if (align_planar)
{
- LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, value, te);
- LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, value, te);
+ LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, value, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, value, te, object->getID());
}
}
}
@@ -539,8 +559,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
if (align_planar)
{
- LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, value, te);
- LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, value, te);
+ LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, value, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, value, te, object->getID());
}
}
}
@@ -612,6 +632,68 @@ private:
LLFace* mCenterFace;
};
+struct LLPanelFaceSetAlignedConcreteTEFunctor : public LLSelectedTEFunctor
+{
+ LLPanelFaceSetAlignedConcreteTEFunctor(LLPanelFace* panel, LLFace* center_face, LLRender::eTexIndex map) :
+ mPanel(panel),
+ mChefFace(center_face),
+ mMap(map)
+ {}
+
+ virtual bool apply(LLViewerObject* object, S32 te)
+ {
+ LLFace* facep = object->mDrawable->getFace(te);
+ if (!facep)
+ {
+ return true;
+ }
+
+ if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
+ {
+ return true;
+ }
+
+ if (mChefFace != facep)
+ {
+ LLVector2 uv_offset, uv_scale;
+ F32 uv_rot;
+ if (facep->calcAlignedPlanarTE(mChefFace, &uv_offset, &uv_scale, &uv_rot, mMap))
+ {
+ switch (mMap)
+ {
+ case LLRender::DIFFUSE_MAP:
+ object->setTEOffset(te, uv_offset.mV[VX], uv_offset.mV[VY]);
+ object->setTEScale(te, uv_scale.mV[VX], uv_scale.mV[VY]);
+ object->setTERotation(te, uv_rot);
+ break;
+ case LLRender::NORMAL_MAP:
+ LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, uv_rot, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
+ break;
+ case LLRender::SPECULAR_MAP:
+ LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, uv_rot, te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
+ LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
+ break;
+ default: /*make compiler happy*/
+ break;
+ }
+ }
+ }
+
+ return true;
+ }
+private:
+ LLPanelFace* mPanel;
+ LLFace* mChefFace;
+ LLRender::eTexIndex mMap;
+};
+
// Functor that tests if a face is aligned to mCenterFace
struct LLPanelFaceGetIsAlignedTEFunctor : public LLSelectedTEFunctor
{
@@ -697,6 +779,17 @@ void LLPanelFace::sendTextureInfo()
LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc);
}
+void LLPanelFace::alignTestureLayer()
+{
+ LLFace* last_face = NULL;
+ bool identical_face = false;
+ LLSelectedTE::getFace(last_face, identical_face);
+
+ LLRadioGroup * radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
+ LLPanelFaceSetAlignedConcreteTEFunctor setfunc(this, last_face, static_cast<LLRender::eTexIndex>(radio_mat_type->getSelectedIndex()));
+ LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
+}
+
void LLPanelFace::getState()
{
updateUI();
@@ -983,6 +1076,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
bool enabled = (editable && isIdenticalPlanarTexgen());
childSetValue("checkbox planar align", align_planar && enabled);
childSetEnabled("checkbox planar align", enabled);
+ childSetEnabled("button align textures", enabled && LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 1);
if (align_planar && enabled)
{
@@ -2134,7 +2228,18 @@ void LLPanelFace::onCommitMaterialBumpyRot(LLUICtrl* ctrl, void* userdata)
}
else
{
- LLSelectedTEMaterial::setNormalRotation(self,self->getCurrentBumpyRot() * DEG_TO_RAD);
+ if ((bool)self->childGetValue("checkbox planar align").asBoolean())
+ {
+ LLFace* last_face = NULL;
+ bool identical_face = false;
+ LLSelectedTE::getFace(last_face, identical_face);
+ LLPanelFaceSetAlignedTEFunctor setfunc(self, last_face);
+ LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
+ }
+ else
+ {
+ LLSelectedTEMaterial::setNormalRotation(self, self->getCurrentBumpyRot() * DEG_TO_RAD);
+ }
}
}
@@ -2151,7 +2256,18 @@ void LLPanelFace::onCommitMaterialShinyRot(LLUICtrl* ctrl, void* userdata)
}
else
{
- LLSelectedTEMaterial::setSpecularRotation(self,self->getCurrentShinyRot() * DEG_TO_RAD);
+ if ((bool)self->childGetValue("checkbox planar align").asBoolean())
+ {
+ LLFace* last_face = NULL;
+ bool identical_face = false;
+ LLSelectedTE::getFace(last_face, identical_face);
+ LLPanelFaceSetAlignedTEFunctor setfunc(self, last_face);
+ LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
+ }
+ else
+ {
+ LLSelectedTEMaterial::setSpecularRotation(self, self->getCurrentShinyRot() * DEG_TO_RAD);
+ }
}
}
@@ -2408,6 +2524,11 @@ void LLPanelFace::onClickAutoFix(void* userdata)
LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc);
}
+void LLPanelFace::onAlignTexture(void* userdata)
+{
+ LLPanelFace* self = (LLPanelFace*)userdata;
+ self->alignTestureLayer();
+}
// TODO: I don't know who put these in or what these are for???