Skip to content

Commit 1970390

Browse files
committed
Autofit Blinn Phong normal and specular when using repeats per meter
1 parent 3dc6c22 commit 1970390

File tree

2 files changed

+62
-22
lines changed

2 files changed

+62
-22
lines changed

indra/newview/llpanelface.cpp

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,18 +3750,8 @@ void LLPanelFace::onCommitRepeatsPerMeter()
37503750
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
37513751
{
37523752
LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter);
3753-
3754-
mBumpyScaleU->setValue(obj_scale_s * repeats_per_meter);
3755-
mBumpyScaleV->setValue(obj_scale_t * repeats_per_meter);
3756-
3757-
LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter);
3758-
LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter);
3759-
3760-
mShinyScaleU->setValue(obj_scale_s * repeats_per_meter);
3761-
mShinyScaleV->setValue(obj_scale_t * repeats_per_meter);
3762-
3763-
LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter);
3764-
LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter);
3753+
LLSelectedTEMaterial::selectionNormalScaleAutofit(this, repeats_per_meter);
3754+
LLSelectedTEMaterial::selectionSpecularScaleAutofit(this, repeats_per_meter);
37653755
}
37663756
else
37673757
{
@@ -3772,18 +3762,10 @@ void LLPanelFace::onCommitRepeatsPerMeter()
37723762
LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter);
37733763
break;
37743764
case MATTYPE_NORMAL:
3775-
mBumpyScaleU->setValue(obj_scale_s * repeats_per_meter);
3776-
mBumpyScaleV->setValue(obj_scale_t * repeats_per_meter);
3777-
3778-
LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter);
3779-
LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter);
3765+
LLSelectedTEMaterial::selectionNormalScaleAutofit(this, repeats_per_meter);
37803766
break;
37813767
case MATTYPE_SPECULAR:
3782-
mBumpyScaleU->setValue(obj_scale_s * repeats_per_meter);
3783-
mBumpyScaleV->setValue(obj_scale_t * repeats_per_meter);
3784-
3785-
LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter);
3786-
LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter);
3768+
LLSelectedTEMaterial::selectionSpecularScaleAutofit(this, repeats_per_meter);
37873769
break;
37883770
default:
37893771
llassert(false);
@@ -5366,6 +5348,62 @@ void LLPanelFace::LLSelectedTEMaterial::getCurrentDiffuseAlphaMode(U8& diffuse_a
53665348
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &get_diff_mode, diffuse_alpha_mode);
53675349
}
53685350

5351+
void LLPanelFace::LLSelectedTEMaterial::selectionNormalScaleAutofit(LLPanelFace* panel_face, F32 repeats_per_meter)
5352+
{
5353+
struct f : public LLSelectedTEFunctor
5354+
{
5355+
LLPanelFace* mFacePanel;
5356+
F32 mRepeatsPerMeter;
5357+
f(LLPanelFace* face_panel, const F32& repeats_per_meter) : mFacePanel(face_panel), mRepeatsPerMeter(repeats_per_meter) {}
5358+
bool apply(LLViewerObject* object, S32 te)
5359+
{
5360+
if (object->permModify())
5361+
{
5362+
// Compute S,T to axis mapping
5363+
U32 s_axis, t_axis;
5364+
if (!LLPrimitive::getTESTAxes(te, &s_axis, &t_axis))
5365+
return true;
5366+
5367+
F32 new_s = object->getScale().mV[s_axis] * mRepeatsPerMeter;
5368+
F32 new_t = object->getScale().mV[t_axis] * mRepeatsPerMeter;
5369+
5370+
setNormalRepeatX(mFacePanel, new_s, te);
5371+
setNormalRepeatY(mFacePanel, new_t, te);
5372+
}
5373+
return true;
5374+
}
5375+
} setfunc(panel_face, repeats_per_meter);
5376+
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
5377+
}
5378+
5379+
void LLPanelFace::LLSelectedTEMaterial::selectionSpecularScaleAutofit(LLPanelFace* panel_face, F32 repeats_per_meter)
5380+
{
5381+
struct f : public LLSelectedTEFunctor
5382+
{
5383+
LLPanelFace* mFacePanel;
5384+
F32 mRepeatsPerMeter;
5385+
f(LLPanelFace* face_panel, const F32& repeats_per_meter) : mFacePanel(face_panel), mRepeatsPerMeter(repeats_per_meter) {}
5386+
bool apply(LLViewerObject* object, S32 te)
5387+
{
5388+
if (object->permModify())
5389+
{
5390+
// Compute S,T to axis mapping
5391+
U32 s_axis, t_axis;
5392+
if (!LLPrimitive::getTESTAxes(te, &s_axis, &t_axis))
5393+
return true;
5394+
5395+
F32 new_s = object->getScale().mV[s_axis] * mRepeatsPerMeter;
5396+
F32 new_t = object->getScale().mV[t_axis] * mRepeatsPerMeter;
5397+
5398+
setSpecularRepeatX(mFacePanel, new_s, te);
5399+
setSpecularRepeatY(mFacePanel, new_t, te);
5400+
}
5401+
return true;
5402+
}
5403+
} setfunc(panel_face, repeats_per_meter);
5404+
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
5405+
}
5406+
53695407
void LLPanelFace::LLSelectedTE::getObjectScaleS(F32& scale_s, bool& identical)
53705408
{
53715409
struct LLSelectedTEGetObjectScaleS : public LLSelectedTEGetFunctor<F32>

indra/newview/llpanelface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ class LLPanelFace : public LLPanel
650650
static void getMaxSpecularRepeats(F32& repeats, bool& identical);
651651
static void getMaxNormalRepeats(F32& repeats, bool& identical);
652652
static void getCurrentDiffuseAlphaMode(U8& diffuse_alpha_mode, bool& identical, bool diffuse_texture_has_alpha);
653+
static void selectionNormalScaleAutofit(LLPanelFace* panel_face, F32 repeats_per_meter);
654+
static void selectionSpecularScaleAutofit(LLPanelFace* panel_face, F32 repeats_per_meter);
653655

654656
DEF_GET_MAT_STATE(LLUUID, const LLUUID&, getNormalID, LLUUID::null, false, LLUUID::null);
655657
DEF_GET_MAT_STATE(LLUUID, const LLUUID&, getSpecularID, LLUUID::null, false, LLUUID::null);

0 commit comments

Comments
 (0)